diff options
author | Davide Italiano <davide@freebsd.org> | 2016-08-10 06:33:32 +0000 |
---|---|---|
committer | Davide Italiano <davide@freebsd.org> | 2016-08-10 06:33:32 +0000 |
commit | 873219c4064a7b2e0d5801090f7c129277e69e2c (patch) | |
tree | 02c67d00d9f94db4d0ec0c0d60403b7e4281d31b /llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp | |
parent | 15f6f6cb971cb54c5e42d32d22a3dfaa6dd46553 (diff) | |
download | llvm-873219c4064a7b2e0d5801090f7c129277e69e2c.zip llvm-873219c4064a7b2e0d5801090f7c129277e69e2c.tar.gz llvm-873219c4064a7b2e0d5801090f7c129277e69e2c.tar.bz2 |
[SimplifyLibCalls] Restore the old behaviour, emit a libcall.
Hal pointed out that the semantic of our intrinsic and the libc
call are slightly different. Add a comment while I'm here to
explain why we can't emit an intrinsic. Thanks Hal!
llvm-svn: 278200
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp index a958eee..c10a1ff 100644 --- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp @@ -1052,9 +1052,11 @@ Value *LibCallSimplifier::optimizePow(CallInst *CI, IRBuilder<> &B) { if (CI->hasUnsafeAlgebra()) { IRBuilder<>::FastMathFlagGuard Guard(B); B.setFastMathFlags(CI->getFastMathFlags()); - Value *Sqrt = Intrinsic::getDeclaration(CI->getModule(), Intrinsic::sqrt, - Op1->getType()); - return B.CreateCall(Sqrt, Op1, "sqrt"); + + // Unlike other math intrinsics, sqrt has differerent semantics + // from the libc function. See LangRef for details. + return emitUnaryFloatFnCall(Op1, TLI->getName(LibFunc::sqrt), B, + Callee->getAttributes()); } // Expand pow(x, 0.5) to (x == -infinity ? +infinity : fabs(sqrt(x))). |