diff options
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))). |