mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 02:52:53 +02:00
SimplifyLibCalls: Remove checks for fabs
Use the intrinsic instead of emitting the libcall which will be replaced by the intrinsic. llvm-svn: 292176
This commit is contained in:
parent
4212c78a62
commit
018a8adda0
@ -1094,9 +1094,7 @@ Value *LibCallSimplifier::optimizePow(CallInst *CI, IRBuilder<> &B) {
|
||||
|
||||
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(CallInst *CI, IRBuilder<> &B) {
|
||||
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;
|
||||
|
@ -279,9 +279,12 @@ define float @float_powsqrt(float %x) nounwind readnone {
|
||||
; 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
|
||||
|
Loading…
Reference in New Issue
Block a user