[llvm] [ConstantFold] Fold `log1p` and `log1pf` when the input parameter is a constant value. (PR #112113)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 14 08:34:33 PDT 2024
================
@@ -2394,6 +2395,11 @@ static Constant *ConstantFoldScalarCall1(StringRef Name,
if (!APF.isZero() && TLI->has(Func))
return ConstantFoldFP(logb, APF, Ty);
break;
+ case LibFunc_log1p:
+ case LibFunc_log1pf:
+ if (APF > APFloat(APF.getSemantics(), "-1") && TLI->has(Func))
----------------
c8ef wrote:
If I wrote this:
```C++
case LibFunc_log1pf:
llvm::errs() << APFloat::getOne(APF.getSemantics(), true) << " " << APFloat(APF.getSemantics(), "-1") << '\n';
if (APF > APFloat::getOne(APF.getSemantics(), true) && TLI->has(Func))
return ConstantFoldFP(log1p, APF, Ty);
break;
```
I got:
```
1.84467441E+19 -1
1.84467441E+19 -1
1.8446744073709552E+19 -1
1.8446744073709552E+19 -1
1.84467441E+19 -1
1.84467441E+19 -1
1.8446744073709552E+19 -1
1.8446744073709552E+19 -1
1.84467441E+19 -1
1.84467441E+19 -1
1.8446744073709552E+19 -1
1.8446744073709552E+19 -1
1.84467441E+19 -1
1.84467441E+19 -1
1.8446744073709552E+19 -1
1.8446744073709552E+19 -1
```
https://github.com/llvm/llvm-project/pull/112113
More information about the llvm-commits
mailing list