1 ; RUN: llc -O0 -march=amdgcn -mcpu=gfx900 -amdgpu-dpp-combine=false -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX9,GFX9-O0 %s
2 ; RUN: llc -march=amdgcn -mcpu=gfx900 -amdgpu-dpp-combine=false -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX9,GFX9-O3 %s
4 define amdgpu_cs void @no_cfg(<4 x i32> inreg %tmp14) {
5 %tmp100 = call <2 x float> @llvm.amdgcn.raw.buffer.load.v2f32(<4 x i32> %tmp14, i32 0, i32 0, i32 0)
6 %tmp101 = bitcast <2 x float> %tmp100 to <2 x i32>
7 %tmp102 = extractelement <2 x i32> %tmp101, i32 0
8 %tmp103 = extractelement <2 x i32> %tmp101, i32 1
9 %tmp105 = tail call i32 @llvm.amdgcn.set.inactive.i32(i32 %tmp102, i32 0)
10 %tmp107 = tail call i32 @llvm.amdgcn.set.inactive.i32(i32 %tmp103, i32 0)
12 ; GFX9: v_mov_b32_dpp v[[FIRST_MOV:[0-9]+]], v{{[0-9]+}} row_bcast:31 row_mask:0xc bank_mask:0xf
13 ; GFX9: v_add_u32_e32 v[[FIRST_ADD:[0-9]+]], v{{[0-9]+}}, v[[FIRST_MOV]]
14 ; GFX9: v_mov_b32_e32 v[[FIRST:[0-9]+]], v[[FIRST_ADD]]
15 %tmp120 = tail call i32 @llvm.amdgcn.update.dpp.i32(i32 0, i32 %tmp105, i32 323, i32 12, i32 15, i1 false)
16 %tmp121 = add i32 %tmp105, %tmp120
17 %tmp122 = tail call i32 @llvm.amdgcn.wwm.i32(i32 %tmp121)
19 ; GFX9: v_mov_b32_dpp v[[SECOND_MOV:[0-9]+]], v{{[0-9]+}} row_bcast:31 row_mask:0xc bank_mask:0xf
20 ; GFX9: v_add_u32_e32 v[[SECOND_ADD:[0-9]+]], v{{[0-9]+}}, v[[SECOND_MOV]]
21 ; GFX9: v_mov_b32_e32 v[[SECOND:[0-9]+]], v[[SECOND_ADD]]
22 %tmp135 = tail call i32 @llvm.amdgcn.update.dpp.i32(i32 0, i32 %tmp107, i32 323, i32 12, i32 15, i1 false)
23 %tmp136 = add i32 %tmp107, %tmp135
24 %tmp137 = tail call i32 @llvm.amdgcn.wwm.i32(i32 %tmp136)
26 ; GFX9-O3: v_cmp_eq_u32_e32 vcc, v[[FIRST]], v[[SECOND]]
27 ; GFX9-O0: v_cmp_eq_u32_e64 s{{\[}}{{[0-9]+}}:{{[0-9]+}}{{\]}}, v[[FIRST]], v[[SECOND]]
28 %tmp138 = icmp eq i32 %tmp122, %tmp137
29 %tmp139 = sext i1 %tmp138 to i32
30 %tmp140 = shl nsw i32 %tmp139, 1
31 %tmp141 = and i32 %tmp140, 2
32 %tmp145 = bitcast i32 %tmp141 to float
33 call void @llvm.amdgcn.raw.buffer.store.f32(float %tmp145, <4 x i32> %tmp14, i32 4, i32 0, i32 0)
37 define amdgpu_cs void @cfg(<4 x i32> inreg %tmp14, i32 %arg) {
39 %tmp100 = call <2 x float> @llvm.amdgcn.raw.buffer.load.v2f32(<4 x i32> %tmp14, i32 0, i32 0, i32 0)
40 %tmp101 = bitcast <2 x float> %tmp100 to <2 x i32>
41 %tmp102 = extractelement <2 x i32> %tmp101, i32 0
42 %tmp105 = tail call i32 @llvm.amdgcn.set.inactive.i32(i32 %tmp102, i32 0)
44 ; GFX9: v_mov_b32_dpp v[[FIRST_MOV:[0-9]+]], v{{[0-9]+}} row_bcast:31 row_mask:0xc bank_mask:0xf
45 ; GFX9: v_add_u32_e32 v[[FIRST_ADD:[0-9]+]], v{{[0-9]+}}, v[[FIRST_MOV]]
46 ; GFX9: v_mov_b32_e32 v[[FIRST:[0-9]+]], v[[FIRST_ADD]]
47 ; GFX9-O0: buffer_store_dword v[[FIRST]], off, s{{\[}}{{[0-9]+}}:{{[0-9]+}}{{\]}}, s[[FIRST_SGPR_OFFSET:[0-9]+]] offset:[[FIRST_IMM_OFFSET:[0-9]+]]
48 %tmp120 = tail call i32 @llvm.amdgcn.update.dpp.i32(i32 0, i32 %tmp105, i32 323, i32 12, i32 15, i1 false)
49 %tmp121 = add i32 %tmp105, %tmp120
50 %tmp122 = tail call i32 @llvm.amdgcn.wwm.i32(i32 %tmp121)
52 %cond = icmp eq i32 %arg, 0
53 br i1 %cond, label %if, label %merge
55 %tmp103 = extractelement <2 x i32> %tmp101, i32 1
56 %tmp107 = tail call i32 @llvm.amdgcn.set.inactive.i32(i32 %tmp103, i32 0)
58 ; GFX9: v_mov_b32_dpp v[[SECOND_MOV:[0-9]+]], v{{[0-9]+}} row_bcast:31 row_mask:0xc bank_mask:0xf
59 ; GFX9: v_add_u32_e32 v[[SECOND_ADD:[0-9]+]], v{{[0-9]+}}, v[[SECOND_MOV]]
60 ; GFX9: v_mov_b32_e32 v[[SECOND:[0-9]+]], v[[SECOND_ADD]]
61 ; GFX9-O0: buffer_store_dword v[[SECOND]], off, s{{\[}}{{[0-9]+}}:{{[0-9]+}}{{\]}}, s[[SECOND_SGPR_OFFSET:[0-9]+]] offset:[[SECOND_IMM_OFFSET:[0-9]+]]
62 %tmp135 = tail call i32 @llvm.amdgcn.update.dpp.i32(i32 0, i32 %tmp107, i32 323, i32 12, i32 15, i1 false)
63 %tmp136 = add i32 %tmp107, %tmp135
64 %tmp137 = tail call i32 @llvm.amdgcn.wwm.i32(i32 %tmp136)
68 %merge_value = phi i32 [ 0, %entry ], [%tmp137, %if ]
69 ; GFX9-O3: v_cmp_eq_u32_e32 vcc, v[[FIRST]], v[[SECOND]]
70 ; GFX9-O0: buffer_load_dword v[[SECOND:[0-9]+]], off, s{{\[}}{{[0-9]+}}:{{[0-9]+}}{{\]}}, s[[SECOND_SGPR_OFFSET]] offset:[[SECOND_IMM_OFFSET]]
71 ; GFX9-O0: buffer_load_dword v[[FIRST:[0-9]+]], off, s{{\[}}{{[0-9]+}}:{{[0-9]+}}{{\]}}, s[[FIRST_SGPR_OFFSET]] offset:[[FIRST_IMM_OFFSET]]
72 ; GFX9-O0: v_cmp_eq_u32_e64 s{{\[}}{{[0-9]+}}:{{[0-9]+}}{{\]}}, v[[FIRST]], v[[SECOND]]
73 %tmp138 = icmp eq i32 %tmp122, %merge_value
74 %tmp139 = sext i1 %tmp138 to i32
75 %tmp140 = shl nsw i32 %tmp139, 1
76 %tmp141 = and i32 %tmp140, 2
77 %tmp145 = bitcast i32 %tmp141 to float
78 call void @llvm.amdgcn.raw.buffer.store.f32(float %tmp145, <4 x i32> %tmp14, i32 4, i32 0, i32 0)
82 define i32 @called(i32 %a) noinline {
83 ; GFX9: v_add_u32_e32 v1, v0, v0
85 ; GFX9: v_mul_lo_u32 v0, v1, v0
86 %mul = mul i32 %add, %a
87 ; GFX9: v_sub_u32_e32 v0, v0, v1
88 %sub = sub i32 %mul, %add
92 define amdgpu_kernel void @call(<4 x i32> inreg %tmp14, i32 inreg %arg) {
93 ; GFX9-O0: v_mov_b32_e32 v0, s2
94 ; GFX9-O3: v_mov_b32_e32 v2, s0
95 ; GFX9-NEXT: s_not_b64 exec, exec
96 ; GFX9-O0-NEXT: v_mov_b32_e32 v0, s3
97 ; GFX9-O3-NEXT: v_mov_b32_e32 v2, 0
98 ; GFX9-NEXT: s_not_b64 exec, exec
99 %tmp107 = tail call i32 @llvm.amdgcn.set.inactive.i32(i32 %arg, i32 0)
100 ; GFX9-O0: buffer_store_dword v0
101 ; GFX9-O3: v_mov_b32_e32 v0, v2
103 %tmp134 = call i32 @called(i32 %tmp107)
104 ; GFX9-O0: buffer_load_dword v1
105 ; GFX9-O3: v_mov_b32_e32 v1, v0
106 ; GFX9-O0: v_add_u32_e32 v0, v0, v1
107 ; GFX9-O3: v_add_u32_e32 v1, v1, v2
108 %tmp136 = add i32 %tmp134, %tmp107
109 %tmp137 = tail call i32 @llvm.amdgcn.wwm.i32(i32 %tmp136)
110 ; GFX9-O0: buffer_store_dword v2
111 ; GFX9-O3: buffer_store_dword v0
112 call void @llvm.amdgcn.raw.buffer.store.i32(i32 %tmp137, <4 x i32> %tmp14, i32 4, i32 0, i32 0)
116 define i64 @called_i64(i64 %a) noinline {
117 %add = add i64 %a, %a
118 %mul = mul i64 %add, %a
119 %sub = sub i64 %mul, %add
123 define amdgpu_kernel void @call_i64(<4 x i32> inreg %tmp14, i64 inreg %arg) {
124 ; GFX9-O0: v_mov_b32_e32 v0, s0
125 ; GFX9-O0: v_mov_b32_e32 v1, s1
126 ; GFX9-O3: v_mov_b32_e32 v7, s1
127 ; GFX9-O3: v_mov_b32_e32 v6, s0
128 ; GFX9-NEXT: s_not_b64 exec, exec
129 ; GFX9-O0-NEXT: v_mov_b32_e32 v0, s2
130 ; GFX9-O0-NEXT: v_mov_b32_e32 v1, s3
131 ; GFX9-O3-NEXT: v_mov_b32_e32 v6, 0
132 ; GFX9-O3-NEXT: v_mov_b32_e32 v7, 0
133 ; GFX9-NEXT: s_not_b64 exec, exec
134 %tmp107 = tail call i64 @llvm.amdgcn.set.inactive.i64(i64 %arg, i64 0)
135 ; GFX9-O0: buffer_store_dword v0
136 ; GFX9-O0: buffer_store_dword v1
138 %tmp134 = call i64 @called_i64(i64 %tmp107)
139 ; GFX9-O0: buffer_load_dword v6
140 ; GFX9-O0: buffer_load_dword v7
141 %tmp136 = add i64 %tmp134, %tmp107
142 %tmp137 = tail call i64 @llvm.amdgcn.wwm.i64(i64 %tmp136)
143 %tmp138 = bitcast i64 %tmp137 to <2 x i32>
144 call void @llvm.amdgcn.raw.buffer.store.v2i32(<2 x i32> %tmp138, <4 x i32> %tmp14, i32 4, i32 0, i32 0)
148 define amdgpu_cs void @_amdgpu_cs_main(<4 x i32> inreg %desc, i32 %index) {
149 %tmp17 = shl i32 %index, 5
150 ; GFX9: buffer_load_dwordx4
151 %tmp18 = tail call <4 x i32> @llvm.amdgcn.s.buffer.load.v4i32(<4 x i32> %desc, i32 %tmp17, i32 0)
152 %.i0.upto1.bc = bitcast <4 x i32> %tmp18 to <2 x i64>
153 %tmp19 = or i32 %tmp17, 16
154 ; GFX9: buffer_load_dwordx2
155 %tmp20 = tail call <2 x i32> @llvm.amdgcn.s.buffer.load.v2i32(<4 x i32> %desc, i32 %tmp19, i32 0)
156 %.i0.upto1.extract = extractelement <2 x i64> %.i0.upto1.bc, i32 0
157 %tmp22 = tail call i64 @llvm.amdgcn.set.inactive.i64(i64 %.i0.upto1.extract, i64 9223372036854775807)
158 %tmp97 = tail call i64 @llvm.amdgcn.wwm.i64(i64 %tmp22)
159 %.i1.upto1.extract = extractelement <2 x i64> %.i0.upto1.bc, i32 1
160 %tmp99 = tail call i64 @llvm.amdgcn.set.inactive.i64(i64 %.i1.upto1.extract, i64 9223372036854775807)
161 %tmp174 = tail call i64 @llvm.amdgcn.wwm.i64(i64 %tmp99)
162 %.i25 = bitcast <2 x i32> %tmp20 to i64
163 %tmp176 = tail call i64 @llvm.amdgcn.set.inactive.i64(i64 %.i25, i64 9223372036854775807)
164 %tmp251 = tail call i64 @llvm.amdgcn.wwm.i64(i64 %tmp176)
165 %.cast = bitcast i64 %tmp97 to <2 x float>
166 %.cast6 = bitcast i64 %tmp174 to <2 x float>
167 %.cast7 = bitcast i64 %tmp251 to <2 x float>
168 %tmp254 = shufflevector <2 x float> %.cast, <2 x float> %.cast6, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
169 ; GFX9: buffer_store_dwordx4
170 tail call void @llvm.amdgcn.raw.buffer.store.v4f32(<4 x float> %tmp254, <4 x i32> %desc, i32 %tmp17, i32 0, i32 0)
171 ; GFX9: buffer_store_dwordx2
172 tail call void @llvm.amdgcn.raw.buffer.store.v2f32(<2 x float> %.cast7, <4 x i32> %desc, i32 %tmp19, i32 0, i32 0)
176 declare i32 @llvm.amdgcn.wwm.i32(i32)
177 declare i64 @llvm.amdgcn.wwm.i64(i64)
178 declare i32 @llvm.amdgcn.set.inactive.i32(i32, i32)
179 declare i64 @llvm.amdgcn.set.inactive.i64(i64, i64)
180 declare i32 @llvm.amdgcn.update.dpp.i32(i32, i32, i32, i32, i32, i1)
181 declare <2 x float> @llvm.amdgcn.raw.buffer.load.v2f32(<4 x i32>, i32, i32, i32)
182 declare void @llvm.amdgcn.raw.buffer.store.f32(float, <4 x i32>, i32, i32, i32)
183 declare void @llvm.amdgcn.raw.buffer.store.i32(i32, <4 x i32>, i32, i32, i32)
184 declare void @llvm.amdgcn.raw.buffer.store.v2i32(<2 x i32>, <4 x i32>, i32, i32, i32)
185 declare void @llvm.amdgcn.raw.buffer.store.v2f32(<2 x float>, <4 x i32>, i32, i32, i32)
186 declare void @llvm.amdgcn.raw.buffer.store.v4f32(<4 x float>, <4 x i32>, i32, i32, i32)
187 declare <2 x i32> @llvm.amdgcn.s.buffer.load.v2i32(<4 x i32>, i32, i32)
188 declare <4 x i32> @llvm.amdgcn.s.buffer.load.v4i32(<4 x i32>, i32, i32)