aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ConstantFolding.cpp
diff options
context:
space:
mode:
authorMatthew Devereau <matthew.devereau@arm.com>2024-04-18 10:19:01 +0100
committerGitHub <noreply@github.com>2024-04-18 10:19:01 +0100
commite90bc9cfd4d22c89dd993f62ede700ae25df49c5 (patch)
tree648e9fc005bddd1205464cbc11b5097be8ad9b86 /llvm/lib/Analysis/ConstantFolding.cpp
parent63d8058ef50a3186b6b6a5db254f44673fea3d19 (diff)
downloadllvm-e90bc9cfd4d22c89dd993f62ede700ae25df49c5.zip
llvm-e90bc9cfd4d22c89dd993f62ede700ae25df49c5.tar.gz
llvm-e90bc9cfd4d22c89dd993f62ede700ae25df49c5.tar.bz2
Constant Fold Logf128 calls (#84501)
This patch enables constant folding for 128 bit floating-point logf calls. This is achieved by querying if the host system has the logf128() symbol available with a CMake test. If so, replace the runtime call with the compile time value returned from logf128.
Diffstat (limited to 'llvm/lib/Analysis/ConstantFolding.cpp')
-rw-r--r--llvm/lib/Analysis/ConstantFolding.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 749374a..e292ff3 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -2089,6 +2089,17 @@ static Constant *ConstantFoldScalarCall1(StringRef Name,
if (IntrinsicID == Intrinsic::canonicalize)
return constantFoldCanonicalize(Ty, Call, U);
+#if defined(__FLOAT128__) && defined(HAS_LOGF128)
+ if (Ty->isFP128Ty()) {
+ switch (IntrinsicID) {
+ default:
+ return nullptr;
+ case Intrinsic::log:
+ return ConstantFP::get(Ty, logf128(Op->getValueAPF().convertToQuad()));
+ }
+ }
+#endif
+
if (!Ty->isHalfTy() && !Ty->isFloatTy() && !Ty->isDoubleTy())
return nullptr;