summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2016-01-12 19:06:35 +0000
committerSanjay Patel <spatel@rotateright.com>2016-01-12 19:06:35 +0000
commit53ba88dbb042132bbaf7e5ca6ccc2d5051272581 (patch)
tree70b2762ffa49886f774ef53b8d8902e262cf39fb /llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
parent87b0fe075ea2573a0009ceef8cc84f05f7b2f782 (diff)
downloadbcm5719-llvm-53ba88dbb042132bbaf7e5ca6ccc2d5051272581.tar.gz
bcm5719-llvm-53ba88dbb042132bbaf7e5ca6ccc2d5051272581.zip
[LibCallSimplifier] use instruction-level fast-math-flags to transform pow(x, 0.5) calls
Also, propagate the FMF to the newly created sqrt() call. llvm-svn: 257503
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
index 2551abef75b..dc074406014 100644
--- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -1164,9 +1164,12 @@ Value *LibCallSimplifier::optimizePow(CallInst *CI, IRBuilder<> &B) {
LibFunc::fabsl)) {
// In -ffast-math, pow(x, 0.5) -> sqrt(x).
- if (UnsafeFPMath)
+ if (CI->hasUnsafeAlgebra()) {
+ IRBuilder<>::FastMathFlagGuard Guard(B);
+ B.setFastMathFlags(CI->getFastMathFlags());
return EmitUnaryFloatFnCall(Op1, TLI->getName(LibFunc::sqrt), B,
Callee->getAttributes());
+ }
// Expand pow(x, 0.5) to (x == -infinity ? +infinity : fabs(sqrt(x))).
// This is faster than calling pow, and still handles negative zero
OpenPOWER on IntegriCloud