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 (ptr addrspace(1)): local memory global used by non-kernel function
102 define void @func_use_lds_global_constexpr_cast(ptr addrspace(1) %out) {
103 ; GFX8-LABEL: func_use_lds_global_constexpr_cast:
105 ; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
106 ; GFX8-NEXT: s_mov_b64 s[4:5], 0xc8
107 ; GFX8-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
108 ; GFX8-NEXT: s_waitcnt lgkmcnt(0)
109 ; GFX8-NEXT: s_trap 2
110 ; GFX8-NEXT: s_setpc_b64 s[30:31]
112 ; GFX9-LABEL: func_use_lds_global_constexpr_cast:
114 ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
115 ; GFX9-NEXT: s_trap 2
116 ; GFX9-NEXT: s_setpc_b64 s[30:31]
118 ; CHECK-LABEL: func_use_lds_global_constexpr_cast:
120 ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
121 ; CHECK-NEXT: s_cbranch_execnz .LBB1_2
122 ; CHECK-NEXT: ; %bb.1:
123 ; CHECK-NEXT: s_setpc_b64 s[30:31]
124 ; CHECK-NEXT: .LBB1_2:
125 ; CHECK-NEXT: s_endpgm
126 store i32 ptrtoint (ptr addrspace(3) @lds to i32), ptr addrspace(1) %out, align 4
130 ; ERR: warning: <unknown>:0:0: in function func_uses_lds_multi void (i1): local memory global used by non-kernel function
131 define void @func_uses_lds_multi(i1 %cond) {
132 ; GFX8-SDAG-LABEL: func_uses_lds_multi:
133 ; GFX8-SDAG: ; %bb.0: ; %entry
134 ; GFX8-SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
135 ; GFX8-SDAG-NEXT: v_and_b32_e32 v0, 1, v0
136 ; GFX8-SDAG-NEXT: v_cmp_eq_u32_e32 vcc, 1, v0
137 ; GFX8-SDAG-NEXT: s_xor_b64 s[4:5], vcc, -1
138 ; GFX8-SDAG-NEXT: s_mov_b32 m0, -1
139 ; GFX8-SDAG-NEXT: s_and_saveexec_b64 s[6:7], s[4:5]
140 ; GFX8-SDAG-NEXT: s_xor_b64 s[4:5], exec, s[6:7]
141 ; GFX8-SDAG-NEXT: s_cbranch_execz .LBB2_2
142 ; GFX8-SDAG-NEXT: ; %bb.1: ; %bb1
143 ; GFX8-SDAG-NEXT: v_mov_b32_e32 v0, 1
144 ; GFX8-SDAG-NEXT: s_mov_b64 s[6:7], 0xc8
145 ; GFX8-SDAG-NEXT: ds_write_b32 v0, v0
146 ; GFX8-SDAG-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
147 ; GFX8-SDAG-NEXT: s_waitcnt lgkmcnt(0)
148 ; GFX8-SDAG-NEXT: s_trap 2
149 ; GFX8-SDAG-NEXT: .LBB2_2: ; %Flow
150 ; GFX8-SDAG-NEXT: s_andn2_saveexec_b64 s[4:5], s[4:5]
151 ; GFX8-SDAG-NEXT: s_cbranch_execz .LBB2_4
152 ; GFX8-SDAG-NEXT: ; %bb.3: ; %bb0
153 ; GFX8-SDAG-NEXT: v_mov_b32_e32 v0, 0
154 ; GFX8-SDAG-NEXT: s_mov_b64 s[6:7], 0xc8
155 ; GFX8-SDAG-NEXT: ds_write_b32 v0, v0
156 ; GFX8-SDAG-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
157 ; GFX8-SDAG-NEXT: s_waitcnt lgkmcnt(0)
158 ; GFX8-SDAG-NEXT: s_trap 2
159 ; GFX8-SDAG-NEXT: .LBB2_4: ; %ret
160 ; GFX8-SDAG-NEXT: s_or_b64 exec, exec, s[4:5]
161 ; GFX8-SDAG-NEXT: v_mov_b32_e32 v0, 2
162 ; GFX8-SDAG-NEXT: s_mov_b64 s[4:5], 0xc8
163 ; GFX8-SDAG-NEXT: ds_write_b32 v0, v0
164 ; GFX8-SDAG-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
165 ; GFX8-SDAG-NEXT: s_waitcnt lgkmcnt(0)
166 ; GFX8-SDAG-NEXT: s_trap 2
167 ; GFX8-SDAG-NEXT: s_setpc_b64 s[30:31]
169 ; GFX8-GISEL-LABEL: func_uses_lds_multi:
170 ; GFX8-GISEL: ; %bb.0: ; %entry
171 ; GFX8-GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
172 ; GFX8-GISEL-NEXT: v_and_b32_e32 v0, 1, v0
173 ; GFX8-GISEL-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0
174 ; GFX8-GISEL-NEXT: s_xor_b64 s[4:5], vcc, -1
175 ; GFX8-GISEL-NEXT: s_and_saveexec_b64 s[6:7], s[4:5]
176 ; GFX8-GISEL-NEXT: s_xor_b64 s[4:5], exec, s[6:7]
177 ; GFX8-GISEL-NEXT: s_cbranch_execz .LBB2_2
178 ; GFX8-GISEL-NEXT: ; %bb.1: ; %bb1
179 ; GFX8-GISEL-NEXT: s_mov_b64 s[6:7], 0xc8
180 ; GFX8-GISEL-NEXT: v_mov_b32_e32 v0, 1
181 ; GFX8-GISEL-NEXT: s_mov_b32 m0, -1
182 ; GFX8-GISEL-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
183 ; GFX8-GISEL-NEXT: s_waitcnt lgkmcnt(0)
184 ; GFX8-GISEL-NEXT: s_trap 2
185 ; GFX8-GISEL-NEXT: ds_write_b32 v0, v0
186 ; GFX8-GISEL-NEXT: .LBB2_2: ; %Flow
187 ; GFX8-GISEL-NEXT: s_andn2_saveexec_b64 s[4:5], s[4:5]
188 ; GFX8-GISEL-NEXT: s_cbranch_execz .LBB2_4
189 ; GFX8-GISEL-NEXT: ; %bb.3: ; %bb0
190 ; GFX8-GISEL-NEXT: s_mov_b64 s[6:7], 0xc8
191 ; GFX8-GISEL-NEXT: v_mov_b32_e32 v0, 0
192 ; GFX8-GISEL-NEXT: s_mov_b32 m0, -1
193 ; GFX8-GISEL-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
194 ; GFX8-GISEL-NEXT: s_waitcnt lgkmcnt(0)
195 ; GFX8-GISEL-NEXT: s_trap 2
196 ; GFX8-GISEL-NEXT: ds_write_b32 v0, v0
197 ; GFX8-GISEL-NEXT: .LBB2_4: ; %ret
198 ; GFX8-GISEL-NEXT: s_or_b64 exec, exec, s[4:5]
199 ; GFX8-GISEL-NEXT: s_mov_b64 s[4:5], 0xc8
200 ; GFX8-GISEL-NEXT: v_mov_b32_e32 v0, 2
201 ; GFX8-GISEL-NEXT: s_mov_b32 m0, -1
202 ; GFX8-GISEL-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
203 ; GFX8-GISEL-NEXT: s_waitcnt lgkmcnt(0)
204 ; GFX8-GISEL-NEXT: s_trap 2
205 ; GFX8-GISEL-NEXT: ds_write_b32 v0, v0
206 ; GFX8-GISEL-NEXT: s_waitcnt lgkmcnt(0)
207 ; GFX8-GISEL-NEXT: s_setpc_b64 s[30:31]
209 ; GFX9-SDAG-LABEL: func_uses_lds_multi:
210 ; GFX9-SDAG: ; %bb.0: ; %entry
211 ; GFX9-SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
212 ; GFX9-SDAG-NEXT: v_and_b32_e32 v0, 1, v0
213 ; GFX9-SDAG-NEXT: v_cmp_eq_u32_e32 vcc, 1, v0
214 ; GFX9-SDAG-NEXT: s_xor_b64 s[4:5], vcc, -1
215 ; GFX9-SDAG-NEXT: s_and_saveexec_b64 s[6:7], s[4:5]
216 ; GFX9-SDAG-NEXT: s_xor_b64 s[4:5], exec, s[6:7]
217 ; GFX9-SDAG-NEXT: s_cbranch_execz .LBB2_2
218 ; GFX9-SDAG-NEXT: ; %bb.1: ; %bb1
219 ; GFX9-SDAG-NEXT: v_mov_b32_e32 v0, 1
220 ; GFX9-SDAG-NEXT: ds_write_b32 v0, v0
221 ; GFX9-SDAG-NEXT: s_trap 2
222 ; GFX9-SDAG-NEXT: .LBB2_2: ; %Flow
223 ; GFX9-SDAG-NEXT: s_andn2_saveexec_b64 s[4:5], s[4:5]
224 ; GFX9-SDAG-NEXT: s_cbranch_execz .LBB2_4
225 ; GFX9-SDAG-NEXT: ; %bb.3: ; %bb0
226 ; GFX9-SDAG-NEXT: v_mov_b32_e32 v0, 0
227 ; GFX9-SDAG-NEXT: ds_write_b32 v0, v0
228 ; GFX9-SDAG-NEXT: s_trap 2
229 ; GFX9-SDAG-NEXT: .LBB2_4: ; %ret
230 ; GFX9-SDAG-NEXT: s_or_b64 exec, exec, s[4:5]
231 ; GFX9-SDAG-NEXT: v_mov_b32_e32 v0, 2
232 ; GFX9-SDAG-NEXT: ds_write_b32 v0, v0
233 ; GFX9-SDAG-NEXT: s_trap 2
234 ; GFX9-SDAG-NEXT: s_waitcnt lgkmcnt(0)
235 ; GFX9-SDAG-NEXT: s_setpc_b64 s[30:31]
237 ; GFX9-GISEL-LABEL: func_uses_lds_multi:
238 ; GFX9-GISEL: ; %bb.0: ; %entry
239 ; GFX9-GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
240 ; GFX9-GISEL-NEXT: v_and_b32_e32 v0, 1, v0
241 ; GFX9-GISEL-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0
242 ; GFX9-GISEL-NEXT: s_xor_b64 s[4:5], vcc, -1
243 ; GFX9-GISEL-NEXT: s_and_saveexec_b64 s[6:7], s[4:5]
244 ; GFX9-GISEL-NEXT: s_xor_b64 s[4:5], exec, s[6:7]
245 ; GFX9-GISEL-NEXT: s_cbranch_execz .LBB2_2
246 ; GFX9-GISEL-NEXT: ; %bb.1: ; %bb1
247 ; GFX9-GISEL-NEXT: v_mov_b32_e32 v0, 1
248 ; GFX9-GISEL-NEXT: s_trap 2
249 ; GFX9-GISEL-NEXT: ds_write_b32 v0, v0
250 ; GFX9-GISEL-NEXT: .LBB2_2: ; %Flow
251 ; GFX9-GISEL-NEXT: s_andn2_saveexec_b64 s[4:5], s[4:5]
252 ; GFX9-GISEL-NEXT: s_cbranch_execz .LBB2_4
253 ; GFX9-GISEL-NEXT: ; %bb.3: ; %bb0
254 ; GFX9-GISEL-NEXT: v_mov_b32_e32 v0, 0
255 ; GFX9-GISEL-NEXT: s_trap 2
256 ; GFX9-GISEL-NEXT: ds_write_b32 v0, v0
257 ; GFX9-GISEL-NEXT: .LBB2_4: ; %ret
258 ; GFX9-GISEL-NEXT: s_or_b64 exec, exec, s[4:5]
259 ; GFX9-GISEL-NEXT: v_mov_b32_e32 v0, 2
260 ; GFX9-GISEL-NEXT: s_trap 2
261 ; GFX9-GISEL-NEXT: ds_write_b32 v0, v0
262 ; GFX9-GISEL-NEXT: s_waitcnt lgkmcnt(0)
263 ; GFX9-GISEL-NEXT: s_setpc_b64 s[30:31]
265 ; SDAG-LABEL: func_uses_lds_multi:
266 ; SDAG: ; %bb.0: ; %entry
267 ; SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
268 ; SDAG-NEXT: v_and_b32_e32 v0, 1, v0
269 ; SDAG-NEXT: v_cmp_eq_u32_e32 vcc, 1, v0
270 ; SDAG-NEXT: s_xor_b64 s[4:5], vcc, -1
271 ; SDAG-NEXT: s_and_saveexec_b64 s[6:7], s[4:5]
272 ; SDAG-NEXT: s_xor_b64 s[4:5], exec, s[6:7]
273 ; SDAG-NEXT: s_cbranch_execz .LBB2_2
274 ; SDAG-NEXT: ; %bb.1: ; %bb1
275 ; SDAG-NEXT: v_mov_b32_e32 v0, 1
276 ; SDAG-NEXT: ds_write_b32 v0, v0
277 ; SDAG-NEXT: s_cbranch_execnz .LBB2_6
278 ; SDAG-NEXT: .LBB2_2: ; %Flow
279 ; SDAG-NEXT: s_andn2_saveexec_b64 s[4:5], s[4:5]
280 ; SDAG-NEXT: s_cbranch_execz .LBB2_4
281 ; SDAG-NEXT: ; %bb.3: ; %bb0
282 ; SDAG-NEXT: v_mov_b32_e32 v0, 0
283 ; SDAG-NEXT: ds_write_b32 v0, v0
284 ; SDAG-NEXT: s_cbranch_execnz .LBB2_6
285 ; SDAG-NEXT: .LBB2_4: ; %ret
286 ; SDAG-NEXT: s_or_b64 exec, exec, s[4:5]
287 ; SDAG-NEXT: v_mov_b32_e32 v0, 2
288 ; SDAG-NEXT: ds_write_b32 v0, v0
289 ; SDAG-NEXT: s_cbranch_execnz .LBB2_6
290 ; SDAG-NEXT: ; %bb.5: ; %ret
291 ; SDAG-NEXT: s_waitcnt lgkmcnt(0)
292 ; SDAG-NEXT: s_setpc_b64 s[30:31]
293 ; SDAG-NEXT: .LBB2_6:
294 ; SDAG-NEXT: s_endpgm
296 ; GISEL-LABEL: func_uses_lds_multi:
297 ; GISEL: ; %bb.0: ; %entry
298 ; GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
299 ; GISEL-NEXT: v_and_b32_e32 v0, 1, v0
300 ; GISEL-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0
301 ; GISEL-NEXT: s_xor_b64 s[4:5], vcc, -1
302 ; GISEL-NEXT: s_and_saveexec_b64 s[6:7], s[4:5]
303 ; GISEL-NEXT: s_xor_b64 s[4:5], exec, s[6:7]
304 ; GISEL-NEXT: s_cbranch_execz .LBB2_3
305 ; GISEL-NEXT: ; %bb.1: ; %bb1
306 ; GISEL-NEXT: s_cbranch_execnz .LBB2_8
307 ; GISEL-NEXT: ; %bb.2: ; %bb1
308 ; GISEL-NEXT: v_mov_b32_e32 v0, 1
309 ; GISEL-NEXT: ds_write_b32 v0, v0
310 ; GISEL-NEXT: .LBB2_3: ; %Flow
311 ; GISEL-NEXT: s_andn2_saveexec_b64 s[4:5], s[4:5]
312 ; GISEL-NEXT: s_cbranch_execz .LBB2_6
313 ; GISEL-NEXT: ; %bb.4: ; %bb0
314 ; GISEL-NEXT: s_cbranch_execnz .LBB2_8
315 ; GISEL-NEXT: ; %bb.5: ; %bb0
316 ; GISEL-NEXT: v_mov_b32_e32 v0, 0
317 ; GISEL-NEXT: ds_write_b32 v0, v0
318 ; GISEL-NEXT: .LBB2_6: ; %ret
319 ; GISEL-NEXT: s_or_b64 exec, exec, s[4:5]
320 ; GISEL-NEXT: s_cbranch_execnz .LBB2_8
321 ; GISEL-NEXT: ; %bb.7: ; %ret
322 ; GISEL-NEXT: v_mov_b32_e32 v0, 2
323 ; GISEL-NEXT: ds_write_b32 v0, v0
324 ; GISEL-NEXT: s_waitcnt lgkmcnt(0)
325 ; GISEL-NEXT: s_setpc_b64 s[30:31]
326 ; GISEL-NEXT: .LBB2_8:
327 ; GISEL-NEXT: s_endpgm
329 br i1 %cond, label %bb0, label %bb1
332 store volatile i32 0, ptr addrspace(3) @lds, align 4
336 store volatile i32 1, ptr addrspace(3) @lds, align 4
340 store volatile i32 2, ptr addrspace(3) @lds, align 4
344 ; ERR: warning: <unknown>:0:0: in function func_uses_lds_code_after void (ptr addrspace(1)): local memory global used by non-kernel function
345 define void @func_uses_lds_code_after(ptr addrspace(1) %ptr) {
346 ; GFX8-SDAG-LABEL: func_uses_lds_code_after:
347 ; GFX8-SDAG: ; %bb.0:
348 ; GFX8-SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
349 ; GFX8-SDAG-NEXT: v_mov_b32_e32 v2, 0
350 ; GFX8-SDAG-NEXT: s_mov_b32 m0, -1
351 ; GFX8-SDAG-NEXT: ds_write_b32 v0, v2
352 ; GFX8-SDAG-NEXT: s_mov_b64 s[4:5], 0xc8
353 ; GFX8-SDAG-NEXT: v_mov_b32_e32 v2, 1
354 ; GFX8-SDAG-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
355 ; GFX8-SDAG-NEXT: s_waitcnt lgkmcnt(0)
356 ; GFX8-SDAG-NEXT: s_trap 2
357 ; GFX8-SDAG-NEXT: flat_store_dword v[0:1], v2
358 ; GFX8-SDAG-NEXT: s_waitcnt vmcnt(0)
359 ; GFX8-SDAG-NEXT: s_setpc_b64 s[30:31]
361 ; GFX8-GISEL-LABEL: func_uses_lds_code_after:
362 ; GFX8-GISEL: ; %bb.0:
363 ; GFX8-GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
364 ; GFX8-GISEL-NEXT: s_mov_b64 s[4:5], 0xc8
365 ; GFX8-GISEL-NEXT: v_mov_b32_e32 v2, 0
366 ; GFX8-GISEL-NEXT: s_mov_b32 m0, -1
367 ; GFX8-GISEL-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
368 ; GFX8-GISEL-NEXT: s_waitcnt lgkmcnt(0)
369 ; GFX8-GISEL-NEXT: s_trap 2
370 ; GFX8-GISEL-NEXT: ds_write_b32 v0, v2
371 ; GFX8-GISEL-NEXT: v_mov_b32_e32 v2, 1
372 ; GFX8-GISEL-NEXT: flat_store_dword v[0:1], v2
373 ; GFX8-GISEL-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
374 ; GFX8-GISEL-NEXT: s_setpc_b64 s[30:31]
376 ; GFX9-SDAG-LABEL: func_uses_lds_code_after:
377 ; GFX9-SDAG: ; %bb.0:
378 ; GFX9-SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
379 ; GFX9-SDAG-NEXT: v_mov_b32_e32 v2, 0
380 ; GFX9-SDAG-NEXT: ds_write_b32 v0, v2
381 ; GFX9-SDAG-NEXT: v_mov_b32_e32 v2, 1
382 ; GFX9-SDAG-NEXT: s_trap 2
383 ; GFX9-SDAG-NEXT: global_store_dword v[0:1], v2, off
384 ; GFX9-SDAG-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
385 ; GFX9-SDAG-NEXT: s_setpc_b64 s[30:31]
387 ; GFX9-GISEL-LABEL: func_uses_lds_code_after:
388 ; GFX9-GISEL: ; %bb.0:
389 ; GFX9-GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
390 ; GFX9-GISEL-NEXT: v_mov_b32_e32 v2, 0
391 ; GFX9-GISEL-NEXT: s_trap 2
392 ; GFX9-GISEL-NEXT: ds_write_b32 v0, v2
393 ; GFX9-GISEL-NEXT: v_mov_b32_e32 v2, 1
394 ; GFX9-GISEL-NEXT: global_store_dword v[0:1], v2, off
395 ; GFX9-GISEL-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
396 ; GFX9-GISEL-NEXT: s_setpc_b64 s[30:31]
398 ; SDAG-LABEL: func_uses_lds_code_after:
400 ; SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
401 ; SDAG-NEXT: v_mov_b32_e32 v2, 0
402 ; SDAG-NEXT: ds_write_b32 v0, v2
403 ; SDAG-NEXT: s_cbranch_execnz .LBB3_2
404 ; SDAG-NEXT: ; %bb.1:
405 ; SDAG-NEXT: v_mov_b32_e32 v2, 1
406 ; SDAG-NEXT: global_store_dword v[0:1], v2, off
407 ; SDAG-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
408 ; SDAG-NEXT: s_setpc_b64 s[30:31]
409 ; SDAG-NEXT: .LBB3_2:
410 ; SDAG-NEXT: s_endpgm
412 ; GISEL-LABEL: func_uses_lds_code_after:
414 ; GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
415 ; GISEL-NEXT: s_cbranch_execnz .LBB3_2
416 ; GISEL-NEXT: ; %bb.1:
417 ; GISEL-NEXT: v_mov_b32_e32 v2, 0
418 ; GISEL-NEXT: ds_write_b32 v0, v2
419 ; GISEL-NEXT: v_mov_b32_e32 v2, 1
420 ; GISEL-NEXT: global_store_dword v[0:1], v2, off
421 ; GISEL-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
422 ; GISEL-NEXT: s_setpc_b64 s[30:31]
423 ; GISEL-NEXT: .LBB3_2:
424 ; GISEL-NEXT: s_endpgm
425 store volatile i32 0, ptr addrspace(3) @lds, align 4
426 store volatile i32 1, ptr addrspace(1) %ptr, align 4
430 ; 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
431 define i32 @func_uses_lds_phi_after(i1 %cond, ptr addrspace(1) %ptr) {
432 ; GFX8-SDAG-LABEL: func_uses_lds_phi_after:
433 ; GFX8-SDAG: ; %bb.0: ; %entry
434 ; GFX8-SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
435 ; GFX8-SDAG-NEXT: v_mov_b32_e32 v3, v0
436 ; GFX8-SDAG-NEXT: flat_load_dword v0, v[1:2] glc
437 ; GFX8-SDAG-NEXT: s_waitcnt vmcnt(0)
438 ; GFX8-SDAG-NEXT: v_and_b32_e32 v3, 1, v3
439 ; GFX8-SDAG-NEXT: v_cmp_eq_u32_e32 vcc, 1, v3
440 ; GFX8-SDAG-NEXT: s_and_saveexec_b64 s[4:5], vcc
441 ; GFX8-SDAG-NEXT: s_cbranch_execz .LBB4_2
442 ; GFX8-SDAG-NEXT: ; %bb.1: ; %use.bb
443 ; GFX8-SDAG-NEXT: v_mov_b32_e32 v0, 0
444 ; GFX8-SDAG-NEXT: s_mov_b32 m0, -1
445 ; GFX8-SDAG-NEXT: s_mov_b64 s[6:7], 0xc8
446 ; GFX8-SDAG-NEXT: ds_write_b32 v0, v0
447 ; GFX8-SDAG-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
448 ; GFX8-SDAG-NEXT: s_waitcnt lgkmcnt(0)
449 ; GFX8-SDAG-NEXT: s_trap 2
450 ; GFX8-SDAG-NEXT: flat_load_dword v0, v[1:2] glc
451 ; GFX8-SDAG-NEXT: s_waitcnt vmcnt(0)
452 ; GFX8-SDAG-NEXT: .LBB4_2: ; %ret
453 ; GFX8-SDAG-NEXT: s_or_b64 exec, exec, s[4:5]
454 ; GFX8-SDAG-NEXT: s_setpc_b64 s[30:31]
456 ; GFX8-GISEL-LABEL: func_uses_lds_phi_after:
457 ; GFX8-GISEL: ; %bb.0: ; %entry
458 ; GFX8-GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
459 ; GFX8-GISEL-NEXT: v_mov_b32_e32 v3, v0
460 ; GFX8-GISEL-NEXT: flat_load_dword v0, v[1:2] glc
461 ; GFX8-GISEL-NEXT: s_waitcnt vmcnt(0)
462 ; GFX8-GISEL-NEXT: v_and_b32_e32 v3, 1, v3
463 ; GFX8-GISEL-NEXT: v_cmp_ne_u32_e32 vcc, 0, v3
464 ; GFX8-GISEL-NEXT: s_and_saveexec_b64 s[4:5], vcc
465 ; GFX8-GISEL-NEXT: s_cbranch_execz .LBB4_2
466 ; GFX8-GISEL-NEXT: ; %bb.1: ; %use.bb
467 ; GFX8-GISEL-NEXT: s_mov_b64 s[6:7], 0xc8
468 ; GFX8-GISEL-NEXT: v_mov_b32_e32 v0, 0
469 ; GFX8-GISEL-NEXT: s_mov_b32 m0, -1
470 ; GFX8-GISEL-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
471 ; GFX8-GISEL-NEXT: s_waitcnt lgkmcnt(0)
472 ; GFX8-GISEL-NEXT: s_trap 2
473 ; GFX8-GISEL-NEXT: ds_write_b32 v0, v0
474 ; GFX8-GISEL-NEXT: flat_load_dword v0, v[1:2] glc
475 ; GFX8-GISEL-NEXT: s_waitcnt vmcnt(0)
476 ; GFX8-GISEL-NEXT: .LBB4_2: ; %ret
477 ; GFX8-GISEL-NEXT: s_or_b64 exec, exec, s[4:5]
478 ; GFX8-GISEL-NEXT: s_waitcnt lgkmcnt(0)
479 ; GFX8-GISEL-NEXT: s_setpc_b64 s[30:31]
481 ; GFX9-SDAG-LABEL: func_uses_lds_phi_after:
482 ; GFX9-SDAG: ; %bb.0: ; %entry
483 ; GFX9-SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
484 ; GFX9-SDAG-NEXT: v_mov_b32_e32 v3, v0
485 ; GFX9-SDAG-NEXT: global_load_dword v0, v[1:2], off glc
486 ; GFX9-SDAG-NEXT: s_waitcnt vmcnt(0)
487 ; GFX9-SDAG-NEXT: v_and_b32_e32 v3, 1, v3
488 ; GFX9-SDAG-NEXT: v_cmp_eq_u32_e32 vcc, 1, v3
489 ; GFX9-SDAG-NEXT: s_and_saveexec_b64 s[4:5], vcc
490 ; GFX9-SDAG-NEXT: s_cbranch_execz .LBB4_2
491 ; GFX9-SDAG-NEXT: ; %bb.1: ; %use.bb
492 ; GFX9-SDAG-NEXT: v_mov_b32_e32 v0, 0
493 ; GFX9-SDAG-NEXT: ds_write_b32 v0, v0
494 ; GFX9-SDAG-NEXT: s_trap 2
495 ; GFX9-SDAG-NEXT: global_load_dword v0, v[1:2], off glc
496 ; GFX9-SDAG-NEXT: s_waitcnt vmcnt(0)
497 ; GFX9-SDAG-NEXT: .LBB4_2: ; %ret
498 ; GFX9-SDAG-NEXT: s_or_b64 exec, exec, s[4:5]
499 ; GFX9-SDAG-NEXT: s_waitcnt lgkmcnt(0)
500 ; GFX9-SDAG-NEXT: s_setpc_b64 s[30:31]
502 ; GFX9-GISEL-LABEL: func_uses_lds_phi_after:
503 ; GFX9-GISEL: ; %bb.0: ; %entry
504 ; GFX9-GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
505 ; GFX9-GISEL-NEXT: v_mov_b32_e32 v3, v0
506 ; GFX9-GISEL-NEXT: global_load_dword v0, v[1:2], off glc
507 ; GFX9-GISEL-NEXT: s_waitcnt vmcnt(0)
508 ; GFX9-GISEL-NEXT: v_and_b32_e32 v3, 1, v3
509 ; GFX9-GISEL-NEXT: v_cmp_ne_u32_e32 vcc, 0, v3
510 ; GFX9-GISEL-NEXT: s_and_saveexec_b64 s[4:5], vcc
511 ; GFX9-GISEL-NEXT: s_cbranch_execz .LBB4_2
512 ; GFX9-GISEL-NEXT: ; %bb.1: ; %use.bb
513 ; GFX9-GISEL-NEXT: v_mov_b32_e32 v0, 0
514 ; GFX9-GISEL-NEXT: s_trap 2
515 ; GFX9-GISEL-NEXT: ds_write_b32 v0, v0
516 ; GFX9-GISEL-NEXT: global_load_dword v0, v[1:2], off glc
517 ; GFX9-GISEL-NEXT: s_waitcnt vmcnt(0)
518 ; GFX9-GISEL-NEXT: .LBB4_2: ; %ret
519 ; GFX9-GISEL-NEXT: s_or_b64 exec, exec, s[4:5]
520 ; GFX9-GISEL-NEXT: s_waitcnt lgkmcnt(0)
521 ; GFX9-GISEL-NEXT: s_setpc_b64 s[30:31]
523 ; SDAG-LABEL: func_uses_lds_phi_after:
524 ; SDAG: ; %bb.0: ; %entry
525 ; SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
526 ; SDAG-NEXT: v_mov_b32_e32 v3, v0
527 ; SDAG-NEXT: global_load_dword v0, v[1:2], off glc
528 ; SDAG-NEXT: s_waitcnt vmcnt(0)
529 ; SDAG-NEXT: v_and_b32_e32 v3, 1, v3
530 ; SDAG-NEXT: v_cmp_eq_u32_e32 vcc, 1, v3
531 ; SDAG-NEXT: s_and_saveexec_b64 s[4:5], vcc
532 ; SDAG-NEXT: s_cbranch_execz .LBB4_3
533 ; SDAG-NEXT: ; %bb.1: ; %use.bb
534 ; SDAG-NEXT: v_mov_b32_e32 v0, 0
535 ; SDAG-NEXT: ds_write_b32 v0, v0
536 ; SDAG-NEXT: s_cbranch_execnz .LBB4_4
537 ; SDAG-NEXT: ; %bb.2: ; %use.bb
538 ; SDAG-NEXT: global_load_dword v0, v[1:2], off glc
539 ; SDAG-NEXT: s_waitcnt vmcnt(0)
540 ; SDAG-NEXT: .LBB4_3: ; %ret
541 ; SDAG-NEXT: s_or_b64 exec, exec, s[4:5]
542 ; SDAG-NEXT: s_waitcnt lgkmcnt(0)
543 ; SDAG-NEXT: s_setpc_b64 s[30:31]
544 ; SDAG-NEXT: .LBB4_4:
545 ; SDAG-NEXT: s_endpgm
547 ; GISEL-LABEL: func_uses_lds_phi_after:
548 ; GISEL: ; %bb.0: ; %entry
549 ; GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
550 ; GISEL-NEXT: v_mov_b32_e32 v3, v0
551 ; GISEL-NEXT: global_load_dword v0, v[1:2], off glc
552 ; GISEL-NEXT: s_waitcnt vmcnt(0)
553 ; GISEL-NEXT: v_and_b32_e32 v3, 1, v3
554 ; GISEL-NEXT: v_cmp_ne_u32_e32 vcc, 0, v3
555 ; GISEL-NEXT: s_and_saveexec_b64 s[4:5], vcc
556 ; GISEL-NEXT: s_cbranch_execz .LBB4_3
557 ; GISEL-NEXT: ; %bb.1: ; %use.bb
558 ; GISEL-NEXT: s_cbranch_execnz .LBB4_4
559 ; GISEL-NEXT: ; %bb.2: ; %use.bb
560 ; GISEL-NEXT: v_mov_b32_e32 v0, 0
561 ; GISEL-NEXT: ds_write_b32 v0, v0
562 ; GISEL-NEXT: global_load_dword v0, v[1:2], off glc
563 ; GISEL-NEXT: s_waitcnt vmcnt(0)
564 ; GISEL-NEXT: .LBB4_3: ; %ret
565 ; GISEL-NEXT: s_or_b64 exec, exec, s[4:5]
566 ; GISEL-NEXT: s_waitcnt lgkmcnt(0)
567 ; GISEL-NEXT: s_setpc_b64 s[30:31]
568 ; GISEL-NEXT: .LBB4_4:
569 ; GISEL-NEXT: s_endpgm
571 %entry.load = load volatile i32, ptr addrspace(1) %ptr
572 br i1 %cond, label %use.bb, label %ret
575 store volatile i32 0, ptr addrspace(3) @lds, align 4
576 %use.bb.load = load volatile i32, ptr addrspace(1) %ptr
580 %phi = phi i32 [ %entry.load, %entry ], [ %use.bb.load, %use.bb ]