From: Davide Italiano Date: Mon, 8 Aug 2016 03:23:01 +0000 (+0000) Subject: [SimplifyLibCalls] Emit sqrt intrinsic instead of a libcall. X-Git-Tag: llvmorg-4.0.0-rc1~13096 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e3b916d1649de6689034aa1dcf9ceaeba4db72dc;p=platform%2Fupstream%2Fllvm.git [SimplifyLibCalls] Emit sqrt intrinsic instead of a libcall. llvm-svn: 277972 --- diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp index 5e648db..a958eee 100644 --- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp @@ -1052,8 +1052,9 @@ Value *LibCallSimplifier::optimizePow(CallInst *CI, IRBuilder<> &B) { if (CI->hasUnsafeAlgebra()) { IRBuilder<>::FastMathFlagGuard Guard(B); B.setFastMathFlags(CI->getFastMathFlags()); - return emitUnaryFloatFnCall(Op1, TLI->getName(LibFunc::sqrt), B, - Callee->getAttributes()); + Value *Sqrt = Intrinsic::getDeclaration(CI->getModule(), Intrinsic::sqrt, + Op1->getType()); + return B.CreateCall(Sqrt, Op1, "sqrt"); } // Expand pow(x, 0.5) to (x == -infinity ? +infinity : fabs(sqrt(x))). diff --git a/llvm/test/Transforms/InstCombine/pow-sqrt.ll b/llvm/test/Transforms/InstCombine/pow-sqrt.ll index 1e6166c..27d804d 100644 --- a/llvm/test/Transforms/InstCombine/pow-sqrt.ll +++ b/llvm/test/Transforms/InstCombine/pow-sqrt.ll @@ -6,7 +6,7 @@ define double @pow_half(double %x) { } ; CHECK-LABEL: define double @pow_half( -; CHECK-NEXT: %sqrt = call fast double @sqrt(double %x) +; CHECK-NEXT: %sqrt = call fast double @llvm.sqrt.f64(double %x) ; CHECK-NEXT: ret double %sqrt declare double @llvm.pow.f64(double, double)