1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=amdgcn-amd- -mcpu=gfx600 -verify-machineinstrs < %s | FileCheck --check-prefixes=GFX6 %s
3 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx700 -verify-machineinstrs < %s | FileCheck --check-prefixes=GFX7 %s
4 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -verify-machineinstrs < %s | FileCheck --check-prefixes=GFX10-WGP %s
5 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -mattr=+cumode -verify-machineinstrs < %s | FileCheck --check-prefixes=GFX10-CU %s
6 ; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx700 -amdgcn-skip-cache-invalidations -verify-machineinstrs < %s | FileCheck --check-prefixes=SKIP-CACHE-INV %s
7 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1100 -verify-machineinstrs < %s | FileCheck --check-prefixes=GFX11-WGP %s
8 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1100 -mattr=+cumode -verify-machineinstrs < %s | FileCheck --check-prefixes=GFX11-CU %s
10 define amdgpu_kernel void @global_volatile_load_0(
11 ; GFX6-LABEL: global_volatile_load_0:
12 ; GFX6: ; %bb.0: ; %entry
13 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
14 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
15 ; GFX6-NEXT: s_mov_b32 s6, -1
16 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
17 ; GFX6-NEXT: s_mov_b32 s4, s0
18 ; GFX6-NEXT: s_mov_b32 s5, s1
19 ; GFX6-NEXT: buffer_load_dword v0, off, s[4:7], 0 glc
20 ; GFX6-NEXT: s_waitcnt vmcnt(0)
21 ; GFX6-NEXT: s_mov_b32 s4, s2
22 ; GFX6-NEXT: s_mov_b32 s5, s3
23 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
26 ; GFX7-LABEL: global_volatile_load_0:
27 ; GFX7: ; %bb.0: ; %entry
28 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
29 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
30 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
31 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
32 ; GFX7-NEXT: flat_load_dword v2, v[0:1] glc
33 ; GFX7-NEXT: s_waitcnt vmcnt(0)
34 ; GFX7-NEXT: v_mov_b32_e32 v0, s2
35 ; GFX7-NEXT: v_mov_b32_e32 v1, s3
36 ; GFX7-NEXT: flat_store_dword v[0:1], v2
39 ; GFX10-WGP-LABEL: global_volatile_load_0:
40 ; GFX10-WGP: ; %bb.0: ; %entry
41 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
42 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
43 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
44 ; GFX10-WGP-NEXT: global_load_dword v1, v0, s[0:1] glc dlc
45 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
46 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[2:3]
47 ; GFX10-WGP-NEXT: s_endpgm
49 ; GFX10-CU-LABEL: global_volatile_load_0:
50 ; GFX10-CU: ; %bb.0: ; %entry
51 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
52 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
53 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
54 ; GFX10-CU-NEXT: global_load_dword v1, v0, s[0:1] glc dlc
55 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
56 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[2:3]
57 ; GFX10-CU-NEXT: s_endpgm
59 ; SKIP-CACHE-INV-LABEL: global_volatile_load_0:
60 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
61 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
62 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
63 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
64 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
65 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
66 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
67 ; SKIP-CACHE-INV-NEXT: buffer_load_dword v0, off, s[4:7], 0 glc
68 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
69 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s2
70 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s3
71 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
72 ; SKIP-CACHE-INV-NEXT: s_endpgm
74 ; GFX11-WGP-LABEL: global_volatile_load_0:
75 ; GFX11-WGP: ; %bb.0: ; %entry
76 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
77 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
78 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
79 ; GFX11-WGP-NEXT: global_load_b32 v1, v0, s[0:1] glc dlc
80 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
81 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[2:3]
82 ; GFX11-WGP-NEXT: s_nop 0
83 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
84 ; GFX11-WGP-NEXT: s_endpgm
86 ; GFX11-CU-LABEL: global_volatile_load_0:
87 ; GFX11-CU: ; %bb.0: ; %entry
88 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
89 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
90 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
91 ; GFX11-CU-NEXT: global_load_b32 v1, v0, s[0:1] glc dlc
92 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
93 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[2:3]
94 ; GFX11-CU-NEXT: s_nop 0
95 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
96 ; GFX11-CU-NEXT: s_endpgm
97 ptr addrspace(1) %in, ptr addrspace(1) %out) {
99 %val = load volatile i32, ptr addrspace(1) %in, align 4
100 store i32 %val, ptr addrspace(1) %out
104 define amdgpu_kernel void @global_volatile_load_1(
105 ; GFX6-LABEL: global_volatile_load_1:
106 ; GFX6: ; %bb.0: ; %entry
107 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
108 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
109 ; GFX6-NEXT: v_lshlrev_b32_e32 v0, 2, v0
110 ; GFX6-NEXT: v_mov_b32_e32 v1, 0
111 ; GFX6-NEXT: s_mov_b32 s6, -1
112 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
113 ; GFX6-NEXT: s_mov_b32 s4, s2
114 ; GFX6-NEXT: s_mov_b32 s5, s3
115 ; GFX6-NEXT: s_mov_b32 s2, 0
116 ; GFX6-NEXT: s_mov_b32 s3, s7
117 ; GFX6-NEXT: buffer_load_dword v0, v[0:1], s[0:3], 0 addr64 glc
118 ; GFX6-NEXT: s_waitcnt vmcnt(0)
119 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
120 ; GFX6-NEXT: s_endpgm
122 ; GFX7-LABEL: global_volatile_load_1:
123 ; GFX7: ; %bb.0: ; %entry
124 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
125 ; GFX7-NEXT: v_lshlrev_b32_e32 v0, 2, v0
126 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
127 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
128 ; GFX7-NEXT: v_add_i32_e32 v0, vcc, s0, v0
129 ; GFX7-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
130 ; GFX7-NEXT: flat_load_dword v2, v[0:1] glc
131 ; GFX7-NEXT: s_waitcnt vmcnt(0)
132 ; GFX7-NEXT: v_mov_b32_e32 v0, s2
133 ; GFX7-NEXT: v_mov_b32_e32 v1, s3
134 ; GFX7-NEXT: flat_store_dword v[0:1], v2
135 ; GFX7-NEXT: s_endpgm
137 ; GFX10-WGP-LABEL: global_volatile_load_1:
138 ; GFX10-WGP: ; %bb.0: ; %entry
139 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
140 ; GFX10-WGP-NEXT: v_lshlrev_b32_e32 v0, 2, v0
141 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, 0
142 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
143 ; GFX10-WGP-NEXT: global_load_dword v0, v0, s[0:1] glc dlc
144 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
145 ; GFX10-WGP-NEXT: global_store_dword v1, v0, s[2:3]
146 ; GFX10-WGP-NEXT: s_endpgm
148 ; GFX10-CU-LABEL: global_volatile_load_1:
149 ; GFX10-CU: ; %bb.0: ; %entry
150 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
151 ; GFX10-CU-NEXT: v_lshlrev_b32_e32 v0, 2, v0
152 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, 0
153 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
154 ; GFX10-CU-NEXT: global_load_dword v0, v0, s[0:1] glc dlc
155 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
156 ; GFX10-CU-NEXT: global_store_dword v1, v0, s[2:3]
157 ; GFX10-CU-NEXT: s_endpgm
159 ; SKIP-CACHE-INV-LABEL: global_volatile_load_1:
160 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
161 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
162 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
163 ; SKIP-CACHE-INV-NEXT: v_lshlrev_b32_e32 v0, 2, v0
164 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, 0
165 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
166 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
167 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s2
168 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s3
169 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, 0
170 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s7
171 ; SKIP-CACHE-INV-NEXT: buffer_load_dword v0, v[0:1], s[0:3], 0 addr64 glc
172 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
173 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
174 ; SKIP-CACHE-INV-NEXT: s_endpgm
176 ; GFX11-WGP-LABEL: global_volatile_load_1:
177 ; GFX11-WGP: ; %bb.0: ; %entry
178 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
179 ; GFX11-WGP-NEXT: v_dual_mov_b32 v1, 0 :: v_dual_lshlrev_b32 v0, 2, v0
180 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
181 ; GFX11-WGP-NEXT: global_load_b32 v0, v0, s[0:1] glc dlc
182 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
183 ; GFX11-WGP-NEXT: global_store_b32 v1, v0, s[2:3]
184 ; GFX11-WGP-NEXT: s_nop 0
185 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
186 ; GFX11-WGP-NEXT: s_endpgm
188 ; GFX11-CU-LABEL: global_volatile_load_1:
189 ; GFX11-CU: ; %bb.0: ; %entry
190 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
191 ; GFX11-CU-NEXT: v_dual_mov_b32 v1, 0 :: v_dual_lshlrev_b32 v0, 2, v0
192 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
193 ; GFX11-CU-NEXT: global_load_b32 v0, v0, s[0:1] glc dlc
194 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
195 ; GFX11-CU-NEXT: global_store_b32 v1, v0, s[2:3]
196 ; GFX11-CU-NEXT: s_nop 0
197 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
198 ; GFX11-CU-NEXT: s_endpgm
199 ptr addrspace(1) %in, ptr addrspace(1) %out) {
201 %tid = call i32 @llvm.amdgcn.workitem.id.x()
202 %val.gep = getelementptr inbounds i32, ptr addrspace(1) %in, i32 %tid
203 %val = load volatile i32, ptr addrspace(1) %val.gep, align 4
204 store i32 %val, ptr addrspace(1) %out
208 define amdgpu_kernel void @global_volatile_store_0(
209 ; GFX6-LABEL: global_volatile_store_0:
210 ; GFX6: ; %bb.0: ; %entry
211 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
212 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
213 ; GFX6-NEXT: s_mov_b32 s6, -1
214 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
215 ; GFX6-NEXT: s_load_dword s0, s[0:1], 0x0
216 ; GFX6-NEXT: s_mov_b32 s4, s2
217 ; GFX6-NEXT: s_mov_b32 s5, s3
218 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
219 ; GFX6-NEXT: v_mov_b32_e32 v0, s0
220 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
221 ; GFX6-NEXT: s_waitcnt vmcnt(0)
222 ; GFX6-NEXT: s_endpgm
224 ; GFX7-LABEL: global_volatile_store_0:
225 ; GFX7: ; %bb.0: ; %entry
226 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
227 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
228 ; GFX7-NEXT: s_load_dword s0, s[0:1], 0x0
229 ; GFX7-NEXT: v_mov_b32_e32 v0, s2
230 ; GFX7-NEXT: v_mov_b32_e32 v1, s3
231 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
232 ; GFX7-NEXT: v_mov_b32_e32 v2, s0
233 ; GFX7-NEXT: flat_store_dword v[0:1], v2
234 ; GFX7-NEXT: s_waitcnt vmcnt(0)
235 ; GFX7-NEXT: s_endpgm
237 ; GFX10-WGP-LABEL: global_volatile_store_0:
238 ; GFX10-WGP: ; %bb.0: ; %entry
239 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
240 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
241 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
242 ; GFX10-WGP-NEXT: s_load_dword s0, s[0:1], 0x0
243 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
244 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s0
245 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[2:3]
246 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
247 ; GFX10-WGP-NEXT: s_endpgm
249 ; GFX10-CU-LABEL: global_volatile_store_0:
250 ; GFX10-CU: ; %bb.0: ; %entry
251 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
252 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
253 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
254 ; GFX10-CU-NEXT: s_load_dword s0, s[0:1], 0x0
255 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
256 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s0
257 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[2:3]
258 ; GFX10-CU-NEXT: s_waitcnt_vscnt null, 0x0
259 ; GFX10-CU-NEXT: s_endpgm
261 ; SKIP-CACHE-INV-LABEL: global_volatile_store_0:
262 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
263 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
264 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
265 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
266 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
267 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x0
268 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s2
269 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s3
270 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
271 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
272 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
273 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
274 ; SKIP-CACHE-INV-NEXT: s_endpgm
276 ; GFX11-WGP-LABEL: global_volatile_store_0:
277 ; GFX11-WGP: ; %bb.0: ; %entry
278 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
279 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
280 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x0
281 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
282 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s0
283 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[2:3] dlc
284 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
285 ; GFX11-WGP-NEXT: s_nop 0
286 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
287 ; GFX11-WGP-NEXT: s_endpgm
289 ; GFX11-CU-LABEL: global_volatile_store_0:
290 ; GFX11-CU: ; %bb.0: ; %entry
291 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
292 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
293 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x0
294 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
295 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s0
296 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[2:3] dlc
297 ; GFX11-CU-NEXT: s_waitcnt_vscnt null, 0x0
298 ; GFX11-CU-NEXT: s_nop 0
299 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
300 ; GFX11-CU-NEXT: s_endpgm
301 ptr addrspace(1) %in, ptr addrspace(1) %out) {
303 %val = load i32, ptr addrspace(1) %in, align 4
304 store volatile i32 %val, ptr addrspace(1) %out
308 define amdgpu_kernel void @global_volatile_store_1(
309 ; GFX6-LABEL: global_volatile_store_1:
310 ; GFX6: ; %bb.0: ; %entry
311 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
312 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
313 ; GFX6-NEXT: s_mov_b32 s6, 0
314 ; GFX6-NEXT: v_lshlrev_b32_e32 v0, 2, v0
315 ; GFX6-NEXT: v_mov_b32_e32 v1, 0
316 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
317 ; GFX6-NEXT: s_load_dword s0, s[0:1], 0x0
318 ; GFX6-NEXT: s_mov_b64 s[4:5], s[2:3]
319 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
320 ; GFX6-NEXT: v_mov_b32_e32 v2, s0
321 ; GFX6-NEXT: buffer_store_dword v2, v[0:1], s[4:7], 0 addr64
322 ; GFX6-NEXT: s_waitcnt vmcnt(0)
323 ; GFX6-NEXT: s_endpgm
325 ; GFX7-LABEL: global_volatile_store_1:
326 ; GFX7: ; %bb.0: ; %entry
327 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
328 ; GFX7-NEXT: v_lshlrev_b32_e32 v0, 2, v0
329 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
330 ; GFX7-NEXT: s_load_dword s0, s[0:1], 0x0
331 ; GFX7-NEXT: v_mov_b32_e32 v1, s3
332 ; GFX7-NEXT: v_add_i32_e32 v0, vcc, s2, v0
333 ; GFX7-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
334 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
335 ; GFX7-NEXT: v_mov_b32_e32 v2, s0
336 ; GFX7-NEXT: flat_store_dword v[0:1], v2
337 ; GFX7-NEXT: s_waitcnt vmcnt(0)
338 ; GFX7-NEXT: s_endpgm
340 ; GFX10-WGP-LABEL: global_volatile_store_1:
341 ; GFX10-WGP: ; %bb.0: ; %entry
342 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
343 ; GFX10-WGP-NEXT: v_lshlrev_b32_e32 v0, 2, v0
344 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
345 ; GFX10-WGP-NEXT: s_load_dword s0, s[0:1], 0x0
346 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
347 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s0
348 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[2:3]
349 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
350 ; GFX10-WGP-NEXT: s_endpgm
352 ; GFX10-CU-LABEL: global_volatile_store_1:
353 ; GFX10-CU: ; %bb.0: ; %entry
354 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
355 ; GFX10-CU-NEXT: v_lshlrev_b32_e32 v0, 2, v0
356 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
357 ; GFX10-CU-NEXT: s_load_dword s0, s[0:1], 0x0
358 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
359 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s0
360 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[2:3]
361 ; GFX10-CU-NEXT: s_waitcnt_vscnt null, 0x0
362 ; GFX10-CU-NEXT: s_endpgm
364 ; SKIP-CACHE-INV-LABEL: global_volatile_store_1:
365 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
366 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
367 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
368 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0
369 ; SKIP-CACHE-INV-NEXT: v_lshlrev_b32_e32 v0, 2, v0
370 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, 0
371 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
372 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x0
373 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[4:5], s[2:3]
374 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
375 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
376 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v2, v[0:1], s[4:7], 0 addr64
377 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
378 ; SKIP-CACHE-INV-NEXT: s_endpgm
380 ; GFX11-WGP-LABEL: global_volatile_store_1:
381 ; GFX11-WGP: ; %bb.0: ; %entry
382 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
383 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
384 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x0
385 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
386 ; GFX11-WGP-NEXT: v_dual_mov_b32 v1, s0 :: v_dual_lshlrev_b32 v0, 2, v0
387 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[2:3] dlc
388 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
389 ; GFX11-WGP-NEXT: s_nop 0
390 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
391 ; GFX11-WGP-NEXT: s_endpgm
393 ; GFX11-CU-LABEL: global_volatile_store_1:
394 ; GFX11-CU: ; %bb.0: ; %entry
395 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
396 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
397 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x0
398 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
399 ; GFX11-CU-NEXT: v_dual_mov_b32 v1, s0 :: v_dual_lshlrev_b32 v0, 2, v0
400 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[2:3] dlc
401 ; GFX11-CU-NEXT: s_waitcnt_vscnt null, 0x0
402 ; GFX11-CU-NEXT: s_nop 0
403 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
404 ; GFX11-CU-NEXT: s_endpgm
405 ptr addrspace(1) %in, ptr addrspace(1) %out) {
407 %tid = call i32 @llvm.amdgcn.workitem.id.x()
408 %val = load i32, ptr addrspace(1) %in, align 4
409 %out.gep = getelementptr inbounds i32, ptr addrspace(1) %out, i32 %tid
410 store volatile i32 %val, ptr addrspace(1) %out.gep
414 define amdgpu_kernel void @global_volatile_workgroup_acquire_load(
415 ; GFX6-LABEL: global_volatile_workgroup_acquire_load:
416 ; GFX6: ; %bb.0: ; %entry
417 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
418 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
419 ; GFX6-NEXT: s_mov_b32 s6, -1
420 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
421 ; GFX6-NEXT: s_mov_b32 s4, s0
422 ; GFX6-NEXT: s_mov_b32 s5, s1
423 ; GFX6-NEXT: buffer_load_dword v0, off, s[4:7], 0
424 ; GFX6-NEXT: s_mov_b32 s4, s2
425 ; GFX6-NEXT: s_mov_b32 s5, s3
426 ; GFX6-NEXT: s_waitcnt vmcnt(0)
427 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
428 ; GFX6-NEXT: s_endpgm
430 ; GFX7-LABEL: global_volatile_workgroup_acquire_load:
431 ; GFX7: ; %bb.0: ; %entry
432 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
433 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
434 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
435 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
436 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
437 ; GFX7-NEXT: v_mov_b32_e32 v0, s2
438 ; GFX7-NEXT: v_mov_b32_e32 v1, s3
439 ; GFX7-NEXT: s_waitcnt vmcnt(0)
440 ; GFX7-NEXT: flat_store_dword v[0:1], v2
441 ; GFX7-NEXT: s_endpgm
443 ; GFX10-WGP-LABEL: global_volatile_workgroup_acquire_load:
444 ; GFX10-WGP: ; %bb.0: ; %entry
445 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
446 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
447 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
448 ; GFX10-WGP-NEXT: global_load_dword v1, v0, s[0:1] glc
449 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
450 ; GFX10-WGP-NEXT: buffer_gl0_inv
451 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[2:3]
452 ; GFX10-WGP-NEXT: s_endpgm
454 ; GFX10-CU-LABEL: global_volatile_workgroup_acquire_load:
455 ; GFX10-CU: ; %bb.0: ; %entry
456 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
457 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
458 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
459 ; GFX10-CU-NEXT: global_load_dword v1, v0, s[0:1]
460 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
461 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[2:3]
462 ; GFX10-CU-NEXT: s_endpgm
464 ; SKIP-CACHE-INV-LABEL: global_volatile_workgroup_acquire_load:
465 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
466 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
467 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
468 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
469 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
470 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
471 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
472 ; SKIP-CACHE-INV-NEXT: buffer_load_dword v0, off, s[4:7], 0
473 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s2
474 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s3
475 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
476 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
477 ; SKIP-CACHE-INV-NEXT: s_endpgm
479 ; GFX11-WGP-LABEL: global_volatile_workgroup_acquire_load:
480 ; GFX11-WGP: ; %bb.0: ; %entry
481 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
482 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
483 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
484 ; GFX11-WGP-NEXT: global_load_b32 v1, v0, s[0:1] glc
485 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
486 ; GFX11-WGP-NEXT: buffer_gl0_inv
487 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[2:3]
488 ; GFX11-WGP-NEXT: s_nop 0
489 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
490 ; GFX11-WGP-NEXT: s_endpgm
492 ; GFX11-CU-LABEL: global_volatile_workgroup_acquire_load:
493 ; GFX11-CU: ; %bb.0: ; %entry
494 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
495 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
496 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
497 ; GFX11-CU-NEXT: global_load_b32 v1, v0, s[0:1]
498 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
499 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[2:3]
500 ; GFX11-CU-NEXT: s_nop 0
501 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
502 ; GFX11-CU-NEXT: s_endpgm
503 ptr addrspace(1) %in, ptr addrspace(1) %out) {
505 %val = load atomic volatile i32, ptr addrspace(1) %in syncscope("workgroup") acquire, align 4
506 store i32 %val, ptr addrspace(1) %out
510 define amdgpu_kernel void @global_volatile_workgroup_release_store(
511 ; GFX6-LABEL: global_volatile_workgroup_release_store:
512 ; GFX6: ; %bb.0: ; %entry
513 ; GFX6-NEXT: s_load_dword s4, s[0:1], 0x9
514 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
515 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
516 ; GFX6-NEXT: s_mov_b32 s2, -1
517 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
518 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
519 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
520 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
521 ; GFX6-NEXT: s_endpgm
523 ; GFX7-LABEL: global_volatile_workgroup_release_store:
524 ; GFX7: ; %bb.0: ; %entry
525 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
526 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x0
527 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
528 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
529 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
530 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
531 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
532 ; GFX7-NEXT: flat_store_dword v[0:1], v2
533 ; GFX7-NEXT: s_endpgm
535 ; GFX10-WGP-LABEL: global_volatile_workgroup_release_store:
536 ; GFX10-WGP: ; %bb.0: ; %entry
537 ; GFX10-WGP-NEXT: s_clause 0x1
538 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x0
539 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
540 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
541 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
542 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
543 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
544 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
545 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
546 ; GFX10-WGP-NEXT: s_endpgm
548 ; GFX10-CU-LABEL: global_volatile_workgroup_release_store:
549 ; GFX10-CU: ; %bb.0: ; %entry
550 ; GFX10-CU-NEXT: s_clause 0x1
551 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x0
552 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
553 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
554 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
555 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
556 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
557 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
558 ; GFX10-CU-NEXT: s_endpgm
560 ; SKIP-CACHE-INV-LABEL: global_volatile_workgroup_release_store:
561 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
562 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x0
563 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
564 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
565 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
566 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
567 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
568 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
569 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
570 ; SKIP-CACHE-INV-NEXT: s_endpgm
572 ; GFX11-WGP-LABEL: global_volatile_workgroup_release_store:
573 ; GFX11-WGP: ; %bb.0: ; %entry
574 ; GFX11-WGP-NEXT: s_clause 0x1
575 ; GFX11-WGP-NEXT: s_load_b32 s2, s[0:1], 0x0
576 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
577 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
578 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
579 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
580 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
581 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
582 ; GFX11-WGP-NEXT: s_nop 0
583 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
584 ; GFX11-WGP-NEXT: s_endpgm
586 ; GFX11-CU-LABEL: global_volatile_workgroup_release_store:
587 ; GFX11-CU: ; %bb.0: ; %entry
588 ; GFX11-CU-NEXT: s_clause 0x1
589 ; GFX11-CU-NEXT: s_load_b32 s2, s[0:1], 0x0
590 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
591 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
592 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
593 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
594 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
595 ; GFX11-CU-NEXT: s_nop 0
596 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
597 ; GFX11-CU-NEXT: s_endpgm
598 i32 %in, ptr addrspace(1) %out) {
600 store atomic volatile i32 %in, ptr addrspace(1) %out syncscope("workgroup") release, align 4
604 declare i32 @llvm.amdgcn.workitem.id.x()