[llvm] ConstantFold logl calls (PR #94944)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 12 01:54:16 PDT 2024
================
@@ -2085,15 +2085,18 @@ static Constant *ConstantFoldScalarCall1(StringRef Name,
if (IntrinsicID == Intrinsic::canonicalize)
return constantFoldCanonicalize(Ty, Call, U);
+ // Try to handle special fp128 cases before bailing
#if defined(HAS_IEE754_FLOAT128) && defined(HAS_LOGF128)
if (Ty->isFP128Ty()) {
- switch (IntrinsicID) {
- default:
- return nullptr;
- case Intrinsic::log:
- return ConstantFP::get(Ty, logf128(Op->getValueAPF().convertToQuad()));
- }
+ const APFloat &Fp128APF = Op->getValueAPF();
+ if (IntrinsicID == Intrinsic::log)
+ return ConstantFP::get(Ty, logf128(Fp128APF.convertToQuad()));
}
+
+ LibFunc Fp128Func = NotLibFunc;
+ if (Ty->isFP128Ty() && TLI->getLibFunc(Name, Fp128Func) &&
+ TLI->has(Fp128Func) && Fp128Func == LibFunc_logl)
+ return ConstantFP::get(Ty, logf128(Op->getValueAPF().convertToQuad()));
----------------
arsenm wrote:
Combine these under 1 isFP128Ty check?
https://github.com/llvm/llvm-project/pull/94944
More information about the llvm-commits
mailing list