1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -march=amdgcn -mcpu=gfx90a -run-pass si-insert-waitcnts -verify-machineinstrs %s -o - | FileCheck -check-prefix=GCN %s
5 define amdgpu_kernel void @flat_zero_waitcnt(i32 addrspace(1)* %global4,
6 <4 x i32> addrspace(1)* %global16,
12 define amdgpu_kernel void @single_fallthrough_successor_no_end_block_wait() {
16 define amdgpu_kernel void @single_branch_successor_not_next_block() {
20 define amdgpu_kernel void @preexisting_waitcnt() {
24 define amdgpu_kernel void @bundle_no_waitcnt() {
28 define amdgpu_kernel void @preexisting_waitcnt_in_bundle() {
32 define amdgpu_kernel void @insert_in_bundle() {
36 define amdgpu_kernel void @exit_bundle() {
40 define amdgpu_kernel void @cross_bundle() {
48 # Global loads will return in order so we should:
55 name: flat_zero_waitcnt
58 ; GCN-LABEL: name: flat_zero_waitcnt
60 ; GCN: successors: %bb.1(0x80000000)
62 ; GCN: $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr :: (load (s32) from %ir.global4, addrspace 1)
63 ; GCN: $agpr4_agpr5_agpr6_agpr7 = FLAT_LOAD_DWORDX4 $vgpr8_vgpr9, 0, 0, implicit $exec, implicit $flat_scr :: (load (s128) from %ir.global16, addrspace 1)
65 ; GCN: $agpr0 = V_ACCVGPR_MOV_B32 $agpr1, implicit $exec
68 ; GCN: successors: %bb.2(0x80000000)
69 ; GCN: $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr
71 ; GCN: $agpr4_agpr5_agpr6_agpr7 = FLAT_LOAD_DWORDX4 $vgpr8_vgpr9, 0, 0, implicit $exec, implicit $flat_scr :: (load (s128) from %ir.global16, addrspace 1)
72 ; GCN: $vgpr0 = V_ACCVGPR_READ_B32_e64 $agpr1, implicit $exec
75 ; GCN: S_WAITCNT 49279
76 ; GCN: $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr :: (load (s32) from %ir.flat4)
78 ; GCN: $agpr4_agpr5_agpr6_agpr7 = FLAT_LOAD_DWORDX4 $vgpr8_vgpr9, 0, 0, implicit $exec, implicit $flat_scr :: (load (s128) from %ir.flat16)
79 ; GCN: $vgpr0 = V_ACCVGPR_READ_B32_e64 $agpr1, implicit $exec
83 $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr :: (load (s32) from %ir.global4)
84 $agpr4_agpr5_agpr6_agpr7 = FLAT_LOAD_DWORDX4 $vgpr8_vgpr9, 0, 0, implicit $exec, implicit $flat_scr :: (load (s128) from %ir.global16)
85 $agpr0 = V_ACCVGPR_MOV_B32 $agpr1, implicit $exec
90 $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr
91 $agpr4_agpr5_agpr6_agpr7 = FLAT_LOAD_DWORDX4 $vgpr8_vgpr9, 0, 0, implicit $exec, implicit $flat_scr :: (load (s128) from %ir.global16)
92 $vgpr0 = V_ACCVGPR_READ_B32_e64 $agpr1, implicit $exec
96 $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr :: (load (s32) from %ir.flat4)
97 $agpr4_agpr5_agpr6_agpr7 = FLAT_LOAD_DWORDX4 $vgpr8_vgpr9, 0, 0, implicit $exec, implicit $flat_scr :: (load (s128) from %ir.flat16)
98 $vgpr0 = V_ACCVGPR_READ_B32_e64 $agpr1, implicit $exec
102 # There is only a single fallthrough successor block, so there's no
103 # need to wait immediately.
106 name: single_fallthrough_successor_no_end_block_wait
109 ; GCN-LABEL: name: single_fallthrough_successor_no_end_block_wait
111 ; GCN: successors: %bb.1(0x80000000)
113 ; GCN: $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr
115 ; GCN: $vgpr4_vgpr5 = V_LSHLREV_B64_e64 4, $vgpr8_vgpr9, implicit $exec
117 ; GCN: FLAT_STORE_DWORD $vgpr4_vgpr5, $agpr0, 0, 0, implicit $exec, implicit $flat_scr
121 $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr
124 $vgpr4_vgpr5 = V_LSHLREV_B64_e64 4, $vgpr8_vgpr9, implicit $exec
125 FLAT_STORE_DWORD $vgpr4_vgpr5, $agpr0, 0, 0, implicit $exec, implicit $flat_scr
129 # The block has a single predecessor with a single successor, but it
130 # is not the next block so it's non-obvious that the wait is not needed.
135 name: single_branch_successor_not_next_block
138 ; GCN-LABEL: name: single_branch_successor_not_next_block
140 ; GCN: successors: %bb.2(0x80000000)
142 ; GCN: $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr
143 ; GCN: S_BRANCH %bb.2
145 ; GCN: FLAT_STORE_DWORD $vgpr8_vgpr9, $agpr10, 0, 0, implicit $exec, implicit $flat_scr
148 ; GCN: $vgpr4_vgpr5 = V_LSHLREV_B64_e64 4, $vgpr8_vgpr9, implicit $exec
150 ; GCN: FLAT_STORE_DWORD $vgpr4_vgpr5, $agpr0, 0, 0, implicit $exec, implicit $flat_scr
154 $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr
158 FLAT_STORE_DWORD $vgpr8_vgpr9, $agpr10, 0, 0, implicit $exec, implicit $flat_scr
162 $vgpr4_vgpr5 = V_LSHLREV_B64_e64 4, $vgpr8_vgpr9, implicit $exec
163 FLAT_STORE_DWORD $vgpr4_vgpr5, $agpr0, 0, 0, implicit $exec, implicit $flat_scr
167 # GCN-LABEL: name: preexisting_waitcnt{{$}}
168 # GCN: FLAT_LOAD_DWORD
169 # GCN-NEXT: S_WAITCNT 0
171 name: preexisting_waitcnt
172 tracksRegLiveness: true
174 isEntryFunction: true
177 liveins: $vgpr1_vgpr2
178 $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr
180 FLAT_STORE_DWORD $vgpr2_vgpr3, $agpr0, 0, 0, implicit $exec, implicit $flat_scr
186 name: bundle_no_waitcnt
187 tracksRegLiveness: true
189 isEntryFunction: true
192 liveins: $vgpr1_vgpr2
193 ; GCN-LABEL: name: bundle_no_waitcnt
194 ; GCN: liveins: $vgpr1_vgpr2
195 ; GCN: $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr
201 ; GCN: FLAT_STORE_DWORD $vgpr2_vgpr3, $agpr0, 0, 0, implicit $exec, implicit $flat_scr
202 $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr
207 FLAT_STORE_DWORD $vgpr2_vgpr3, $agpr0, 0, 0, implicit $exec, implicit $flat_scr
213 # See the waitcnt inside the bundle and don't insert an extra
214 name: preexisting_waitcnt_in_bundle
215 tracksRegLiveness: true
217 isEntryFunction: true
220 liveins: $vgpr1_vgpr2
221 ; GCN-LABEL: name: preexisting_waitcnt_in_bundle
222 ; GCN: liveins: $vgpr1_vgpr2
223 ; GCN: $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr
228 ; GCN: FLAT_STORE_DWORD $vgpr2_vgpr3, $agpr0, 0, 0, implicit $exec, implicit $flat_scr
229 $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr
234 FLAT_STORE_DWORD $vgpr2_vgpr3, $agpr0, 0, 0, implicit $exec, implicit $flat_scr
240 # Def and use inside bundle
242 name: insert_in_bundle
243 tracksRegLiveness: true
245 isEntryFunction: true
248 liveins: $vgpr1_vgpr2
249 ; GCN-LABEL: name: insert_in_bundle
250 ; GCN: liveins: $vgpr1_vgpr2
251 ; GCN: BUNDLE implicit-def $agpr0, implicit $vgpr2_vgpr3 {
252 ; GCN: $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr
254 ; GCN: FLAT_STORE_DWORD $vgpr2_vgpr3, internal $agpr0, 0, 0, implicit $exec, implicit $flat_scr
256 BUNDLE implicit-def $agpr0, implicit $vgpr2_vgpr3 {
257 $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr
258 FLAT_STORE_DWORD $vgpr2_vgpr3, internal $agpr0, 0, 0, implicit $exec, implicit $flat_scr
264 # Def is last instruction in bundle, use is outside bundle
268 tracksRegLiveness: true
270 isEntryFunction: true
273 liveins: $vgpr1_vgpr2
274 ; GCN-LABEL: name: exit_bundle
275 ; GCN: liveins: $vgpr1_vgpr2
276 ; GCN: BUNDLE implicit-def $agpr0, implicit $vgpr2_vgpr3 {
277 ; GCN: $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr
280 ; GCN: FLAT_STORE_DWORD $vgpr2_vgpr3, $agpr0, 0, 0, implicit $exec, implicit $flat_scr
281 BUNDLE implicit-def $agpr0, implicit $vgpr2_vgpr3 {
282 $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr
285 FLAT_STORE_DWORD $vgpr2_vgpr3, $agpr0, 0, 0, implicit $exec, implicit $flat_scr
291 # Def is in bundle, use is in another bundle
295 tracksRegLiveness: true
297 isEntryFunction: true
300 liveins: $vgpr1_vgpr2
301 ; GCN-LABEL: name: cross_bundle
302 ; GCN: liveins: $vgpr1_vgpr2
303 ; GCN: BUNDLE implicit-def $agpr0, implicit $vgpr2_vgpr3 {
304 ; GCN: $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr
307 ; GCN: BUNDLE implicit $agpr0, implicit $vgpr2_vgpr3 {
308 ; GCN: FLAT_STORE_DWORD $vgpr2_vgpr3, $agpr0, 0, 0, implicit $exec, implicit $flat_scr
310 BUNDLE implicit-def $agpr0, implicit $vgpr2_vgpr3 {
311 $agpr0 = FLAT_LOAD_DWORD $vgpr2_vgpr3, 0, 0, implicit $exec, implicit $flat_scr
313 BUNDLE implicit $agpr0, implicit $vgpr2_vgpr3 {
314 FLAT_STORE_DWORD $vgpr2_vgpr3, $agpr0, 0, 0, implicit $exec, implicit $flat_scr