[llvm] [InstCombine] Add log-pow simplification for FP exponent edge case. (PR #76641)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 8 06:09:30 PST 2024
================
@@ -2495,13 +2495,17 @@ Value *LibCallSimplifier::optimizeLog(CallInst *Log, IRBuilderBase &B) {
// log(pow(x,y)) -> y*log(x)
AttributeList NoAttrs;
- if (ArgLb == PowLb || ArgID == Intrinsic::pow) {
+ if (ArgLb == PowLb || ArgID == Intrinsic::pow || ArgID == Intrinsic::powi) {
Value *LogX =
Log->doesNotAccessMemory()
? B.CreateCall(Intrinsic::getDeclaration(Mod, LogID, Ty),
Arg->getOperand(0), "log")
: emitUnaryFloatFnCall(Arg->getOperand(0), TLI, LogNm, B, NoAttrs);
- Value *MulY = B.CreateFMul(Arg->getArgOperand(1), LogX, "mul");
+ Value *Y = Arg->getArgOperand(1);
+ // Cast exponent to FP if integer.
+ if (ArgID == Intrinsic::powi)
+ Y = B.CreateCast(Instruction::SIToFP, Y, Ty, "cast");
----------------
nikic wrote:
```suggestion
Y = B.CreateSIToFP(Y, Ty, "cast");
```
https://github.com/llvm/llvm-project/pull/76641
More information about the llvm-commits
mailing list