summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp5
-rw-r--r--llvm/test/Transforms/InstCombine/pow-sqrt.ll2
2 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
index 5e648db7ed5..a958eeeae88 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 1e6166c5f11..27d804dd5fc 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)
OpenPOWER on IntegriCloud