1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -march=amdgcn -mcpu=gfx908 -verify-machineinstrs -run-pass si-insert-waitcnts -o - %s | FileCheck -check-prefixes=GFX9 %s
5 name: test_waitcnt_preexisting_lgkmcnt_unmodified
10 ; GFX9-LABEL: name: test_waitcnt_preexisting_lgkmcnt_unmodified
12 ; GFX9: $vgpr0_vgpr1 = DS_READ2_B32 $vgpr0, 0, 1, 0, implicit $m0, implicit $exec
13 ; GFX9: S_WAITCNT 49279
14 ; GFX9: $vgpr0 = FLAT_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr
16 ; GFX9: FLAT_STORE_DWORD $vgpr0_vgpr1, $vgpr0, 0, 0, implicit $exec, implicit $flat_scr
18 $vgpr0_vgpr1 = DS_READ2_B32 $vgpr0, 0, 1, 0, implicit $m0, implicit $exec
20 $vgpr0 = FLAT_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr
21 FLAT_STORE_DWORD $vgpr0_vgpr1, $vgpr0, 0, 0, implicit $exec, implicit $flat_scr
26 name: test_waitcnt_preexisting_vmcnt_unmodified
31 ; GFX9-LABEL: name: test_waitcnt_preexisting_vmcnt_unmodified
33 ; GFX9: $vgpr0_vgpr1 = GLOBAL_LOAD_DWORDX2 $vgpr0_vgpr1, 0, 0, implicit $exec
34 ; GFX9: S_WAITCNT 3952
35 ; GFX9: $vgpr0 = FLAT_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr
37 ; GFX9: FLAT_STORE_DWORD $vgpr0_vgpr1, $vgpr0, 0, 0, implicit $exec, implicit $flat_scr
39 $vgpr0_vgpr1 = GLOBAL_LOAD_DWORDX2 $vgpr0_vgpr1, 0, 0, implicit $exec
41 $vgpr0 = FLAT_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr
42 FLAT_STORE_DWORD $vgpr0_vgpr1, $vgpr0, 0, 0, implicit $exec, implicit $flat_scr
46 # Respect preexisting waitcnt and add required wait.
49 name: test_waitcnt_preexisting_vmcnt_needs_lgkmcnt
54 ; GFX9-LABEL: name: test_waitcnt_preexisting_vmcnt_needs_lgkmcnt
56 ; GFX9: $vgpr0_vgpr1 = DS_READ2_B32 $vgpr0, 0, 1, 0, implicit $m0, implicit $exec
58 ; GFX9: $vgpr0 = FLAT_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr
60 ; GFX9: FLAT_STORE_DWORD $vgpr0_vgpr1, $vgpr0, 0, 0, implicit $exec, implicit $flat_scr
62 $vgpr0_vgpr1 = DS_READ2_B32 $vgpr0, 0, 1, 0, implicit $m0, implicit $exec
64 $vgpr0 = FLAT_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr
65 FLAT_STORE_DWORD $vgpr0_vgpr1, $vgpr0, 0, 0, implicit $exec, implicit $flat_scr
70 name: test_waitcnt_preexisting_lgkmcnt_needs_vmcnt
75 ; GFX9-LABEL: name: test_waitcnt_preexisting_lgkmcnt_needs_vmcnt
77 ; GFX9: $vgpr0_vgpr1 = GLOBAL_LOAD_DWORDX2 $vgpr0_vgpr1, 0, 0, implicit $exec
79 ; GFX9: $vgpr0 = FLAT_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr
81 ; GFX9: FLAT_STORE_DWORD $vgpr0_vgpr1, $vgpr0, 0, 0, implicit $exec, implicit $flat_scr
83 $vgpr0_vgpr1 = GLOBAL_LOAD_DWORDX2 $vgpr0_vgpr1, 0, 0, implicit $exec
85 $vgpr0 = FLAT_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr
86 FLAT_STORE_DWORD $vgpr0_vgpr1, $vgpr0, 0, 0, implicit $exec, implicit $flat_scr
90 # Apply wait for all counters from preexisting waitcnt regardless of the wait
91 # required by the next instruction.
94 name: test_waitcnt_preexisting_apply_all_counters
97 liveins: $vgpr0_vgpr1, $vgpr2
99 ; GFX9-LABEL: name: test_waitcnt_preexisting_apply_all_counters
101 ; GFX9: $vgpr4_vgpr5 = GLOBAL_LOAD_DWORDX2 $vgpr0_vgpr1, 0, 0, implicit $exec
102 ; GFX9: $vgpr6_vgpr7 = DS_READ2_B32 $vgpr2, 0, 1, 0, implicit $m0, implicit $exec
104 ; GFX9: $vgpr6 = V_OR_B32_e32 1, killed $vgpr6, implicit $exec
105 ; GFX9: $vgpr0 = FLAT_LOAD_DWORD $vgpr4_vgpr5, 0, 0, implicit $exec, implicit $flat_scr
106 ; GFX9: S_WAITCNT 112
107 ; GFX9: FLAT_STORE_DWORD $vgpr0_vgpr1, $vgpr0, 0, 0, implicit $exec, implicit $flat_scr
108 $vgpr4_vgpr5 = GLOBAL_LOAD_DWORDX2 $vgpr0_vgpr1, 0, 0, implicit $exec
109 $vgpr6_vgpr7 = DS_READ2_B32 $vgpr2, 0, 1, 0, implicit $m0, implicit $exec
111 $vgpr6 = V_OR_B32_e32 1, killed $vgpr6, implicit $exec
112 $vgpr0 = FLAT_LOAD_DWORD $vgpr4_vgpr5, 0, 0, implicit $exec, implicit $flat_scr
113 FLAT_STORE_DWORD $vgpr0_vgpr1, $vgpr0, 0, 0, implicit $exec, implicit $flat_scr
117 name: test_waitcnt_preexisting_combine_waitcnt
120 liveins: $vgpr0_vgpr1
122 ; GFX9-LABEL: name: test_waitcnt_preexisting_combine_waitcnt
124 ; GFX9: $vgpr0 = FLAT_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr
126 ; GFX9: FLAT_STORE_DWORD $vgpr0_vgpr1, $vgpr0, 0, 0, implicit $exec, implicit $flat_scr
127 $vgpr0 = FLAT_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr
134 FLAT_STORE_DWORD $vgpr0_vgpr1, $vgpr0, 0, 0, implicit $exec, implicit $flat_scr
138 name: test_waitcnt_preexisting_combine_waitcnt_diff_counters
141 liveins: $vgpr0_vgpr1
143 ; GFX9-LABEL: name: test_waitcnt_preexisting_combine_waitcnt_diff_counters
145 ; GFX9: $vgpr0 = FLAT_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr
146 ; GFX9: S_WAITCNT 112
147 ; GFX9: FLAT_STORE_DWORD $vgpr0_vgpr1, $vgpr0, 0, 0, implicit $exec, implicit $flat_scr
148 $vgpr0 = FLAT_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr
151 FLAT_STORE_DWORD $vgpr0_vgpr1, $vgpr0, 0, 0, implicit $exec, implicit $flat_scr
154 # Apply preexisting waitcnt when no wait is immediately needed.
155 # FIXME: Move waitcnt as late as possible.
158 name: test_waitcnt_preexisting_early_wait
161 liveins: $vgpr0_vgpr1
163 ; GFX9-LABEL: name: test_waitcnt_preexisting_early_wait
165 ; GFX9: $vgpr0 = FLAT_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr
170 ; GFX9: FLAT_STORE_DWORD $vgpr0_vgpr1, $vgpr0, 0, 0, implicit $exec, implicit $flat_scr
172 $vgpr0 = FLAT_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr
177 FLAT_STORE_DWORD $vgpr0_vgpr1, $vgpr0, 0, 0, implicit $exec, implicit $flat_scr
182 name: test_waitcnt_preexisting_ignore_kill
185 liveins: $vgpr0_vgpr1
187 ; GFX9-LABEL: name: test_waitcnt_preexisting_ignore_kill
189 ; GFX9: $vgpr0 = FLAT_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr
190 ; GFX9: S_WAITCNT 3952
192 $vgpr0 = FLAT_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr
197 # Combine preexisting waitcnt with wait added to the start of a non-entry function.
200 name: test_waitcnt_preexisting_func_start
203 ; GFX9-LABEL: name: test_waitcnt_preexisting_func_start
205 ; GFX9-NOT: S_WAITCNT 0
211 # Verify that extra waitcnt are not added after buffer invalidate instructions.
214 name: test_waitcnt_preexisting_buffer_inv
217 ; GFX9-LABEL: name: test_waitcnt_preexisting_buffer_inv
219 ; GFX9: $vgpr0_vgpr1 = GLOBAL_LOAD_DWORDX2 $vgpr0_vgpr1, 0, 0, implicit $exec
220 ; GFX9: S_WAITCNT 3952
221 ; GFX9: BUFFER_INVL2 implicit $exec
222 ; GFX9: BUFFER_WBINVL1_VOL implicit $exec
223 ; GFX9: $vgpr0 = FLAT_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr
224 ; GFX9: S_WAITCNT 112
225 ; GFX9: FLAT_STORE_DWORD $vgpr0_vgpr1, $vgpr0, 0, 0, implicit $exec, implicit $flat_scr
227 $vgpr0_vgpr1 = GLOBAL_LOAD_DWORDX2 $vgpr0_vgpr1, 0, 0, implicit $exec
229 BUFFER_INVL2 implicit $exec
230 BUFFER_WBINVL1_VOL implicit $exec
231 $vgpr0 = FLAT_LOAD_DWORD $vgpr0_vgpr1, 0, 0, implicit $exec, implicit $flat_scr
232 FLAT_STORE_DWORD $vgpr0_vgpr1, $vgpr0, 0, 0, implicit $exec, implicit $flat_scr