[SimplifyLibCalls] Emit sqrt intrinsic instead of a libcall.

llvm-svn: 277972
This commit is contained in:
Davide Italiano 2016-08-08 03:23:01 +00:00
parent 68e74847bf
commit e3b916d164
2 changed files with 4 additions and 3 deletions

View File

@ -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))).

View File

@ -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)