1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=amdgcn -mcpu=gfx1200 -run-pass post-RA-hazard-rec,amdgpu-wait-sgpr-hazards -o - %s | FileCheck -check-prefix=GCN %s
5 define amdgpu_gs void @hazard_disable() #0 { ret void }
6 define amdgpu_gs void @hazard_enable() #1 { ret void }
7 define amdgpu_cs void @hazard_calls() #2 { ret void }
8 define void @hazard_callee1() #2 { ret void }
9 define void @hazard_callee2() #2 { ret void }
10 define amdgpu_cs void @hazard_cull_vmem() #3 { ret void }
11 define amdgpu_cs void @hazard_cull_vmem2() #4 { ret void }
12 define amdgpu_cs void @hazard_cull_sample() #3 { ret void }
13 define amdgpu_cs void @hazard_cull_bvh() #3 { ret void }
14 define amdgpu_cs void @hazard_nocull_scratch() #3 { ret void }
15 define amdgpu_cs void @hazard_cull_global() #3 { ret void }
16 define amdgpu_cs void @hazard_nocull_flat() #3 { ret void }
18 attributes #0 = { "amdgpu-sgpr-hazard-wait"="0" }
19 attributes #1 = { "amdgpu-sgpr-hazard-wait"="1" }
20 attributes #2 = { "amdgpu-sgpr-hazard-boundary-cull" }
21 attributes #3 = { "amdgpu-sgpr-hazard-mem-wait-cull" "amdgpu-sgpr-hazard-mem-wait-cull-threshold"="1" }
22 attributes #4 = { "amdgpu-sgpr-hazard-mem-wait-cull" "amdgpu-sgpr-hazard-mem-wait-cull-threshold"="2" }
29 ; GCN-LABEL: name: hazard_disable
30 ; GCN: $vgpr1 = V_CNDMASK_B32_e64 0, $vgpr1, 0, $vgpr2, $sgpr0, implicit $exec
31 ; GCN-NEXT: $sgpr0_sgpr1 = S_GETPC_B64
32 ; GCN-NEXT: $sgpr3 = S_ADD_U32 $sgpr0, 0, implicit-def $scc
33 ; GCN-NEXT: S_ENDPGM 0
34 $vgpr1 = V_CNDMASK_B32_e64 0, $vgpr1, 0, $vgpr2, $sgpr0, implicit $exec
35 $sgpr0_sgpr1 = S_GETPC_B64
36 $sgpr3 = S_ADD_U32 $sgpr0, 0, implicit-def $scc
44 ; GCN-LABEL: name: hazard_enable
45 ; GCN: $vgpr1 = V_CNDMASK_B32_e64 0, $vgpr1, 0, $vgpr2, $sgpr0, implicit $exec
46 ; GCN-NEXT: $sgpr0_sgpr1 = S_GETPC_B64
47 ; GCN-NEXT: S_WAITCNT_DEPCTR 65534
48 ; GCN-NEXT: $sgpr3 = S_ADD_U32 $sgpr0, 0, implicit-def $scc
49 ; GCN-NEXT: S_ENDPGM 0
50 $vgpr1 = V_CNDMASK_B32_e64 0, $vgpr1, 0, $vgpr2, $sgpr0, implicit $exec
51 $sgpr0_sgpr1 = S_GETPC_B64
52 $sgpr3 = S_ADD_U32 $sgpr0, 0, implicit-def $scc
61 ; GCN-LABEL: name: hazard_calls
63 ; GCN-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
65 ; GCN-NEXT: $vgpr0 = V_WRITELANE_B32 0, $sgpr4, $vgpr0
66 ; GCN-NEXT: $vgpr0 = V_WRITELANE_B32 1, $sgpr8, $vgpr0
67 ; GCN-NEXT: $vgpr0 = V_WRITELANE_B32 2, $sgpr16, $vgpr0
68 ; GCN-NEXT: $vgpr0 = V_WRITELANE_B32 3, $sgpr18, $vgpr0
69 ; GCN-NEXT: $vgpr0 = V_WRITELANE_B32 4, $sgpr20, $vgpr0
70 ; GCN-NEXT: $vgpr0 = V_WRITELANE_B32 5, $sgpr22, $vgpr0
71 ; GCN-NEXT: S_CBRANCH_SCC0 %bb.2, implicit $scc
72 ; GCN-NEXT: S_BRANCH %bb.1
75 ; GCN-NEXT: successors: %bb.3(0x40000000), %bb.4(0x40000000)
77 ; GCN-NEXT: S_CBRANCH_SCC0 %bb.3, implicit $scc
78 ; GCN-NEXT: S_BRANCH %bb.4
81 ; GCN-NEXT: $sgpr16 = S_MOV_B32 0
82 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
83 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
84 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
85 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
86 ; GCN-NEXT: S_WAITCNT_DEPCTR 65534
87 ; GCN-NEXT: S_SETPC_B64 $sgpr0_sgpr1
90 ; GCN-NEXT: $sgpr18 = S_MOV_B32 0
91 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
92 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
93 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
94 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
95 ; GCN-NEXT: S_WAITCNT_DEPCTR 65534
96 ; GCN-NEXT: S_SETPC_B64_return $sgpr0_sgpr1
99 ; GCN-NEXT: successors: %bb.5(0x80000000)
101 ; GCN-NEXT: $vcc_lo = S_MOV_B32 0
102 ; GCN-NEXT: $sgpr20 = S_MOV_B32 0
103 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
104 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
105 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
106 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
107 ; GCN-NEXT: S_WAITCNT_DEPCTR 65534
108 ; GCN-NEXT: $sgpr4_sgpr5 = S_SWAPPC_B64 $sgpr2_sgpr3
109 ; GCN-NEXT: $sgpr4 = S_ADD_U32 $sgpr4, 0, implicit-def $scc
112 ; GCN-NEXT: successors: %bb.6(0x80000000)
114 ; GCN-NEXT: $sgpr8_sgpr9 = S_CALL_B64 0
117 ; GCN-NEXT: $sgpr22 = S_MOV_B32 $sgpr8
118 ; GCN-NEXT: S_ENDPGM 0
120 $vgpr0 = V_WRITELANE_B32 0, $sgpr4, $vgpr0
121 $vgpr0 = V_WRITELANE_B32 1, $sgpr8, $vgpr0
122 $vgpr0 = V_WRITELANE_B32 2, $sgpr16, $vgpr0
123 $vgpr0 = V_WRITELANE_B32 3, $sgpr18, $vgpr0
124 $vgpr0 = V_WRITELANE_B32 4, $sgpr20, $vgpr0
125 $vgpr0 = V_WRITELANE_B32 5, $sgpr22, $vgpr0
126 S_CBRANCH_SCC0 %bb.2, implicit $scc
130 S_CBRANCH_SCC0 %bb.3, implicit $scc
134 $sgpr16 = S_MOV_B32 0
135 S_SETPC_B64 $sgpr0_sgpr1
138 $sgpr18 = S_MOV_B32 0
139 S_SETPC_B64_return $sgpr0_sgpr1
142 $vcc_lo = S_MOV_B32 0
143 $sgpr20 = S_MOV_B32 0
144 $sgpr4_sgpr5 = S_SWAPPC_B64 $sgpr2_sgpr3
145 $sgpr4 = S_ADD_U32 $sgpr4, 0, implicit-def $scc
148 $sgpr8_sgpr9 = S_CALL_B64 0
151 $sgpr22 = S_MOV_B32 $sgpr8
159 ; GCN-LABEL: name: hazard_callee1
160 ; GCN: $sgpr1 = S_CSELECT_B32 -1, 0, implicit $scc
161 ; GCN-NEXT: $sgpr2 = S_ADD_U32 $sgpr1, 0, implicit-def $scc
162 ; GCN-NEXT: S_SETPC_B64_return $sgpr30_sgpr31
163 $sgpr1 = S_CSELECT_B32 -1, 0, implicit $scc
164 $sgpr2 = S_ADD_U32 $sgpr1, 0, implicit-def $scc
165 S_SETPC_B64_return $sgpr30_sgpr31
172 ; GCN-LABEL: name: hazard_callee2
173 ; GCN: $vgpr1, $sgpr0 = V_ADDC_U32_e64 0, $vgpr1, $sgpr0, 0, implicit $exec
174 ; GCN-NEXT: $sgpr1 = S_CSELECT_B32 -1, 0, implicit $scc
175 ; GCN-NEXT: S_WAITCNT_DEPCTR 65534
176 ; GCN-NEXT: $sgpr2 = S_ADD_U32 $sgpr1, 0, implicit-def $scc
177 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
178 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
179 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
180 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
181 ; GCN-NEXT: S_SETPC_B64_return $sgpr30_sgpr31
182 $vgpr1, $sgpr0 = V_ADDC_U32_e64 0, $vgpr1, $sgpr0, 0, implicit $exec
183 $sgpr1 = S_CSELECT_B32 -1, 0, implicit $scc
184 $sgpr2 = S_ADD_U32 $sgpr1, 0, implicit-def $scc
185 S_SETPC_B64_return $sgpr30_sgpr31
189 name: hazard_cull_vmem
192 ; GCN-LABEL: name: hazard_cull_vmem
193 ; GCN: $vgpr1, $sgpr0 = V_ADDC_U32_e64 0, $vgpr1, $sgpr0, 0, implicit $exec
194 ; GCN-NEXT: $vgpr3 = BUFFER_LOAD_DWORD_OFFSET $sgpr4_sgpr5_sgpr6_sgpr7, $sgpr8, 0, 0, 0, implicit $exec
195 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
196 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
197 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
198 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
199 ; GCN-NEXT: S_WAIT_LOADCNT 0
200 ; GCN-NEXT: $sgpr0_sgpr1 = S_GETPC_B64
201 ; GCN-NEXT: $sgpr3 = S_ADD_U32 $sgpr0, 0, implicit-def $scc
202 ; GCN-NEXT: S_ENDPGM 0
203 $vgpr1, $sgpr0 = V_ADDC_U32_e64 0, $vgpr1, $sgpr0, 0, implicit $exec
204 $vgpr3 = BUFFER_LOAD_DWORD_OFFSET $sgpr4_sgpr5_sgpr6_sgpr7, $sgpr8, 0, 0, 0, implicit $exec
206 $sgpr0_sgpr1 = S_GETPC_B64
207 $sgpr3 = S_ADD_U32 $sgpr0, 0, implicit-def $scc
212 name: hazard_cull_vmem2
215 ; GCN-LABEL: name: hazard_cull_vmem2
216 ; GCN: $vgpr1, $sgpr0 = V_ADDC_U32_e64 0, $vgpr1, $sgpr0, 0, implicit $exec
217 ; GCN-NEXT: $vgpr3 = BUFFER_LOAD_DWORD_OFFSET $sgpr4_sgpr5_sgpr6_sgpr7, $sgpr8, 0, 0, 0, implicit $exec
218 ; GCN-NEXT: S_WAIT_LOADCNT 0
219 ; GCN-NEXT: $vgpr1, $sgpr0 = V_ADDC_U32_e64 0, $vgpr1, $sgpr2, 0, implicit $exec
220 ; GCN-NEXT: $vgpr4 = BUFFER_LOAD_DWORD_OFFSET $sgpr4_sgpr5_sgpr6_sgpr7, $sgpr8, 0, 0, 0, implicit $exec
221 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
222 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
223 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
224 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
225 ; GCN-NEXT: S_WAIT_LOADCNT 0
226 ; GCN-NEXT: $sgpr0_sgpr1 = S_GETPC_B64
227 ; GCN-NEXT: $sgpr3 = S_ADD_U32 $sgpr0, 0, implicit-def $scc
228 ; GCN-NEXT: S_ENDPGM 0
229 $vgpr1, $sgpr0 = V_ADDC_U32_e64 0, $vgpr1, $sgpr0, 0, implicit $exec
230 $vgpr3 = BUFFER_LOAD_DWORD_OFFSET $sgpr4_sgpr5_sgpr6_sgpr7, $sgpr8, 0, 0, 0, implicit $exec
232 $vgpr1, $sgpr0 = V_ADDC_U32_e64 0, $vgpr1, $sgpr2, 0, implicit $exec
233 $vgpr4 = BUFFER_LOAD_DWORD_OFFSET $sgpr4_sgpr5_sgpr6_sgpr7, $sgpr8, 0, 0, 0, implicit $exec
235 $sgpr0_sgpr1 = S_GETPC_B64
236 $sgpr3 = S_ADD_U32 $sgpr0, 0, implicit-def $scc
241 name: hazard_cull_sample
244 ; GCN-LABEL: name: hazard_cull_sample
245 ; GCN: $vgpr1, $sgpr0 = V_ADDC_U32_e64 0, $vgpr1, $sgpr0, 0, implicit $exec
246 ; GCN-NEXT: $vgpr10 = IMAGE_SAMPLE_LZ_V1_V2_gfx12 $vgpr3, $vgpr4, $sgpr0_sgpr1_sgpr2_sgpr3_sgpr4_sgpr5_sgpr6_sgpr7, $sgpr8_sgpr9_sgpr10_sgpr11, 1, 1, -1, 0, 0, 0, 0, 0, 0, implicit $exec :: (load (s128))
247 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
248 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
249 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
250 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
251 ; GCN-NEXT: S_WAIT_SAMPLECNT 0
252 ; GCN-NEXT: $sgpr0_sgpr1 = S_GETPC_B64
253 ; GCN-NEXT: $sgpr3 = S_ADD_U32 $sgpr0, 0, implicit-def $scc
254 ; GCN-NEXT: S_ENDPGM 0
255 $vgpr1, $sgpr0 = V_ADDC_U32_e64 0, $vgpr1, $sgpr0, 0, implicit $exec
256 $vgpr10 = IMAGE_SAMPLE_LZ_V1_V2_gfx12 $vgpr3, $vgpr4, $sgpr0_sgpr1_sgpr2_sgpr3_sgpr4_sgpr5_sgpr6_sgpr7, $sgpr8_sgpr9_sgpr10_sgpr11, 1, 1, -1, 0, 0, 0, 0, 0, 0, implicit $exec :: (load (s128))
258 $sgpr0_sgpr1 = S_GETPC_B64
259 $sgpr3 = S_ADD_U32 $sgpr0, 0, implicit-def $scc
264 name: hazard_cull_bvh
267 ; GCN-LABEL: name: hazard_cull_bvh
268 ; GCN: $vgpr1, $sgpr0 = V_ADDC_U32_e64 0, $vgpr1, $sgpr0, 0, implicit $exec
269 ; GCN-NEXT: $vgpr0_vgpr1_vgpr2_vgpr3 = IMAGE_BVH_INTERSECT_RAY_sa_gfx11 $vgpr4_vgpr5_vgpr6_vgpr7_vgpr8_vgpr9_vgpr10_vgpr11_vgpr12_vgpr13_vgpr14, renamable $sgpr0_sgpr1_sgpr2_sgpr3, 0, implicit $exec :: (dereferenceable load (s128), addrspace 7)
270 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
271 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
272 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
273 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
274 ; GCN-NEXT: S_WAIT_BVHCNT 0
275 ; GCN-NEXT: $sgpr0_sgpr1 = S_GETPC_B64
276 ; GCN-NEXT: $sgpr3 = S_ADD_U32 $sgpr0, 0, implicit-def $scc
277 ; GCN-NEXT: S_ENDPGM 0
278 $vgpr1, $sgpr0 = V_ADDC_U32_e64 0, $vgpr1, $sgpr0, 0, implicit $exec
279 $vgpr0_vgpr1_vgpr2_vgpr3 = IMAGE_BVH_INTERSECT_RAY_sa_gfx11 $vgpr4_vgpr5_vgpr6_vgpr7_vgpr8_vgpr9_vgpr10_vgpr11_vgpr12_vgpr13_vgpr14, renamable $sgpr0_sgpr1_sgpr2_sgpr3, 0, implicit $exec :: (dereferenceable load (s128), addrspace 7)
281 $sgpr0_sgpr1 = S_GETPC_B64
282 $sgpr3 = S_ADD_U32 $sgpr0, 0, implicit-def $scc
287 name: hazard_nocull_scratch
290 ; GCN-LABEL: name: hazard_nocull_scratch
291 ; GCN: $vgpr1, $sgpr0 = V_ADDC_U32_e64 0, $vgpr1, $sgpr0, 0, implicit $exec
292 ; GCN-NEXT: $vgpr0 = SCRATCH_LOAD_DWORD $vgpr0, 0, 0, implicit $exec, implicit $flat_scr
293 ; GCN-NEXT: S_WAIT_LOADCNT 0
294 ; GCN-NEXT: $sgpr0_sgpr1 = S_GETPC_B64
295 ; GCN-NEXT: S_WAITCNT_DEPCTR 65534
296 ; GCN-NEXT: $sgpr3 = S_ADD_U32 $sgpr0, 0, implicit-def $scc
297 ; GCN-NEXT: S_ENDPGM 0
298 $vgpr1, $sgpr0 = V_ADDC_U32_e64 0, $vgpr1, $sgpr0, 0, implicit $exec
299 $vgpr0 = SCRATCH_LOAD_DWORD $vgpr0, 0, 0, implicit $exec, implicit $flat_scr
301 $sgpr0_sgpr1 = S_GETPC_B64
302 $sgpr3 = S_ADD_U32 $sgpr0, 0, implicit-def $scc
307 name: hazard_cull_global
310 ; GCN-LABEL: name: hazard_cull_global
311 ; GCN: $vgpr1, $sgpr0 = V_ADDC_U32_e64 0, $vgpr1, $sgpr0, 0, implicit $exec
312 ; GCN-NEXT: $vgpr0 = GLOBAL_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec
313 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
314 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
315 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
316 ; GCN-NEXT: DS_NOP implicit $m0, implicit $exec
317 ; GCN-NEXT: S_WAIT_LOADCNT 0
318 ; GCN-NEXT: $sgpr0_sgpr1 = S_GETPC_B64
319 ; GCN-NEXT: $sgpr3 = S_ADD_U32 $sgpr0, 0, implicit-def $scc
320 ; GCN-NEXT: S_ENDPGM 0
321 $vgpr1, $sgpr0 = V_ADDC_U32_e64 0, $vgpr1, $sgpr0, 0, implicit $exec
322 $vgpr0 = GLOBAL_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec
324 $sgpr0_sgpr1 = S_GETPC_B64
325 $sgpr3 = S_ADD_U32 $sgpr0, 0, implicit-def $scc
330 name: hazard_nocull_flat
333 ; GCN-LABEL: name: hazard_nocull_flat
334 ; GCN: $vgpr1, $sgpr0 = V_ADDC_U32_e64 0, $vgpr1, $sgpr0, 0, implicit $exec
335 ; GCN-NEXT: $vgpr0 = FLAT_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr
336 ; GCN-NEXT: S_WAIT_LOADCNT 0
337 ; GCN-NEXT: $sgpr0_sgpr1 = S_GETPC_B64
338 ; GCN-NEXT: S_WAITCNT_DEPCTR 65534
339 ; GCN-NEXT: $sgpr3 = S_ADD_U32 $sgpr0, 0, implicit-def $scc
340 ; GCN-NEXT: S_ENDPGM 0
341 $vgpr1, $sgpr0 = V_ADDC_U32_e64 0, $vgpr1, $sgpr0, 0, implicit $exec
342 $vgpr0 = FLAT_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr
344 $sgpr0_sgpr1 = S_GETPC_B64
345 $sgpr3 = S_ADD_U32 $sgpr0, 0, implicit-def $scc