From 873219c4064a7b2e0d5801090f7c129277e69e2c Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Wed, 10 Aug 2016 06:33:32 +0000 Subject: [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 --- llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'llvm/lib/Transforms/Utils') diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp index a958eeeae88..c10a1ff6dab 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))). -- cgit v1.2.3