1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -global-isel -march=amdgcn -mcpu=gfx900 --denormal-fp-math=preserve-sign < %s | FileCheck -check-prefix=GFX9-FAST-DENORM %s
3 ; RUN: llc -global-isel -march=amdgcn -mcpu=gfx1010 --denormal-fp-math=preserve-sign < %s | FileCheck -check-prefix=GFX10-FAST-DENORM %s
5 ; fold (fadd fast (fpext (fmul fast x, y)), z) -> (fma (fpext x), (fpext y), z)
6 ; fold (fadd fast x, (fpext (fmul fast y, z))) -> (fma (fpext y), (fpext z), x)
8 define amdgpu_vs float @test_f16_f32_add_ext_mul(half inreg %x, half inreg %y, float inreg %z) {
9 ; GFX9-FAST-DENORM-LABEL: test_f16_f32_add_ext_mul:
10 ; GFX9-FAST-DENORM: ; %bb.0: ; %.entry
11 ; GFX9-FAST-DENORM-NEXT: v_mov_b32_e32 v0, s1
12 ; GFX9-FAST-DENORM-NEXT: v_mov_b32_e32 v1, s2
13 ; GFX9-FAST-DENORM-NEXT: v_mad_mix_f32 v0, s0, v0, v1 op_sel_hi:[1,1,0]
14 ; GFX9-FAST-DENORM-NEXT: ; return to shader part epilog
16 ; GFX10-FAST-DENORM-LABEL: test_f16_f32_add_ext_mul:
17 ; GFX10-FAST-DENORM: ; %bb.0: ; %.entry
18 ; GFX10-FAST-DENORM-NEXT: v_mov_b32_e32 v0, s2
19 ; GFX10-FAST-DENORM-NEXT: v_fma_mix_f32 v0, s0, s1, v0 op_sel_hi:[1,1,0]
20 ; GFX10-FAST-DENORM-NEXT: ; return to shader part epilog
22 %a = fmul fast half %x, %y
23 %b = fpext half %a to float
24 %c = fadd fast float %b, %z
28 define amdgpu_vs float @test_f16_f32_add_ext_mul_rhs(half inreg %x, half inreg %y, float inreg %z) {
29 ; GFX9-FAST-DENORM-LABEL: test_f16_f32_add_ext_mul_rhs:
30 ; GFX9-FAST-DENORM: ; %bb.0: ; %.entry
31 ; GFX9-FAST-DENORM-NEXT: v_mov_b32_e32 v0, s1
32 ; GFX9-FAST-DENORM-NEXT: v_mov_b32_e32 v1, s2
33 ; GFX9-FAST-DENORM-NEXT: v_mad_mix_f32 v0, s0, v0, v1 op_sel_hi:[1,1,0]
34 ; GFX9-FAST-DENORM-NEXT: ; return to shader part epilog
36 ; GFX10-FAST-DENORM-LABEL: test_f16_f32_add_ext_mul_rhs:
37 ; GFX10-FAST-DENORM: ; %bb.0: ; %.entry
38 ; GFX10-FAST-DENORM-NEXT: v_mov_b32_e32 v0, s2
39 ; GFX10-FAST-DENORM-NEXT: v_fma_mix_f32 v0, s0, s1, v0 op_sel_hi:[1,1,0]
40 ; GFX10-FAST-DENORM-NEXT: ; return to shader part epilog
42 %a = fmul fast half %x, %y
43 %b = fpext half %a to float
44 %c = fadd fast float %z, %b
48 define amdgpu_vs <5 x float> @test_5xf16_5xf32_add_ext_mul(<5 x half> inreg %x, <5 x half> inreg %y, <5 x float> inreg %z) {
49 ; GFX9-FAST-DENORM-LABEL: test_5xf16_5xf32_add_ext_mul:
50 ; GFX9-FAST-DENORM: ; %bb.0: ; %.entry
51 ; GFX9-FAST-DENORM-NEXT: v_mov_b32_e32 v0, s3
52 ; GFX9-FAST-DENORM-NEXT: v_mov_b32_e32 v1, s4
53 ; GFX9-FAST-DENORM-NEXT: v_mov_b32_e32 v2, s5
54 ; GFX9-FAST-DENORM-NEXT: v_pk_mul_f16 v0, s0, v0
55 ; GFX9-FAST-DENORM-NEXT: v_pk_mul_f16 v1, s1, v1
56 ; GFX9-FAST-DENORM-NEXT: v_pk_mul_f16 v2, s2, v2
57 ; GFX9-FAST-DENORM-NEXT: v_cvt_f32_f16_e32 v3, v0
58 ; GFX9-FAST-DENORM-NEXT: v_cvt_f32_f16_sdwa v4, v0 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1
59 ; GFX9-FAST-DENORM-NEXT: v_cvt_f32_f16_e32 v5, v1
60 ; GFX9-FAST-DENORM-NEXT: v_cvt_f32_f16_sdwa v6, v1 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1
61 ; GFX9-FAST-DENORM-NEXT: v_cvt_f32_f16_e32 v7, v2
62 ; GFX9-FAST-DENORM-NEXT: v_add_f32_e32 v0, s6, v3
63 ; GFX9-FAST-DENORM-NEXT: v_add_f32_e32 v1, s7, v4
64 ; GFX9-FAST-DENORM-NEXT: v_add_f32_e32 v2, s8, v5
65 ; GFX9-FAST-DENORM-NEXT: v_add_f32_e32 v3, s9, v6
66 ; GFX9-FAST-DENORM-NEXT: v_add_f32_e32 v4, s10, v7
67 ; GFX9-FAST-DENORM-NEXT: ; return to shader part epilog
69 ; GFX10-FAST-DENORM-LABEL: test_5xf16_5xf32_add_ext_mul:
70 ; GFX10-FAST-DENORM: ; %bb.0: ; %.entry
71 ; GFX10-FAST-DENORM-NEXT: v_mov_b32_e32 v0, s6
72 ; GFX10-FAST-DENORM-NEXT: v_mov_b32_e32 v1, s7
73 ; GFX10-FAST-DENORM-NEXT: v_mov_b32_e32 v2, s8
74 ; GFX10-FAST-DENORM-NEXT: v_mov_b32_e32 v3, s9
75 ; GFX10-FAST-DENORM-NEXT: v_mov_b32_e32 v4, s10
76 ; GFX10-FAST-DENORM-NEXT: v_fma_mix_f32 v0, s0, s3, v0 op_sel_hi:[1,1,0]
77 ; GFX10-FAST-DENORM-NEXT: v_fma_mix_f32 v1, s0, s3, v1 op_sel:[1,1,0] op_sel_hi:[1,1,0]
78 ; GFX10-FAST-DENORM-NEXT: v_fma_mix_f32 v2, s1, s4, v2 op_sel_hi:[1,1,0]
79 ; GFX10-FAST-DENORM-NEXT: v_fma_mix_f32 v3, s1, s4, v3 op_sel:[1,1,0] op_sel_hi:[1,1,0]
80 ; GFX10-FAST-DENORM-NEXT: v_fma_mix_f32 v4, s2, s5, v4 op_sel_hi:[1,1,0]
81 ; GFX10-FAST-DENORM-NEXT: ; return to shader part epilog
83 %a = fmul fast <5 x half> %x, %y
84 %b = fpext <5 x half> %a to <5 x float>
85 %c = fadd fast <5 x float> %b, %z
89 define amdgpu_vs <6 x float> @test_6xf16_6xf32_add_ext_mul_rhs(<6 x half> inreg %x, <6 x half> inreg %y, <6 x float> inreg %z) {
90 ; GFX9-FAST-DENORM-LABEL: test_6xf16_6xf32_add_ext_mul_rhs:
91 ; GFX9-FAST-DENORM: ; %bb.0: ; %.entry
92 ; GFX9-FAST-DENORM-NEXT: v_mov_b32_e32 v0, s3
93 ; GFX9-FAST-DENORM-NEXT: v_mov_b32_e32 v1, s4
94 ; GFX9-FAST-DENORM-NEXT: v_mov_b32_e32 v2, s5
95 ; GFX9-FAST-DENORM-NEXT: v_pk_mul_f16 v0, s0, v0
96 ; GFX9-FAST-DENORM-NEXT: v_pk_mul_f16 v1, s1, v1
97 ; GFX9-FAST-DENORM-NEXT: v_pk_mul_f16 v2, s2, v2
98 ; GFX9-FAST-DENORM-NEXT: v_cvt_f32_f16_e32 v3, v0
99 ; GFX9-FAST-DENORM-NEXT: v_cvt_f32_f16_sdwa v4, v0 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1
100 ; GFX9-FAST-DENORM-NEXT: v_cvt_f32_f16_e32 v5, v1
101 ; GFX9-FAST-DENORM-NEXT: v_cvt_f32_f16_sdwa v6, v1 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1
102 ; GFX9-FAST-DENORM-NEXT: v_cvt_f32_f16_e32 v7, v2
103 ; GFX9-FAST-DENORM-NEXT: v_cvt_f32_f16_sdwa v8, v2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1
104 ; GFX9-FAST-DENORM-NEXT: v_add_f32_e32 v0, s6, v3
105 ; GFX9-FAST-DENORM-NEXT: v_add_f32_e32 v1, s7, v4
106 ; GFX9-FAST-DENORM-NEXT: v_add_f32_e32 v2, s8, v5
107 ; GFX9-FAST-DENORM-NEXT: v_add_f32_e32 v3, s9, v6
108 ; GFX9-FAST-DENORM-NEXT: v_add_f32_e32 v4, s10, v7
109 ; GFX9-FAST-DENORM-NEXT: v_add_f32_e32 v5, s11, v8
110 ; GFX9-FAST-DENORM-NEXT: ; return to shader part epilog
112 ; GFX10-FAST-DENORM-LABEL: test_6xf16_6xf32_add_ext_mul_rhs:
113 ; GFX10-FAST-DENORM: ; %bb.0: ; %.entry
114 ; GFX10-FAST-DENORM-NEXT: v_mov_b32_e32 v0, s6
115 ; GFX10-FAST-DENORM-NEXT: v_mov_b32_e32 v1, s7
116 ; GFX10-FAST-DENORM-NEXT: v_mov_b32_e32 v2, s8
117 ; GFX10-FAST-DENORM-NEXT: v_mov_b32_e32 v3, s9
118 ; GFX10-FAST-DENORM-NEXT: v_mov_b32_e32 v4, s10
119 ; GFX10-FAST-DENORM-NEXT: v_mov_b32_e32 v5, s11
120 ; GFX10-FAST-DENORM-NEXT: v_fma_mix_f32 v0, s0, s3, v0 op_sel_hi:[1,1,0]
121 ; GFX10-FAST-DENORM-NEXT: v_fma_mix_f32 v1, s0, s3, v1 op_sel:[1,1,0] op_sel_hi:[1,1,0]
122 ; GFX10-FAST-DENORM-NEXT: v_fma_mix_f32 v2, s1, s4, v2 op_sel_hi:[1,1,0]
123 ; GFX10-FAST-DENORM-NEXT: v_fma_mix_f32 v3, s1, s4, v3 op_sel:[1,1,0] op_sel_hi:[1,1,0]
124 ; GFX10-FAST-DENORM-NEXT: v_fma_mix_f32 v4, s2, s5, v4 op_sel_hi:[1,1,0]
125 ; GFX10-FAST-DENORM-NEXT: v_fma_mix_f32 v5, s2, s5, v5 op_sel:[1,1,0] op_sel_hi:[1,1,0]
126 ; GFX10-FAST-DENORM-NEXT: ; return to shader part epilog
128 %a = fmul fast <6 x half> %x, %y
129 %b = fpext <6 x half> %a to <6 x float>
130 %c = fadd fast <6 x float> %z, %b