1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -global-isel=0 -mtriple=amdgcn-amd-amdhsa -mcpu=fiji -o - -amdgpu-enable-lower-module-lds=false %s 2> %t | FileCheck -check-prefixes=GFX8,GFX8-SDAG %s
3 ; RUN: FileCheck -check-prefix=ERR %s < %t
5 ; RUN: llc -global-isel=1 -mtriple=amdgcn-amd-amdhsa -mcpu=fiji -o - -amdgpu-enable-lower-module-lds=false %s 2> %t | FileCheck -check-prefixes=GFX8,GFX8-GISEL %s
6 ; RUN: FileCheck -check-prefix=ERR %s < %t
8 ; RUN: llc -global-isel=0 -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -o - -amdgpu-enable-lower-module-lds=false %s 2> %t | FileCheck -check-prefixes=GFX9,GFX9-SDAG %s
9 ; RUN: FileCheck -check-prefix=ERR %s < %t
11 ; RUN: llc -global-isel=1 -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -o - -amdgpu-enable-lower-module-lds=false %s 2> %t | FileCheck -check-prefixes=GFX9,GFX9-GISEL %s
12 ; RUN: FileCheck -check-prefix=ERR %s < %t
14 ; Test there's no verifier error if a function directly uses LDS and
15 ; we emit a trap. The s_endpgm needs to be emitted in a terminator
18 ; RUN: llc -global-isel=0 -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx900 -verify-machineinstrs < %s 2> %t | FileCheck -check-prefixes=CHECK,SDAG %s
19 ; RUN: FileCheck -check-prefix=ERR %s < %t
21 ; RUN: llc -global-isel=1 -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx900 -verify-machineinstrs < %s 2> %t | FileCheck -check-prefixes=CHECK,GISEL %s
22 ; RUN: FileCheck -check-prefix=ERR %s < %t
25 @lds = internal addrspace(3) global float poison, align 4
27 ; FIXME: The DAG should probably move the trap before the access.
29 ; ERR: warning: <unknown>:0:0: in function func_use_lds_global void (): local memory global used by non-kernel function
30 define void @func_use_lds_global() {
31 ; GFX8-SDAG-LABEL: func_use_lds_global:
33 ; GFX8-SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
34 ; GFX8-SDAG-NEXT: v_mov_b32_e32 v0, 0
35 ; GFX8-SDAG-NEXT: s_mov_b32 m0, -1
36 ; GFX8-SDAG-NEXT: s_mov_b64 s[4:5], 0xc8
37 ; GFX8-SDAG-NEXT: ds_write_b32 v0, v0
38 ; GFX8-SDAG-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
39 ; GFX8-SDAG-NEXT: s_waitcnt lgkmcnt(0)
40 ; GFX8-SDAG-NEXT: s_trap 2
41 ; GFX8-SDAG-NEXT: s_setpc_b64 s[30:31]
43 ; GFX8-GISEL-LABEL: func_use_lds_global:
44 ; GFX8-GISEL: ; %bb.0:
45 ; GFX8-GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
46 ; GFX8-GISEL-NEXT: s_mov_b64 s[4:5], 0xc8
47 ; GFX8-GISEL-NEXT: v_mov_b32_e32 v0, 0
48 ; GFX8-GISEL-NEXT: s_mov_b32 m0, -1
49 ; GFX8-GISEL-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
50 ; GFX8-GISEL-NEXT: s_waitcnt lgkmcnt(0)
51 ; GFX8-GISEL-NEXT: s_trap 2
52 ; GFX8-GISEL-NEXT: ds_write_b32 v0, v0
53 ; GFX8-GISEL-NEXT: s_waitcnt lgkmcnt(0)
54 ; GFX8-GISEL-NEXT: s_setpc_b64 s[30:31]
56 ; GFX9-SDAG-LABEL: func_use_lds_global:
58 ; GFX9-SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
59 ; GFX9-SDAG-NEXT: v_mov_b32_e32 v0, 0
60 ; GFX9-SDAG-NEXT: ds_write_b32 v0, v0
61 ; GFX9-SDAG-NEXT: s_trap 2
62 ; GFX9-SDAG-NEXT: s_waitcnt lgkmcnt(0)
63 ; GFX9-SDAG-NEXT: s_setpc_b64 s[30:31]
65 ; GFX9-GISEL-LABEL: func_use_lds_global:
66 ; GFX9-GISEL: ; %bb.0:
67 ; GFX9-GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
68 ; GFX9-GISEL-NEXT: v_mov_b32_e32 v0, 0
69 ; GFX9-GISEL-NEXT: s_trap 2
70 ; GFX9-GISEL-NEXT: ds_write_b32 v0, v0
71 ; GFX9-GISEL-NEXT: s_waitcnt lgkmcnt(0)
72 ; GFX9-GISEL-NEXT: s_setpc_b64 s[30:31]
74 ; SDAG-LABEL: func_use_lds_global:
76 ; SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
77 ; SDAG-NEXT: v_mov_b32_e32 v0, 0
78 ; SDAG-NEXT: ds_write_b32 v0, v0
79 ; SDAG-NEXT: s_cbranch_execnz .LBB0_2
81 ; SDAG-NEXT: s_waitcnt lgkmcnt(0)
82 ; SDAG-NEXT: s_setpc_b64 s[30:31]
86 ; GISEL-LABEL: func_use_lds_global:
88 ; GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
89 ; GISEL-NEXT: s_cbranch_execnz .LBB0_2
90 ; GISEL-NEXT: ; %bb.1:
91 ; GISEL-NEXT: v_mov_b32_e32 v0, 0
92 ; GISEL-NEXT: ds_write_b32 v0, v0
93 ; GISEL-NEXT: s_waitcnt lgkmcnt(0)
94 ; GISEL-NEXT: s_setpc_b64 s[30:31]
95 ; GISEL-NEXT: .LBB0_2:
96 ; GISEL-NEXT: s_endpgm
97 store volatile float 0.0, ptr addrspace(3) @lds, align 4
101 ; ERR: warning: <unknown>:0:0: in function func_use_lds_global_constexpr_cast void (): local memory global used by non-kernel function
102 define void @func_use_lds_global_constexpr_cast() {
103 ; GFX8-SDAG-LABEL: func_use_lds_global_constexpr_cast:
104 ; GFX8-SDAG: ; %bb.0:
105 ; GFX8-SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
106 ; GFX8-SDAG-NEXT: s_mov_b64 s[4:5], 0xc8
107 ; GFX8-SDAG-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
108 ; GFX8-SDAG-NEXT: s_waitcnt lgkmcnt(0)
109 ; GFX8-SDAG-NEXT: s_trap 2
110 ; GFX8-SDAG-NEXT: s_setpc_b64 s[30:31]
112 ; GFX8-GISEL-LABEL: func_use_lds_global_constexpr_cast:
113 ; GFX8-GISEL: ; %bb.0:
114 ; GFX8-GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
115 ; GFX8-GISEL-NEXT: s_mov_b64 s[4:5], 0xc8
116 ; GFX8-GISEL-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
117 ; GFX8-GISEL-NEXT: s_waitcnt lgkmcnt(0)
118 ; GFX8-GISEL-NEXT: s_trap 2
119 ; GFX8-GISEL-NEXT: flat_store_dword v[0:1], v0
120 ; GFX8-GISEL-NEXT: s_waitcnt vmcnt(0)
121 ; GFX8-GISEL-NEXT: s_setpc_b64 s[30:31]
123 ; GFX9-SDAG-LABEL: func_use_lds_global_constexpr_cast:
124 ; GFX9-SDAG: ; %bb.0:
125 ; GFX9-SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
126 ; GFX9-SDAG-NEXT: s_trap 2
127 ; GFX9-SDAG-NEXT: s_setpc_b64 s[30:31]
129 ; GFX9-GISEL-LABEL: func_use_lds_global_constexpr_cast:
130 ; GFX9-GISEL: ; %bb.0:
131 ; GFX9-GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
132 ; GFX9-GISEL-NEXT: s_trap 2
133 ; GFX9-GISEL-NEXT: global_store_dword v[0:1], v0, off
134 ; GFX9-GISEL-NEXT: s_waitcnt vmcnt(0)
135 ; GFX9-GISEL-NEXT: s_setpc_b64 s[30:31]
137 ; SDAG-LABEL: func_use_lds_global_constexpr_cast:
139 ; SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
140 ; SDAG-NEXT: s_cbranch_execnz .LBB1_2
141 ; SDAG-NEXT: ; %bb.1:
142 ; SDAG-NEXT: s_setpc_b64 s[30:31]
143 ; SDAG-NEXT: .LBB1_2:
144 ; SDAG-NEXT: s_endpgm
146 ; GISEL-LABEL: func_use_lds_global_constexpr_cast:
148 ; GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
149 ; GISEL-NEXT: s_cbranch_execnz .LBB1_2
150 ; GISEL-NEXT: ; %bb.1:
151 ; GISEL-NEXT: global_store_dword v[0:1], v0, off
152 ; GISEL-NEXT: s_waitcnt vmcnt(0)
153 ; GISEL-NEXT: s_setpc_b64 s[30:31]
154 ; GISEL-NEXT: .LBB1_2:
155 ; GISEL-NEXT: s_endpgm
156 store volatile i32 ptrtoint (ptr addrspace(3) @lds to i32), ptr addrspace(1) poison, align 4
160 ; ERR: warning: <unknown>:0:0: in function func_uses_lds_multi void (i1): local memory global used by non-kernel function
161 define void @func_uses_lds_multi(i1 %cond) {
162 ; GFX8-SDAG-LABEL: func_uses_lds_multi:
163 ; GFX8-SDAG: ; %bb.0: ; %entry
164 ; GFX8-SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
165 ; GFX8-SDAG-NEXT: v_and_b32_e32 v0, 1, v0
166 ; GFX8-SDAG-NEXT: v_cmp_eq_u32_e32 vcc, 1, v0
167 ; GFX8-SDAG-NEXT: s_xor_b64 s[4:5], vcc, -1
168 ; GFX8-SDAG-NEXT: s_mov_b32 m0, -1
169 ; GFX8-SDAG-NEXT: s_and_saveexec_b64 s[6:7], s[4:5]
170 ; GFX8-SDAG-NEXT: s_xor_b64 s[4:5], exec, s[6:7]
171 ; GFX8-SDAG-NEXT: s_cbranch_execz .LBB2_2
172 ; GFX8-SDAG-NEXT: ; %bb.1: ; %bb1
173 ; GFX8-SDAG-NEXT: v_mov_b32_e32 v0, 1
174 ; GFX8-SDAG-NEXT: s_mov_b64 s[6:7], 0xc8
175 ; GFX8-SDAG-NEXT: ds_write_b32 v0, v0
176 ; GFX8-SDAG-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
177 ; GFX8-SDAG-NEXT: s_waitcnt lgkmcnt(0)
178 ; GFX8-SDAG-NEXT: s_trap 2
179 ; GFX8-SDAG-NEXT: .LBB2_2: ; %Flow
180 ; GFX8-SDAG-NEXT: s_andn2_saveexec_b64 s[4:5], s[4:5]
181 ; GFX8-SDAG-NEXT: s_cbranch_execz .LBB2_4
182 ; GFX8-SDAG-NEXT: ; %bb.3: ; %bb0
183 ; GFX8-SDAG-NEXT: v_mov_b32_e32 v0, 0
184 ; GFX8-SDAG-NEXT: s_mov_b64 s[6:7], 0xc8
185 ; GFX8-SDAG-NEXT: ds_write_b32 v0, v0
186 ; GFX8-SDAG-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
187 ; GFX8-SDAG-NEXT: s_waitcnt lgkmcnt(0)
188 ; GFX8-SDAG-NEXT: s_trap 2
189 ; GFX8-SDAG-NEXT: .LBB2_4: ; %ret
190 ; GFX8-SDAG-NEXT: s_or_b64 exec, exec, s[4:5]
191 ; GFX8-SDAG-NEXT: v_mov_b32_e32 v0, 2
192 ; GFX8-SDAG-NEXT: s_mov_b64 s[4:5], 0xc8
193 ; GFX8-SDAG-NEXT: ds_write_b32 v0, v0
194 ; GFX8-SDAG-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
195 ; GFX8-SDAG-NEXT: s_waitcnt lgkmcnt(0)
196 ; GFX8-SDAG-NEXT: s_trap 2
197 ; GFX8-SDAG-NEXT: s_setpc_b64 s[30:31]
199 ; GFX8-GISEL-LABEL: func_uses_lds_multi:
200 ; GFX8-GISEL: ; %bb.0: ; %entry
201 ; GFX8-GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
202 ; GFX8-GISEL-NEXT: v_and_b32_e32 v0, 1, v0
203 ; GFX8-GISEL-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0
204 ; GFX8-GISEL-NEXT: s_xor_b64 s[4:5], vcc, -1
205 ; GFX8-GISEL-NEXT: s_and_saveexec_b64 s[6:7], s[4:5]
206 ; GFX8-GISEL-NEXT: s_xor_b64 s[4:5], exec, s[6:7]
207 ; GFX8-GISEL-NEXT: s_cbranch_execz .LBB2_2
208 ; GFX8-GISEL-NEXT: ; %bb.1: ; %bb1
209 ; GFX8-GISEL-NEXT: s_mov_b64 s[6:7], 0xc8
210 ; GFX8-GISEL-NEXT: v_mov_b32_e32 v0, 1
211 ; GFX8-GISEL-NEXT: s_mov_b32 m0, -1
212 ; GFX8-GISEL-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
213 ; GFX8-GISEL-NEXT: s_waitcnt lgkmcnt(0)
214 ; GFX8-GISEL-NEXT: s_trap 2
215 ; GFX8-GISEL-NEXT: ds_write_b32 v0, v0
216 ; GFX8-GISEL-NEXT: .LBB2_2: ; %Flow
217 ; GFX8-GISEL-NEXT: s_andn2_saveexec_b64 s[4:5], s[4:5]
218 ; GFX8-GISEL-NEXT: s_cbranch_execz .LBB2_4
219 ; GFX8-GISEL-NEXT: ; %bb.3: ; %bb0
220 ; GFX8-GISEL-NEXT: s_mov_b64 s[6:7], 0xc8
221 ; GFX8-GISEL-NEXT: v_mov_b32_e32 v0, 0
222 ; GFX8-GISEL-NEXT: s_mov_b32 m0, -1
223 ; GFX8-GISEL-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
224 ; GFX8-GISEL-NEXT: s_waitcnt lgkmcnt(0)
225 ; GFX8-GISEL-NEXT: s_trap 2
226 ; GFX8-GISEL-NEXT: ds_write_b32 v0, v0
227 ; GFX8-GISEL-NEXT: .LBB2_4: ; %ret
228 ; GFX8-GISEL-NEXT: s_or_b64 exec, exec, s[4:5]
229 ; GFX8-GISEL-NEXT: s_mov_b64 s[4:5], 0xc8
230 ; GFX8-GISEL-NEXT: v_mov_b32_e32 v0, 2
231 ; GFX8-GISEL-NEXT: s_mov_b32 m0, -1
232 ; GFX8-GISEL-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
233 ; GFX8-GISEL-NEXT: s_waitcnt lgkmcnt(0)
234 ; GFX8-GISEL-NEXT: s_trap 2
235 ; GFX8-GISEL-NEXT: ds_write_b32 v0, v0
236 ; GFX8-GISEL-NEXT: s_waitcnt lgkmcnt(0)
237 ; GFX8-GISEL-NEXT: s_setpc_b64 s[30:31]
239 ; GFX9-SDAG-LABEL: func_uses_lds_multi:
240 ; GFX9-SDAG: ; %bb.0: ; %entry
241 ; GFX9-SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
242 ; GFX9-SDAG-NEXT: v_and_b32_e32 v0, 1, v0
243 ; GFX9-SDAG-NEXT: v_cmp_eq_u32_e32 vcc, 1, v0
244 ; GFX9-SDAG-NEXT: s_xor_b64 s[4:5], vcc, -1
245 ; GFX9-SDAG-NEXT: s_and_saveexec_b64 s[6:7], s[4:5]
246 ; GFX9-SDAG-NEXT: s_xor_b64 s[4:5], exec, s[6:7]
247 ; GFX9-SDAG-NEXT: s_cbranch_execz .LBB2_2
248 ; GFX9-SDAG-NEXT: ; %bb.1: ; %bb1
249 ; GFX9-SDAG-NEXT: v_mov_b32_e32 v0, 1
250 ; GFX9-SDAG-NEXT: ds_write_b32 v0, v0
251 ; GFX9-SDAG-NEXT: s_trap 2
252 ; GFX9-SDAG-NEXT: .LBB2_2: ; %Flow
253 ; GFX9-SDAG-NEXT: s_andn2_saveexec_b64 s[4:5], s[4:5]
254 ; GFX9-SDAG-NEXT: s_cbranch_execz .LBB2_4
255 ; GFX9-SDAG-NEXT: ; %bb.3: ; %bb0
256 ; GFX9-SDAG-NEXT: v_mov_b32_e32 v0, 0
257 ; GFX9-SDAG-NEXT: ds_write_b32 v0, v0
258 ; GFX9-SDAG-NEXT: s_trap 2
259 ; GFX9-SDAG-NEXT: .LBB2_4: ; %ret
260 ; GFX9-SDAG-NEXT: s_or_b64 exec, exec, s[4:5]
261 ; GFX9-SDAG-NEXT: v_mov_b32_e32 v0, 2
262 ; GFX9-SDAG-NEXT: ds_write_b32 v0, v0
263 ; GFX9-SDAG-NEXT: s_trap 2
264 ; GFX9-SDAG-NEXT: s_waitcnt lgkmcnt(0)
265 ; GFX9-SDAG-NEXT: s_setpc_b64 s[30:31]
267 ; GFX9-GISEL-LABEL: func_uses_lds_multi:
268 ; GFX9-GISEL: ; %bb.0: ; %entry
269 ; GFX9-GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
270 ; GFX9-GISEL-NEXT: v_and_b32_e32 v0, 1, v0
271 ; GFX9-GISEL-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0
272 ; GFX9-GISEL-NEXT: s_xor_b64 s[4:5], vcc, -1
273 ; GFX9-GISEL-NEXT: s_and_saveexec_b64 s[6:7], s[4:5]
274 ; GFX9-GISEL-NEXT: s_xor_b64 s[4:5], exec, s[6:7]
275 ; GFX9-GISEL-NEXT: s_cbranch_execz .LBB2_2
276 ; GFX9-GISEL-NEXT: ; %bb.1: ; %bb1
277 ; GFX9-GISEL-NEXT: v_mov_b32_e32 v0, 1
278 ; GFX9-GISEL-NEXT: s_trap 2
279 ; GFX9-GISEL-NEXT: ds_write_b32 v0, v0
280 ; GFX9-GISEL-NEXT: .LBB2_2: ; %Flow
281 ; GFX9-GISEL-NEXT: s_andn2_saveexec_b64 s[4:5], s[4:5]
282 ; GFX9-GISEL-NEXT: s_cbranch_execz .LBB2_4
283 ; GFX9-GISEL-NEXT: ; %bb.3: ; %bb0
284 ; GFX9-GISEL-NEXT: v_mov_b32_e32 v0, 0
285 ; GFX9-GISEL-NEXT: s_trap 2
286 ; GFX9-GISEL-NEXT: ds_write_b32 v0, v0
287 ; GFX9-GISEL-NEXT: .LBB2_4: ; %ret
288 ; GFX9-GISEL-NEXT: s_or_b64 exec, exec, s[4:5]
289 ; GFX9-GISEL-NEXT: v_mov_b32_e32 v0, 2
290 ; GFX9-GISEL-NEXT: s_trap 2
291 ; GFX9-GISEL-NEXT: ds_write_b32 v0, v0
292 ; GFX9-GISEL-NEXT: s_waitcnt lgkmcnt(0)
293 ; GFX9-GISEL-NEXT: s_setpc_b64 s[30:31]
295 ; SDAG-LABEL: func_uses_lds_multi:
296 ; SDAG: ; %bb.0: ; %entry
297 ; SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
298 ; SDAG-NEXT: v_and_b32_e32 v0, 1, v0
299 ; SDAG-NEXT: v_cmp_eq_u32_e32 vcc, 1, v0
300 ; SDAG-NEXT: s_xor_b64 s[4:5], vcc, -1
301 ; SDAG-NEXT: s_and_saveexec_b64 s[6:7], s[4:5]
302 ; SDAG-NEXT: s_xor_b64 s[4:5], exec, s[6:7]
303 ; SDAG-NEXT: s_cbranch_execz .LBB2_2
304 ; SDAG-NEXT: ; %bb.1: ; %bb1
305 ; SDAG-NEXT: v_mov_b32_e32 v0, 1
306 ; SDAG-NEXT: ds_write_b32 v0, v0
307 ; SDAG-NEXT: s_cbranch_execnz .LBB2_6
308 ; SDAG-NEXT: .LBB2_2: ; %Flow
309 ; SDAG-NEXT: s_andn2_saveexec_b64 s[4:5], s[4:5]
310 ; SDAG-NEXT: s_cbranch_execz .LBB2_4
311 ; SDAG-NEXT: ; %bb.3: ; %bb0
312 ; SDAG-NEXT: v_mov_b32_e32 v0, 0
313 ; SDAG-NEXT: ds_write_b32 v0, v0
314 ; SDAG-NEXT: s_cbranch_execnz .LBB2_6
315 ; SDAG-NEXT: .LBB2_4: ; %ret
316 ; SDAG-NEXT: s_or_b64 exec, exec, s[4:5]
317 ; SDAG-NEXT: v_mov_b32_e32 v0, 2
318 ; SDAG-NEXT: ds_write_b32 v0, v0
319 ; SDAG-NEXT: s_cbranch_execnz .LBB2_6
320 ; SDAG-NEXT: ; %bb.5: ; %ret
321 ; SDAG-NEXT: s_waitcnt lgkmcnt(0)
322 ; SDAG-NEXT: s_setpc_b64 s[30:31]
323 ; SDAG-NEXT: .LBB2_6:
324 ; SDAG-NEXT: s_endpgm
326 ; GISEL-LABEL: func_uses_lds_multi:
327 ; GISEL: ; %bb.0: ; %entry
328 ; GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
329 ; GISEL-NEXT: v_and_b32_e32 v0, 1, v0
330 ; GISEL-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0
331 ; GISEL-NEXT: s_xor_b64 s[4:5], vcc, -1
332 ; GISEL-NEXT: s_and_saveexec_b64 s[6:7], s[4:5]
333 ; GISEL-NEXT: s_xor_b64 s[4:5], exec, s[6:7]
334 ; GISEL-NEXT: s_cbranch_execz .LBB2_3
335 ; GISEL-NEXT: ; %bb.1: ; %bb1
336 ; GISEL-NEXT: s_cbranch_execnz .LBB2_8
337 ; GISEL-NEXT: ; %bb.2: ; %bb1
338 ; GISEL-NEXT: v_mov_b32_e32 v0, 1
339 ; GISEL-NEXT: ds_write_b32 v0, v0
340 ; GISEL-NEXT: .LBB2_3: ; %Flow
341 ; GISEL-NEXT: s_andn2_saveexec_b64 s[4:5], s[4:5]
342 ; GISEL-NEXT: s_cbranch_execz .LBB2_6
343 ; GISEL-NEXT: ; %bb.4: ; %bb0
344 ; GISEL-NEXT: s_cbranch_execnz .LBB2_8
345 ; GISEL-NEXT: ; %bb.5: ; %bb0
346 ; GISEL-NEXT: v_mov_b32_e32 v0, 0
347 ; GISEL-NEXT: ds_write_b32 v0, v0
348 ; GISEL-NEXT: .LBB2_6: ; %ret
349 ; GISEL-NEXT: s_or_b64 exec, exec, s[4:5]
350 ; GISEL-NEXT: s_cbranch_execnz .LBB2_8
351 ; GISEL-NEXT: ; %bb.7: ; %ret
352 ; GISEL-NEXT: v_mov_b32_e32 v0, 2
353 ; GISEL-NEXT: ds_write_b32 v0, v0
354 ; GISEL-NEXT: s_waitcnt lgkmcnt(0)
355 ; GISEL-NEXT: s_setpc_b64 s[30:31]
356 ; GISEL-NEXT: .LBB2_8:
357 ; GISEL-NEXT: s_endpgm
359 br i1 %cond, label %bb0, label %bb1
362 store volatile i32 0, ptr addrspace(3) @lds, align 4
366 store volatile i32 1, ptr addrspace(3) @lds, align 4
370 store volatile i32 2, ptr addrspace(3) @lds, align 4
374 ; ERR: warning: <unknown>:0:0: in function func_uses_lds_code_after void (ptr addrspace(1)): local memory global used by non-kernel function
375 define void @func_uses_lds_code_after(ptr addrspace(1) %ptr) {
376 ; GFX8-SDAG-LABEL: func_uses_lds_code_after:
377 ; GFX8-SDAG: ; %bb.0:
378 ; GFX8-SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
379 ; GFX8-SDAG-NEXT: v_mov_b32_e32 v2, 0
380 ; GFX8-SDAG-NEXT: s_mov_b32 m0, -1
381 ; GFX8-SDAG-NEXT: ds_write_b32 v0, v2
382 ; GFX8-SDAG-NEXT: s_mov_b64 s[4:5], 0xc8
383 ; GFX8-SDAG-NEXT: v_mov_b32_e32 v2, 1
384 ; GFX8-SDAG-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
385 ; GFX8-SDAG-NEXT: s_waitcnt lgkmcnt(0)
386 ; GFX8-SDAG-NEXT: s_trap 2
387 ; GFX8-SDAG-NEXT: flat_store_dword v[0:1], v2
388 ; GFX8-SDAG-NEXT: s_waitcnt vmcnt(0)
389 ; GFX8-SDAG-NEXT: s_setpc_b64 s[30:31]
391 ; GFX8-GISEL-LABEL: func_uses_lds_code_after:
392 ; GFX8-GISEL: ; %bb.0:
393 ; GFX8-GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
394 ; GFX8-GISEL-NEXT: s_mov_b64 s[4:5], 0xc8
395 ; GFX8-GISEL-NEXT: v_mov_b32_e32 v2, 0
396 ; GFX8-GISEL-NEXT: s_mov_b32 m0, -1
397 ; GFX8-GISEL-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
398 ; GFX8-GISEL-NEXT: s_waitcnt lgkmcnt(0)
399 ; GFX8-GISEL-NEXT: s_trap 2
400 ; GFX8-GISEL-NEXT: ds_write_b32 v0, v2
401 ; GFX8-GISEL-NEXT: v_mov_b32_e32 v2, 1
402 ; GFX8-GISEL-NEXT: flat_store_dword v[0:1], v2
403 ; GFX8-GISEL-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
404 ; GFX8-GISEL-NEXT: s_setpc_b64 s[30:31]
406 ; GFX9-SDAG-LABEL: func_uses_lds_code_after:
407 ; GFX9-SDAG: ; %bb.0:
408 ; GFX9-SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
409 ; GFX9-SDAG-NEXT: v_mov_b32_e32 v2, 0
410 ; GFX9-SDAG-NEXT: ds_write_b32 v0, v2
411 ; GFX9-SDAG-NEXT: v_mov_b32_e32 v2, 1
412 ; GFX9-SDAG-NEXT: s_trap 2
413 ; GFX9-SDAG-NEXT: global_store_dword v[0:1], v2, off
414 ; GFX9-SDAG-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
415 ; GFX9-SDAG-NEXT: s_setpc_b64 s[30:31]
417 ; GFX9-GISEL-LABEL: func_uses_lds_code_after:
418 ; GFX9-GISEL: ; %bb.0:
419 ; GFX9-GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
420 ; GFX9-GISEL-NEXT: v_mov_b32_e32 v2, 0
421 ; GFX9-GISEL-NEXT: s_trap 2
422 ; GFX9-GISEL-NEXT: ds_write_b32 v0, v2
423 ; GFX9-GISEL-NEXT: v_mov_b32_e32 v2, 1
424 ; GFX9-GISEL-NEXT: global_store_dword v[0:1], v2, off
425 ; GFX9-GISEL-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
426 ; GFX9-GISEL-NEXT: s_setpc_b64 s[30:31]
428 ; SDAG-LABEL: func_uses_lds_code_after:
430 ; SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
431 ; SDAG-NEXT: v_mov_b32_e32 v2, 0
432 ; SDAG-NEXT: ds_write_b32 v0, v2
433 ; SDAG-NEXT: s_cbranch_execnz .LBB3_2
434 ; SDAG-NEXT: ; %bb.1:
435 ; SDAG-NEXT: v_mov_b32_e32 v2, 1
436 ; SDAG-NEXT: global_store_dword v[0:1], v2, off
437 ; SDAG-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
438 ; SDAG-NEXT: s_setpc_b64 s[30:31]
439 ; SDAG-NEXT: .LBB3_2:
440 ; SDAG-NEXT: s_endpgm
442 ; GISEL-LABEL: func_uses_lds_code_after:
444 ; GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
445 ; GISEL-NEXT: s_cbranch_execnz .LBB3_2
446 ; GISEL-NEXT: ; %bb.1:
447 ; GISEL-NEXT: v_mov_b32_e32 v2, 0
448 ; GISEL-NEXT: ds_write_b32 v0, v2
449 ; GISEL-NEXT: v_mov_b32_e32 v2, 1
450 ; GISEL-NEXT: global_store_dword v[0:1], v2, off
451 ; GISEL-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
452 ; GISEL-NEXT: s_setpc_b64 s[30:31]
453 ; GISEL-NEXT: .LBB3_2:
454 ; GISEL-NEXT: s_endpgm
455 store volatile i32 0, ptr addrspace(3) @lds, align 4
456 store volatile i32 1, ptr addrspace(1) %ptr, align 4
460 ; ERR: warning: <unknown>:0:0: in function func_uses_lds_phi_after i32 (i1, ptr addrspace(1)): local memory global used by non-kernel function
461 define i32 @func_uses_lds_phi_after(i1 %cond, ptr addrspace(1) %ptr) {
462 ; GFX8-SDAG-LABEL: func_uses_lds_phi_after:
463 ; GFX8-SDAG: ; %bb.0: ; %entry
464 ; GFX8-SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
465 ; GFX8-SDAG-NEXT: v_mov_b32_e32 v3, v0
466 ; GFX8-SDAG-NEXT: flat_load_dword v0, v[1:2] glc
467 ; GFX8-SDAG-NEXT: s_waitcnt vmcnt(0)
468 ; GFX8-SDAG-NEXT: v_and_b32_e32 v3, 1, v3
469 ; GFX8-SDAG-NEXT: v_cmp_eq_u32_e32 vcc, 1, v3
470 ; GFX8-SDAG-NEXT: s_and_saveexec_b64 s[4:5], vcc
471 ; GFX8-SDAG-NEXT: s_cbranch_execz .LBB4_2
472 ; GFX8-SDAG-NEXT: ; %bb.1: ; %use.bb
473 ; GFX8-SDAG-NEXT: v_mov_b32_e32 v0, 0
474 ; GFX8-SDAG-NEXT: s_mov_b32 m0, -1
475 ; GFX8-SDAG-NEXT: s_mov_b64 s[6:7], 0xc8
476 ; GFX8-SDAG-NEXT: ds_write_b32 v0, v0
477 ; GFX8-SDAG-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
478 ; GFX8-SDAG-NEXT: s_waitcnt lgkmcnt(0)
479 ; GFX8-SDAG-NEXT: s_trap 2
480 ; GFX8-SDAG-NEXT: flat_load_dword v0, v[1:2] glc
481 ; GFX8-SDAG-NEXT: s_waitcnt vmcnt(0)
482 ; GFX8-SDAG-NEXT: .LBB4_2: ; %ret
483 ; GFX8-SDAG-NEXT: s_or_b64 exec, exec, s[4:5]
484 ; GFX8-SDAG-NEXT: s_setpc_b64 s[30:31]
486 ; GFX8-GISEL-LABEL: func_uses_lds_phi_after:
487 ; GFX8-GISEL: ; %bb.0: ; %entry
488 ; GFX8-GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
489 ; GFX8-GISEL-NEXT: v_mov_b32_e32 v3, v0
490 ; GFX8-GISEL-NEXT: flat_load_dword v0, v[1:2] glc
491 ; GFX8-GISEL-NEXT: s_waitcnt vmcnt(0)
492 ; GFX8-GISEL-NEXT: v_and_b32_e32 v3, 1, v3
493 ; GFX8-GISEL-NEXT: v_cmp_ne_u32_e32 vcc, 0, v3
494 ; GFX8-GISEL-NEXT: s_and_saveexec_b64 s[4:5], vcc
495 ; GFX8-GISEL-NEXT: s_cbranch_execz .LBB4_2
496 ; GFX8-GISEL-NEXT: ; %bb.1: ; %use.bb
497 ; GFX8-GISEL-NEXT: s_mov_b64 s[6:7], 0xc8
498 ; GFX8-GISEL-NEXT: v_mov_b32_e32 v0, 0
499 ; GFX8-GISEL-NEXT: s_mov_b32 m0, -1
500 ; GFX8-GISEL-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
501 ; GFX8-GISEL-NEXT: s_waitcnt lgkmcnt(0)
502 ; GFX8-GISEL-NEXT: s_trap 2
503 ; GFX8-GISEL-NEXT: ds_write_b32 v0, v0
504 ; GFX8-GISEL-NEXT: flat_load_dword v0, v[1:2] glc
505 ; GFX8-GISEL-NEXT: s_waitcnt vmcnt(0)
506 ; GFX8-GISEL-NEXT: .LBB4_2: ; %ret
507 ; GFX8-GISEL-NEXT: s_or_b64 exec, exec, s[4:5]
508 ; GFX8-GISEL-NEXT: s_waitcnt lgkmcnt(0)
509 ; GFX8-GISEL-NEXT: s_setpc_b64 s[30:31]
511 ; GFX9-SDAG-LABEL: func_uses_lds_phi_after:
512 ; GFX9-SDAG: ; %bb.0: ; %entry
513 ; GFX9-SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
514 ; GFX9-SDAG-NEXT: v_mov_b32_e32 v3, v0
515 ; GFX9-SDAG-NEXT: global_load_dword v0, v[1:2], off glc
516 ; GFX9-SDAG-NEXT: s_waitcnt vmcnt(0)
517 ; GFX9-SDAG-NEXT: v_and_b32_e32 v3, 1, v3
518 ; GFX9-SDAG-NEXT: v_cmp_eq_u32_e32 vcc, 1, v3
519 ; GFX9-SDAG-NEXT: s_and_saveexec_b64 s[4:5], vcc
520 ; GFX9-SDAG-NEXT: s_cbranch_execz .LBB4_2
521 ; GFX9-SDAG-NEXT: ; %bb.1: ; %use.bb
522 ; GFX9-SDAG-NEXT: v_mov_b32_e32 v0, 0
523 ; GFX9-SDAG-NEXT: ds_write_b32 v0, v0
524 ; GFX9-SDAG-NEXT: s_trap 2
525 ; GFX9-SDAG-NEXT: global_load_dword v0, v[1:2], off glc
526 ; GFX9-SDAG-NEXT: s_waitcnt vmcnt(0)
527 ; GFX9-SDAG-NEXT: .LBB4_2: ; %ret
528 ; GFX9-SDAG-NEXT: s_or_b64 exec, exec, s[4:5]
529 ; GFX9-SDAG-NEXT: s_waitcnt lgkmcnt(0)
530 ; GFX9-SDAG-NEXT: s_setpc_b64 s[30:31]
532 ; GFX9-GISEL-LABEL: func_uses_lds_phi_after:
533 ; GFX9-GISEL: ; %bb.0: ; %entry
534 ; GFX9-GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
535 ; GFX9-GISEL-NEXT: v_mov_b32_e32 v3, v0
536 ; GFX9-GISEL-NEXT: global_load_dword v0, v[1:2], off glc
537 ; GFX9-GISEL-NEXT: s_waitcnt vmcnt(0)
538 ; GFX9-GISEL-NEXT: v_and_b32_e32 v3, 1, v3
539 ; GFX9-GISEL-NEXT: v_cmp_ne_u32_e32 vcc, 0, v3
540 ; GFX9-GISEL-NEXT: s_and_saveexec_b64 s[4:5], vcc
541 ; GFX9-GISEL-NEXT: s_cbranch_execz .LBB4_2
542 ; GFX9-GISEL-NEXT: ; %bb.1: ; %use.bb
543 ; GFX9-GISEL-NEXT: v_mov_b32_e32 v0, 0
544 ; GFX9-GISEL-NEXT: s_trap 2
545 ; GFX9-GISEL-NEXT: ds_write_b32 v0, v0
546 ; GFX9-GISEL-NEXT: global_load_dword v0, v[1:2], off glc
547 ; GFX9-GISEL-NEXT: s_waitcnt vmcnt(0)
548 ; GFX9-GISEL-NEXT: .LBB4_2: ; %ret
549 ; GFX9-GISEL-NEXT: s_or_b64 exec, exec, s[4:5]
550 ; GFX9-GISEL-NEXT: s_waitcnt lgkmcnt(0)
551 ; GFX9-GISEL-NEXT: s_setpc_b64 s[30:31]
553 ; SDAG-LABEL: func_uses_lds_phi_after:
554 ; SDAG: ; %bb.0: ; %entry
555 ; SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
556 ; SDAG-NEXT: v_mov_b32_e32 v3, v0
557 ; SDAG-NEXT: global_load_dword v0, v[1:2], off glc
558 ; SDAG-NEXT: s_waitcnt vmcnt(0)
559 ; SDAG-NEXT: v_and_b32_e32 v3, 1, v3
560 ; SDAG-NEXT: v_cmp_eq_u32_e32 vcc, 1, v3
561 ; SDAG-NEXT: s_and_saveexec_b64 s[4:5], vcc
562 ; SDAG-NEXT: s_cbranch_execz .LBB4_3
563 ; SDAG-NEXT: ; %bb.1: ; %use.bb
564 ; SDAG-NEXT: v_mov_b32_e32 v0, 0
565 ; SDAG-NEXT: ds_write_b32 v0, v0
566 ; SDAG-NEXT: s_cbranch_execnz .LBB4_4
567 ; SDAG-NEXT: ; %bb.2: ; %use.bb
568 ; SDAG-NEXT: global_load_dword v0, v[1:2], off glc
569 ; SDAG-NEXT: s_waitcnt vmcnt(0)
570 ; SDAG-NEXT: .LBB4_3: ; %ret
571 ; SDAG-NEXT: s_or_b64 exec, exec, s[4:5]
572 ; SDAG-NEXT: s_waitcnt lgkmcnt(0)
573 ; SDAG-NEXT: s_setpc_b64 s[30:31]
574 ; SDAG-NEXT: .LBB4_4:
575 ; SDAG-NEXT: s_endpgm
577 ; GISEL-LABEL: func_uses_lds_phi_after:
578 ; GISEL: ; %bb.0: ; %entry
579 ; GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
580 ; GISEL-NEXT: v_mov_b32_e32 v3, v0
581 ; GISEL-NEXT: global_load_dword v0, v[1:2], off glc
582 ; GISEL-NEXT: s_waitcnt vmcnt(0)
583 ; GISEL-NEXT: v_and_b32_e32 v3, 1, v3
584 ; GISEL-NEXT: v_cmp_ne_u32_e32 vcc, 0, v3
585 ; GISEL-NEXT: s_and_saveexec_b64 s[4:5], vcc
586 ; GISEL-NEXT: s_cbranch_execz .LBB4_3
587 ; GISEL-NEXT: ; %bb.1: ; %use.bb
588 ; GISEL-NEXT: s_cbranch_execnz .LBB4_4
589 ; GISEL-NEXT: ; %bb.2: ; %use.bb
590 ; GISEL-NEXT: v_mov_b32_e32 v0, 0
591 ; GISEL-NEXT: ds_write_b32 v0, v0
592 ; GISEL-NEXT: global_load_dword v0, v[1:2], off glc
593 ; GISEL-NEXT: s_waitcnt vmcnt(0)
594 ; GISEL-NEXT: .LBB4_3: ; %ret
595 ; GISEL-NEXT: s_or_b64 exec, exec, s[4:5]
596 ; GISEL-NEXT: s_waitcnt lgkmcnt(0)
597 ; GISEL-NEXT: s_setpc_b64 s[30:31]
598 ; GISEL-NEXT: .LBB4_4:
599 ; GISEL-NEXT: s_endpgm
601 %entry.load = load volatile i32, ptr addrspace(1) %ptr
602 br i1 %cond, label %use.bb, label %ret
605 store volatile i32 0, ptr addrspace(3) @lds, align 4
606 %use.bb.load = load volatile i32, ptr addrspace(1) %ptr
610 %phi = phi i32 [ %entry.load, %entry ], [ %use.bb.load, %use.bb ]
614 ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: