[llvm] r292176 - SimplifyLibCalls: Remove checks for fabs
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 16 16:30:32 PST 2017
Author: arsenm
Date: Mon Jan 16 18:30:31 2017
New Revision: 292176
URL: http://llvm.org/viewvc/llvm-project?rev=292176&view=rev
Log:
SimplifyLibCalls: Remove checks for fabs
Use the intrinsic instead of emitting the libcall which
will be replaced by the intrinsic.
Modified:
llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp
llvm/trunk/test/Transforms/InstCombine/win-math.ll
Modified: llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp?rev=292176&r1=292175&r2=292176&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp Mon Jan 16 18:30:31 2017
@@ -1094,9 +1094,7 @@ Value *LibCallSimplifier::optimizePow(Ca
if (Op2C->isExactlyValue(0.5) &&
hasUnaryFloatFn(TLI, Op2->getType(), LibFunc::sqrt, LibFunc::sqrtf,
- LibFunc::sqrtl) &&
- hasUnaryFloatFn(TLI, Op2->getType(), LibFunc::fabs, LibFunc::fabsf,
- LibFunc::fabsl)) {
+ LibFunc::sqrtl)) {
// In -ffast-math, pow(x, 0.5) -> sqrt(x).
if (CI->hasUnsafeAlgebra()) {
@@ -1116,8 +1114,12 @@ Value *LibCallSimplifier::optimizePow(Ca
Value *Inf = ConstantFP::getInfinity(CI->getType());
Value *NegInf = ConstantFP::getInfinity(CI->getType(), true);
Value *Sqrt = emitUnaryFloatFnCall(Op1, "sqrt", B, Callee->getAttributes());
- Value *FAbs =
- emitUnaryFloatFnCall(Sqrt, "fabs", B, Callee->getAttributes());
+
+ Module *M = Callee->getParent();
+ Function *FabsF = Intrinsic::getDeclaration(M, Intrinsic::fabs,
+ CI->getType());
+ Value *FAbs = B.CreateCall(FabsF, Sqrt);
+
Value *FCmp = B.CreateFCmpOEQ(Op1, NegInf);
Value *Sel = B.CreateSelect(FCmp, Inf, FAbs);
return Sel;
Modified: llvm/trunk/test/Transforms/InstCombine/win-math.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/win-math.ll?rev=292176&r1=292175&r2=292176&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/win-math.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/win-math.ll Mon Jan 16 18:30:31 2017
@@ -279,9 +279,12 @@ define float @float_powsqrt(float %x) no
; WIN32-LABEL: @float_powsqrt(
; WIN32-NOT: float @sqrtf
; WIN32: float @powf
+
; WIN64-LABEL: @float_powsqrt(
-; WIN64-NOT: float @sqrtf
-; WIN64: float @powf
+; WIN64: float @sqrtf
+; WIN64: float @llvm.fabs.f32(
+; WIN64-NOT: float @powf
+
; MINGW32-LABEL: @float_powsqrt(
; MINGW32: float @sqrtf
; MINGW32: float @llvm.fabs.f32
More information about the llvm-commits
mailing list