[PATCH] D14045: [SimplifyLibCalls] Add a new transform: pow(exp(x), y) -> exp(x*y)
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 25 11:49:12 PDT 2015
majnemer added a comment.
I'm not sure what the implications of this transform are with respect to correctness. My naïve understanding is that this could produce different results because it removes a step where rounding was introduced. I'd feel more comfortable with this if @scanon, @resistor and/or @escha could take a look.
================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:1096
@@ +1095,3 @@
+ // pow(exp(x), y) -> exp(x*y)
+ if (CallInst *OpC = dyn_cast<CallInst>(Op1)) {
+ LibFunc::Func Func;
----------------
Please use `auto *OpC` here.
================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:1102
@@ +1101,3 @@
+ if (TLI->getLibFunc(FuncName, Func) && TLI->has(Func) &&
+ Func == LibFunc::exp && Op2->getType()->isDoubleTy())
+ return EmitUnaryFloatFnCall(
----------------
Any reason in particular why we must limit this to `isDoubleTy`?
================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:1103-1105
@@ +1102,5 @@
+ Func == LibFunc::exp && Op2->getType()->isDoubleTy())
+ return EmitUnaryFloatFnCall(
+ B.CreateFMul(OpC->getArgOperand(0), Op2, "mul"),
+ TLI->getName(LibFunc::exp), B, Callee->getAttributes());
+ }
----------------
Is this clang-format'd?
================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:1105
@@ +1104,3 @@
+ B.CreateFMul(OpC->getArgOperand(0), Op2, "mul"),
+ TLI->getName(LibFunc::exp), B, Callee->getAttributes());
+ }
----------------
Wouldn't `TLI->getName(LibFunc::exp)` be equivalent to `FuncName` ?
http://reviews.llvm.org/D14045
More information about the llvm-commits
mailing list