summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2017-12-10 16:52:26 +0000
committerSanjay Patel <spatel@rotateright.com>2017-12-10 16:52:26 +0000
commit09ec34349a51b68dd5b6e5ab023f52230ec1c579 (patch)
tree860c58001a64d91d5420f0335362d2f0d30abf60 /llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
parent719bc64ba57b41935a49c7c7ea0f37c3c719c5e2 (diff)
downloadbcm5719-llvm-09ec34349a51b68dd5b6e5ab023f52230ec1c579.tar.gz
bcm5719-llvm-09ec34349a51b68dd5b6e5ab023f52230ec1c579.zip
[SimplifyLibCalls] propagate FMF when folding pow(x, 2.0) call (PR35601)
This should fix the larger problem with sqrt shown in: https://bugs.llvm.org/show_bug.cgi?id=35601 llvm-svn: 320310
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
index c392492e331..273a5e79a7d 100644
--- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -1206,8 +1206,13 @@ Value *LibCallSimplifier::optimizePow(CallInst *CI, IRBuilder<> &B) {
if (Op2C->isExactlyValue(1.0)) // pow(x, 1.0) -> x
return Op1;
- if (Op2C->isExactlyValue(2.0)) // pow(x, 2.0) -> x*x
+ if (Op2C->isExactlyValue(2.0)) {
+ // pow(x, 2.0) --> x * x
+ IRBuilder<>::FastMathFlagGuard Guard(B);
+ B.setFastMathFlags(CI->getFastMathFlags());
return B.CreateFMul(Op1, Op1, "pow2");
+ }
+ // FIXME: This should propagate the FMF of the call to the fdiv.
if (Op2C->isExactlyValue(-1.0)) // pow(x, -1.0) -> 1.0/x
return B.CreateFDiv(ConstantFP::get(CI->getType(), 1.0), Op1, "powrecip");
OpenPOWER on IntegriCloud