mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-24 12:19:53 +00:00
InstCombine: Canonicalize fast fmuladd to fmul + fadd
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295353 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
62209f2721
commit
89f19b28dd
@ -2044,8 +2044,21 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
|
||||
return replaceInstUsesWith(*II, V);
|
||||
break;
|
||||
}
|
||||
case Intrinsic::fma:
|
||||
case Intrinsic::fmuladd: {
|
||||
// Canonicalize fast fmuladd to the separate fmul + fadd.
|
||||
if (II->hasUnsafeAlgebra()) {
|
||||
BuilderTy::FastMathFlagGuard Guard(*Builder);
|
||||
Builder->setFastMathFlags(II->getFastMathFlags());
|
||||
Value *Mul = Builder->CreateFMul(II->getArgOperand(0),
|
||||
II->getArgOperand(1));
|
||||
Value *Add = Builder->CreateFAdd(Mul, II->getArgOperand(2));
|
||||
Add->takeName(II);
|
||||
return replaceInstUsesWith(*II, Add);
|
||||
}
|
||||
|
||||
LLVM_FALLTHROUGH;
|
||||
}
|
||||
case Intrinsic::fma: {
|
||||
Value *Src0 = II->getArgOperand(0);
|
||||
Value *Src1 = II->getArgOperand(1);
|
||||
|
||||
|
@ -78,7 +78,8 @@ define float @fmuladd_fneg_x_fneg_y(float %x, float %y, float %z) {
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @fmuladd_fneg_x_fneg_y_fast(
|
||||
; CHECK: %fmuladd = call fast float @llvm.fmuladd.f32(float %x, float %y, float %z)
|
||||
; CHECK-NEXT: %1 = fmul fast float %x, %y
|
||||
; CHECK-NEXT: %fmuladd = fadd fast float %1, %z
|
||||
define float @fmuladd_fneg_x_fneg_y_fast(float %x, float %y, float %z) {
|
||||
%x.fneg = fsub float -0.0, %x
|
||||
%y.fneg = fsub float -0.0, %y
|
||||
@ -122,7 +123,8 @@ define float @fmuladd_fabs_x_fabs_x(float %x, float %z) {
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @fmuladd_fabs_x_fabs_x_fast(
|
||||
; CHECK: %fmuladd = call fast float @llvm.fmuladd.f32(float %x, float %x, float %z)
|
||||
; CHECK-NEXT: %1 = fmul fast float %x, %x
|
||||
; CHECK-NEXT: %fmuladd = fadd fast float %1, %z
|
||||
define float @fmuladd_fabs_x_fabs_x_fast(float %x, float %z) {
|
||||
%x.fabs = call float @llvm.fabs.f32(float %x)
|
||||
%fmuladd = call fast float @llvm.fmuladd.f32(float %x.fabs, float %x.fabs, float %z)
|
||||
@ -144,7 +146,8 @@ define float @fma_k_y_z_fast(float %y, float %z) {
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @fmuladd_k_y_z_fast(
|
||||
; CHECK: %fmuladd = call fast float @llvm.fmuladd.f32(float %y, float 4.000000e+00, float %z)
|
||||
; CHECK: %1 = fmul fast float %y, 4.000000e+00
|
||||
; CHECK-NEXT: %fmuladd = fadd fast float %1, %z
|
||||
define float @fmuladd_k_y_z_fast(float %y, float %z) {
|
||||
%fmuladd = call fast float @llvm.fmuladd.f32(float 4.0, float %y, float %z)
|
||||
ret float %fmuladd
|
||||
|
Loading…
Reference in New Issue
Block a user