diff options
author | Guy David <49722543+guy-david@users.noreply.github.com> | 2025-05-09 07:25:35 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-09 07:25:35 +0300 |
commit | a1beb619403a781153c170f041f39a3bac1cebb7 (patch) | |
tree | 73abbfd83b85cea1057e1de3a015c118b3e09af8 /llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp | |
parent | 74e5a3b61e87c8c2b830286796b72dda67942b6b (diff) | |
download | llvm-a1beb619403a781153c170f041f39a3bac1cebb7.zip llvm-a1beb619403a781153c170f041f39a3bac1cebb7.tar.gz llvm-a1beb619403a781153c170f041f39a3bac1cebb7.tar.bz2 |
[SimplifyLibCalls] Shrink sin, cos to sinf, cosf when allowed (#139082)
This optimization already exists, but for the libcall versions of these
functions and not for their intrinsic form.
Solves https://github.com/llvm/llvm-project/issues/139044.
There are probably more opportunities for other intrinsics, because the
switch-case in `LibCallSimplifier::optimizeCall` covers only `pow`,
`exp2`, `log`, `log2`, `log10`, `sqrt`, `memset`, `memcpy` and
`memmove`.
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp index 941e787..94a79ad 100644 --- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp @@ -4136,6 +4136,11 @@ Value *LibCallSimplifier::optimizeCall(CallInst *CI, IRBuilderBase &Builder) { return optimizeMemCpy(CI, Builder); case Intrinsic::memmove: return optimizeMemMove(CI, Builder); + case Intrinsic::sin: + case Intrinsic::cos: + if (UnsafeFPShrink) + return optimizeUnaryDoubleFP(CI, Builder, TLI, /*isPrecise=*/true); + return nullptr; default: return nullptr; } |