forked from OSchip/llvm-project
[SimplifyLibCalls] Emit sqrt intrinsic instead of a libcall.
llvm-svn: 277972
This commit is contained in:
parent
68e74847bf
commit
e3b916d164
llvm
|
@ -1052,8 +1052,9 @@ Value *LibCallSimplifier::optimizePow(CallInst *CI, IRBuilder<> &B) {
|
||||||
if (CI->hasUnsafeAlgebra()) {
|
if (CI->hasUnsafeAlgebra()) {
|
||||||
IRBuilder<>::FastMathFlagGuard Guard(B);
|
IRBuilder<>::FastMathFlagGuard Guard(B);
|
||||||
B.setFastMathFlags(CI->getFastMathFlags());
|
B.setFastMathFlags(CI->getFastMathFlags());
|
||||||
return emitUnaryFloatFnCall(Op1, TLI->getName(LibFunc::sqrt), B,
|
Value *Sqrt = Intrinsic::getDeclaration(CI->getModule(), Intrinsic::sqrt,
|
||||||
Callee->getAttributes());
|
Op1->getType());
|
||||||
|
return B.CreateCall(Sqrt, Op1, "sqrt");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expand pow(x, 0.5) to (x == -infinity ? +infinity : fabs(sqrt(x))).
|
// Expand pow(x, 0.5) to (x == -infinity ? +infinity : fabs(sqrt(x))).
|
||||||
|
|
|
@ -6,7 +6,7 @@ define double @pow_half(double %x) {
|
||||||
}
|
}
|
||||||
|
|
||||||
; CHECK-LABEL: define double @pow_half(
|
; 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
|
; CHECK-NEXT: ret double %sqrt
|
||||||
|
|
||||||
declare double @llvm.pow.f64(double, double)
|
declare double @llvm.pow.f64(double, double)
|
||||||
|
|
Loading…
Reference in New Issue