aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ConstantFolding.cpp
diff options
context:
space:
mode:
authorc8ef <c8ef@outlook.com>2024-10-22 12:58:11 +0800
committerGitHub <noreply@github.com>2024-10-22 12:58:11 +0800
commitb90ea5caade7b92796276937467a0dabc355a62e (patch)
treed030c92958db526d6e5f8e710819ba05ebfc80bc /llvm/lib/Analysis/ConstantFolding.cpp
parent2437784a178adb299cf6e363427e98611e3d2460 (diff)
downloadllvm-b90ea5caade7b92796276937467a0dabc355a62e.zip
llvm-b90ea5caade7b92796276937467a0dabc355a62e.tar.gz
llvm-b90ea5caade7b92796276937467a0dabc355a62e.tar.bz2
[ConstantFold] Fold `erf` and `erff` when the input parameter is a constant value. (#113079)
This patch adds support for constant folding for the `erf` and `erff` libc functions.
Diffstat (limited to 'llvm/lib/Analysis/ConstantFolding.cpp')
-rw-r--r--llvm/lib/Analysis/ConstantFolding.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 530e928..c5a2c2f 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -1672,8 +1672,8 @@ bool llvm::canConstantFoldCallTo(const CallBase *Call, const Function *F) {
Name == "cos" || Name == "cosf" ||
Name == "cosh" || Name == "coshf";
case 'e':
- return Name == "exp" || Name == "expf" ||
- Name == "exp2" || Name == "exp2f";
+ return Name == "exp" || Name == "expf" || Name == "exp2" ||
+ Name == "exp2f" || Name == "erf" || Name == "erff";
case 'f':
return Name == "fabs" || Name == "fabsf" ||
Name == "floor" || Name == "floorf" ||
@@ -2412,6 +2412,11 @@ static Constant *ConstantFoldScalarCall1(StringRef Name,
break;
case LibFunc_logl:
return nullptr;
+ case LibFunc_erf:
+ case LibFunc_erff:
+ if (TLI->has(Func))
+ return ConstantFoldFP(erf, APF, Ty);
+ break;
case LibFunc_nearbyint:
case LibFunc_nearbyintf:
case LibFunc_rint:
@@ -3597,7 +3602,6 @@ bool llvm::isMathLibCallNoop(const CallBase *Call,
// Per POSIX, this MAY fail if Op is denormal. We choose not failing.
return true;
-
case LibFunc_asinl:
case LibFunc_asin:
case LibFunc_asinf: