Skip to content

Commit

Permalink
[AMDGPU] New test case where it is better not to form FMA
Browse files Browse the repository at this point in the history
  • Loading branch information
jayfoad committed Jun 1, 2023
1 parent 2697ffd commit e2490b7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions llvm/test/CodeGen/AMDGPU/dagcombine-fma-fmad.ll
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,23 @@ define amdgpu_ps float @fmac_sequence_innermost_fmul_multiple_use(float inreg %a
ret float %t7
}

; "fmul %m, 2.0" could select to an FMA instruction, but it is no better than
; selecting it as a multiply. In some cases the multiply is better because
; SIFoldOperands can fold it into a previous instruction as an output modifier.
define amdgpu_ps float @fma_vs_output_modifier(float %x, i32 %n) #0 {
; GCN-LABEL: fma_vs_output_modifier:
; GCN: ; %bb.0:
; GCN-NEXT: v_cvt_f32_i32_e64 v1, v1 mul:2
; GCN-NEXT: v_mul_f32_e32 v0, v0, v0
; GCN-NEXT: v_mul_f32_e32 v0, v0, v1
; GCN-NEXT: ; return to shader part epilog
%s = sitofp i32 %n to float
%m = fmul contract float %x, %x
%a = fmul contract float %m, 2.0
%r = fmul reassoc nsz float %a, %s
ret float %r
}

; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
declare float @llvm.maxnum.f32(float, float) #1

Expand Down

0 comments on commit e2490b7

Please sign in to comment.