1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -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=gfx90a -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX90A-NOTTGSPLIT %s
8 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx90a -mattr=+tgsplit -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX90A-TGSPLIT %s
9 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx940 -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX940-NOTTGSPLIT %s
10 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx940 -mattr=+tgsplit -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX940-TGSPLIT %s
11 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1100 -verify-machineinstrs < %s | FileCheck --check-prefixes=GFX11-WGP %s
12 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1100 -mattr=+cumode -verify-machineinstrs < %s | FileCheck --check-prefixes=GFX11-CU %s
14 define amdgpu_kernel void @global_workgroup_unordered_load(
15 ; GFX6-LABEL: global_workgroup_unordered_load:
16 ; GFX6: ; %bb.0: ; %entry
17 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
18 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
19 ; GFX6-NEXT: s_mov_b32 s6, -1
20 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
21 ; GFX6-NEXT: s_mov_b32 s4, s0
22 ; GFX6-NEXT: s_mov_b32 s5, s1
23 ; GFX6-NEXT: buffer_load_dword v0, off, s[4:7], 0
24 ; GFX6-NEXT: s_mov_b32 s4, s2
25 ; GFX6-NEXT: s_mov_b32 s5, s3
26 ; GFX6-NEXT: s_waitcnt vmcnt(0)
27 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
30 ; GFX7-LABEL: global_workgroup_unordered_load:
31 ; GFX7: ; %bb.0: ; %entry
32 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
33 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
34 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
35 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
36 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
37 ; GFX7-NEXT: v_mov_b32_e32 v0, s2
38 ; GFX7-NEXT: v_mov_b32_e32 v1, s3
39 ; GFX7-NEXT: s_waitcnt vmcnt(0)
40 ; GFX7-NEXT: flat_store_dword v[0:1], v2
43 ; GFX10-WGP-LABEL: global_workgroup_unordered_load:
44 ; GFX10-WGP: ; %bb.0: ; %entry
45 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
46 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
47 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
48 ; GFX10-WGP-NEXT: global_load_dword v1, v0, s[0:1]
49 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
50 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[2:3]
51 ; GFX10-WGP-NEXT: s_endpgm
53 ; GFX10-CU-LABEL: global_workgroup_unordered_load:
54 ; GFX10-CU: ; %bb.0: ; %entry
55 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
56 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
57 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
58 ; GFX10-CU-NEXT: global_load_dword v1, v0, s[0:1]
59 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
60 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[2:3]
61 ; GFX10-CU-NEXT: s_endpgm
63 ; SKIP-CACHE-INV-LABEL: global_workgroup_unordered_load:
64 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
65 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
66 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
67 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
68 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
69 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
70 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
71 ; SKIP-CACHE-INV-NEXT: buffer_load_dword v0, off, s[4:7], 0
72 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s2
73 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s3
74 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
75 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
76 ; SKIP-CACHE-INV-NEXT: s_endpgm
78 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_unordered_load:
79 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
80 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
81 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
82 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
83 ; GFX90A-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[0:1]
84 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
85 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
86 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
88 ; GFX90A-TGSPLIT-LABEL: global_workgroup_unordered_load:
89 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
90 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
91 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
92 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
93 ; GFX90A-TGSPLIT-NEXT: global_load_dword v1, v0, s[0:1]
94 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
95 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
96 ; GFX90A-TGSPLIT-NEXT: s_endpgm
98 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_unordered_load:
99 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
100 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
101 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
102 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
103 ; GFX940-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[0:1]
104 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
105 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
106 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
108 ; GFX940-TGSPLIT-LABEL: global_workgroup_unordered_load:
109 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
110 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
111 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
112 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
113 ; GFX940-TGSPLIT-NEXT: global_load_dword v1, v0, s[0:1]
114 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
115 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
116 ; GFX940-TGSPLIT-NEXT: s_endpgm
118 ; GFX11-WGP-LABEL: global_workgroup_unordered_load:
119 ; GFX11-WGP: ; %bb.0: ; %entry
120 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
121 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
122 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
123 ; GFX11-WGP-NEXT: global_load_b32 v1, v0, s[0:1]
124 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
125 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[2:3]
126 ; GFX11-WGP-NEXT: s_nop 0
127 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
128 ; GFX11-WGP-NEXT: s_endpgm
130 ; GFX11-CU-LABEL: global_workgroup_unordered_load:
131 ; GFX11-CU: ; %bb.0: ; %entry
132 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
133 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
134 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
135 ; GFX11-CU-NEXT: global_load_b32 v1, v0, s[0:1]
136 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
137 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[2:3]
138 ; GFX11-CU-NEXT: s_nop 0
139 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
140 ; GFX11-CU-NEXT: s_endpgm
141 ptr addrspace(1) %in, ptr addrspace(1) %out) {
143 %val = load atomic i32, ptr addrspace(1) %in syncscope("workgroup") unordered, align 4
144 store i32 %val, ptr addrspace(1) %out
148 define amdgpu_kernel void @global_workgroup_monotonic_load(
149 ; GFX6-LABEL: global_workgroup_monotonic_load:
150 ; GFX6: ; %bb.0: ; %entry
151 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
152 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
153 ; GFX6-NEXT: s_mov_b32 s6, -1
154 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
155 ; GFX6-NEXT: s_mov_b32 s4, s0
156 ; GFX6-NEXT: s_mov_b32 s5, s1
157 ; GFX6-NEXT: buffer_load_dword v0, off, s[4:7], 0
158 ; GFX6-NEXT: s_mov_b32 s4, s2
159 ; GFX6-NEXT: s_mov_b32 s5, s3
160 ; GFX6-NEXT: s_waitcnt vmcnt(0)
161 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
162 ; GFX6-NEXT: s_endpgm
164 ; GFX7-LABEL: global_workgroup_monotonic_load:
165 ; GFX7: ; %bb.0: ; %entry
166 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
167 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
168 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
169 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
170 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
171 ; GFX7-NEXT: v_mov_b32_e32 v0, s2
172 ; GFX7-NEXT: v_mov_b32_e32 v1, s3
173 ; GFX7-NEXT: s_waitcnt vmcnt(0)
174 ; GFX7-NEXT: flat_store_dword v[0:1], v2
175 ; GFX7-NEXT: s_endpgm
177 ; GFX10-WGP-LABEL: global_workgroup_monotonic_load:
178 ; GFX10-WGP: ; %bb.0: ; %entry
179 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
180 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
181 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
182 ; GFX10-WGP-NEXT: global_load_dword v1, v0, s[0:1] glc
183 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
184 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[2:3]
185 ; GFX10-WGP-NEXT: s_endpgm
187 ; GFX10-CU-LABEL: global_workgroup_monotonic_load:
188 ; GFX10-CU: ; %bb.0: ; %entry
189 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
190 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
191 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
192 ; GFX10-CU-NEXT: global_load_dword v1, v0, s[0:1]
193 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
194 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[2:3]
195 ; GFX10-CU-NEXT: s_endpgm
197 ; SKIP-CACHE-INV-LABEL: global_workgroup_monotonic_load:
198 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
199 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
200 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
201 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
202 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
203 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
204 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
205 ; SKIP-CACHE-INV-NEXT: buffer_load_dword v0, off, s[4:7], 0
206 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s2
207 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s3
208 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
209 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
210 ; SKIP-CACHE-INV-NEXT: s_endpgm
212 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_monotonic_load:
213 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
214 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
215 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
216 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
217 ; GFX90A-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[0:1]
218 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
219 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
220 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
222 ; GFX90A-TGSPLIT-LABEL: global_workgroup_monotonic_load:
223 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
224 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
225 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
226 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
227 ; GFX90A-TGSPLIT-NEXT: global_load_dword v1, v0, s[0:1] glc
228 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
229 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
230 ; GFX90A-TGSPLIT-NEXT: s_endpgm
232 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_monotonic_load:
233 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
234 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
235 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
236 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
237 ; GFX940-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[0:1] sc0
238 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
239 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
240 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
242 ; GFX940-TGSPLIT-LABEL: global_workgroup_monotonic_load:
243 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
244 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
245 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
246 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
247 ; GFX940-TGSPLIT-NEXT: global_load_dword v1, v0, s[0:1] sc0
248 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
249 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
250 ; GFX940-TGSPLIT-NEXT: s_endpgm
252 ; GFX11-WGP-LABEL: global_workgroup_monotonic_load:
253 ; GFX11-WGP: ; %bb.0: ; %entry
254 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
255 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
256 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
257 ; GFX11-WGP-NEXT: global_load_b32 v1, v0, s[0:1] glc
258 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
259 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[2:3]
260 ; GFX11-WGP-NEXT: s_nop 0
261 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
262 ; GFX11-WGP-NEXT: s_endpgm
264 ; GFX11-CU-LABEL: global_workgroup_monotonic_load:
265 ; GFX11-CU: ; %bb.0: ; %entry
266 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
267 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
268 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
269 ; GFX11-CU-NEXT: global_load_b32 v1, v0, s[0:1]
270 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
271 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[2:3]
272 ; GFX11-CU-NEXT: s_nop 0
273 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
274 ; GFX11-CU-NEXT: s_endpgm
275 ptr addrspace(1) %in, ptr addrspace(1) %out) {
277 %val = load atomic i32, ptr addrspace(1) %in syncscope("workgroup") monotonic, align 4
278 store i32 %val, ptr addrspace(1) %out
282 define amdgpu_kernel void @global_workgroup_acquire_load(
283 ; GFX6-LABEL: global_workgroup_acquire_load:
284 ; GFX6: ; %bb.0: ; %entry
285 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
286 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
287 ; GFX6-NEXT: s_mov_b32 s6, -1
288 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
289 ; GFX6-NEXT: s_mov_b32 s4, s0
290 ; GFX6-NEXT: s_mov_b32 s5, s1
291 ; GFX6-NEXT: buffer_load_dword v0, off, s[4:7], 0
292 ; GFX6-NEXT: s_mov_b32 s4, s2
293 ; GFX6-NEXT: s_mov_b32 s5, s3
294 ; GFX6-NEXT: s_waitcnt vmcnt(0)
295 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
296 ; GFX6-NEXT: s_endpgm
298 ; GFX7-LABEL: global_workgroup_acquire_load:
299 ; GFX7: ; %bb.0: ; %entry
300 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
301 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
302 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
303 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
304 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
305 ; GFX7-NEXT: v_mov_b32_e32 v0, s2
306 ; GFX7-NEXT: v_mov_b32_e32 v1, s3
307 ; GFX7-NEXT: s_waitcnt vmcnt(0)
308 ; GFX7-NEXT: flat_store_dword v[0:1], v2
309 ; GFX7-NEXT: s_endpgm
311 ; GFX10-WGP-LABEL: global_workgroup_acquire_load:
312 ; GFX10-WGP: ; %bb.0: ; %entry
313 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
314 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
315 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
316 ; GFX10-WGP-NEXT: global_load_dword v1, v0, s[0:1] glc
317 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
318 ; GFX10-WGP-NEXT: buffer_gl0_inv
319 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[2:3]
320 ; GFX10-WGP-NEXT: s_endpgm
322 ; GFX10-CU-LABEL: global_workgroup_acquire_load:
323 ; GFX10-CU: ; %bb.0: ; %entry
324 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
325 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
326 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
327 ; GFX10-CU-NEXT: global_load_dword v1, v0, s[0:1]
328 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
329 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[2:3]
330 ; GFX10-CU-NEXT: s_endpgm
332 ; SKIP-CACHE-INV-LABEL: global_workgroup_acquire_load:
333 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
334 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
335 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
336 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
337 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
338 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
339 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
340 ; SKIP-CACHE-INV-NEXT: buffer_load_dword v0, off, s[4:7], 0
341 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s2
342 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s3
343 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
344 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
345 ; SKIP-CACHE-INV-NEXT: s_endpgm
347 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acquire_load:
348 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
349 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
350 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
351 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
352 ; GFX90A-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[0:1]
353 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
354 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
355 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
357 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acquire_load:
358 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
359 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
360 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
361 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
362 ; GFX90A-TGSPLIT-NEXT: global_load_dword v1, v0, s[0:1] glc
363 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
364 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
365 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
366 ; GFX90A-TGSPLIT-NEXT: s_endpgm
368 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acquire_load:
369 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
370 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
371 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
372 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
373 ; GFX940-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[0:1] sc0
374 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
375 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
376 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
378 ; GFX940-TGSPLIT-LABEL: global_workgroup_acquire_load:
379 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
380 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
381 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
382 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
383 ; GFX940-TGSPLIT-NEXT: global_load_dword v1, v0, s[0:1] sc0
384 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
385 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
386 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
387 ; GFX940-TGSPLIT-NEXT: s_endpgm
389 ; GFX11-WGP-LABEL: global_workgroup_acquire_load:
390 ; GFX11-WGP: ; %bb.0: ; %entry
391 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
392 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
393 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
394 ; GFX11-WGP-NEXT: global_load_b32 v1, v0, s[0:1] glc
395 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
396 ; GFX11-WGP-NEXT: buffer_gl0_inv
397 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[2:3]
398 ; GFX11-WGP-NEXT: s_nop 0
399 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
400 ; GFX11-WGP-NEXT: s_endpgm
402 ; GFX11-CU-LABEL: global_workgroup_acquire_load:
403 ; GFX11-CU: ; %bb.0: ; %entry
404 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
405 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
406 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
407 ; GFX11-CU-NEXT: global_load_b32 v1, v0, s[0:1]
408 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
409 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[2:3]
410 ; GFX11-CU-NEXT: s_nop 0
411 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
412 ; GFX11-CU-NEXT: s_endpgm
413 ptr addrspace(1) %in, ptr addrspace(1) %out) {
415 %val = load atomic i32, ptr addrspace(1) %in syncscope("workgroup") acquire, align 4
416 store i32 %val, ptr addrspace(1) %out
420 define amdgpu_kernel void @global_workgroup_seq_cst_load(
421 ; GFX6-LABEL: global_workgroup_seq_cst_load:
422 ; GFX6: ; %bb.0: ; %entry
423 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
424 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
425 ; GFX6-NEXT: s_mov_b32 s6, -1
426 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
427 ; GFX6-NEXT: s_mov_b32 s4, s0
428 ; GFX6-NEXT: s_mov_b32 s5, s1
429 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
430 ; GFX6-NEXT: buffer_load_dword v0, off, s[4:7], 0
431 ; GFX6-NEXT: s_mov_b32 s4, s2
432 ; GFX6-NEXT: s_mov_b32 s5, s3
433 ; GFX6-NEXT: s_waitcnt vmcnt(0)
434 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
435 ; GFX6-NEXT: s_endpgm
437 ; GFX7-LABEL: global_workgroup_seq_cst_load:
438 ; GFX7: ; %bb.0: ; %entry
439 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
440 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
441 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
442 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
443 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
444 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
445 ; GFX7-NEXT: v_mov_b32_e32 v0, s2
446 ; GFX7-NEXT: v_mov_b32_e32 v1, s3
447 ; GFX7-NEXT: s_waitcnt vmcnt(0)
448 ; GFX7-NEXT: flat_store_dword v[0:1], v2
449 ; GFX7-NEXT: s_endpgm
451 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_load:
452 ; GFX10-WGP: ; %bb.0: ; %entry
453 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
454 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
455 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
456 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
457 ; GFX10-WGP-NEXT: global_load_dword v1, v0, s[0:1] glc
458 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
459 ; GFX10-WGP-NEXT: buffer_gl0_inv
460 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[2:3]
461 ; GFX10-WGP-NEXT: s_endpgm
463 ; GFX10-CU-LABEL: global_workgroup_seq_cst_load:
464 ; GFX10-CU: ; %bb.0: ; %entry
465 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
466 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
467 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
468 ; GFX10-CU-NEXT: global_load_dword v1, v0, s[0:1]
469 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
470 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[2:3]
471 ; GFX10-CU-NEXT: s_endpgm
473 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_load:
474 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
475 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
476 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
477 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
478 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
479 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
480 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
481 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
482 ; SKIP-CACHE-INV-NEXT: buffer_load_dword v0, off, s[4:7], 0
483 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s2
484 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s3
485 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
486 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
487 ; SKIP-CACHE-INV-NEXT: s_endpgm
489 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_load:
490 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
491 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
492 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
493 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
494 ; GFX90A-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[0:1]
495 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
496 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
497 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
499 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_load:
500 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
501 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
502 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
503 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
504 ; GFX90A-TGSPLIT-NEXT: global_load_dword v1, v0, s[0:1] glc
505 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
506 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
507 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
508 ; GFX90A-TGSPLIT-NEXT: s_endpgm
510 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_load:
511 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
512 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
513 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
514 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
515 ; GFX940-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[0:1] sc0
516 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
517 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
518 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
520 ; GFX940-TGSPLIT-LABEL: global_workgroup_seq_cst_load:
521 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
522 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
523 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
524 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
525 ; GFX940-TGSPLIT-NEXT: global_load_dword v1, v0, s[0:1] sc0
526 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
527 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
528 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
529 ; GFX940-TGSPLIT-NEXT: s_endpgm
531 ; GFX11-WGP-LABEL: global_workgroup_seq_cst_load:
532 ; GFX11-WGP: ; %bb.0: ; %entry
533 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
534 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
535 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
536 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
537 ; GFX11-WGP-NEXT: global_load_b32 v1, v0, s[0:1] glc
538 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
539 ; GFX11-WGP-NEXT: buffer_gl0_inv
540 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[2:3]
541 ; GFX11-WGP-NEXT: s_nop 0
542 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
543 ; GFX11-WGP-NEXT: s_endpgm
545 ; GFX11-CU-LABEL: global_workgroup_seq_cst_load:
546 ; GFX11-CU: ; %bb.0: ; %entry
547 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
548 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
549 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
550 ; GFX11-CU-NEXT: global_load_b32 v1, v0, s[0:1]
551 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
552 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[2:3]
553 ; GFX11-CU-NEXT: s_nop 0
554 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
555 ; GFX11-CU-NEXT: s_endpgm
556 ptr addrspace(1) %in, ptr addrspace(1) %out) {
558 %val = load atomic i32, ptr addrspace(1) %in syncscope("workgroup") seq_cst, align 4
559 store i32 %val, ptr addrspace(1) %out
563 define amdgpu_kernel void @global_workgroup_unordered_store(
564 ; GFX6-LABEL: global_workgroup_unordered_store:
565 ; GFX6: ; %bb.0: ; %entry
566 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x0
567 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
568 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
569 ; GFX6-NEXT: s_mov_b32 s2, -1
570 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
571 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
572 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
573 ; GFX6-NEXT: s_endpgm
575 ; GFX7-LABEL: global_workgroup_unordered_store:
576 ; GFX7: ; %bb.0: ; %entry
577 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
578 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x0
579 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
580 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
581 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
582 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
583 ; GFX7-NEXT: flat_store_dword v[0:1], v2
584 ; GFX7-NEXT: s_endpgm
586 ; GFX10-WGP-LABEL: global_workgroup_unordered_store:
587 ; GFX10-WGP: ; %bb.0: ; %entry
588 ; GFX10-WGP-NEXT: s_clause 0x1
589 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x0
590 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
591 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
592 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
593 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
594 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
595 ; GFX10-WGP-NEXT: s_endpgm
597 ; GFX10-CU-LABEL: global_workgroup_unordered_store:
598 ; GFX10-CU: ; %bb.0: ; %entry
599 ; GFX10-CU-NEXT: s_clause 0x1
600 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x0
601 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
602 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
603 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
604 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
605 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
606 ; GFX10-CU-NEXT: s_endpgm
608 ; SKIP-CACHE-INV-LABEL: global_workgroup_unordered_store:
609 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
610 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x0
611 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
612 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
613 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
614 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
615 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
616 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
617 ; SKIP-CACHE-INV-NEXT: s_endpgm
619 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_unordered_store:
620 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
621 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
622 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
623 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
624 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
625 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
626 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
627 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
629 ; GFX90A-TGSPLIT-LABEL: global_workgroup_unordered_store:
630 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
631 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
632 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
633 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
634 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
635 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
636 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
637 ; GFX90A-TGSPLIT-NEXT: s_endpgm
639 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_unordered_store:
640 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
641 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
642 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
643 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
644 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
645 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s4
646 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
647 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
649 ; GFX940-TGSPLIT-LABEL: global_workgroup_unordered_store:
650 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
651 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
652 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
653 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
654 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
655 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s4
656 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
657 ; GFX940-TGSPLIT-NEXT: s_endpgm
659 ; GFX11-WGP-LABEL: global_workgroup_unordered_store:
660 ; GFX11-WGP: ; %bb.0: ; %entry
661 ; GFX11-WGP-NEXT: s_clause 0x1
662 ; GFX11-WGP-NEXT: s_load_b32 s2, s[0:1], 0x0
663 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
664 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
665 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
666 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
667 ; GFX11-WGP-NEXT: s_nop 0
668 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
669 ; GFX11-WGP-NEXT: s_endpgm
671 ; GFX11-CU-LABEL: global_workgroup_unordered_store:
672 ; GFX11-CU: ; %bb.0: ; %entry
673 ; GFX11-CU-NEXT: s_clause 0x1
674 ; GFX11-CU-NEXT: s_load_b32 s2, s[0:1], 0x0
675 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
676 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
677 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
678 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
679 ; GFX11-CU-NEXT: s_nop 0
680 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
681 ; GFX11-CU-NEXT: s_endpgm
682 i32 %in, ptr addrspace(1) %out) {
684 store atomic i32 %in, ptr addrspace(1) %out syncscope("workgroup") unordered, align 4
688 define amdgpu_kernel void @global_workgroup_monotonic_store(
689 ; GFX6-LABEL: global_workgroup_monotonic_store:
690 ; GFX6: ; %bb.0: ; %entry
691 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x0
692 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
693 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
694 ; GFX6-NEXT: s_mov_b32 s2, -1
695 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
696 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
697 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
698 ; GFX6-NEXT: s_endpgm
700 ; GFX7-LABEL: global_workgroup_monotonic_store:
701 ; GFX7: ; %bb.0: ; %entry
702 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
703 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x0
704 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
705 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
706 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
707 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
708 ; GFX7-NEXT: flat_store_dword v[0:1], v2
709 ; GFX7-NEXT: s_endpgm
711 ; GFX10-WGP-LABEL: global_workgroup_monotonic_store:
712 ; GFX10-WGP: ; %bb.0: ; %entry
713 ; GFX10-WGP-NEXT: s_clause 0x1
714 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x0
715 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
716 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
717 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
718 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
719 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
720 ; GFX10-WGP-NEXT: s_endpgm
722 ; GFX10-CU-LABEL: global_workgroup_monotonic_store:
723 ; GFX10-CU: ; %bb.0: ; %entry
724 ; GFX10-CU-NEXT: s_clause 0x1
725 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x0
726 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
727 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
728 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
729 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
730 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
731 ; GFX10-CU-NEXT: s_endpgm
733 ; SKIP-CACHE-INV-LABEL: global_workgroup_monotonic_store:
734 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
735 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x0
736 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
737 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
738 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
739 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
740 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
741 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
742 ; SKIP-CACHE-INV-NEXT: s_endpgm
744 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_monotonic_store:
745 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
746 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
747 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
748 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
749 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
750 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
751 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
752 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
754 ; GFX90A-TGSPLIT-LABEL: global_workgroup_monotonic_store:
755 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
756 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
757 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
758 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
759 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
760 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
761 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
762 ; GFX90A-TGSPLIT-NEXT: s_endpgm
764 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_monotonic_store:
765 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
766 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
767 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
768 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
769 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
770 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s4
771 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
772 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
774 ; GFX940-TGSPLIT-LABEL: global_workgroup_monotonic_store:
775 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
776 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
777 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
778 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
779 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
780 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s4
781 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
782 ; GFX940-TGSPLIT-NEXT: s_endpgm
784 ; GFX11-WGP-LABEL: global_workgroup_monotonic_store:
785 ; GFX11-WGP: ; %bb.0: ; %entry
786 ; GFX11-WGP-NEXT: s_clause 0x1
787 ; GFX11-WGP-NEXT: s_load_b32 s2, s[0:1], 0x0
788 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
789 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
790 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
791 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
792 ; GFX11-WGP-NEXT: s_nop 0
793 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
794 ; GFX11-WGP-NEXT: s_endpgm
796 ; GFX11-CU-LABEL: global_workgroup_monotonic_store:
797 ; GFX11-CU: ; %bb.0: ; %entry
798 ; GFX11-CU-NEXT: s_clause 0x1
799 ; GFX11-CU-NEXT: s_load_b32 s2, s[0:1], 0x0
800 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
801 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
802 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
803 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
804 ; GFX11-CU-NEXT: s_nop 0
805 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
806 ; GFX11-CU-NEXT: s_endpgm
807 i32 %in, ptr addrspace(1) %out) {
809 store atomic i32 %in, ptr addrspace(1) %out syncscope("workgroup") monotonic, align 4
813 define amdgpu_kernel void @global_workgroup_release_store(
814 ; GFX6-LABEL: global_workgroup_release_store:
815 ; GFX6: ; %bb.0: ; %entry
816 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x0
817 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
818 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
819 ; GFX6-NEXT: s_mov_b32 s2, -1
820 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
821 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
822 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
823 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
824 ; GFX6-NEXT: s_endpgm
826 ; GFX7-LABEL: global_workgroup_release_store:
827 ; GFX7: ; %bb.0: ; %entry
828 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
829 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x0
830 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
831 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
832 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
833 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
834 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
835 ; GFX7-NEXT: flat_store_dword v[0:1], v2
836 ; GFX7-NEXT: s_endpgm
838 ; GFX10-WGP-LABEL: global_workgroup_release_store:
839 ; GFX10-WGP: ; %bb.0: ; %entry
840 ; GFX10-WGP-NEXT: s_clause 0x1
841 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x0
842 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
843 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
844 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
845 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
846 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
847 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
848 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
849 ; GFX10-WGP-NEXT: s_endpgm
851 ; GFX10-CU-LABEL: global_workgroup_release_store:
852 ; GFX10-CU: ; %bb.0: ; %entry
853 ; GFX10-CU-NEXT: s_clause 0x1
854 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x0
855 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
856 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
857 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
858 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
859 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
860 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
861 ; GFX10-CU-NEXT: s_endpgm
863 ; SKIP-CACHE-INV-LABEL: global_workgroup_release_store:
864 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
865 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x0
866 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
867 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
868 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
869 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
870 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
871 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
872 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
873 ; SKIP-CACHE-INV-NEXT: s_endpgm
875 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_release_store:
876 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
877 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
878 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
879 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
880 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
881 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
882 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
883 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
884 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
886 ; GFX90A-TGSPLIT-LABEL: global_workgroup_release_store:
887 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
888 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
889 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
890 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
891 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
892 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
893 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
894 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
895 ; GFX90A-TGSPLIT-NEXT: s_endpgm
897 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_release_store:
898 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
899 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
900 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
901 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
902 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
903 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s4
904 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
905 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
906 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
908 ; GFX940-TGSPLIT-LABEL: global_workgroup_release_store:
909 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
910 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
911 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
912 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
913 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
914 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s4
915 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
916 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
917 ; GFX940-TGSPLIT-NEXT: s_endpgm
919 ; GFX11-WGP-LABEL: global_workgroup_release_store:
920 ; GFX11-WGP: ; %bb.0: ; %entry
921 ; GFX11-WGP-NEXT: s_clause 0x1
922 ; GFX11-WGP-NEXT: s_load_b32 s2, s[0:1], 0x0
923 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
924 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
925 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
926 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
927 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
928 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
929 ; GFX11-WGP-NEXT: s_nop 0
930 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
931 ; GFX11-WGP-NEXT: s_endpgm
933 ; GFX11-CU-LABEL: global_workgroup_release_store:
934 ; GFX11-CU: ; %bb.0: ; %entry
935 ; GFX11-CU-NEXT: s_clause 0x1
936 ; GFX11-CU-NEXT: s_load_b32 s2, s[0:1], 0x0
937 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
938 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
939 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
940 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
941 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
942 ; GFX11-CU-NEXT: s_nop 0
943 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
944 ; GFX11-CU-NEXT: s_endpgm
945 i32 %in, ptr addrspace(1) %out) {
947 store atomic i32 %in, ptr addrspace(1) %out syncscope("workgroup") release, align 4
951 define amdgpu_kernel void @global_workgroup_seq_cst_store(
952 ; GFX6-LABEL: global_workgroup_seq_cst_store:
953 ; GFX6: ; %bb.0: ; %entry
954 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x0
955 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
956 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
957 ; GFX6-NEXT: s_mov_b32 s2, -1
958 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
959 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
960 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
961 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
962 ; GFX6-NEXT: s_endpgm
964 ; GFX7-LABEL: global_workgroup_seq_cst_store:
965 ; GFX7: ; %bb.0: ; %entry
966 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
967 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x0
968 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
969 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
970 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
971 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
972 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
973 ; GFX7-NEXT: flat_store_dword v[0:1], v2
974 ; GFX7-NEXT: s_endpgm
976 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_store:
977 ; GFX10-WGP: ; %bb.0: ; %entry
978 ; GFX10-WGP-NEXT: s_clause 0x1
979 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x0
980 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
981 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
982 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
983 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
984 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
985 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
986 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
987 ; GFX10-WGP-NEXT: s_endpgm
989 ; GFX10-CU-LABEL: global_workgroup_seq_cst_store:
990 ; GFX10-CU: ; %bb.0: ; %entry
991 ; GFX10-CU-NEXT: s_clause 0x1
992 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x0
993 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
994 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
995 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
996 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
997 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
998 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
999 ; GFX10-CU-NEXT: s_endpgm
1001 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_store:
1002 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1003 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x0
1004 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
1005 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
1006 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
1007 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1008 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
1009 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1010 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
1011 ; SKIP-CACHE-INV-NEXT: s_endpgm
1013 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_store:
1014 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1015 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
1016 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
1017 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1018 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1019 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1020 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1021 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
1022 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1024 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_store:
1025 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1026 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
1027 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
1028 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1029 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1030 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1031 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1032 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
1033 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1035 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_store:
1036 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
1037 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
1038 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
1039 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1040 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1041 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s4
1042 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1043 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
1044 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
1046 ; GFX940-TGSPLIT-LABEL: global_workgroup_seq_cst_store:
1047 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
1048 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
1049 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
1050 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1051 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1052 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s4
1053 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1054 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
1055 ; GFX940-TGSPLIT-NEXT: s_endpgm
1057 ; GFX11-WGP-LABEL: global_workgroup_seq_cst_store:
1058 ; GFX11-WGP: ; %bb.0: ; %entry
1059 ; GFX11-WGP-NEXT: s_clause 0x1
1060 ; GFX11-WGP-NEXT: s_load_b32 s2, s[0:1], 0x0
1061 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
1062 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1063 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
1064 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1065 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1066 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
1067 ; GFX11-WGP-NEXT: s_nop 0
1068 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
1069 ; GFX11-WGP-NEXT: s_endpgm
1071 ; GFX11-CU-LABEL: global_workgroup_seq_cst_store:
1072 ; GFX11-CU: ; %bb.0: ; %entry
1073 ; GFX11-CU-NEXT: s_clause 0x1
1074 ; GFX11-CU-NEXT: s_load_b32 s2, s[0:1], 0x0
1075 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
1076 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1077 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
1078 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1079 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
1080 ; GFX11-CU-NEXT: s_nop 0
1081 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
1082 ; GFX11-CU-NEXT: s_endpgm
1083 i32 %in, ptr addrspace(1) %out) {
1085 store atomic i32 %in, ptr addrspace(1) %out syncscope("workgroup") seq_cst, align 4
1089 define amdgpu_kernel void @global_workgroup_monotonic_atomicrmw(
1090 ; GFX6-LABEL: global_workgroup_monotonic_atomicrmw:
1091 ; GFX6: ; %bb.0: ; %entry
1092 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x2
1093 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1094 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
1095 ; GFX6-NEXT: s_mov_b32 s2, -1
1096 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1097 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
1098 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
1099 ; GFX6-NEXT: s_endpgm
1101 ; GFX7-LABEL: global_workgroup_monotonic_atomicrmw:
1102 ; GFX7: ; %bb.0: ; %entry
1103 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1104 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
1105 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1106 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
1107 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
1108 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
1109 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
1110 ; GFX7-NEXT: s_endpgm
1112 ; GFX10-WGP-LABEL: global_workgroup_monotonic_atomicrmw:
1113 ; GFX10-WGP: ; %bb.0: ; %entry
1114 ; GFX10-WGP-NEXT: s_clause 0x1
1115 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
1116 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1117 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
1118 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1119 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
1120 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[0:1]
1121 ; GFX10-WGP-NEXT: s_endpgm
1123 ; GFX10-CU-LABEL: global_workgroup_monotonic_atomicrmw:
1124 ; GFX10-CU: ; %bb.0: ; %entry
1125 ; GFX10-CU-NEXT: s_clause 0x1
1126 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
1127 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1128 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
1129 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1130 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
1131 ; GFX10-CU-NEXT: global_atomic_swap v0, v1, s[0:1]
1132 ; GFX10-CU-NEXT: s_endpgm
1134 ; SKIP-CACHE-INV-LABEL: global_workgroup_monotonic_atomicrmw:
1135 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1136 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x2
1137 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x0
1138 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
1139 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
1140 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1141 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
1142 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
1143 ; SKIP-CACHE-INV-NEXT: s_endpgm
1145 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_monotonic_atomicrmw:
1146 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1147 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1148 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1149 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1150 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1151 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1152 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
1153 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1155 ; GFX90A-TGSPLIT-LABEL: global_workgroup_monotonic_atomicrmw:
1156 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1157 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1158 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1159 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1160 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1161 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1162 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
1163 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1165 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_monotonic_atomicrmw:
1166 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
1167 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
1168 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1169 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1170 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1171 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s4
1172 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[2:3]
1173 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
1175 ; GFX940-TGSPLIT-LABEL: global_workgroup_monotonic_atomicrmw:
1176 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
1177 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
1178 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1179 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1180 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1181 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s4
1182 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[2:3]
1183 ; GFX940-TGSPLIT-NEXT: s_endpgm
1185 ; GFX11-WGP-LABEL: global_workgroup_monotonic_atomicrmw:
1186 ; GFX11-WGP: ; %bb.0: ; %entry
1187 ; GFX11-WGP-NEXT: s_clause 0x1
1188 ; GFX11-WGP-NEXT: s_load_b32 s2, s[0:1], 0x8
1189 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
1190 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1191 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
1192 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
1193 ; GFX11-WGP-NEXT: s_nop 0
1194 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
1195 ; GFX11-WGP-NEXT: s_endpgm
1197 ; GFX11-CU-LABEL: global_workgroup_monotonic_atomicrmw:
1198 ; GFX11-CU: ; %bb.0: ; %entry
1199 ; GFX11-CU-NEXT: s_clause 0x1
1200 ; GFX11-CU-NEXT: s_load_b32 s2, s[0:1], 0x8
1201 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
1202 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1203 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
1204 ; GFX11-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
1205 ; GFX11-CU-NEXT: s_nop 0
1206 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
1207 ; GFX11-CU-NEXT: s_endpgm
1208 ptr addrspace(1) %out, i32 %in) {
1210 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup") monotonic
1214 define amdgpu_kernel void @global_workgroup_acquire_atomicrmw(
1215 ; GFX6-LABEL: global_workgroup_acquire_atomicrmw:
1216 ; GFX6: ; %bb.0: ; %entry
1217 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x2
1218 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1219 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
1220 ; GFX6-NEXT: s_mov_b32 s2, -1
1221 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1222 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
1223 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
1224 ; GFX6-NEXT: s_endpgm
1226 ; GFX7-LABEL: global_workgroup_acquire_atomicrmw:
1227 ; GFX7: ; %bb.0: ; %entry
1228 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1229 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
1230 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1231 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
1232 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
1233 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
1234 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
1235 ; GFX7-NEXT: s_endpgm
1237 ; GFX10-WGP-LABEL: global_workgroup_acquire_atomicrmw:
1238 ; GFX10-WGP: ; %bb.0: ; %entry
1239 ; GFX10-WGP-NEXT: s_clause 0x1
1240 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
1241 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1242 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
1243 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1244 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
1245 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[0:1]
1246 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1247 ; GFX10-WGP-NEXT: buffer_gl0_inv
1248 ; GFX10-WGP-NEXT: s_endpgm
1250 ; GFX10-CU-LABEL: global_workgroup_acquire_atomicrmw:
1251 ; GFX10-CU: ; %bb.0: ; %entry
1252 ; GFX10-CU-NEXT: s_clause 0x1
1253 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
1254 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1255 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
1256 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1257 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
1258 ; GFX10-CU-NEXT: global_atomic_swap v0, v1, s[0:1]
1259 ; GFX10-CU-NEXT: s_endpgm
1261 ; SKIP-CACHE-INV-LABEL: global_workgroup_acquire_atomicrmw:
1262 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1263 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x2
1264 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x0
1265 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
1266 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
1267 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1268 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
1269 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
1270 ; SKIP-CACHE-INV-NEXT: s_endpgm
1272 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acquire_atomicrmw:
1273 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1274 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1275 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1276 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1277 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1278 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1279 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
1280 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1282 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acquire_atomicrmw:
1283 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1284 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1285 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1286 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1287 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1288 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1289 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
1290 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1291 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
1292 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1294 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acquire_atomicrmw:
1295 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
1296 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
1297 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1298 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1299 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1300 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s4
1301 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[2:3]
1302 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
1304 ; GFX940-TGSPLIT-LABEL: global_workgroup_acquire_atomicrmw:
1305 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
1306 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
1307 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1308 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1309 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1310 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s4
1311 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[2:3]
1312 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1313 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
1314 ; GFX940-TGSPLIT-NEXT: s_endpgm
1316 ; GFX11-WGP-LABEL: global_workgroup_acquire_atomicrmw:
1317 ; GFX11-WGP: ; %bb.0: ; %entry
1318 ; GFX11-WGP-NEXT: s_clause 0x1
1319 ; GFX11-WGP-NEXT: s_load_b32 s2, s[0:1], 0x8
1320 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
1321 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1322 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
1323 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
1324 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1325 ; GFX11-WGP-NEXT: buffer_gl0_inv
1326 ; GFX11-WGP-NEXT: s_endpgm
1328 ; GFX11-CU-LABEL: global_workgroup_acquire_atomicrmw:
1329 ; GFX11-CU: ; %bb.0: ; %entry
1330 ; GFX11-CU-NEXT: s_clause 0x1
1331 ; GFX11-CU-NEXT: s_load_b32 s2, s[0:1], 0x8
1332 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
1333 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1334 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
1335 ; GFX11-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
1336 ; GFX11-CU-NEXT: s_nop 0
1337 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
1338 ; GFX11-CU-NEXT: s_endpgm
1339 ptr addrspace(1) %out, i32 %in) {
1341 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup") acquire
1345 define amdgpu_kernel void @global_workgroup_release_atomicrmw(
1346 ; GFX6-LABEL: global_workgroup_release_atomicrmw:
1347 ; GFX6: ; %bb.0: ; %entry
1348 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x2
1349 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1350 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
1351 ; GFX6-NEXT: s_mov_b32 s2, -1
1352 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1353 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
1354 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1355 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
1356 ; GFX6-NEXT: s_endpgm
1358 ; GFX7-LABEL: global_workgroup_release_atomicrmw:
1359 ; GFX7: ; %bb.0: ; %entry
1360 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1361 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
1362 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1363 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
1364 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
1365 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
1366 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1367 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
1368 ; GFX7-NEXT: s_endpgm
1370 ; GFX10-WGP-LABEL: global_workgroup_release_atomicrmw:
1371 ; GFX10-WGP: ; %bb.0: ; %entry
1372 ; GFX10-WGP-NEXT: s_clause 0x1
1373 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
1374 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1375 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
1376 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1377 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
1378 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1379 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1380 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[0:1]
1381 ; GFX10-WGP-NEXT: s_endpgm
1383 ; GFX10-CU-LABEL: global_workgroup_release_atomicrmw:
1384 ; GFX10-CU: ; %bb.0: ; %entry
1385 ; GFX10-CU-NEXT: s_clause 0x1
1386 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
1387 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1388 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
1389 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1390 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
1391 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1392 ; GFX10-CU-NEXT: global_atomic_swap v0, v1, s[0:1]
1393 ; GFX10-CU-NEXT: s_endpgm
1395 ; SKIP-CACHE-INV-LABEL: global_workgroup_release_atomicrmw:
1396 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1397 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x2
1398 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x0
1399 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
1400 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
1401 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1402 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
1403 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1404 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
1405 ; SKIP-CACHE-INV-NEXT: s_endpgm
1407 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_release_atomicrmw:
1408 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1409 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1410 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1411 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1412 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1413 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1414 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1415 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
1416 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1418 ; GFX90A-TGSPLIT-LABEL: global_workgroup_release_atomicrmw:
1419 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1420 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1421 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1422 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1423 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1424 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1425 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1426 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
1427 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1429 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_release_atomicrmw:
1430 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
1431 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
1432 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1433 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1434 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1435 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s4
1436 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1437 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[2:3]
1438 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
1440 ; GFX940-TGSPLIT-LABEL: global_workgroup_release_atomicrmw:
1441 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
1442 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
1443 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1444 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1445 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1446 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s4
1447 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1448 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[2:3]
1449 ; GFX940-TGSPLIT-NEXT: s_endpgm
1451 ; GFX11-WGP-LABEL: global_workgroup_release_atomicrmw:
1452 ; GFX11-WGP: ; %bb.0: ; %entry
1453 ; GFX11-WGP-NEXT: s_clause 0x1
1454 ; GFX11-WGP-NEXT: s_load_b32 s2, s[0:1], 0x8
1455 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
1456 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1457 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
1458 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1459 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1460 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
1461 ; GFX11-WGP-NEXT: s_nop 0
1462 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
1463 ; GFX11-WGP-NEXT: s_endpgm
1465 ; GFX11-CU-LABEL: global_workgroup_release_atomicrmw:
1466 ; GFX11-CU: ; %bb.0: ; %entry
1467 ; GFX11-CU-NEXT: s_clause 0x1
1468 ; GFX11-CU-NEXT: s_load_b32 s2, s[0:1], 0x8
1469 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
1470 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1471 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
1472 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1473 ; GFX11-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
1474 ; GFX11-CU-NEXT: s_nop 0
1475 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
1476 ; GFX11-CU-NEXT: s_endpgm
1477 ptr addrspace(1) %out, i32 %in) {
1479 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup") release
1483 define amdgpu_kernel void @global_workgroup_acq_rel_atomicrmw(
1484 ; GFX6-LABEL: global_workgroup_acq_rel_atomicrmw:
1485 ; GFX6: ; %bb.0: ; %entry
1486 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x2
1487 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1488 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
1489 ; GFX6-NEXT: s_mov_b32 s2, -1
1490 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1491 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
1492 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1493 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
1494 ; GFX6-NEXT: s_endpgm
1496 ; GFX7-LABEL: global_workgroup_acq_rel_atomicrmw:
1497 ; GFX7: ; %bb.0: ; %entry
1498 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1499 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
1500 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1501 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
1502 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
1503 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
1504 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1505 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
1506 ; GFX7-NEXT: s_endpgm
1508 ; GFX10-WGP-LABEL: global_workgroup_acq_rel_atomicrmw:
1509 ; GFX10-WGP: ; %bb.0: ; %entry
1510 ; GFX10-WGP-NEXT: s_clause 0x1
1511 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
1512 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1513 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
1514 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1515 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
1516 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1517 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1518 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[0:1]
1519 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1520 ; GFX10-WGP-NEXT: buffer_gl0_inv
1521 ; GFX10-WGP-NEXT: s_endpgm
1523 ; GFX10-CU-LABEL: global_workgroup_acq_rel_atomicrmw:
1524 ; GFX10-CU: ; %bb.0: ; %entry
1525 ; GFX10-CU-NEXT: s_clause 0x1
1526 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
1527 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1528 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
1529 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1530 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
1531 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1532 ; GFX10-CU-NEXT: global_atomic_swap v0, v1, s[0:1]
1533 ; GFX10-CU-NEXT: s_endpgm
1535 ; SKIP-CACHE-INV-LABEL: global_workgroup_acq_rel_atomicrmw:
1536 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1537 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x2
1538 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x0
1539 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
1540 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
1541 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1542 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
1543 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1544 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
1545 ; SKIP-CACHE-INV-NEXT: s_endpgm
1547 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_atomicrmw:
1548 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1549 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1550 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1551 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1552 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1553 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1554 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1555 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
1556 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1558 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acq_rel_atomicrmw:
1559 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1560 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1561 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1562 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1563 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1564 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1565 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1566 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
1567 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1568 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
1569 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1571 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_atomicrmw:
1572 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
1573 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
1574 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1575 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1576 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1577 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s4
1578 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1579 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[2:3]
1580 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
1582 ; GFX940-TGSPLIT-LABEL: global_workgroup_acq_rel_atomicrmw:
1583 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
1584 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
1585 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1586 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1587 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1588 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s4
1589 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1590 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[2:3]
1591 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1592 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
1593 ; GFX940-TGSPLIT-NEXT: s_endpgm
1595 ; GFX11-WGP-LABEL: global_workgroup_acq_rel_atomicrmw:
1596 ; GFX11-WGP: ; %bb.0: ; %entry
1597 ; GFX11-WGP-NEXT: s_clause 0x1
1598 ; GFX11-WGP-NEXT: s_load_b32 s2, s[0:1], 0x8
1599 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
1600 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1601 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
1602 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1603 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1604 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
1605 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1606 ; GFX11-WGP-NEXT: buffer_gl0_inv
1607 ; GFX11-WGP-NEXT: s_endpgm
1609 ; GFX11-CU-LABEL: global_workgroup_acq_rel_atomicrmw:
1610 ; GFX11-CU: ; %bb.0: ; %entry
1611 ; GFX11-CU-NEXT: s_clause 0x1
1612 ; GFX11-CU-NEXT: s_load_b32 s2, s[0:1], 0x8
1613 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
1614 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1615 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
1616 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1617 ; GFX11-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
1618 ; GFX11-CU-NEXT: s_nop 0
1619 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
1620 ; GFX11-CU-NEXT: s_endpgm
1621 ptr addrspace(1) %out, i32 %in) {
1623 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup") acq_rel
1627 define amdgpu_kernel void @global_workgroup_seq_cst_atomicrmw(
1628 ; GFX6-LABEL: global_workgroup_seq_cst_atomicrmw:
1629 ; GFX6: ; %bb.0: ; %entry
1630 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x2
1631 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1632 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
1633 ; GFX6-NEXT: s_mov_b32 s2, -1
1634 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1635 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
1636 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1637 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
1638 ; GFX6-NEXT: s_endpgm
1640 ; GFX7-LABEL: global_workgroup_seq_cst_atomicrmw:
1641 ; GFX7: ; %bb.0: ; %entry
1642 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1643 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
1644 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1645 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
1646 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
1647 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
1648 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1649 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
1650 ; GFX7-NEXT: s_endpgm
1652 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_atomicrmw:
1653 ; GFX10-WGP: ; %bb.0: ; %entry
1654 ; GFX10-WGP-NEXT: s_clause 0x1
1655 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
1656 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1657 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
1658 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1659 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
1660 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1661 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1662 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[0:1]
1663 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1664 ; GFX10-WGP-NEXT: buffer_gl0_inv
1665 ; GFX10-WGP-NEXT: s_endpgm
1667 ; GFX10-CU-LABEL: global_workgroup_seq_cst_atomicrmw:
1668 ; GFX10-CU: ; %bb.0: ; %entry
1669 ; GFX10-CU-NEXT: s_clause 0x1
1670 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
1671 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1672 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
1673 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1674 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
1675 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1676 ; GFX10-CU-NEXT: global_atomic_swap v0, v1, s[0:1]
1677 ; GFX10-CU-NEXT: s_endpgm
1679 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_atomicrmw:
1680 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1681 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x2
1682 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x0
1683 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
1684 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
1685 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1686 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
1687 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1688 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
1689 ; SKIP-CACHE-INV-NEXT: s_endpgm
1691 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_atomicrmw:
1692 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1693 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1694 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1695 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1696 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1697 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1698 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1699 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
1700 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1702 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_atomicrmw:
1703 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1704 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1705 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1706 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1707 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1708 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1709 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1710 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
1711 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1712 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
1713 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1715 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_atomicrmw:
1716 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
1717 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
1718 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1719 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1720 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1721 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s4
1722 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1723 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[2:3]
1724 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
1726 ; GFX940-TGSPLIT-LABEL: global_workgroup_seq_cst_atomicrmw:
1727 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
1728 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
1729 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1730 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1731 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1732 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s4
1733 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1734 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[2:3]
1735 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1736 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
1737 ; GFX940-TGSPLIT-NEXT: s_endpgm
1739 ; GFX11-WGP-LABEL: global_workgroup_seq_cst_atomicrmw:
1740 ; GFX11-WGP: ; %bb.0: ; %entry
1741 ; GFX11-WGP-NEXT: s_clause 0x1
1742 ; GFX11-WGP-NEXT: s_load_b32 s2, s[0:1], 0x8
1743 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
1744 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1745 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
1746 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1747 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1748 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
1749 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1750 ; GFX11-WGP-NEXT: buffer_gl0_inv
1751 ; GFX11-WGP-NEXT: s_endpgm
1753 ; GFX11-CU-LABEL: global_workgroup_seq_cst_atomicrmw:
1754 ; GFX11-CU: ; %bb.0: ; %entry
1755 ; GFX11-CU-NEXT: s_clause 0x1
1756 ; GFX11-CU-NEXT: s_load_b32 s2, s[0:1], 0x8
1757 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
1758 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1759 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
1760 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1761 ; GFX11-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
1762 ; GFX11-CU-NEXT: s_nop 0
1763 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
1764 ; GFX11-CU-NEXT: s_endpgm
1765 ptr addrspace(1) %out, i32 %in) {
1767 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup") seq_cst
1771 define amdgpu_kernel void @global_workgroup_acquire_ret_atomicrmw(
1772 ; GFX6-LABEL: global_workgroup_acquire_ret_atomicrmw:
1773 ; GFX6: ; %bb.0: ; %entry
1774 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x2
1775 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1776 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
1777 ; GFX6-NEXT: s_mov_b32 s2, -1
1778 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1779 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
1780 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0 glc
1781 ; GFX6-NEXT: s_waitcnt vmcnt(0)
1782 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
1783 ; GFX6-NEXT: s_endpgm
1785 ; GFX7-LABEL: global_workgroup_acquire_ret_atomicrmw:
1786 ; GFX7: ; %bb.0: ; %entry
1787 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1788 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
1789 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1790 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
1791 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
1792 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
1793 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
1794 ; GFX7-NEXT: s_waitcnt vmcnt(0)
1795 ; GFX7-NEXT: flat_store_dword v[0:1], v2
1796 ; GFX7-NEXT: s_endpgm
1798 ; GFX10-WGP-LABEL: global_workgroup_acquire_ret_atomicrmw:
1799 ; GFX10-WGP: ; %bb.0: ; %entry
1800 ; GFX10-WGP-NEXT: s_clause 0x1
1801 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
1802 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1803 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
1804 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1805 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
1806 ; GFX10-WGP-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
1807 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
1808 ; GFX10-WGP-NEXT: buffer_gl0_inv
1809 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
1810 ; GFX10-WGP-NEXT: s_endpgm
1812 ; GFX10-CU-LABEL: global_workgroup_acquire_ret_atomicrmw:
1813 ; GFX10-CU: ; %bb.0: ; %entry
1814 ; GFX10-CU-NEXT: s_clause 0x1
1815 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
1816 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1817 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
1818 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1819 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
1820 ; GFX10-CU-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
1821 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
1822 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
1823 ; GFX10-CU-NEXT: s_endpgm
1825 ; SKIP-CACHE-INV-LABEL: global_workgroup_acquire_ret_atomicrmw:
1826 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1827 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x2
1828 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x0
1829 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
1830 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
1831 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1832 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
1833 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0 glc
1834 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
1835 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
1836 ; SKIP-CACHE-INV-NEXT: s_endpgm
1838 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acquire_ret_atomicrmw:
1839 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1840 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1841 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1842 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1843 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1844 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1845 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
1846 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
1847 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
1848 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1850 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acquire_ret_atomicrmw:
1851 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1852 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1853 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1854 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1855 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1856 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1857 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
1858 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1859 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
1860 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
1861 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1863 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acquire_ret_atomicrmw:
1864 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
1865 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
1866 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1867 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1868 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1869 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s4
1870 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[2:3] sc0
1871 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
1872 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
1873 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
1875 ; GFX940-TGSPLIT-LABEL: global_workgroup_acquire_ret_atomicrmw:
1876 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
1877 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
1878 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1879 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1880 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1881 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s4
1882 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[2:3] sc0
1883 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1884 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
1885 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
1886 ; GFX940-TGSPLIT-NEXT: s_endpgm
1888 ; GFX11-WGP-LABEL: global_workgroup_acquire_ret_atomicrmw:
1889 ; GFX11-WGP: ; %bb.0: ; %entry
1890 ; GFX11-WGP-NEXT: s_clause 0x1
1891 ; GFX11-WGP-NEXT: s_load_b32 s2, s[0:1], 0x8
1892 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
1893 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1894 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
1895 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] glc
1896 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
1897 ; GFX11-WGP-NEXT: buffer_gl0_inv
1898 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
1899 ; GFX11-WGP-NEXT: s_nop 0
1900 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
1901 ; GFX11-WGP-NEXT: s_endpgm
1903 ; GFX11-CU-LABEL: global_workgroup_acquire_ret_atomicrmw:
1904 ; GFX11-CU: ; %bb.0: ; %entry
1905 ; GFX11-CU-NEXT: s_clause 0x1
1906 ; GFX11-CU-NEXT: s_load_b32 s2, s[0:1], 0x8
1907 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
1908 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1909 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
1910 ; GFX11-CU-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] glc
1911 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
1912 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
1913 ; GFX11-CU-NEXT: s_nop 0
1914 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
1915 ; GFX11-CU-NEXT: s_endpgm
1916 ptr addrspace(1) %out, i32 %in) {
1918 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup") acquire
1919 store i32 %val, ptr addrspace(1) %out, align 4
1923 define amdgpu_kernel void @global_workgroup_acq_rel_ret_atomicrmw(
1924 ; GFX6-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
1925 ; GFX6: ; %bb.0: ; %entry
1926 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x2
1927 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1928 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
1929 ; GFX6-NEXT: s_mov_b32 s2, -1
1930 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1931 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
1932 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1933 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0 glc
1934 ; GFX6-NEXT: s_waitcnt vmcnt(0)
1935 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
1936 ; GFX6-NEXT: s_endpgm
1938 ; GFX7-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
1939 ; GFX7: ; %bb.0: ; %entry
1940 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1941 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
1942 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1943 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
1944 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
1945 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
1946 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1947 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
1948 ; GFX7-NEXT: s_waitcnt vmcnt(0)
1949 ; GFX7-NEXT: flat_store_dword v[0:1], v2
1950 ; GFX7-NEXT: s_endpgm
1952 ; GFX10-WGP-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
1953 ; GFX10-WGP: ; %bb.0: ; %entry
1954 ; GFX10-WGP-NEXT: s_clause 0x1
1955 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
1956 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1957 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
1958 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1959 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
1960 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1961 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1962 ; GFX10-WGP-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
1963 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
1964 ; GFX10-WGP-NEXT: buffer_gl0_inv
1965 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
1966 ; GFX10-WGP-NEXT: s_endpgm
1968 ; GFX10-CU-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
1969 ; GFX10-CU: ; %bb.0: ; %entry
1970 ; GFX10-CU-NEXT: s_clause 0x1
1971 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
1972 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1973 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
1974 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1975 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
1976 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1977 ; GFX10-CU-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
1978 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
1979 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
1980 ; GFX10-CU-NEXT: s_endpgm
1982 ; SKIP-CACHE-INV-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
1983 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1984 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x2
1985 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x0
1986 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
1987 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
1988 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1989 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
1990 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1991 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0 glc
1992 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
1993 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
1994 ; SKIP-CACHE-INV-NEXT: s_endpgm
1996 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
1997 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1998 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1999 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2000 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2001 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2002 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
2003 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2004 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
2005 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
2006 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
2007 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2009 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
2010 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2011 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
2012 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2013 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2014 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2015 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
2016 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2017 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
2018 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2019 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
2020 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
2021 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2023 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
2024 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
2025 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
2026 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
2027 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2028 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2029 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s4
2030 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2031 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[2:3] sc0
2032 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
2033 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
2034 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
2036 ; GFX940-TGSPLIT-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
2037 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
2038 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
2039 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
2040 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2041 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2042 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s4
2043 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2044 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[2:3] sc0
2045 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2046 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
2047 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
2048 ; GFX940-TGSPLIT-NEXT: s_endpgm
2050 ; GFX11-WGP-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
2051 ; GFX11-WGP: ; %bb.0: ; %entry
2052 ; GFX11-WGP-NEXT: s_clause 0x1
2053 ; GFX11-WGP-NEXT: s_load_b32 s2, s[0:1], 0x8
2054 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
2055 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
2056 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
2057 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2058 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2059 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] glc
2060 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
2061 ; GFX11-WGP-NEXT: buffer_gl0_inv
2062 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
2063 ; GFX11-WGP-NEXT: s_nop 0
2064 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
2065 ; GFX11-WGP-NEXT: s_endpgm
2067 ; GFX11-CU-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
2068 ; GFX11-CU: ; %bb.0: ; %entry
2069 ; GFX11-CU-NEXT: s_clause 0x1
2070 ; GFX11-CU-NEXT: s_load_b32 s2, s[0:1], 0x8
2071 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
2072 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2073 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
2074 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2075 ; GFX11-CU-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] glc
2076 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
2077 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
2078 ; GFX11-CU-NEXT: s_nop 0
2079 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
2080 ; GFX11-CU-NEXT: s_endpgm
2081 ptr addrspace(1) %out, i32 %in) {
2083 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup") acq_rel
2084 store i32 %val, ptr addrspace(1) %out, align 4
2088 define amdgpu_kernel void @global_workgroup_seq_cst_ret_atomicrmw(
2089 ; GFX6-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
2090 ; GFX6: ; %bb.0: ; %entry
2091 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x2
2092 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2093 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
2094 ; GFX6-NEXT: s_mov_b32 s2, -1
2095 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2096 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
2097 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2098 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0 glc
2099 ; GFX6-NEXT: s_waitcnt vmcnt(0)
2100 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
2101 ; GFX6-NEXT: s_endpgm
2103 ; GFX7-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
2104 ; GFX7: ; %bb.0: ; %entry
2105 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2106 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
2107 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2108 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
2109 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
2110 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
2111 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2112 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
2113 ; GFX7-NEXT: s_waitcnt vmcnt(0)
2114 ; GFX7-NEXT: flat_store_dword v[0:1], v2
2115 ; GFX7-NEXT: s_endpgm
2117 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
2118 ; GFX10-WGP: ; %bb.0: ; %entry
2119 ; GFX10-WGP-NEXT: s_clause 0x1
2120 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
2121 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2122 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
2123 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2124 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
2125 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2126 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2127 ; GFX10-WGP-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
2128 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
2129 ; GFX10-WGP-NEXT: buffer_gl0_inv
2130 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
2131 ; GFX10-WGP-NEXT: s_endpgm
2133 ; GFX10-CU-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
2134 ; GFX10-CU: ; %bb.0: ; %entry
2135 ; GFX10-CU-NEXT: s_clause 0x1
2136 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
2137 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2138 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
2139 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2140 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
2141 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2142 ; GFX10-CU-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
2143 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
2144 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
2145 ; GFX10-CU-NEXT: s_endpgm
2147 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
2148 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2149 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x2
2150 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x0
2151 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
2152 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
2153 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2154 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
2155 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2156 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0 glc
2157 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
2158 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
2159 ; SKIP-CACHE-INV-NEXT: s_endpgm
2161 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
2162 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2163 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
2164 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2165 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2166 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2167 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
2168 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2169 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
2170 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
2171 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
2172 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2174 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
2175 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2176 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
2177 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2178 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2179 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2180 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
2181 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2182 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
2183 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2184 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
2185 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
2186 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2188 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
2189 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
2190 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
2191 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
2192 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2193 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2194 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s4
2195 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2196 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[2:3] sc0
2197 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
2198 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
2199 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
2201 ; GFX940-TGSPLIT-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
2202 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
2203 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
2204 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
2205 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2206 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2207 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s4
2208 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2209 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[2:3] sc0
2210 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2211 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
2212 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
2213 ; GFX940-TGSPLIT-NEXT: s_endpgm
2215 ; GFX11-WGP-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
2216 ; GFX11-WGP: ; %bb.0: ; %entry
2217 ; GFX11-WGP-NEXT: s_clause 0x1
2218 ; GFX11-WGP-NEXT: s_load_b32 s2, s[0:1], 0x8
2219 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
2220 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
2221 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
2222 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2223 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2224 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] glc
2225 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
2226 ; GFX11-WGP-NEXT: buffer_gl0_inv
2227 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
2228 ; GFX11-WGP-NEXT: s_nop 0
2229 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
2230 ; GFX11-WGP-NEXT: s_endpgm
2232 ; GFX11-CU-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
2233 ; GFX11-CU: ; %bb.0: ; %entry
2234 ; GFX11-CU-NEXT: s_clause 0x1
2235 ; GFX11-CU-NEXT: s_load_b32 s2, s[0:1], 0x8
2236 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
2237 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2238 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
2239 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2240 ; GFX11-CU-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] glc
2241 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
2242 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
2243 ; GFX11-CU-NEXT: s_nop 0
2244 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
2245 ; GFX11-CU-NEXT: s_endpgm
2246 ptr addrspace(1) %out, i32 %in) {
2248 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup") seq_cst
2249 store i32 %val, ptr addrspace(1) %out, align 4
2253 define amdgpu_kernel void @global_workgroup_monotonic_monotonic_cmpxchg(
2254 ; GFX6-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
2255 ; GFX6: ; %bb.0: ; %entry
2256 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2257 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
2258 ; GFX6-NEXT: s_mov_b32 s6, -1
2259 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2260 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
2261 ; GFX6-NEXT: s_mov_b32 s4, s0
2262 ; GFX6-NEXT: s_mov_b32 s5, s1
2263 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
2264 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2265 ; GFX6-NEXT: s_endpgm
2267 ; GFX7-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
2268 ; GFX7: ; %bb.0: ; %entry
2269 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2270 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2271 ; GFX7-NEXT: s_add_u32 s0, s0, 16
2272 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
2273 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
2274 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
2275 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
2276 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
2277 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2278 ; GFX7-NEXT: s_endpgm
2280 ; GFX10-WGP-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
2281 ; GFX10-WGP: ; %bb.0: ; %entry
2282 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2283 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
2284 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2285 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
2286 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
2287 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2288 ; GFX10-WGP-NEXT: s_endpgm
2290 ; GFX10-CU-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
2291 ; GFX10-CU: ; %bb.0: ; %entry
2292 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2293 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
2294 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2295 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
2296 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
2297 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2298 ; GFX10-CU-NEXT: s_endpgm
2300 ; SKIP-CACHE-INV-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
2301 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2302 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2303 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
2304 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
2305 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2306 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
2307 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
2308 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
2309 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
2310 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2311 ; SKIP-CACHE-INV-NEXT: s_endpgm
2313 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
2314 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2315 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2316 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2317 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2318 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2319 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2320 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2322 ; GFX90A-TGSPLIT-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
2323 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2324 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2325 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2326 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2327 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2328 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2329 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2331 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
2332 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
2333 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2334 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2335 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2336 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
2337 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2338 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
2340 ; GFX940-TGSPLIT-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
2341 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
2342 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2343 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2344 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2345 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
2346 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2347 ; GFX940-TGSPLIT-NEXT: s_endpgm
2349 ; GFX11-WGP-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
2350 ; GFX11-WGP: ; %bb.0: ; %entry
2351 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
2352 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
2353 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
2354 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
2355 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
2356 ; GFX11-WGP-NEXT: s_nop 0
2357 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
2358 ; GFX11-WGP-NEXT: s_endpgm
2360 ; GFX11-CU-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
2361 ; GFX11-CU: ; %bb.0: ; %entry
2362 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
2363 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
2364 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2365 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
2366 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
2367 ; GFX11-CU-NEXT: s_nop 0
2368 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
2369 ; GFX11-CU-NEXT: s_endpgm
2370 ptr addrspace(1) %out, i32 %in, i32 %old) {
2372 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
2373 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") monotonic monotonic
2377 define amdgpu_kernel void @global_workgroup_acquire_monotonic_cmpxchg(
2378 ; GFX6-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
2379 ; GFX6: ; %bb.0: ; %entry
2380 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2381 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
2382 ; GFX6-NEXT: s_mov_b32 s6, -1
2383 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2384 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
2385 ; GFX6-NEXT: s_mov_b32 s4, s0
2386 ; GFX6-NEXT: s_mov_b32 s5, s1
2387 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
2388 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2389 ; GFX6-NEXT: s_endpgm
2391 ; GFX7-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
2392 ; GFX7: ; %bb.0: ; %entry
2393 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2394 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2395 ; GFX7-NEXT: s_add_u32 s0, s0, 16
2396 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
2397 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
2398 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
2399 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
2400 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
2401 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2402 ; GFX7-NEXT: s_endpgm
2404 ; GFX10-WGP-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
2405 ; GFX10-WGP: ; %bb.0: ; %entry
2406 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2407 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
2408 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2409 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
2410 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
2411 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2412 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2413 ; GFX10-WGP-NEXT: buffer_gl0_inv
2414 ; GFX10-WGP-NEXT: s_endpgm
2416 ; GFX10-CU-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
2417 ; GFX10-CU: ; %bb.0: ; %entry
2418 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2419 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
2420 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2421 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
2422 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
2423 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2424 ; GFX10-CU-NEXT: s_endpgm
2426 ; SKIP-CACHE-INV-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
2427 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2428 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2429 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
2430 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
2431 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2432 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
2433 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
2434 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
2435 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
2436 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2437 ; SKIP-CACHE-INV-NEXT: s_endpgm
2439 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
2440 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2441 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2442 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2443 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2444 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2445 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2446 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2448 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
2449 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2450 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2451 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2452 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2453 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2454 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2455 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2456 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
2457 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2459 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
2460 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
2461 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2462 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2463 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2464 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
2465 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2466 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
2468 ; GFX940-TGSPLIT-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
2469 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
2470 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2471 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2472 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2473 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
2474 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2475 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2476 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
2477 ; GFX940-TGSPLIT-NEXT: s_endpgm
2479 ; GFX11-WGP-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
2480 ; GFX11-WGP: ; %bb.0: ; %entry
2481 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
2482 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
2483 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
2484 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
2485 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
2486 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2487 ; GFX11-WGP-NEXT: buffer_gl0_inv
2488 ; GFX11-WGP-NEXT: s_endpgm
2490 ; GFX11-CU-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
2491 ; GFX11-CU: ; %bb.0: ; %entry
2492 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
2493 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
2494 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2495 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
2496 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
2497 ; GFX11-CU-NEXT: s_nop 0
2498 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
2499 ; GFX11-CU-NEXT: s_endpgm
2500 ptr addrspace(1) %out, i32 %in, i32 %old) {
2502 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
2503 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") acquire monotonic
2507 define amdgpu_kernel void @global_workgroup_release_monotonic_cmpxchg(
2508 ; GFX6-LABEL: global_workgroup_release_monotonic_cmpxchg:
2509 ; GFX6: ; %bb.0: ; %entry
2510 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2511 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
2512 ; GFX6-NEXT: s_mov_b32 s6, -1
2513 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2514 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
2515 ; GFX6-NEXT: s_mov_b32 s4, s0
2516 ; GFX6-NEXT: s_mov_b32 s5, s1
2517 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
2518 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2519 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2520 ; GFX6-NEXT: s_endpgm
2522 ; GFX7-LABEL: global_workgroup_release_monotonic_cmpxchg:
2523 ; GFX7: ; %bb.0: ; %entry
2524 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2525 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2526 ; GFX7-NEXT: s_add_u32 s0, s0, 16
2527 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
2528 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
2529 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
2530 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
2531 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
2532 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2533 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2534 ; GFX7-NEXT: s_endpgm
2536 ; GFX10-WGP-LABEL: global_workgroup_release_monotonic_cmpxchg:
2537 ; GFX10-WGP: ; %bb.0: ; %entry
2538 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2539 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
2540 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2541 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
2542 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
2543 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2544 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2545 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2546 ; GFX10-WGP-NEXT: s_endpgm
2548 ; GFX10-CU-LABEL: global_workgroup_release_monotonic_cmpxchg:
2549 ; GFX10-CU: ; %bb.0: ; %entry
2550 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2551 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
2552 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2553 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
2554 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
2555 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2556 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2557 ; GFX10-CU-NEXT: s_endpgm
2559 ; SKIP-CACHE-INV-LABEL: global_workgroup_release_monotonic_cmpxchg:
2560 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2561 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2562 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
2563 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
2564 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2565 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
2566 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
2567 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
2568 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
2569 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2570 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2571 ; SKIP-CACHE-INV-NEXT: s_endpgm
2573 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_release_monotonic_cmpxchg:
2574 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2575 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2576 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2577 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2578 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2579 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2580 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2581 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2583 ; GFX90A-TGSPLIT-LABEL: global_workgroup_release_monotonic_cmpxchg:
2584 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2585 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2586 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2587 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2588 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2589 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2590 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2591 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2593 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_release_monotonic_cmpxchg:
2594 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
2595 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2596 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2597 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2598 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
2599 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2600 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2601 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
2603 ; GFX940-TGSPLIT-LABEL: global_workgroup_release_monotonic_cmpxchg:
2604 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
2605 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2606 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2607 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2608 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
2609 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2610 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2611 ; GFX940-TGSPLIT-NEXT: s_endpgm
2613 ; GFX11-WGP-LABEL: global_workgroup_release_monotonic_cmpxchg:
2614 ; GFX11-WGP: ; %bb.0: ; %entry
2615 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
2616 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
2617 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
2618 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
2619 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2620 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2621 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
2622 ; GFX11-WGP-NEXT: s_nop 0
2623 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
2624 ; GFX11-WGP-NEXT: s_endpgm
2626 ; GFX11-CU-LABEL: global_workgroup_release_monotonic_cmpxchg:
2627 ; GFX11-CU: ; %bb.0: ; %entry
2628 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
2629 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
2630 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2631 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
2632 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2633 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
2634 ; GFX11-CU-NEXT: s_nop 0
2635 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
2636 ; GFX11-CU-NEXT: s_endpgm
2637 ptr addrspace(1) %out, i32 %in, i32 %old) {
2639 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
2640 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") release monotonic
2644 define amdgpu_kernel void @global_workgroup_acq_rel_monotonic_cmpxchg(
2645 ; GFX6-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
2646 ; GFX6: ; %bb.0: ; %entry
2647 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2648 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
2649 ; GFX6-NEXT: s_mov_b32 s6, -1
2650 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2651 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
2652 ; GFX6-NEXT: s_mov_b32 s4, s0
2653 ; GFX6-NEXT: s_mov_b32 s5, s1
2654 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
2655 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2656 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2657 ; GFX6-NEXT: s_endpgm
2659 ; GFX7-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
2660 ; GFX7: ; %bb.0: ; %entry
2661 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2662 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2663 ; GFX7-NEXT: s_add_u32 s0, s0, 16
2664 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
2665 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
2666 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
2667 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
2668 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
2669 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2670 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2671 ; GFX7-NEXT: s_endpgm
2673 ; GFX10-WGP-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
2674 ; GFX10-WGP: ; %bb.0: ; %entry
2675 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2676 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
2677 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2678 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
2679 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
2680 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2681 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2682 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2683 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2684 ; GFX10-WGP-NEXT: buffer_gl0_inv
2685 ; GFX10-WGP-NEXT: s_endpgm
2687 ; GFX10-CU-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
2688 ; GFX10-CU: ; %bb.0: ; %entry
2689 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2690 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
2691 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2692 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
2693 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
2694 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2695 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2696 ; GFX10-CU-NEXT: s_endpgm
2698 ; SKIP-CACHE-INV-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
2699 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2700 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2701 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
2702 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
2703 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2704 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
2705 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
2706 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
2707 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
2708 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2709 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2710 ; SKIP-CACHE-INV-NEXT: s_endpgm
2712 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
2713 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2714 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2715 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2716 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2717 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2718 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2719 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2720 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2722 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
2723 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2724 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2725 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2726 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2727 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2728 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2729 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2730 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2731 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
2732 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2734 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
2735 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
2736 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2737 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2738 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2739 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
2740 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2741 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2742 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
2744 ; GFX940-TGSPLIT-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
2745 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
2746 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2747 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2748 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2749 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
2750 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2751 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2752 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2753 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
2754 ; GFX940-TGSPLIT-NEXT: s_endpgm
2756 ; GFX11-WGP-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
2757 ; GFX11-WGP: ; %bb.0: ; %entry
2758 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
2759 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
2760 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
2761 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
2762 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2763 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2764 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
2765 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2766 ; GFX11-WGP-NEXT: buffer_gl0_inv
2767 ; GFX11-WGP-NEXT: s_endpgm
2769 ; GFX11-CU-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
2770 ; GFX11-CU: ; %bb.0: ; %entry
2771 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
2772 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
2773 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2774 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
2775 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2776 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
2777 ; GFX11-CU-NEXT: s_nop 0
2778 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
2779 ; GFX11-CU-NEXT: s_endpgm
2780 ptr addrspace(1) %out, i32 %in, i32 %old) {
2782 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
2783 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") acq_rel monotonic
2787 define amdgpu_kernel void @global_workgroup_seq_cst_monotonic_cmpxchg(
2788 ; GFX6-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
2789 ; GFX6: ; %bb.0: ; %entry
2790 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2791 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
2792 ; GFX6-NEXT: s_mov_b32 s6, -1
2793 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2794 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
2795 ; GFX6-NEXT: s_mov_b32 s4, s0
2796 ; GFX6-NEXT: s_mov_b32 s5, s1
2797 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
2798 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2799 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2800 ; GFX6-NEXT: s_endpgm
2802 ; GFX7-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
2803 ; GFX7: ; %bb.0: ; %entry
2804 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2805 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2806 ; GFX7-NEXT: s_add_u32 s0, s0, 16
2807 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
2808 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
2809 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
2810 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
2811 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
2812 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2813 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2814 ; GFX7-NEXT: s_endpgm
2816 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
2817 ; GFX10-WGP: ; %bb.0: ; %entry
2818 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2819 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
2820 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2821 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
2822 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
2823 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2824 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2825 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2826 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2827 ; GFX10-WGP-NEXT: buffer_gl0_inv
2828 ; GFX10-WGP-NEXT: s_endpgm
2830 ; GFX10-CU-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
2831 ; GFX10-CU: ; %bb.0: ; %entry
2832 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2833 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
2834 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2835 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
2836 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
2837 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2838 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2839 ; GFX10-CU-NEXT: s_endpgm
2841 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
2842 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2843 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2844 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
2845 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
2846 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2847 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
2848 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
2849 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
2850 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
2851 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2852 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2853 ; SKIP-CACHE-INV-NEXT: s_endpgm
2855 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
2856 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2857 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2858 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2859 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2860 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2861 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2862 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2863 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2865 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
2866 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2867 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2868 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2869 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2870 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2871 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2872 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2873 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2874 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
2875 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2877 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
2878 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
2879 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2880 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2881 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2882 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
2883 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2884 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2885 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
2887 ; GFX940-TGSPLIT-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
2888 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
2889 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2890 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2891 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2892 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
2893 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2894 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2895 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2896 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
2897 ; GFX940-TGSPLIT-NEXT: s_endpgm
2899 ; GFX11-WGP-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
2900 ; GFX11-WGP: ; %bb.0: ; %entry
2901 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
2902 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
2903 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
2904 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
2905 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2906 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2907 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
2908 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2909 ; GFX11-WGP-NEXT: buffer_gl0_inv
2910 ; GFX11-WGP-NEXT: s_endpgm
2912 ; GFX11-CU-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
2913 ; GFX11-CU: ; %bb.0: ; %entry
2914 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
2915 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
2916 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2917 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
2918 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2919 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
2920 ; GFX11-CU-NEXT: s_nop 0
2921 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
2922 ; GFX11-CU-NEXT: s_endpgm
2923 ptr addrspace(1) %out, i32 %in, i32 %old) {
2925 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
2926 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") seq_cst monotonic
2930 define amdgpu_kernel void @global_workgroup_monotonic_acquire_cmpxchg(
2931 ; GFX6-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
2932 ; GFX6: ; %bb.0: ; %entry
2933 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2934 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
2935 ; GFX6-NEXT: s_mov_b32 s6, -1
2936 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2937 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
2938 ; GFX6-NEXT: s_mov_b32 s4, s0
2939 ; GFX6-NEXT: s_mov_b32 s5, s1
2940 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
2941 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2942 ; GFX6-NEXT: s_endpgm
2944 ; GFX7-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
2945 ; GFX7: ; %bb.0: ; %entry
2946 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2947 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2948 ; GFX7-NEXT: s_add_u32 s0, s0, 16
2949 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
2950 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
2951 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
2952 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
2953 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
2954 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2955 ; GFX7-NEXT: s_endpgm
2957 ; GFX10-WGP-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
2958 ; GFX10-WGP: ; %bb.0: ; %entry
2959 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2960 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
2961 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2962 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
2963 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
2964 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2965 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2966 ; GFX10-WGP-NEXT: buffer_gl0_inv
2967 ; GFX10-WGP-NEXT: s_endpgm
2969 ; GFX10-CU-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
2970 ; GFX10-CU: ; %bb.0: ; %entry
2971 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2972 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
2973 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2974 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
2975 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
2976 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2977 ; GFX10-CU-NEXT: s_endpgm
2979 ; SKIP-CACHE-INV-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
2980 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2981 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2982 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
2983 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
2984 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2985 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
2986 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
2987 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
2988 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
2989 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2990 ; SKIP-CACHE-INV-NEXT: s_endpgm
2992 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
2993 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2994 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2995 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2996 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2997 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2998 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2999 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3001 ; GFX90A-TGSPLIT-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
3002 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3003 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3004 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3005 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3006 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3007 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3008 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3009 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
3010 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3012 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
3013 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
3014 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3015 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3016 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3017 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
3018 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3019 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
3021 ; GFX940-TGSPLIT-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
3022 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
3023 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3024 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3025 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3026 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
3027 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3028 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3029 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
3030 ; GFX940-TGSPLIT-NEXT: s_endpgm
3032 ; GFX11-WGP-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
3033 ; GFX11-WGP: ; %bb.0: ; %entry
3034 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
3035 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
3036 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3037 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
3038 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
3039 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3040 ; GFX11-WGP-NEXT: buffer_gl0_inv
3041 ; GFX11-WGP-NEXT: s_endpgm
3043 ; GFX11-CU-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
3044 ; GFX11-CU: ; %bb.0: ; %entry
3045 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
3046 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
3047 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3048 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
3049 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
3050 ; GFX11-CU-NEXT: s_nop 0
3051 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
3052 ; GFX11-CU-NEXT: s_endpgm
3053 ptr addrspace(1) %out, i32 %in, i32 %old) {
3055 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
3056 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") monotonic acquire
3060 define amdgpu_kernel void @global_workgroup_acquire_acquire_cmpxchg(
3061 ; GFX6-LABEL: global_workgroup_acquire_acquire_cmpxchg:
3062 ; GFX6: ; %bb.0: ; %entry
3063 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3064 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
3065 ; GFX6-NEXT: s_mov_b32 s6, -1
3066 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3067 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
3068 ; GFX6-NEXT: s_mov_b32 s4, s0
3069 ; GFX6-NEXT: s_mov_b32 s5, s1
3070 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
3071 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
3072 ; GFX6-NEXT: s_endpgm
3074 ; GFX7-LABEL: global_workgroup_acquire_acquire_cmpxchg:
3075 ; GFX7: ; %bb.0: ; %entry
3076 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3077 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3078 ; GFX7-NEXT: s_add_u32 s0, s0, 16
3079 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
3080 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
3081 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
3082 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
3083 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
3084 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3085 ; GFX7-NEXT: s_endpgm
3087 ; GFX10-WGP-LABEL: global_workgroup_acquire_acquire_cmpxchg:
3088 ; GFX10-WGP: ; %bb.0: ; %entry
3089 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3090 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
3091 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3092 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
3093 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
3094 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3095 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3096 ; GFX10-WGP-NEXT: buffer_gl0_inv
3097 ; GFX10-WGP-NEXT: s_endpgm
3099 ; GFX10-CU-LABEL: global_workgroup_acquire_acquire_cmpxchg:
3100 ; GFX10-CU: ; %bb.0: ; %entry
3101 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3102 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
3103 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3104 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
3105 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
3106 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3107 ; GFX10-CU-NEXT: s_endpgm
3109 ; SKIP-CACHE-INV-LABEL: global_workgroup_acquire_acquire_cmpxchg:
3110 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3111 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3112 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
3113 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
3114 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3115 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
3116 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
3117 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
3118 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
3119 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
3120 ; SKIP-CACHE-INV-NEXT: s_endpgm
3122 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acquire_acquire_cmpxchg:
3123 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3124 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3125 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3126 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3127 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3128 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3129 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3131 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acquire_acquire_cmpxchg:
3132 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3133 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3134 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3135 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3136 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3137 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3138 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3139 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
3140 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3142 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acquire_acquire_cmpxchg:
3143 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
3144 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3145 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3146 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3147 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
3148 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3149 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
3151 ; GFX940-TGSPLIT-LABEL: global_workgroup_acquire_acquire_cmpxchg:
3152 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
3153 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3154 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3155 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3156 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
3157 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3158 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3159 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
3160 ; GFX940-TGSPLIT-NEXT: s_endpgm
3162 ; GFX11-WGP-LABEL: global_workgroup_acquire_acquire_cmpxchg:
3163 ; GFX11-WGP: ; %bb.0: ; %entry
3164 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
3165 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
3166 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3167 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
3168 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
3169 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3170 ; GFX11-WGP-NEXT: buffer_gl0_inv
3171 ; GFX11-WGP-NEXT: s_endpgm
3173 ; GFX11-CU-LABEL: global_workgroup_acquire_acquire_cmpxchg:
3174 ; GFX11-CU: ; %bb.0: ; %entry
3175 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
3176 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
3177 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3178 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
3179 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
3180 ; GFX11-CU-NEXT: s_nop 0
3181 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
3182 ; GFX11-CU-NEXT: s_endpgm
3183 ptr addrspace(1) %out, i32 %in, i32 %old) {
3185 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
3186 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") acquire acquire
3190 define amdgpu_kernel void @global_workgroup_release_acquire_cmpxchg(
3191 ; GFX6-LABEL: global_workgroup_release_acquire_cmpxchg:
3192 ; GFX6: ; %bb.0: ; %entry
3193 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3194 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
3195 ; GFX6-NEXT: s_mov_b32 s6, -1
3196 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3197 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
3198 ; GFX6-NEXT: s_mov_b32 s4, s0
3199 ; GFX6-NEXT: s_mov_b32 s5, s1
3200 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
3201 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3202 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
3203 ; GFX6-NEXT: s_endpgm
3205 ; GFX7-LABEL: global_workgroup_release_acquire_cmpxchg:
3206 ; GFX7: ; %bb.0: ; %entry
3207 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3208 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3209 ; GFX7-NEXT: s_add_u32 s0, s0, 16
3210 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
3211 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
3212 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
3213 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
3214 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
3215 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3216 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3217 ; GFX7-NEXT: s_endpgm
3219 ; GFX10-WGP-LABEL: global_workgroup_release_acquire_cmpxchg:
3220 ; GFX10-WGP: ; %bb.0: ; %entry
3221 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3222 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
3223 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3224 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
3225 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
3226 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3227 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3228 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3229 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3230 ; GFX10-WGP-NEXT: buffer_gl0_inv
3231 ; GFX10-WGP-NEXT: s_endpgm
3233 ; GFX10-CU-LABEL: global_workgroup_release_acquire_cmpxchg:
3234 ; GFX10-CU: ; %bb.0: ; %entry
3235 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3236 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
3237 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3238 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
3239 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
3240 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3241 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3242 ; GFX10-CU-NEXT: s_endpgm
3244 ; SKIP-CACHE-INV-LABEL: global_workgroup_release_acquire_cmpxchg:
3245 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3246 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3247 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
3248 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
3249 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3250 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
3251 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
3252 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
3253 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
3254 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3255 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
3256 ; SKIP-CACHE-INV-NEXT: s_endpgm
3258 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_release_acquire_cmpxchg:
3259 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3260 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3261 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3262 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3263 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3264 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3265 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3266 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3268 ; GFX90A-TGSPLIT-LABEL: global_workgroup_release_acquire_cmpxchg:
3269 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3270 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3271 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3272 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3273 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3274 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3275 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3276 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3277 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
3278 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3280 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_release_acquire_cmpxchg:
3281 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
3282 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3283 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3284 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3285 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
3286 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3287 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3288 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
3290 ; GFX940-TGSPLIT-LABEL: global_workgroup_release_acquire_cmpxchg:
3291 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
3292 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3293 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3294 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3295 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
3296 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3297 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3298 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3299 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
3300 ; GFX940-TGSPLIT-NEXT: s_endpgm
3302 ; GFX11-WGP-LABEL: global_workgroup_release_acquire_cmpxchg:
3303 ; GFX11-WGP: ; %bb.0: ; %entry
3304 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
3305 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
3306 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3307 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
3308 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3309 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3310 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
3311 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3312 ; GFX11-WGP-NEXT: buffer_gl0_inv
3313 ; GFX11-WGP-NEXT: s_endpgm
3315 ; GFX11-CU-LABEL: global_workgroup_release_acquire_cmpxchg:
3316 ; GFX11-CU: ; %bb.0: ; %entry
3317 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
3318 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
3319 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3320 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
3321 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3322 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
3323 ; GFX11-CU-NEXT: s_nop 0
3324 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
3325 ; GFX11-CU-NEXT: s_endpgm
3326 ptr addrspace(1) %out, i32 %in, i32 %old) {
3328 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
3329 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") release acquire
3333 define amdgpu_kernel void @global_workgroup_acq_rel_acquire_cmpxchg(
3334 ; GFX6-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
3335 ; GFX6: ; %bb.0: ; %entry
3336 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3337 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
3338 ; GFX6-NEXT: s_mov_b32 s6, -1
3339 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3340 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
3341 ; GFX6-NEXT: s_mov_b32 s4, s0
3342 ; GFX6-NEXT: s_mov_b32 s5, s1
3343 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
3344 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3345 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
3346 ; GFX6-NEXT: s_endpgm
3348 ; GFX7-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
3349 ; GFX7: ; %bb.0: ; %entry
3350 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3351 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3352 ; GFX7-NEXT: s_add_u32 s0, s0, 16
3353 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
3354 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
3355 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
3356 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
3357 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
3358 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3359 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3360 ; GFX7-NEXT: s_endpgm
3362 ; GFX10-WGP-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
3363 ; GFX10-WGP: ; %bb.0: ; %entry
3364 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3365 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
3366 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3367 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
3368 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
3369 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3370 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3371 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3372 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3373 ; GFX10-WGP-NEXT: buffer_gl0_inv
3374 ; GFX10-WGP-NEXT: s_endpgm
3376 ; GFX10-CU-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
3377 ; GFX10-CU: ; %bb.0: ; %entry
3378 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3379 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
3380 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3381 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
3382 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
3383 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3384 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3385 ; GFX10-CU-NEXT: s_endpgm
3387 ; SKIP-CACHE-INV-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
3388 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3389 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3390 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
3391 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
3392 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3393 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
3394 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
3395 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
3396 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
3397 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3398 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
3399 ; SKIP-CACHE-INV-NEXT: s_endpgm
3401 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
3402 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3403 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3404 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3405 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3406 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3407 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3408 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3409 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3411 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
3412 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3413 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3414 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3415 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3416 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3417 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3418 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3419 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3420 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
3421 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3423 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
3424 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
3425 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3426 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3427 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3428 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
3429 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3430 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3431 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
3433 ; GFX940-TGSPLIT-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
3434 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
3435 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3436 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3437 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3438 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
3439 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3440 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3441 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3442 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
3443 ; GFX940-TGSPLIT-NEXT: s_endpgm
3445 ; GFX11-WGP-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
3446 ; GFX11-WGP: ; %bb.0: ; %entry
3447 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
3448 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
3449 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3450 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
3451 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3452 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3453 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
3454 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3455 ; GFX11-WGP-NEXT: buffer_gl0_inv
3456 ; GFX11-WGP-NEXT: s_endpgm
3458 ; GFX11-CU-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
3459 ; GFX11-CU: ; %bb.0: ; %entry
3460 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
3461 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
3462 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3463 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
3464 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3465 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
3466 ; GFX11-CU-NEXT: s_nop 0
3467 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
3468 ; GFX11-CU-NEXT: s_endpgm
3469 ptr addrspace(1) %out, i32 %in, i32 %old) {
3471 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
3472 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") acq_rel acquire
3476 define amdgpu_kernel void @global_workgroup_seq_cst_acquire_cmpxchg(
3477 ; GFX6-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
3478 ; GFX6: ; %bb.0: ; %entry
3479 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3480 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
3481 ; GFX6-NEXT: s_mov_b32 s6, -1
3482 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3483 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
3484 ; GFX6-NEXT: s_mov_b32 s4, s0
3485 ; GFX6-NEXT: s_mov_b32 s5, s1
3486 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
3487 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3488 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
3489 ; GFX6-NEXT: s_endpgm
3491 ; GFX7-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
3492 ; GFX7: ; %bb.0: ; %entry
3493 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3494 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3495 ; GFX7-NEXT: s_add_u32 s0, s0, 16
3496 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
3497 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
3498 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
3499 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
3500 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
3501 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3502 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3503 ; GFX7-NEXT: s_endpgm
3505 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
3506 ; GFX10-WGP: ; %bb.0: ; %entry
3507 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3508 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
3509 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3510 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
3511 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
3512 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3513 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3514 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3515 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3516 ; GFX10-WGP-NEXT: buffer_gl0_inv
3517 ; GFX10-WGP-NEXT: s_endpgm
3519 ; GFX10-CU-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
3520 ; GFX10-CU: ; %bb.0: ; %entry
3521 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3522 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
3523 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3524 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
3525 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
3526 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3527 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3528 ; GFX10-CU-NEXT: s_endpgm
3530 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
3531 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3532 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3533 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
3534 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
3535 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3536 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
3537 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
3538 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
3539 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
3540 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3541 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
3542 ; SKIP-CACHE-INV-NEXT: s_endpgm
3544 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
3545 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3546 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3547 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3548 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3549 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3550 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3551 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3552 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3554 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
3555 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3556 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3557 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3558 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3559 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3560 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3561 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3562 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3563 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
3564 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3566 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
3567 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
3568 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3569 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3570 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3571 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
3572 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3573 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3574 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
3576 ; GFX940-TGSPLIT-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
3577 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
3578 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3579 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3580 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3581 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
3582 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3583 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3584 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3585 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
3586 ; GFX940-TGSPLIT-NEXT: s_endpgm
3588 ; GFX11-WGP-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
3589 ; GFX11-WGP: ; %bb.0: ; %entry
3590 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
3591 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
3592 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3593 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
3594 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3595 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3596 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
3597 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3598 ; GFX11-WGP-NEXT: buffer_gl0_inv
3599 ; GFX11-WGP-NEXT: s_endpgm
3601 ; GFX11-CU-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
3602 ; GFX11-CU: ; %bb.0: ; %entry
3603 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
3604 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
3605 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3606 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
3607 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3608 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
3609 ; GFX11-CU-NEXT: s_nop 0
3610 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
3611 ; GFX11-CU-NEXT: s_endpgm
3612 ptr addrspace(1) %out, i32 %in, i32 %old) {
3614 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
3615 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") seq_cst acquire
3619 define amdgpu_kernel void @global_workgroup_monotonic_seq_cst_cmpxchg(
3620 ; GFX6-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
3621 ; GFX6: ; %bb.0: ; %entry
3622 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3623 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
3624 ; GFX6-NEXT: s_mov_b32 s6, -1
3625 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3626 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
3627 ; GFX6-NEXT: s_mov_b32 s4, s0
3628 ; GFX6-NEXT: s_mov_b32 s5, s1
3629 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
3630 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3631 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
3632 ; GFX6-NEXT: s_endpgm
3634 ; GFX7-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
3635 ; GFX7: ; %bb.0: ; %entry
3636 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3637 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3638 ; GFX7-NEXT: s_add_u32 s0, s0, 16
3639 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
3640 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
3641 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
3642 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
3643 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
3644 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3645 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3646 ; GFX7-NEXT: s_endpgm
3648 ; GFX10-WGP-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
3649 ; GFX10-WGP: ; %bb.0: ; %entry
3650 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3651 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
3652 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3653 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
3654 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
3655 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3656 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3657 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3658 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3659 ; GFX10-WGP-NEXT: buffer_gl0_inv
3660 ; GFX10-WGP-NEXT: s_endpgm
3662 ; GFX10-CU-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
3663 ; GFX10-CU: ; %bb.0: ; %entry
3664 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3665 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
3666 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3667 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
3668 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
3669 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3670 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3671 ; GFX10-CU-NEXT: s_endpgm
3673 ; SKIP-CACHE-INV-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
3674 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3675 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3676 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
3677 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
3678 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3679 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
3680 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
3681 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
3682 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
3683 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3684 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
3685 ; SKIP-CACHE-INV-NEXT: s_endpgm
3687 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
3688 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3689 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3690 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3691 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3692 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3693 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3694 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3695 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3697 ; GFX90A-TGSPLIT-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
3698 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3699 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3700 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3701 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3702 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3703 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3704 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3705 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3706 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
3707 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3709 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
3710 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
3711 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3712 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3713 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3714 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
3715 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3716 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3717 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
3719 ; GFX940-TGSPLIT-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
3720 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
3721 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3722 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3723 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3724 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
3725 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3726 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3727 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3728 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
3729 ; GFX940-TGSPLIT-NEXT: s_endpgm
3731 ; GFX11-WGP-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
3732 ; GFX11-WGP: ; %bb.0: ; %entry
3733 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
3734 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
3735 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3736 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
3737 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3738 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3739 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
3740 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3741 ; GFX11-WGP-NEXT: buffer_gl0_inv
3742 ; GFX11-WGP-NEXT: s_endpgm
3744 ; GFX11-CU-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
3745 ; GFX11-CU: ; %bb.0: ; %entry
3746 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
3747 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
3748 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3749 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
3750 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3751 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
3752 ; GFX11-CU-NEXT: s_nop 0
3753 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
3754 ; GFX11-CU-NEXT: s_endpgm
3755 ptr addrspace(1) %out, i32 %in, i32 %old) {
3757 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
3758 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") monotonic seq_cst
3762 define amdgpu_kernel void @global_workgroup_acquire_seq_cst_cmpxchg(
3763 ; GFX6-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
3764 ; GFX6: ; %bb.0: ; %entry
3765 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3766 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
3767 ; GFX6-NEXT: s_mov_b32 s6, -1
3768 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3769 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
3770 ; GFX6-NEXT: s_mov_b32 s4, s0
3771 ; GFX6-NEXT: s_mov_b32 s5, s1
3772 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
3773 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3774 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
3775 ; GFX6-NEXT: s_endpgm
3777 ; GFX7-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
3778 ; GFX7: ; %bb.0: ; %entry
3779 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3780 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3781 ; GFX7-NEXT: s_add_u32 s0, s0, 16
3782 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
3783 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
3784 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
3785 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
3786 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
3787 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3788 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3789 ; GFX7-NEXT: s_endpgm
3791 ; GFX10-WGP-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
3792 ; GFX10-WGP: ; %bb.0: ; %entry
3793 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3794 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
3795 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3796 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
3797 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
3798 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3799 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3800 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3801 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3802 ; GFX10-WGP-NEXT: buffer_gl0_inv
3803 ; GFX10-WGP-NEXT: s_endpgm
3805 ; GFX10-CU-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
3806 ; GFX10-CU: ; %bb.0: ; %entry
3807 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3808 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
3809 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3810 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
3811 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
3812 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3813 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3814 ; GFX10-CU-NEXT: s_endpgm
3816 ; SKIP-CACHE-INV-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
3817 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3818 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3819 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
3820 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
3821 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3822 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
3823 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
3824 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
3825 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
3826 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3827 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
3828 ; SKIP-CACHE-INV-NEXT: s_endpgm
3830 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
3831 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3832 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3833 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3834 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3835 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3836 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3837 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3838 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3840 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
3841 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3842 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3843 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3844 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3845 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3846 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3847 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3848 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3849 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
3850 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3852 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
3853 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
3854 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3855 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3856 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3857 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
3858 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3859 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3860 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
3862 ; GFX940-TGSPLIT-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
3863 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
3864 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3865 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3866 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3867 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
3868 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3869 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3870 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3871 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
3872 ; GFX940-TGSPLIT-NEXT: s_endpgm
3874 ; GFX11-WGP-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
3875 ; GFX11-WGP: ; %bb.0: ; %entry
3876 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
3877 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
3878 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3879 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
3880 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3881 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3882 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
3883 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3884 ; GFX11-WGP-NEXT: buffer_gl0_inv
3885 ; GFX11-WGP-NEXT: s_endpgm
3887 ; GFX11-CU-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
3888 ; GFX11-CU: ; %bb.0: ; %entry
3889 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
3890 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
3891 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3892 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
3893 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3894 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
3895 ; GFX11-CU-NEXT: s_nop 0
3896 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
3897 ; GFX11-CU-NEXT: s_endpgm
3898 ptr addrspace(1) %out, i32 %in, i32 %old) {
3900 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
3901 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") acquire seq_cst
3905 define amdgpu_kernel void @global_workgroup_release_seq_cst_cmpxchg(
3906 ; GFX6-LABEL: global_workgroup_release_seq_cst_cmpxchg:
3907 ; GFX6: ; %bb.0: ; %entry
3908 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3909 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
3910 ; GFX6-NEXT: s_mov_b32 s6, -1
3911 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3912 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
3913 ; GFX6-NEXT: s_mov_b32 s4, s0
3914 ; GFX6-NEXT: s_mov_b32 s5, s1
3915 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
3916 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3917 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
3918 ; GFX6-NEXT: s_endpgm
3920 ; GFX7-LABEL: global_workgroup_release_seq_cst_cmpxchg:
3921 ; GFX7: ; %bb.0: ; %entry
3922 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3923 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3924 ; GFX7-NEXT: s_add_u32 s0, s0, 16
3925 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
3926 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
3927 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
3928 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
3929 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
3930 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3931 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3932 ; GFX7-NEXT: s_endpgm
3934 ; GFX10-WGP-LABEL: global_workgroup_release_seq_cst_cmpxchg:
3935 ; GFX10-WGP: ; %bb.0: ; %entry
3936 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3937 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
3938 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3939 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
3940 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
3941 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3942 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3943 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3944 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3945 ; GFX10-WGP-NEXT: buffer_gl0_inv
3946 ; GFX10-WGP-NEXT: s_endpgm
3948 ; GFX10-CU-LABEL: global_workgroup_release_seq_cst_cmpxchg:
3949 ; GFX10-CU: ; %bb.0: ; %entry
3950 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3951 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
3952 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3953 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
3954 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
3955 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3956 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3957 ; GFX10-CU-NEXT: s_endpgm
3959 ; SKIP-CACHE-INV-LABEL: global_workgroup_release_seq_cst_cmpxchg:
3960 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3961 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3962 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
3963 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
3964 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3965 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
3966 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
3967 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
3968 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
3969 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3970 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
3971 ; SKIP-CACHE-INV-NEXT: s_endpgm
3973 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_release_seq_cst_cmpxchg:
3974 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3975 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3976 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3977 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3978 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3979 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3980 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3981 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3983 ; GFX90A-TGSPLIT-LABEL: global_workgroup_release_seq_cst_cmpxchg:
3984 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3985 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3986 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3987 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3988 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3989 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3990 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3991 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3992 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
3993 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3995 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_release_seq_cst_cmpxchg:
3996 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
3997 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3998 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3999 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4000 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
4001 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4002 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
4003 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
4005 ; GFX940-TGSPLIT-LABEL: global_workgroup_release_seq_cst_cmpxchg:
4006 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
4007 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4008 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4009 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4010 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
4011 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4012 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
4013 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4014 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
4015 ; GFX940-TGSPLIT-NEXT: s_endpgm
4017 ; GFX11-WGP-LABEL: global_workgroup_release_seq_cst_cmpxchg:
4018 ; GFX11-WGP: ; %bb.0: ; %entry
4019 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
4020 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
4021 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
4022 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
4023 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4024 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4025 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
4026 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4027 ; GFX11-WGP-NEXT: buffer_gl0_inv
4028 ; GFX11-WGP-NEXT: s_endpgm
4030 ; GFX11-CU-LABEL: global_workgroup_release_seq_cst_cmpxchg:
4031 ; GFX11-CU: ; %bb.0: ; %entry
4032 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
4033 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
4034 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4035 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
4036 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4037 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
4038 ; GFX11-CU-NEXT: s_nop 0
4039 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
4040 ; GFX11-CU-NEXT: s_endpgm
4041 ptr addrspace(1) %out, i32 %in, i32 %old) {
4043 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
4044 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") release seq_cst
4048 define amdgpu_kernel void @global_workgroup_acq_rel_seq_cst_cmpxchg(
4049 ; GFX6-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
4050 ; GFX6: ; %bb.0: ; %entry
4051 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4052 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
4053 ; GFX6-NEXT: s_mov_b32 s6, -1
4054 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4055 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
4056 ; GFX6-NEXT: s_mov_b32 s4, s0
4057 ; GFX6-NEXT: s_mov_b32 s5, s1
4058 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
4059 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4060 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
4061 ; GFX6-NEXT: s_endpgm
4063 ; GFX7-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
4064 ; GFX7: ; %bb.0: ; %entry
4065 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4066 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4067 ; GFX7-NEXT: s_add_u32 s0, s0, 16
4068 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
4069 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
4070 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
4071 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
4072 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
4073 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4074 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4075 ; GFX7-NEXT: s_endpgm
4077 ; GFX10-WGP-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
4078 ; GFX10-WGP: ; %bb.0: ; %entry
4079 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4080 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
4081 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4082 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
4083 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
4084 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4085 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4086 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
4087 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4088 ; GFX10-WGP-NEXT: buffer_gl0_inv
4089 ; GFX10-WGP-NEXT: s_endpgm
4091 ; GFX10-CU-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
4092 ; GFX10-CU: ; %bb.0: ; %entry
4093 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4094 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
4095 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4096 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
4097 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
4098 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4099 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
4100 ; GFX10-CU-NEXT: s_endpgm
4102 ; SKIP-CACHE-INV-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
4103 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4104 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4105 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
4106 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
4107 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4108 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
4109 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
4110 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
4111 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
4112 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4113 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
4114 ; SKIP-CACHE-INV-NEXT: s_endpgm
4116 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
4117 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4118 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4119 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4120 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4121 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4122 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4123 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
4124 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4126 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
4127 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4128 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4129 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4130 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4131 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4132 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4133 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
4134 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4135 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
4136 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4138 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
4139 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
4140 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4141 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4142 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4143 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
4144 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4145 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
4146 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
4148 ; GFX940-TGSPLIT-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
4149 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
4150 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4151 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4152 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4153 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
4154 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4155 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
4156 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4157 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
4158 ; GFX940-TGSPLIT-NEXT: s_endpgm
4160 ; GFX11-WGP-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
4161 ; GFX11-WGP: ; %bb.0: ; %entry
4162 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
4163 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
4164 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
4165 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
4166 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4167 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4168 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
4169 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4170 ; GFX11-WGP-NEXT: buffer_gl0_inv
4171 ; GFX11-WGP-NEXT: s_endpgm
4173 ; GFX11-CU-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
4174 ; GFX11-CU: ; %bb.0: ; %entry
4175 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
4176 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
4177 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4178 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
4179 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4180 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
4181 ; GFX11-CU-NEXT: s_nop 0
4182 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
4183 ; GFX11-CU-NEXT: s_endpgm
4184 ptr addrspace(1) %out, i32 %in, i32 %old) {
4186 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
4187 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") acq_rel seq_cst
4191 define amdgpu_kernel void @global_workgroup_seq_cst_seq_cst_cmpxchg(
4192 ; GFX6-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
4193 ; GFX6: ; %bb.0: ; %entry
4194 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4195 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
4196 ; GFX6-NEXT: s_mov_b32 s6, -1
4197 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4198 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
4199 ; GFX6-NEXT: s_mov_b32 s4, s0
4200 ; GFX6-NEXT: s_mov_b32 s5, s1
4201 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
4202 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4203 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
4204 ; GFX6-NEXT: s_endpgm
4206 ; GFX7-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
4207 ; GFX7: ; %bb.0: ; %entry
4208 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4209 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4210 ; GFX7-NEXT: s_add_u32 s0, s0, 16
4211 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
4212 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
4213 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
4214 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
4215 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
4216 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4217 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4218 ; GFX7-NEXT: s_endpgm
4220 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
4221 ; GFX10-WGP: ; %bb.0: ; %entry
4222 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4223 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
4224 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4225 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
4226 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
4227 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4228 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4229 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
4230 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4231 ; GFX10-WGP-NEXT: buffer_gl0_inv
4232 ; GFX10-WGP-NEXT: s_endpgm
4234 ; GFX10-CU-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
4235 ; GFX10-CU: ; %bb.0: ; %entry
4236 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4237 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
4238 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4239 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
4240 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
4241 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4242 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
4243 ; GFX10-CU-NEXT: s_endpgm
4245 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
4246 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4247 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4248 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
4249 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
4250 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4251 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
4252 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
4253 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
4254 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
4255 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4256 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
4257 ; SKIP-CACHE-INV-NEXT: s_endpgm
4259 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
4260 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4261 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4262 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4263 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4264 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4265 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4266 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
4267 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4269 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
4270 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4271 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4272 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4273 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4274 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4275 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4276 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
4277 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4278 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
4279 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4281 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
4282 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
4283 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4284 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4285 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4286 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
4287 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4288 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
4289 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
4291 ; GFX940-TGSPLIT-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
4292 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
4293 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4294 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4295 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4296 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
4297 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4298 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
4299 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4300 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
4301 ; GFX940-TGSPLIT-NEXT: s_endpgm
4303 ; GFX11-WGP-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
4304 ; GFX11-WGP: ; %bb.0: ; %entry
4305 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
4306 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
4307 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
4308 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
4309 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4310 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4311 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
4312 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4313 ; GFX11-WGP-NEXT: buffer_gl0_inv
4314 ; GFX11-WGP-NEXT: s_endpgm
4316 ; GFX11-CU-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
4317 ; GFX11-CU: ; %bb.0: ; %entry
4318 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
4319 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
4320 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4321 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
4322 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4323 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
4324 ; GFX11-CU-NEXT: s_nop 0
4325 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
4326 ; GFX11-CU-NEXT: s_endpgm
4327 ptr addrspace(1) %out, i32 %in, i32 %old) {
4329 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
4330 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") seq_cst seq_cst
4334 define amdgpu_kernel void @global_workgroup_monotonic_monotonic_ret_cmpxchg(
4335 ; GFX6-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
4336 ; GFX6: ; %bb.0: ; %entry
4337 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4338 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
4339 ; GFX6-NEXT: s_mov_b32 s6, -1
4340 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4341 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
4342 ; GFX6-NEXT: s_mov_b32 s4, s0
4343 ; GFX6-NEXT: s_mov_b32 s5, s1
4344 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
4345 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
4346 ; GFX6-NEXT: s_waitcnt vmcnt(0)
4347 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
4348 ; GFX6-NEXT: s_endpgm
4350 ; GFX7-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
4351 ; GFX7: ; %bb.0: ; %entry
4352 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4353 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4354 ; GFX7-NEXT: s_add_u32 s4, s0, 16
4355 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
4356 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
4357 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
4358 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
4359 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
4360 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4361 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
4362 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
4363 ; GFX7-NEXT: s_waitcnt vmcnt(0)
4364 ; GFX7-NEXT: flat_store_dword v[0:1], v2
4365 ; GFX7-NEXT: s_endpgm
4367 ; GFX10-WGP-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
4368 ; GFX10-WGP: ; %bb.0: ; %entry
4369 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4370 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
4371 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4372 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
4373 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
4374 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4375 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
4376 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
4377 ; GFX10-WGP-NEXT: s_endpgm
4379 ; GFX10-CU-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
4380 ; GFX10-CU: ; %bb.0: ; %entry
4381 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4382 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
4383 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4384 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
4385 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
4386 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4387 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
4388 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
4389 ; GFX10-CU-NEXT: s_endpgm
4391 ; SKIP-CACHE-INV-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
4392 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4393 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4394 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
4395 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
4396 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4397 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
4398 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
4399 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
4400 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
4401 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
4402 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
4403 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
4404 ; SKIP-CACHE-INV-NEXT: s_endpgm
4406 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
4407 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4408 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4409 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4410 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4411 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4412 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4413 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
4414 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
4415 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4417 ; GFX90A-TGSPLIT-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
4418 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4419 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4420 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4421 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4422 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4423 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4424 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4425 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
4426 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4428 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
4429 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
4430 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4431 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4432 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4433 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
4434 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
4435 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
4436 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
4437 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
4439 ; GFX940-TGSPLIT-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
4440 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
4441 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4442 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4443 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4444 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
4445 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
4446 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4447 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
4448 ; GFX940-TGSPLIT-NEXT: s_endpgm
4450 ; GFX11-WGP-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
4451 ; GFX11-WGP: ; %bb.0: ; %entry
4452 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
4453 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
4454 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
4455 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
4456 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
4457 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
4458 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
4459 ; GFX11-WGP-NEXT: s_nop 0
4460 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
4461 ; GFX11-WGP-NEXT: s_endpgm
4463 ; GFX11-CU-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
4464 ; GFX11-CU: ; %bb.0: ; %entry
4465 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
4466 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
4467 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4468 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
4469 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
4470 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
4471 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
4472 ; GFX11-CU-NEXT: s_nop 0
4473 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
4474 ; GFX11-CU-NEXT: s_endpgm
4475 ptr addrspace(1) %out, i32 %in, i32 %old) {
4477 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
4478 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") monotonic monotonic
4479 %val0 = extractvalue { i32, i1 } %val, 0
4480 store i32 %val0, ptr addrspace(1) %out, align 4
4484 define amdgpu_kernel void @global_workgroup_acquire_monotonic_ret_cmpxchg(
4485 ; GFX6-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
4486 ; GFX6: ; %bb.0: ; %entry
4487 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4488 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
4489 ; GFX6-NEXT: s_mov_b32 s6, -1
4490 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4491 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
4492 ; GFX6-NEXT: s_mov_b32 s4, s0
4493 ; GFX6-NEXT: s_mov_b32 s5, s1
4494 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
4495 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
4496 ; GFX6-NEXT: s_waitcnt vmcnt(0)
4497 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
4498 ; GFX6-NEXT: s_endpgm
4500 ; GFX7-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
4501 ; GFX7: ; %bb.0: ; %entry
4502 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4503 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4504 ; GFX7-NEXT: s_add_u32 s4, s0, 16
4505 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
4506 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
4507 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
4508 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
4509 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
4510 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4511 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
4512 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
4513 ; GFX7-NEXT: s_waitcnt vmcnt(0)
4514 ; GFX7-NEXT: flat_store_dword v[0:1], v2
4515 ; GFX7-NEXT: s_endpgm
4517 ; GFX10-WGP-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
4518 ; GFX10-WGP: ; %bb.0: ; %entry
4519 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4520 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
4521 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4522 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
4523 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
4524 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4525 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
4526 ; GFX10-WGP-NEXT: buffer_gl0_inv
4527 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
4528 ; GFX10-WGP-NEXT: s_endpgm
4530 ; GFX10-CU-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
4531 ; GFX10-CU: ; %bb.0: ; %entry
4532 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4533 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
4534 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4535 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
4536 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
4537 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4538 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
4539 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
4540 ; GFX10-CU-NEXT: s_endpgm
4542 ; SKIP-CACHE-INV-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
4543 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4544 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4545 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
4546 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
4547 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4548 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
4549 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
4550 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
4551 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
4552 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
4553 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
4554 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
4555 ; SKIP-CACHE-INV-NEXT: s_endpgm
4557 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
4558 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4559 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4560 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4561 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4562 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4563 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4564 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
4565 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
4566 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4568 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
4569 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4570 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4571 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4572 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4573 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4574 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4575 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4576 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
4577 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
4578 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4580 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
4581 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
4582 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4583 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4584 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4585 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
4586 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
4587 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
4588 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
4589 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
4591 ; GFX940-TGSPLIT-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
4592 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
4593 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4594 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4595 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4596 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
4597 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
4598 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4599 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
4600 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
4601 ; GFX940-TGSPLIT-NEXT: s_endpgm
4603 ; GFX11-WGP-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
4604 ; GFX11-WGP: ; %bb.0: ; %entry
4605 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
4606 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
4607 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
4608 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
4609 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
4610 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
4611 ; GFX11-WGP-NEXT: buffer_gl0_inv
4612 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
4613 ; GFX11-WGP-NEXT: s_nop 0
4614 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
4615 ; GFX11-WGP-NEXT: s_endpgm
4617 ; GFX11-CU-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
4618 ; GFX11-CU: ; %bb.0: ; %entry
4619 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
4620 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
4621 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4622 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
4623 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
4624 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
4625 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
4626 ; GFX11-CU-NEXT: s_nop 0
4627 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
4628 ; GFX11-CU-NEXT: s_endpgm
4629 ptr addrspace(1) %out, i32 %in, i32 %old) {
4631 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
4632 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") acquire monotonic
4633 %val0 = extractvalue { i32, i1 } %val, 0
4634 store i32 %val0, ptr addrspace(1) %out, align 4
4638 define amdgpu_kernel void @global_workgroup_release_monotonic_ret_cmpxchg(
4639 ; GFX6-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
4640 ; GFX6: ; %bb.0: ; %entry
4641 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4642 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
4643 ; GFX6-NEXT: s_mov_b32 s6, -1
4644 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4645 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
4646 ; GFX6-NEXT: s_mov_b32 s4, s0
4647 ; GFX6-NEXT: s_mov_b32 s5, s1
4648 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
4649 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4650 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
4651 ; GFX6-NEXT: s_waitcnt vmcnt(0)
4652 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
4653 ; GFX6-NEXT: s_endpgm
4655 ; GFX7-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
4656 ; GFX7: ; %bb.0: ; %entry
4657 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4658 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4659 ; GFX7-NEXT: s_add_u32 s4, s0, 16
4660 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
4661 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
4662 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
4663 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
4664 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
4665 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4666 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4667 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
4668 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
4669 ; GFX7-NEXT: s_waitcnt vmcnt(0)
4670 ; GFX7-NEXT: flat_store_dword v[0:1], v2
4671 ; GFX7-NEXT: s_endpgm
4673 ; GFX10-WGP-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
4674 ; GFX10-WGP: ; %bb.0: ; %entry
4675 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4676 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
4677 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4678 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
4679 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
4680 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4681 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4682 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4683 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
4684 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
4685 ; GFX10-WGP-NEXT: s_endpgm
4687 ; GFX10-CU-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
4688 ; GFX10-CU: ; %bb.0: ; %entry
4689 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4690 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
4691 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4692 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
4693 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
4694 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4695 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4696 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
4697 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
4698 ; GFX10-CU-NEXT: s_endpgm
4700 ; SKIP-CACHE-INV-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
4701 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4702 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4703 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
4704 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
4705 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4706 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
4707 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
4708 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
4709 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
4710 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4711 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
4712 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
4713 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
4714 ; SKIP-CACHE-INV-NEXT: s_endpgm
4716 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
4717 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4718 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4719 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4720 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4721 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4722 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4723 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4724 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
4725 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
4726 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4728 ; GFX90A-TGSPLIT-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
4729 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4730 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4731 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4732 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4733 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4734 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4735 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4736 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4737 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
4738 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4740 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
4741 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
4742 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4743 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4744 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4745 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
4746 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4747 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
4748 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
4749 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
4750 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
4752 ; GFX940-TGSPLIT-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
4753 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
4754 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4755 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4756 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4757 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
4758 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4759 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
4760 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4761 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
4762 ; GFX940-TGSPLIT-NEXT: s_endpgm
4764 ; GFX11-WGP-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
4765 ; GFX11-WGP: ; %bb.0: ; %entry
4766 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
4767 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
4768 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
4769 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
4770 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4771 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4772 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
4773 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
4774 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
4775 ; GFX11-WGP-NEXT: s_nop 0
4776 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
4777 ; GFX11-WGP-NEXT: s_endpgm
4779 ; GFX11-CU-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
4780 ; GFX11-CU: ; %bb.0: ; %entry
4781 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
4782 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
4783 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4784 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
4785 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4786 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
4787 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
4788 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
4789 ; GFX11-CU-NEXT: s_nop 0
4790 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
4791 ; GFX11-CU-NEXT: s_endpgm
4792 ptr addrspace(1) %out, i32 %in, i32 %old) {
4794 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
4795 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") release monotonic
4796 %val0 = extractvalue { i32, i1 } %val, 0
4797 store i32 %val0, ptr addrspace(1) %out, align 4
4801 define amdgpu_kernel void @global_workgroup_acq_rel_monotonic_ret_cmpxchg(
4802 ; GFX6-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
4803 ; GFX6: ; %bb.0: ; %entry
4804 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4805 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
4806 ; GFX6-NEXT: s_mov_b32 s6, -1
4807 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4808 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
4809 ; GFX6-NEXT: s_mov_b32 s4, s0
4810 ; GFX6-NEXT: s_mov_b32 s5, s1
4811 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
4812 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4813 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
4814 ; GFX6-NEXT: s_waitcnt vmcnt(0)
4815 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
4816 ; GFX6-NEXT: s_endpgm
4818 ; GFX7-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
4819 ; GFX7: ; %bb.0: ; %entry
4820 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4821 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4822 ; GFX7-NEXT: s_add_u32 s4, s0, 16
4823 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
4824 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
4825 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
4826 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
4827 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
4828 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4829 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4830 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
4831 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
4832 ; GFX7-NEXT: s_waitcnt vmcnt(0)
4833 ; GFX7-NEXT: flat_store_dword v[0:1], v2
4834 ; GFX7-NEXT: s_endpgm
4836 ; GFX10-WGP-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
4837 ; GFX10-WGP: ; %bb.0: ; %entry
4838 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4839 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
4840 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4841 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
4842 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
4843 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4844 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4845 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4846 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
4847 ; GFX10-WGP-NEXT: buffer_gl0_inv
4848 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
4849 ; GFX10-WGP-NEXT: s_endpgm
4851 ; GFX10-CU-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
4852 ; GFX10-CU: ; %bb.0: ; %entry
4853 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4854 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
4855 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4856 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
4857 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
4858 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4859 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4860 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
4861 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
4862 ; GFX10-CU-NEXT: s_endpgm
4864 ; SKIP-CACHE-INV-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
4865 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4866 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4867 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
4868 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
4869 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4870 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
4871 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
4872 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
4873 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
4874 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4875 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
4876 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
4877 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
4878 ; SKIP-CACHE-INV-NEXT: s_endpgm
4880 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
4881 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4882 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4883 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4884 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4885 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4886 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4887 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4888 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
4889 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
4890 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4892 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
4893 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4894 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4895 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4896 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4897 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4898 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4899 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4900 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4901 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
4902 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
4903 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4905 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
4906 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
4907 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4908 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4909 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4910 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
4911 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4912 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
4913 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
4914 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
4915 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
4917 ; GFX940-TGSPLIT-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
4918 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
4919 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4920 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4921 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4922 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
4923 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4924 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
4925 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4926 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
4927 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
4928 ; GFX940-TGSPLIT-NEXT: s_endpgm
4930 ; GFX11-WGP-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
4931 ; GFX11-WGP: ; %bb.0: ; %entry
4932 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
4933 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
4934 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
4935 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
4936 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4937 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4938 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
4939 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
4940 ; GFX11-WGP-NEXT: buffer_gl0_inv
4941 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
4942 ; GFX11-WGP-NEXT: s_nop 0
4943 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
4944 ; GFX11-WGP-NEXT: s_endpgm
4946 ; GFX11-CU-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
4947 ; GFX11-CU: ; %bb.0: ; %entry
4948 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
4949 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
4950 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4951 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
4952 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4953 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
4954 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
4955 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
4956 ; GFX11-CU-NEXT: s_nop 0
4957 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
4958 ; GFX11-CU-NEXT: s_endpgm
4959 ptr addrspace(1) %out, i32 %in, i32 %old) {
4961 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
4962 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") acq_rel monotonic
4963 %val0 = extractvalue { i32, i1 } %val, 0
4964 store i32 %val0, ptr addrspace(1) %out, align 4
4968 define amdgpu_kernel void @global_workgroup_seq_cst_monotonic_ret_cmpxchg(
4969 ; GFX6-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
4970 ; GFX6: ; %bb.0: ; %entry
4971 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4972 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
4973 ; GFX6-NEXT: s_mov_b32 s6, -1
4974 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4975 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
4976 ; GFX6-NEXT: s_mov_b32 s4, s0
4977 ; GFX6-NEXT: s_mov_b32 s5, s1
4978 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
4979 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4980 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
4981 ; GFX6-NEXT: s_waitcnt vmcnt(0)
4982 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
4983 ; GFX6-NEXT: s_endpgm
4985 ; GFX7-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
4986 ; GFX7: ; %bb.0: ; %entry
4987 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4988 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4989 ; GFX7-NEXT: s_add_u32 s4, s0, 16
4990 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
4991 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
4992 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
4993 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
4994 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
4995 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4996 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4997 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
4998 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
4999 ; GFX7-NEXT: s_waitcnt vmcnt(0)
5000 ; GFX7-NEXT: flat_store_dword v[0:1], v2
5001 ; GFX7-NEXT: s_endpgm
5003 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
5004 ; GFX10-WGP: ; %bb.0: ; %entry
5005 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5006 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
5007 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5008 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
5009 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
5010 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5011 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5012 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
5013 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
5014 ; GFX10-WGP-NEXT: buffer_gl0_inv
5015 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
5016 ; GFX10-WGP-NEXT: s_endpgm
5018 ; GFX10-CU-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
5019 ; GFX10-CU: ; %bb.0: ; %entry
5020 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5021 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
5022 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5023 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
5024 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
5025 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5026 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
5027 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
5028 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
5029 ; GFX10-CU-NEXT: s_endpgm
5031 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
5032 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5033 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5034 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
5035 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
5036 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5037 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
5038 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
5039 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
5040 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
5041 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5042 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
5043 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
5044 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
5045 ; SKIP-CACHE-INV-NEXT: s_endpgm
5047 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
5048 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5049 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5050 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
5051 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5052 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
5053 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5054 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
5055 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
5056 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
5057 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5059 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
5060 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5061 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5062 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
5063 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5064 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
5065 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5066 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
5067 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5068 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
5069 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
5070 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5072 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
5073 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
5074 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5075 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
5076 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5077 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
5078 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5079 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
5080 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
5081 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
5082 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
5084 ; GFX940-TGSPLIT-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
5085 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
5086 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5087 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
5088 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5089 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
5090 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5091 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
5092 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5093 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
5094 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
5095 ; GFX940-TGSPLIT-NEXT: s_endpgm
5097 ; GFX11-WGP-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
5098 ; GFX11-WGP: ; %bb.0: ; %entry
5099 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
5100 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
5101 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
5102 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
5103 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5104 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5105 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
5106 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
5107 ; GFX11-WGP-NEXT: buffer_gl0_inv
5108 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
5109 ; GFX11-WGP-NEXT: s_nop 0
5110 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
5111 ; GFX11-WGP-NEXT: s_endpgm
5113 ; GFX11-CU-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
5114 ; GFX11-CU: ; %bb.0: ; %entry
5115 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
5116 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
5117 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5118 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
5119 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5120 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
5121 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
5122 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
5123 ; GFX11-CU-NEXT: s_nop 0
5124 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
5125 ; GFX11-CU-NEXT: s_endpgm
5126 ptr addrspace(1) %out, i32 %in, i32 %old) {
5128 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
5129 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") seq_cst monotonic
5130 %val0 = extractvalue { i32, i1 } %val, 0
5131 store i32 %val0, ptr addrspace(1) %out, align 4
5135 define amdgpu_kernel void @global_workgroup_monotonic_acquire_ret_cmpxchg(
5136 ; GFX6-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
5137 ; GFX6: ; %bb.0: ; %entry
5138 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5139 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
5140 ; GFX6-NEXT: s_mov_b32 s6, -1
5141 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5142 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
5143 ; GFX6-NEXT: s_mov_b32 s4, s0
5144 ; GFX6-NEXT: s_mov_b32 s5, s1
5145 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
5146 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
5147 ; GFX6-NEXT: s_waitcnt vmcnt(0)
5148 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
5149 ; GFX6-NEXT: s_endpgm
5151 ; GFX7-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
5152 ; GFX7: ; %bb.0: ; %entry
5153 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5154 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5155 ; GFX7-NEXT: s_add_u32 s4, s0, 16
5156 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
5157 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
5158 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
5159 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
5160 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
5161 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5162 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
5163 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
5164 ; GFX7-NEXT: s_waitcnt vmcnt(0)
5165 ; GFX7-NEXT: flat_store_dword v[0:1], v2
5166 ; GFX7-NEXT: s_endpgm
5168 ; GFX10-WGP-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
5169 ; GFX10-WGP: ; %bb.0: ; %entry
5170 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5171 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
5172 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5173 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
5174 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
5175 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
5176 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
5177 ; GFX10-WGP-NEXT: buffer_gl0_inv
5178 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
5179 ; GFX10-WGP-NEXT: s_endpgm
5181 ; GFX10-CU-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
5182 ; GFX10-CU: ; %bb.0: ; %entry
5183 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5184 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
5185 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5186 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
5187 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
5188 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
5189 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
5190 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
5191 ; GFX10-CU-NEXT: s_endpgm
5193 ; SKIP-CACHE-INV-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
5194 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5195 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5196 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
5197 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
5198 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5199 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
5200 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
5201 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
5202 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
5203 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
5204 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
5205 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
5206 ; SKIP-CACHE-INV-NEXT: s_endpgm
5208 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
5209 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5210 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5211 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
5212 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5213 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
5214 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
5215 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
5216 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
5217 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5219 ; GFX90A-TGSPLIT-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
5220 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5221 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5222 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
5223 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5224 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
5225 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
5226 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5227 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
5228 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
5229 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5231 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
5232 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
5233 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5234 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
5235 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5236 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
5237 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
5238 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
5239 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
5240 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
5242 ; GFX940-TGSPLIT-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
5243 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
5244 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5245 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
5246 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5247 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
5248 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
5249 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5250 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
5251 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
5252 ; GFX940-TGSPLIT-NEXT: s_endpgm
5254 ; GFX11-WGP-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
5255 ; GFX11-WGP: ; %bb.0: ; %entry
5256 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
5257 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
5258 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
5259 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
5260 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
5261 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
5262 ; GFX11-WGP-NEXT: buffer_gl0_inv
5263 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
5264 ; GFX11-WGP-NEXT: s_nop 0
5265 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
5266 ; GFX11-WGP-NEXT: s_endpgm
5268 ; GFX11-CU-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
5269 ; GFX11-CU: ; %bb.0: ; %entry
5270 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
5271 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
5272 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5273 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
5274 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
5275 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
5276 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
5277 ; GFX11-CU-NEXT: s_nop 0
5278 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
5279 ; GFX11-CU-NEXT: s_endpgm
5280 ptr addrspace(1) %out, i32 %in, i32 %old) {
5282 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
5283 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") monotonic acquire
5284 %val0 = extractvalue { i32, i1 } %val, 0
5285 store i32 %val0, ptr addrspace(1) %out, align 4
5289 define amdgpu_kernel void @global_workgroup_acquire_acquire_ret_cmpxchg(
5290 ; GFX6-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
5291 ; GFX6: ; %bb.0: ; %entry
5292 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5293 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
5294 ; GFX6-NEXT: s_mov_b32 s6, -1
5295 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5296 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
5297 ; GFX6-NEXT: s_mov_b32 s4, s0
5298 ; GFX6-NEXT: s_mov_b32 s5, s1
5299 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
5300 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
5301 ; GFX6-NEXT: s_waitcnt vmcnt(0)
5302 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
5303 ; GFX6-NEXT: s_endpgm
5305 ; GFX7-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
5306 ; GFX7: ; %bb.0: ; %entry
5307 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5308 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5309 ; GFX7-NEXT: s_add_u32 s4, s0, 16
5310 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
5311 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
5312 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
5313 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
5314 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
5315 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5316 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
5317 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
5318 ; GFX7-NEXT: s_waitcnt vmcnt(0)
5319 ; GFX7-NEXT: flat_store_dword v[0:1], v2
5320 ; GFX7-NEXT: s_endpgm
5322 ; GFX10-WGP-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
5323 ; GFX10-WGP: ; %bb.0: ; %entry
5324 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5325 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
5326 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5327 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
5328 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
5329 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
5330 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
5331 ; GFX10-WGP-NEXT: buffer_gl0_inv
5332 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
5333 ; GFX10-WGP-NEXT: s_endpgm
5335 ; GFX10-CU-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
5336 ; GFX10-CU: ; %bb.0: ; %entry
5337 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5338 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
5339 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5340 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
5341 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
5342 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
5343 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
5344 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
5345 ; GFX10-CU-NEXT: s_endpgm
5347 ; SKIP-CACHE-INV-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
5348 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5349 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5350 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
5351 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
5352 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5353 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
5354 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
5355 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
5356 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
5357 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
5358 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
5359 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
5360 ; SKIP-CACHE-INV-NEXT: s_endpgm
5362 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
5363 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5364 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5365 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
5366 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5367 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
5368 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
5369 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
5370 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
5371 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5373 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
5374 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5375 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5376 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
5377 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5378 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
5379 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
5380 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5381 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
5382 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
5383 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5385 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
5386 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
5387 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5388 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
5389 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5390 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
5391 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
5392 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
5393 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
5394 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
5396 ; GFX940-TGSPLIT-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
5397 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
5398 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5399 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
5400 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5401 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
5402 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
5403 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5404 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
5405 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
5406 ; GFX940-TGSPLIT-NEXT: s_endpgm
5408 ; GFX11-WGP-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
5409 ; GFX11-WGP: ; %bb.0: ; %entry
5410 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
5411 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
5412 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
5413 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
5414 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
5415 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
5416 ; GFX11-WGP-NEXT: buffer_gl0_inv
5417 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
5418 ; GFX11-WGP-NEXT: s_nop 0
5419 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
5420 ; GFX11-WGP-NEXT: s_endpgm
5422 ; GFX11-CU-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
5423 ; GFX11-CU: ; %bb.0: ; %entry
5424 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
5425 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
5426 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5427 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
5428 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
5429 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
5430 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
5431 ; GFX11-CU-NEXT: s_nop 0
5432 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
5433 ; GFX11-CU-NEXT: s_endpgm
5434 ptr addrspace(1) %out, i32 %in, i32 %old) {
5436 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
5437 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") acquire acquire
5438 %val0 = extractvalue { i32, i1 } %val, 0
5439 store i32 %val0, ptr addrspace(1) %out, align 4
5443 define amdgpu_kernel void @global_workgroup_release_acquire_ret_cmpxchg(
5444 ; GFX6-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
5445 ; GFX6: ; %bb.0: ; %entry
5446 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5447 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
5448 ; GFX6-NEXT: s_mov_b32 s6, -1
5449 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5450 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
5451 ; GFX6-NEXT: s_mov_b32 s4, s0
5452 ; GFX6-NEXT: s_mov_b32 s5, s1
5453 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
5454 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5455 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
5456 ; GFX6-NEXT: s_waitcnt vmcnt(0)
5457 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
5458 ; GFX6-NEXT: s_endpgm
5460 ; GFX7-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
5461 ; GFX7: ; %bb.0: ; %entry
5462 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5463 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5464 ; GFX7-NEXT: s_add_u32 s4, s0, 16
5465 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
5466 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
5467 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
5468 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
5469 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
5470 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5471 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5472 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
5473 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
5474 ; GFX7-NEXT: s_waitcnt vmcnt(0)
5475 ; GFX7-NEXT: flat_store_dword v[0:1], v2
5476 ; GFX7-NEXT: s_endpgm
5478 ; GFX10-WGP-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
5479 ; GFX10-WGP: ; %bb.0: ; %entry
5480 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5481 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
5482 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5483 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
5484 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
5485 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5486 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5487 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
5488 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
5489 ; GFX10-WGP-NEXT: buffer_gl0_inv
5490 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
5491 ; GFX10-WGP-NEXT: s_endpgm
5493 ; GFX10-CU-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
5494 ; GFX10-CU: ; %bb.0: ; %entry
5495 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5496 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
5497 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5498 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
5499 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
5500 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5501 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
5502 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
5503 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
5504 ; GFX10-CU-NEXT: s_endpgm
5506 ; SKIP-CACHE-INV-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
5507 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5508 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5509 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
5510 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
5511 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5512 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
5513 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
5514 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
5515 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
5516 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5517 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
5518 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
5519 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
5520 ; SKIP-CACHE-INV-NEXT: s_endpgm
5522 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
5523 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5524 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5525 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
5526 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5527 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
5528 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5529 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
5530 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
5531 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
5532 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5534 ; GFX90A-TGSPLIT-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
5535 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5536 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5537 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
5538 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5539 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
5540 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5541 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
5542 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5543 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
5544 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
5545 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5547 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
5548 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
5549 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5550 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
5551 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5552 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
5553 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5554 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
5555 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
5556 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
5557 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
5559 ; GFX940-TGSPLIT-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
5560 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
5561 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5562 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
5563 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5564 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
5565 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5566 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
5567 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5568 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
5569 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
5570 ; GFX940-TGSPLIT-NEXT: s_endpgm
5572 ; GFX11-WGP-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
5573 ; GFX11-WGP: ; %bb.0: ; %entry
5574 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
5575 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
5576 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
5577 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
5578 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5579 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5580 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
5581 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
5582 ; GFX11-WGP-NEXT: buffer_gl0_inv
5583 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
5584 ; GFX11-WGP-NEXT: s_nop 0
5585 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
5586 ; GFX11-WGP-NEXT: s_endpgm
5588 ; GFX11-CU-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
5589 ; GFX11-CU: ; %bb.0: ; %entry
5590 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
5591 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
5592 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5593 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
5594 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5595 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
5596 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
5597 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
5598 ; GFX11-CU-NEXT: s_nop 0
5599 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
5600 ; GFX11-CU-NEXT: s_endpgm
5601 ptr addrspace(1) %out, i32 %in, i32 %old) {
5603 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
5604 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") release acquire
5605 %val0 = extractvalue { i32, i1 } %val, 0
5606 store i32 %val0, ptr addrspace(1) %out, align 4
5610 define amdgpu_kernel void @global_workgroup_acq_rel_acquire_ret_cmpxchg(
5611 ; GFX6-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
5612 ; GFX6: ; %bb.0: ; %entry
5613 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5614 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
5615 ; GFX6-NEXT: s_mov_b32 s6, -1
5616 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5617 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
5618 ; GFX6-NEXT: s_mov_b32 s4, s0
5619 ; GFX6-NEXT: s_mov_b32 s5, s1
5620 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
5621 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5622 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
5623 ; GFX6-NEXT: s_waitcnt vmcnt(0)
5624 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
5625 ; GFX6-NEXT: s_endpgm
5627 ; GFX7-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
5628 ; GFX7: ; %bb.0: ; %entry
5629 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5630 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5631 ; GFX7-NEXT: s_add_u32 s4, s0, 16
5632 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
5633 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
5634 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
5635 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
5636 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
5637 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5638 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5639 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
5640 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
5641 ; GFX7-NEXT: s_waitcnt vmcnt(0)
5642 ; GFX7-NEXT: flat_store_dword v[0:1], v2
5643 ; GFX7-NEXT: s_endpgm
5645 ; GFX10-WGP-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
5646 ; GFX10-WGP: ; %bb.0: ; %entry
5647 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5648 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
5649 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5650 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
5651 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
5652 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5653 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5654 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
5655 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
5656 ; GFX10-WGP-NEXT: buffer_gl0_inv
5657 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
5658 ; GFX10-WGP-NEXT: s_endpgm
5660 ; GFX10-CU-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
5661 ; GFX10-CU: ; %bb.0: ; %entry
5662 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5663 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
5664 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5665 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
5666 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
5667 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5668 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
5669 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
5670 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
5671 ; GFX10-CU-NEXT: s_endpgm
5673 ; SKIP-CACHE-INV-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
5674 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5675 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5676 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
5677 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
5678 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5679 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
5680 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
5681 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
5682 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
5683 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5684 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
5685 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
5686 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
5687 ; SKIP-CACHE-INV-NEXT: s_endpgm
5689 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
5690 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5691 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5692 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
5693 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5694 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
5695 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5696 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
5697 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
5698 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
5699 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5701 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
5702 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5703 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5704 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
5705 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5706 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
5707 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5708 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
5709 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5710 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
5711 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
5712 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5714 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
5715 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
5716 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5717 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
5718 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5719 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
5720 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5721 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
5722 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
5723 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
5724 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
5726 ; GFX940-TGSPLIT-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
5727 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
5728 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5729 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
5730 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5731 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
5732 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5733 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
5734 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5735 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
5736 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
5737 ; GFX940-TGSPLIT-NEXT: s_endpgm
5739 ; GFX11-WGP-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
5740 ; GFX11-WGP: ; %bb.0: ; %entry
5741 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
5742 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
5743 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
5744 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
5745 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5746 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5747 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
5748 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
5749 ; GFX11-WGP-NEXT: buffer_gl0_inv
5750 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
5751 ; GFX11-WGP-NEXT: s_nop 0
5752 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
5753 ; GFX11-WGP-NEXT: s_endpgm
5755 ; GFX11-CU-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
5756 ; GFX11-CU: ; %bb.0: ; %entry
5757 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
5758 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
5759 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5760 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
5761 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5762 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
5763 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
5764 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
5765 ; GFX11-CU-NEXT: s_nop 0
5766 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
5767 ; GFX11-CU-NEXT: s_endpgm
5768 ptr addrspace(1) %out, i32 %in, i32 %old) {
5770 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
5771 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") acq_rel acquire
5772 %val0 = extractvalue { i32, i1 } %val, 0
5773 store i32 %val0, ptr addrspace(1) %out, align 4
5777 define amdgpu_kernel void @global_workgroup_seq_cst_acquire_ret_cmpxchg(
5778 ; GFX6-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
5779 ; GFX6: ; %bb.0: ; %entry
5780 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5781 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
5782 ; GFX6-NEXT: s_mov_b32 s6, -1
5783 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5784 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
5785 ; GFX6-NEXT: s_mov_b32 s4, s0
5786 ; GFX6-NEXT: s_mov_b32 s5, s1
5787 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
5788 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5789 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
5790 ; GFX6-NEXT: s_waitcnt vmcnt(0)
5791 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
5792 ; GFX6-NEXT: s_endpgm
5794 ; GFX7-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
5795 ; GFX7: ; %bb.0: ; %entry
5796 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5797 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5798 ; GFX7-NEXT: s_add_u32 s4, s0, 16
5799 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
5800 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
5801 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
5802 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
5803 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
5804 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5805 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5806 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
5807 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
5808 ; GFX7-NEXT: s_waitcnt vmcnt(0)
5809 ; GFX7-NEXT: flat_store_dword v[0:1], v2
5810 ; GFX7-NEXT: s_endpgm
5812 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
5813 ; GFX10-WGP: ; %bb.0: ; %entry
5814 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5815 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
5816 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5817 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
5818 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
5819 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5820 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5821 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
5822 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
5823 ; GFX10-WGP-NEXT: buffer_gl0_inv
5824 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
5825 ; GFX10-WGP-NEXT: s_endpgm
5827 ; GFX10-CU-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
5828 ; GFX10-CU: ; %bb.0: ; %entry
5829 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5830 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
5831 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5832 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
5833 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
5834 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5835 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
5836 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
5837 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
5838 ; GFX10-CU-NEXT: s_endpgm
5840 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
5841 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5842 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5843 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
5844 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
5845 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5846 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
5847 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
5848 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
5849 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
5850 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5851 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
5852 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
5853 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
5854 ; SKIP-CACHE-INV-NEXT: s_endpgm
5856 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
5857 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5858 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5859 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
5860 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5861 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
5862 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5863 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
5864 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
5865 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
5866 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5868 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
5869 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5870 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5871 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
5872 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5873 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
5874 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5875 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
5876 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5877 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
5878 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
5879 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5881 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
5882 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
5883 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5884 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
5885 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5886 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
5887 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5888 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
5889 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
5890 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
5891 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
5893 ; GFX940-TGSPLIT-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
5894 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
5895 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5896 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
5897 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5898 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
5899 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5900 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
5901 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5902 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
5903 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
5904 ; GFX940-TGSPLIT-NEXT: s_endpgm
5906 ; GFX11-WGP-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
5907 ; GFX11-WGP: ; %bb.0: ; %entry
5908 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
5909 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
5910 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
5911 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
5912 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5913 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5914 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
5915 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
5916 ; GFX11-WGP-NEXT: buffer_gl0_inv
5917 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
5918 ; GFX11-WGP-NEXT: s_nop 0
5919 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
5920 ; GFX11-WGP-NEXT: s_endpgm
5922 ; GFX11-CU-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
5923 ; GFX11-CU: ; %bb.0: ; %entry
5924 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
5925 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
5926 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5927 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
5928 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5929 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
5930 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
5931 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
5932 ; GFX11-CU-NEXT: s_nop 0
5933 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
5934 ; GFX11-CU-NEXT: s_endpgm
5935 ptr addrspace(1) %out, i32 %in, i32 %old) {
5937 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
5938 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") seq_cst acquire
5939 %val0 = extractvalue { i32, i1 } %val, 0
5940 store i32 %val0, ptr addrspace(1) %out, align 4
5944 define amdgpu_kernel void @global_workgroup_monotonic_seq_cst_ret_cmpxchg(
5945 ; GFX6-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
5946 ; GFX6: ; %bb.0: ; %entry
5947 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5948 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
5949 ; GFX6-NEXT: s_mov_b32 s6, -1
5950 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5951 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
5952 ; GFX6-NEXT: s_mov_b32 s4, s0
5953 ; GFX6-NEXT: s_mov_b32 s5, s1
5954 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
5955 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5956 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
5957 ; GFX6-NEXT: s_waitcnt vmcnt(0)
5958 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
5959 ; GFX6-NEXT: s_endpgm
5961 ; GFX7-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
5962 ; GFX7: ; %bb.0: ; %entry
5963 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5964 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5965 ; GFX7-NEXT: s_add_u32 s4, s0, 16
5966 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
5967 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
5968 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
5969 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
5970 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
5971 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5972 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5973 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
5974 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
5975 ; GFX7-NEXT: s_waitcnt vmcnt(0)
5976 ; GFX7-NEXT: flat_store_dword v[0:1], v2
5977 ; GFX7-NEXT: s_endpgm
5979 ; GFX10-WGP-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
5980 ; GFX10-WGP: ; %bb.0: ; %entry
5981 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5982 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
5983 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5984 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
5985 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
5986 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5987 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5988 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
5989 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
5990 ; GFX10-WGP-NEXT: buffer_gl0_inv
5991 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
5992 ; GFX10-WGP-NEXT: s_endpgm
5994 ; GFX10-CU-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
5995 ; GFX10-CU: ; %bb.0: ; %entry
5996 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5997 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
5998 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5999 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
6000 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
6001 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6002 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
6003 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
6004 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
6005 ; GFX10-CU-NEXT: s_endpgm
6007 ; SKIP-CACHE-INV-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
6008 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6009 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6010 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
6011 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
6012 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6013 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
6014 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
6015 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
6016 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
6017 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6018 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
6019 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
6020 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
6021 ; SKIP-CACHE-INV-NEXT: s_endpgm
6023 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
6024 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6025 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6026 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6027 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6028 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6029 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6030 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
6031 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
6032 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
6033 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6035 ; GFX90A-TGSPLIT-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
6036 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6037 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6038 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6039 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6040 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6041 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6042 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
6043 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6044 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
6045 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
6046 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6048 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
6049 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
6050 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6051 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6052 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6053 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
6054 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6055 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
6056 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
6057 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
6058 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
6060 ; GFX940-TGSPLIT-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
6061 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
6062 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6063 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6064 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6065 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
6066 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6067 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
6068 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6069 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
6070 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
6071 ; GFX940-TGSPLIT-NEXT: s_endpgm
6073 ; GFX11-WGP-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
6074 ; GFX11-WGP: ; %bb.0: ; %entry
6075 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
6076 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
6077 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
6078 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
6079 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6080 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6081 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
6082 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
6083 ; GFX11-WGP-NEXT: buffer_gl0_inv
6084 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
6085 ; GFX11-WGP-NEXT: s_nop 0
6086 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
6087 ; GFX11-WGP-NEXT: s_endpgm
6089 ; GFX11-CU-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
6090 ; GFX11-CU: ; %bb.0: ; %entry
6091 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
6092 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
6093 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6094 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
6095 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6096 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
6097 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
6098 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
6099 ; GFX11-CU-NEXT: s_nop 0
6100 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
6101 ; GFX11-CU-NEXT: s_endpgm
6102 ptr addrspace(1) %out, i32 %in, i32 %old) {
6104 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
6105 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") monotonic seq_cst
6106 %val0 = extractvalue { i32, i1 } %val, 0
6107 store i32 %val0, ptr addrspace(1) %out, align 4
6111 define amdgpu_kernel void @global_workgroup_acquire_seq_cst_ret_cmpxchg(
6112 ; GFX6-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
6113 ; GFX6: ; %bb.0: ; %entry
6114 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6115 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
6116 ; GFX6-NEXT: s_mov_b32 s6, -1
6117 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6118 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
6119 ; GFX6-NEXT: s_mov_b32 s4, s0
6120 ; GFX6-NEXT: s_mov_b32 s5, s1
6121 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
6122 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6123 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
6124 ; GFX6-NEXT: s_waitcnt vmcnt(0)
6125 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
6126 ; GFX6-NEXT: s_endpgm
6128 ; GFX7-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
6129 ; GFX7: ; %bb.0: ; %entry
6130 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6131 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6132 ; GFX7-NEXT: s_add_u32 s4, s0, 16
6133 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
6134 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
6135 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
6136 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
6137 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
6138 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6139 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
6140 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
6141 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
6142 ; GFX7-NEXT: s_waitcnt vmcnt(0)
6143 ; GFX7-NEXT: flat_store_dword v[0:1], v2
6144 ; GFX7-NEXT: s_endpgm
6146 ; GFX10-WGP-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
6147 ; GFX10-WGP: ; %bb.0: ; %entry
6148 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6149 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
6150 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6151 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
6152 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
6153 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6154 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6155 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
6156 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
6157 ; GFX10-WGP-NEXT: buffer_gl0_inv
6158 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
6159 ; GFX10-WGP-NEXT: s_endpgm
6161 ; GFX10-CU-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
6162 ; GFX10-CU: ; %bb.0: ; %entry
6163 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6164 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
6165 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6166 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
6167 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
6168 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6169 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
6170 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
6171 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
6172 ; GFX10-CU-NEXT: s_endpgm
6174 ; SKIP-CACHE-INV-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
6175 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6176 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6177 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
6178 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
6179 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6180 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
6181 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
6182 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
6183 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
6184 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6185 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
6186 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
6187 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
6188 ; SKIP-CACHE-INV-NEXT: s_endpgm
6190 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
6191 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6192 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6193 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6194 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6195 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6196 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6197 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
6198 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
6199 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
6200 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6202 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
6203 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6204 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6205 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6206 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6207 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6208 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6209 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
6210 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6211 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
6212 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
6213 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6215 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
6216 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
6217 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6218 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6219 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6220 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
6221 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6222 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
6223 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
6224 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
6225 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
6227 ; GFX940-TGSPLIT-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
6228 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
6229 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6230 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6231 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6232 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
6233 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6234 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
6235 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6236 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
6237 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
6238 ; GFX940-TGSPLIT-NEXT: s_endpgm
6240 ; GFX11-WGP-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
6241 ; GFX11-WGP: ; %bb.0: ; %entry
6242 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
6243 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
6244 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
6245 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
6246 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6247 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6248 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
6249 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
6250 ; GFX11-WGP-NEXT: buffer_gl0_inv
6251 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
6252 ; GFX11-WGP-NEXT: s_nop 0
6253 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
6254 ; GFX11-WGP-NEXT: s_endpgm
6256 ; GFX11-CU-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
6257 ; GFX11-CU: ; %bb.0: ; %entry
6258 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
6259 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
6260 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6261 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
6262 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6263 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
6264 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
6265 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
6266 ; GFX11-CU-NEXT: s_nop 0
6267 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
6268 ; GFX11-CU-NEXT: s_endpgm
6269 ptr addrspace(1) %out, i32 %in, i32 %old) {
6271 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
6272 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") acquire seq_cst
6273 %val0 = extractvalue { i32, i1 } %val, 0
6274 store i32 %val0, ptr addrspace(1) %out, align 4
6278 define amdgpu_kernel void @global_workgroup_release_seq_cst_ret_cmpxchg(
6279 ; GFX6-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
6280 ; GFX6: ; %bb.0: ; %entry
6281 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6282 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
6283 ; GFX6-NEXT: s_mov_b32 s6, -1
6284 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6285 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
6286 ; GFX6-NEXT: s_mov_b32 s4, s0
6287 ; GFX6-NEXT: s_mov_b32 s5, s1
6288 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
6289 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6290 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
6291 ; GFX6-NEXT: s_waitcnt vmcnt(0)
6292 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
6293 ; GFX6-NEXT: s_endpgm
6295 ; GFX7-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
6296 ; GFX7: ; %bb.0: ; %entry
6297 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6298 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6299 ; GFX7-NEXT: s_add_u32 s4, s0, 16
6300 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
6301 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
6302 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
6303 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
6304 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
6305 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6306 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
6307 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
6308 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
6309 ; GFX7-NEXT: s_waitcnt vmcnt(0)
6310 ; GFX7-NEXT: flat_store_dword v[0:1], v2
6311 ; GFX7-NEXT: s_endpgm
6313 ; GFX10-WGP-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
6314 ; GFX10-WGP: ; %bb.0: ; %entry
6315 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6316 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
6317 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6318 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
6319 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
6320 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6321 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6322 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
6323 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
6324 ; GFX10-WGP-NEXT: buffer_gl0_inv
6325 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
6326 ; GFX10-WGP-NEXT: s_endpgm
6328 ; GFX10-CU-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
6329 ; GFX10-CU: ; %bb.0: ; %entry
6330 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6331 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
6332 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6333 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
6334 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
6335 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6336 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
6337 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
6338 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
6339 ; GFX10-CU-NEXT: s_endpgm
6341 ; SKIP-CACHE-INV-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
6342 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6343 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6344 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
6345 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
6346 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6347 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
6348 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
6349 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
6350 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
6351 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6352 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
6353 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
6354 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
6355 ; SKIP-CACHE-INV-NEXT: s_endpgm
6357 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
6358 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6359 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6360 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6361 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6362 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6363 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6364 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
6365 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
6366 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
6367 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6369 ; GFX90A-TGSPLIT-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
6370 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6371 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6372 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6373 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6374 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6375 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6376 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
6377 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6378 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
6379 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
6380 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6382 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
6383 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
6384 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6385 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6386 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6387 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
6388 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6389 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
6390 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
6391 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
6392 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
6394 ; GFX940-TGSPLIT-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
6395 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
6396 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6397 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6398 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6399 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
6400 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6401 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
6402 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6403 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
6404 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
6405 ; GFX940-TGSPLIT-NEXT: s_endpgm
6407 ; GFX11-WGP-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
6408 ; GFX11-WGP: ; %bb.0: ; %entry
6409 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
6410 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
6411 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
6412 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
6413 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6414 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6415 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
6416 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
6417 ; GFX11-WGP-NEXT: buffer_gl0_inv
6418 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
6419 ; GFX11-WGP-NEXT: s_nop 0
6420 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
6421 ; GFX11-WGP-NEXT: s_endpgm
6423 ; GFX11-CU-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
6424 ; GFX11-CU: ; %bb.0: ; %entry
6425 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
6426 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
6427 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6428 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
6429 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6430 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
6431 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
6432 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
6433 ; GFX11-CU-NEXT: s_nop 0
6434 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
6435 ; GFX11-CU-NEXT: s_endpgm
6436 ptr addrspace(1) %out, i32 %in, i32 %old) {
6438 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
6439 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") release seq_cst
6440 %val0 = extractvalue { i32, i1 } %val, 0
6441 store i32 %val0, ptr addrspace(1) %out, align 4
6445 define amdgpu_kernel void @global_workgroup_acq_rel_seq_cst_ret_cmpxchg(
6446 ; GFX6-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
6447 ; GFX6: ; %bb.0: ; %entry
6448 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6449 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
6450 ; GFX6-NEXT: s_mov_b32 s6, -1
6451 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6452 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
6453 ; GFX6-NEXT: s_mov_b32 s4, s0
6454 ; GFX6-NEXT: s_mov_b32 s5, s1
6455 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
6456 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6457 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
6458 ; GFX6-NEXT: s_waitcnt vmcnt(0)
6459 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
6460 ; GFX6-NEXT: s_endpgm
6462 ; GFX7-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
6463 ; GFX7: ; %bb.0: ; %entry
6464 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6465 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6466 ; GFX7-NEXT: s_add_u32 s4, s0, 16
6467 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
6468 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
6469 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
6470 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
6471 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
6472 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6473 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
6474 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
6475 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
6476 ; GFX7-NEXT: s_waitcnt vmcnt(0)
6477 ; GFX7-NEXT: flat_store_dword v[0:1], v2
6478 ; GFX7-NEXT: s_endpgm
6480 ; GFX10-WGP-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
6481 ; GFX10-WGP: ; %bb.0: ; %entry
6482 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6483 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
6484 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6485 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
6486 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
6487 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6488 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6489 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
6490 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
6491 ; GFX10-WGP-NEXT: buffer_gl0_inv
6492 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
6493 ; GFX10-WGP-NEXT: s_endpgm
6495 ; GFX10-CU-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
6496 ; GFX10-CU: ; %bb.0: ; %entry
6497 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6498 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
6499 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6500 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
6501 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
6502 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6503 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
6504 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
6505 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
6506 ; GFX10-CU-NEXT: s_endpgm
6508 ; SKIP-CACHE-INV-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
6509 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6510 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6511 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
6512 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
6513 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6514 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
6515 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
6516 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
6517 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
6518 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6519 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
6520 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
6521 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
6522 ; SKIP-CACHE-INV-NEXT: s_endpgm
6524 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
6525 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6526 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6527 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6528 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6529 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6530 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6531 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
6532 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
6533 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
6534 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6536 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
6537 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6538 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6539 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6540 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6541 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6542 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6543 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
6544 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6545 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
6546 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
6547 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6549 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
6550 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
6551 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6552 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6553 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6554 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
6555 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6556 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
6557 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
6558 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
6559 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
6561 ; GFX940-TGSPLIT-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
6562 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
6563 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6564 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6565 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6566 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
6567 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6568 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
6569 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6570 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
6571 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
6572 ; GFX940-TGSPLIT-NEXT: s_endpgm
6574 ; GFX11-WGP-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
6575 ; GFX11-WGP: ; %bb.0: ; %entry
6576 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
6577 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
6578 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
6579 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
6580 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6581 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6582 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
6583 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
6584 ; GFX11-WGP-NEXT: buffer_gl0_inv
6585 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
6586 ; GFX11-WGP-NEXT: s_nop 0
6587 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
6588 ; GFX11-WGP-NEXT: s_endpgm
6590 ; GFX11-CU-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
6591 ; GFX11-CU: ; %bb.0: ; %entry
6592 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
6593 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
6594 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6595 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
6596 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6597 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
6598 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
6599 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
6600 ; GFX11-CU-NEXT: s_nop 0
6601 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
6602 ; GFX11-CU-NEXT: s_endpgm
6603 ptr addrspace(1) %out, i32 %in, i32 %old) {
6605 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
6606 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") acq_rel seq_cst
6607 %val0 = extractvalue { i32, i1 } %val, 0
6608 store i32 %val0, ptr addrspace(1) %out, align 4
6612 define amdgpu_kernel void @global_workgroup_seq_cst_seq_cst_ret_cmpxchg(
6613 ; GFX6-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
6614 ; GFX6: ; %bb.0: ; %entry
6615 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6616 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
6617 ; GFX6-NEXT: s_mov_b32 s6, -1
6618 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6619 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
6620 ; GFX6-NEXT: s_mov_b32 s4, s0
6621 ; GFX6-NEXT: s_mov_b32 s5, s1
6622 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
6623 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6624 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
6625 ; GFX6-NEXT: s_waitcnt vmcnt(0)
6626 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
6627 ; GFX6-NEXT: s_endpgm
6629 ; GFX7-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
6630 ; GFX7: ; %bb.0: ; %entry
6631 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6632 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6633 ; GFX7-NEXT: s_add_u32 s4, s0, 16
6634 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
6635 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
6636 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
6637 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
6638 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
6639 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6640 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
6641 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
6642 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
6643 ; GFX7-NEXT: s_waitcnt vmcnt(0)
6644 ; GFX7-NEXT: flat_store_dword v[0:1], v2
6645 ; GFX7-NEXT: s_endpgm
6647 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
6648 ; GFX10-WGP: ; %bb.0: ; %entry
6649 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6650 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
6651 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6652 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
6653 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
6654 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6655 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6656 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
6657 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
6658 ; GFX10-WGP-NEXT: buffer_gl0_inv
6659 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
6660 ; GFX10-WGP-NEXT: s_endpgm
6662 ; GFX10-CU-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
6663 ; GFX10-CU: ; %bb.0: ; %entry
6664 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6665 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
6666 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6667 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
6668 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
6669 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6670 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
6671 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
6672 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
6673 ; GFX10-CU-NEXT: s_endpgm
6675 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
6676 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6677 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6678 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
6679 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
6680 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6681 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
6682 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
6683 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
6684 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
6685 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6686 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
6687 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
6688 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
6689 ; SKIP-CACHE-INV-NEXT: s_endpgm
6691 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
6692 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6693 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6694 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6695 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6696 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6697 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6698 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
6699 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
6700 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
6701 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6703 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
6704 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6705 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6706 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6707 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6708 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6709 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6710 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
6711 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6712 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
6713 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
6714 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6716 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
6717 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
6718 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6719 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6720 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6721 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
6722 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6723 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
6724 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
6725 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
6726 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
6728 ; GFX940-TGSPLIT-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
6729 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
6730 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6731 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6732 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6733 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
6734 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6735 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
6736 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6737 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
6738 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
6739 ; GFX940-TGSPLIT-NEXT: s_endpgm
6741 ; GFX11-WGP-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
6742 ; GFX11-WGP: ; %bb.0: ; %entry
6743 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
6744 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
6745 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
6746 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
6747 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6748 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6749 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
6750 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
6751 ; GFX11-WGP-NEXT: buffer_gl0_inv
6752 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
6753 ; GFX11-WGP-NEXT: s_nop 0
6754 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
6755 ; GFX11-WGP-NEXT: s_endpgm
6757 ; GFX11-CU-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
6758 ; GFX11-CU: ; %bb.0: ; %entry
6759 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
6760 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
6761 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6762 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
6763 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6764 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
6765 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
6766 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
6767 ; GFX11-CU-NEXT: s_nop 0
6768 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
6769 ; GFX11-CU-NEXT: s_endpgm
6770 ptr addrspace(1) %out, i32 %in, i32 %old) {
6772 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
6773 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") seq_cst seq_cst
6774 %val0 = extractvalue { i32, i1 } %val, 0
6775 store i32 %val0, ptr addrspace(1) %out, align 4
6779 define amdgpu_kernel void @global_workgroup_one_as_unordered_load(
6780 ; GFX6-LABEL: global_workgroup_one_as_unordered_load:
6781 ; GFX6: ; %bb.0: ; %entry
6782 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6783 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
6784 ; GFX6-NEXT: s_mov_b32 s6, -1
6785 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6786 ; GFX6-NEXT: s_mov_b32 s4, s0
6787 ; GFX6-NEXT: s_mov_b32 s5, s1
6788 ; GFX6-NEXT: buffer_load_dword v0, off, s[4:7], 0
6789 ; GFX6-NEXT: s_mov_b32 s4, s2
6790 ; GFX6-NEXT: s_mov_b32 s5, s3
6791 ; GFX6-NEXT: s_waitcnt vmcnt(0)
6792 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
6793 ; GFX6-NEXT: s_endpgm
6795 ; GFX7-LABEL: global_workgroup_one_as_unordered_load:
6796 ; GFX7: ; %bb.0: ; %entry
6797 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6798 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6799 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
6800 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
6801 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
6802 ; GFX7-NEXT: v_mov_b32_e32 v0, s2
6803 ; GFX7-NEXT: v_mov_b32_e32 v1, s3
6804 ; GFX7-NEXT: s_waitcnt vmcnt(0)
6805 ; GFX7-NEXT: flat_store_dword v[0:1], v2
6806 ; GFX7-NEXT: s_endpgm
6808 ; GFX10-WGP-LABEL: global_workgroup_one_as_unordered_load:
6809 ; GFX10-WGP: ; %bb.0: ; %entry
6810 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6811 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
6812 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6813 ; GFX10-WGP-NEXT: global_load_dword v1, v0, s[0:1]
6814 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
6815 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[2:3]
6816 ; GFX10-WGP-NEXT: s_endpgm
6818 ; GFX10-CU-LABEL: global_workgroup_one_as_unordered_load:
6819 ; GFX10-CU: ; %bb.0: ; %entry
6820 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6821 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
6822 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6823 ; GFX10-CU-NEXT: global_load_dword v1, v0, s[0:1]
6824 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
6825 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[2:3]
6826 ; GFX10-CU-NEXT: s_endpgm
6828 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_unordered_load:
6829 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6830 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6831 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
6832 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
6833 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6834 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
6835 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
6836 ; SKIP-CACHE-INV-NEXT: buffer_load_dword v0, off, s[4:7], 0
6837 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s2
6838 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s3
6839 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
6840 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
6841 ; SKIP-CACHE-INV-NEXT: s_endpgm
6843 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_unordered_load:
6844 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6845 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6846 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
6847 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6848 ; GFX90A-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[0:1]
6849 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
6850 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
6851 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6853 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_unordered_load:
6854 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6855 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6856 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
6857 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6858 ; GFX90A-TGSPLIT-NEXT: global_load_dword v1, v0, s[0:1]
6859 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6860 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
6861 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6863 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_unordered_load:
6864 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
6865 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6866 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
6867 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6868 ; GFX940-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[0:1]
6869 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
6870 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
6871 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
6873 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_unordered_load:
6874 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
6875 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6876 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
6877 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6878 ; GFX940-TGSPLIT-NEXT: global_load_dword v1, v0, s[0:1]
6879 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6880 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
6881 ; GFX940-TGSPLIT-NEXT: s_endpgm
6883 ; GFX11-WGP-LABEL: global_workgroup_one_as_unordered_load:
6884 ; GFX11-WGP: ; %bb.0: ; %entry
6885 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
6886 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
6887 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
6888 ; GFX11-WGP-NEXT: global_load_b32 v1, v0, s[0:1]
6889 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
6890 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[2:3]
6891 ; GFX11-WGP-NEXT: s_nop 0
6892 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
6893 ; GFX11-WGP-NEXT: s_endpgm
6895 ; GFX11-CU-LABEL: global_workgroup_one_as_unordered_load:
6896 ; GFX11-CU: ; %bb.0: ; %entry
6897 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
6898 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
6899 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6900 ; GFX11-CU-NEXT: global_load_b32 v1, v0, s[0:1]
6901 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
6902 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[2:3]
6903 ; GFX11-CU-NEXT: s_nop 0
6904 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
6905 ; GFX11-CU-NEXT: s_endpgm
6906 ptr addrspace(1) %in, ptr addrspace(1) %out) {
6908 %val = load atomic i32, ptr addrspace(1) %in syncscope("workgroup-one-as") unordered, align 4
6909 store i32 %val, ptr addrspace(1) %out
6913 define amdgpu_kernel void @global_workgroup_one_as_monotonic_load(
6914 ; GFX6-LABEL: global_workgroup_one_as_monotonic_load:
6915 ; GFX6: ; %bb.0: ; %entry
6916 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6917 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
6918 ; GFX6-NEXT: s_mov_b32 s6, -1
6919 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6920 ; GFX6-NEXT: s_mov_b32 s4, s0
6921 ; GFX6-NEXT: s_mov_b32 s5, s1
6922 ; GFX6-NEXT: buffer_load_dword v0, off, s[4:7], 0
6923 ; GFX6-NEXT: s_mov_b32 s4, s2
6924 ; GFX6-NEXT: s_mov_b32 s5, s3
6925 ; GFX6-NEXT: s_waitcnt vmcnt(0)
6926 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
6927 ; GFX6-NEXT: s_endpgm
6929 ; GFX7-LABEL: global_workgroup_one_as_monotonic_load:
6930 ; GFX7: ; %bb.0: ; %entry
6931 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6932 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6933 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
6934 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
6935 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
6936 ; GFX7-NEXT: v_mov_b32_e32 v0, s2
6937 ; GFX7-NEXT: v_mov_b32_e32 v1, s3
6938 ; GFX7-NEXT: s_waitcnt vmcnt(0)
6939 ; GFX7-NEXT: flat_store_dword v[0:1], v2
6940 ; GFX7-NEXT: s_endpgm
6942 ; GFX10-WGP-LABEL: global_workgroup_one_as_monotonic_load:
6943 ; GFX10-WGP: ; %bb.0: ; %entry
6944 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6945 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
6946 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6947 ; GFX10-WGP-NEXT: global_load_dword v1, v0, s[0:1] glc
6948 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
6949 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[2:3]
6950 ; GFX10-WGP-NEXT: s_endpgm
6952 ; GFX10-CU-LABEL: global_workgroup_one_as_monotonic_load:
6953 ; GFX10-CU: ; %bb.0: ; %entry
6954 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6955 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
6956 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6957 ; GFX10-CU-NEXT: global_load_dword v1, v0, s[0:1]
6958 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
6959 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[2:3]
6960 ; GFX10-CU-NEXT: s_endpgm
6962 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_monotonic_load:
6963 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6964 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6965 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
6966 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
6967 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6968 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
6969 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
6970 ; SKIP-CACHE-INV-NEXT: buffer_load_dword v0, off, s[4:7], 0
6971 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s2
6972 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s3
6973 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
6974 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
6975 ; SKIP-CACHE-INV-NEXT: s_endpgm
6977 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_load:
6978 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6979 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6980 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
6981 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6982 ; GFX90A-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[0:1]
6983 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
6984 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
6985 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6987 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_load:
6988 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6989 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6990 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
6991 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6992 ; GFX90A-TGSPLIT-NEXT: global_load_dword v1, v0, s[0:1] glc
6993 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6994 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
6995 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6997 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_load:
6998 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
6999 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
7000 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7001 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7002 ; GFX940-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[0:1] sc0
7003 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
7004 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
7005 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
7007 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_load:
7008 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
7009 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
7010 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7011 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7012 ; GFX940-TGSPLIT-NEXT: global_load_dword v1, v0, s[0:1] sc0
7013 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7014 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
7015 ; GFX940-TGSPLIT-NEXT: s_endpgm
7017 ; GFX11-WGP-LABEL: global_workgroup_one_as_monotonic_load:
7018 ; GFX11-WGP: ; %bb.0: ; %entry
7019 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
7020 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
7021 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
7022 ; GFX11-WGP-NEXT: global_load_b32 v1, v0, s[0:1] glc
7023 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
7024 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[2:3]
7025 ; GFX11-WGP-NEXT: s_nop 0
7026 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
7027 ; GFX11-WGP-NEXT: s_endpgm
7029 ; GFX11-CU-LABEL: global_workgroup_one_as_monotonic_load:
7030 ; GFX11-CU: ; %bb.0: ; %entry
7031 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
7032 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
7033 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
7034 ; GFX11-CU-NEXT: global_load_b32 v1, v0, s[0:1]
7035 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
7036 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[2:3]
7037 ; GFX11-CU-NEXT: s_nop 0
7038 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
7039 ; GFX11-CU-NEXT: s_endpgm
7040 ptr addrspace(1) %in, ptr addrspace(1) %out) {
7042 %val = load atomic i32, ptr addrspace(1) %in syncscope("workgroup-one-as") monotonic, align 4
7043 store i32 %val, ptr addrspace(1) %out
7047 define amdgpu_kernel void @global_workgroup_one_as_acquire_load(
7048 ; GFX6-LABEL: global_workgroup_one_as_acquire_load:
7049 ; GFX6: ; %bb.0: ; %entry
7050 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
7051 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
7052 ; GFX6-NEXT: s_mov_b32 s6, -1
7053 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7054 ; GFX6-NEXT: s_mov_b32 s4, s0
7055 ; GFX6-NEXT: s_mov_b32 s5, s1
7056 ; GFX6-NEXT: buffer_load_dword v0, off, s[4:7], 0
7057 ; GFX6-NEXT: s_mov_b32 s4, s2
7058 ; GFX6-NEXT: s_mov_b32 s5, s3
7059 ; GFX6-NEXT: s_waitcnt vmcnt(0)
7060 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
7061 ; GFX6-NEXT: s_endpgm
7063 ; GFX7-LABEL: global_workgroup_one_as_acquire_load:
7064 ; GFX7: ; %bb.0: ; %entry
7065 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
7066 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7067 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
7068 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
7069 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
7070 ; GFX7-NEXT: v_mov_b32_e32 v0, s2
7071 ; GFX7-NEXT: v_mov_b32_e32 v1, s3
7072 ; GFX7-NEXT: s_waitcnt vmcnt(0)
7073 ; GFX7-NEXT: flat_store_dword v[0:1], v2
7074 ; GFX7-NEXT: s_endpgm
7076 ; GFX10-WGP-LABEL: global_workgroup_one_as_acquire_load:
7077 ; GFX10-WGP: ; %bb.0: ; %entry
7078 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
7079 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
7080 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7081 ; GFX10-WGP-NEXT: global_load_dword v1, v0, s[0:1] glc
7082 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
7083 ; GFX10-WGP-NEXT: buffer_gl0_inv
7084 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[2:3]
7085 ; GFX10-WGP-NEXT: s_endpgm
7087 ; GFX10-CU-LABEL: global_workgroup_one_as_acquire_load:
7088 ; GFX10-CU: ; %bb.0: ; %entry
7089 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
7090 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
7091 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7092 ; GFX10-CU-NEXT: global_load_dword v1, v0, s[0:1]
7093 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
7094 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[2:3]
7095 ; GFX10-CU-NEXT: s_endpgm
7097 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acquire_load:
7098 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7099 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
7100 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
7101 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
7102 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7103 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
7104 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
7105 ; SKIP-CACHE-INV-NEXT: buffer_load_dword v0, off, s[4:7], 0
7106 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s2
7107 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s3
7108 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
7109 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
7110 ; SKIP-CACHE-INV-NEXT: s_endpgm
7112 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_load:
7113 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7114 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
7115 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7116 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7117 ; GFX90A-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[0:1]
7118 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
7119 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
7120 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7122 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acquire_load:
7123 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7124 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
7125 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7126 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7127 ; GFX90A-TGSPLIT-NEXT: global_load_dword v1, v0, s[0:1] glc
7128 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7129 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
7130 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
7131 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7133 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_load:
7134 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
7135 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
7136 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7137 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7138 ; GFX940-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[0:1] sc0
7139 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
7140 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
7141 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
7143 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acquire_load:
7144 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
7145 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
7146 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7147 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7148 ; GFX940-TGSPLIT-NEXT: global_load_dword v1, v0, s[0:1] sc0
7149 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7150 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
7151 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
7152 ; GFX940-TGSPLIT-NEXT: s_endpgm
7154 ; GFX11-WGP-LABEL: global_workgroup_one_as_acquire_load:
7155 ; GFX11-WGP: ; %bb.0: ; %entry
7156 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
7157 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
7158 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
7159 ; GFX11-WGP-NEXT: global_load_b32 v1, v0, s[0:1] glc
7160 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
7161 ; GFX11-WGP-NEXT: buffer_gl0_inv
7162 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[2:3]
7163 ; GFX11-WGP-NEXT: s_nop 0
7164 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
7165 ; GFX11-WGP-NEXT: s_endpgm
7167 ; GFX11-CU-LABEL: global_workgroup_one_as_acquire_load:
7168 ; GFX11-CU: ; %bb.0: ; %entry
7169 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
7170 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
7171 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
7172 ; GFX11-CU-NEXT: global_load_b32 v1, v0, s[0:1]
7173 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
7174 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[2:3]
7175 ; GFX11-CU-NEXT: s_nop 0
7176 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
7177 ; GFX11-CU-NEXT: s_endpgm
7178 ptr addrspace(1) %in, ptr addrspace(1) %out) {
7180 %val = load atomic i32, ptr addrspace(1) %in syncscope("workgroup-one-as") acquire, align 4
7181 store i32 %val, ptr addrspace(1) %out
7185 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_load(
7186 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_load:
7187 ; GFX6: ; %bb.0: ; %entry
7188 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
7189 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
7190 ; GFX6-NEXT: s_mov_b32 s6, -1
7191 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7192 ; GFX6-NEXT: s_mov_b32 s4, s0
7193 ; GFX6-NEXT: s_mov_b32 s5, s1
7194 ; GFX6-NEXT: buffer_load_dword v0, off, s[4:7], 0
7195 ; GFX6-NEXT: s_mov_b32 s4, s2
7196 ; GFX6-NEXT: s_mov_b32 s5, s3
7197 ; GFX6-NEXT: s_waitcnt vmcnt(0)
7198 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
7199 ; GFX6-NEXT: s_endpgm
7201 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_load:
7202 ; GFX7: ; %bb.0: ; %entry
7203 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
7204 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7205 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
7206 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
7207 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
7208 ; GFX7-NEXT: v_mov_b32_e32 v0, s2
7209 ; GFX7-NEXT: v_mov_b32_e32 v1, s3
7210 ; GFX7-NEXT: s_waitcnt vmcnt(0)
7211 ; GFX7-NEXT: flat_store_dword v[0:1], v2
7212 ; GFX7-NEXT: s_endpgm
7214 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_load:
7215 ; GFX10-WGP: ; %bb.0: ; %entry
7216 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
7217 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
7218 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7219 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7220 ; GFX10-WGP-NEXT: global_load_dword v1, v0, s[0:1] glc
7221 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
7222 ; GFX10-WGP-NEXT: buffer_gl0_inv
7223 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[2:3]
7224 ; GFX10-WGP-NEXT: s_endpgm
7226 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_load:
7227 ; GFX10-CU: ; %bb.0: ; %entry
7228 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
7229 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
7230 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7231 ; GFX10-CU-NEXT: global_load_dword v1, v0, s[0:1]
7232 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
7233 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[2:3]
7234 ; GFX10-CU-NEXT: s_endpgm
7236 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_load:
7237 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7238 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
7239 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
7240 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
7241 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7242 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
7243 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
7244 ; SKIP-CACHE-INV-NEXT: buffer_load_dword v0, off, s[4:7], 0
7245 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s2
7246 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s3
7247 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
7248 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
7249 ; SKIP-CACHE-INV-NEXT: s_endpgm
7251 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_load:
7252 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7253 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
7254 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7255 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7256 ; GFX90A-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[0:1]
7257 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
7258 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
7259 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7261 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_load:
7262 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7263 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
7264 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7265 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7266 ; GFX90A-TGSPLIT-NEXT: global_load_dword v1, v0, s[0:1] glc
7267 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7268 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
7269 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
7270 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7272 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_load:
7273 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
7274 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
7275 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7276 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7277 ; GFX940-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[0:1] sc0
7278 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
7279 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
7280 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
7282 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_load:
7283 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
7284 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
7285 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7286 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7287 ; GFX940-TGSPLIT-NEXT: global_load_dword v1, v0, s[0:1] sc0
7288 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7289 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
7290 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
7291 ; GFX940-TGSPLIT-NEXT: s_endpgm
7293 ; GFX11-WGP-LABEL: global_workgroup_one_as_seq_cst_load:
7294 ; GFX11-WGP: ; %bb.0: ; %entry
7295 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
7296 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
7297 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7298 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7299 ; GFX11-WGP-NEXT: global_load_b32 v1, v0, s[0:1] glc
7300 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
7301 ; GFX11-WGP-NEXT: buffer_gl0_inv
7302 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[2:3]
7303 ; GFX11-WGP-NEXT: s_nop 0
7304 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
7305 ; GFX11-WGP-NEXT: s_endpgm
7307 ; GFX11-CU-LABEL: global_workgroup_one_as_seq_cst_load:
7308 ; GFX11-CU: ; %bb.0: ; %entry
7309 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
7310 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
7311 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
7312 ; GFX11-CU-NEXT: global_load_b32 v1, v0, s[0:1]
7313 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
7314 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[2:3]
7315 ; GFX11-CU-NEXT: s_nop 0
7316 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
7317 ; GFX11-CU-NEXT: s_endpgm
7318 ptr addrspace(1) %in, ptr addrspace(1) %out) {
7320 %val = load atomic i32, ptr addrspace(1) %in syncscope("workgroup-one-as") seq_cst, align 4
7321 store i32 %val, ptr addrspace(1) %out
7325 define amdgpu_kernel void @global_workgroup_one_as_unordered_store(
7326 ; GFX6-LABEL: global_workgroup_one_as_unordered_store:
7327 ; GFX6: ; %bb.0: ; %entry
7328 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x0
7329 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
7330 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
7331 ; GFX6-NEXT: s_mov_b32 s2, -1
7332 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7333 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
7334 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
7335 ; GFX6-NEXT: s_endpgm
7337 ; GFX7-LABEL: global_workgroup_one_as_unordered_store:
7338 ; GFX7: ; %bb.0: ; %entry
7339 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
7340 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x0
7341 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7342 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
7343 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
7344 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
7345 ; GFX7-NEXT: flat_store_dword v[0:1], v2
7346 ; GFX7-NEXT: s_endpgm
7348 ; GFX10-WGP-LABEL: global_workgroup_one_as_unordered_store:
7349 ; GFX10-WGP: ; %bb.0: ; %entry
7350 ; GFX10-WGP-NEXT: s_clause 0x1
7351 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x0
7352 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7353 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
7354 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7355 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
7356 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
7357 ; GFX10-WGP-NEXT: s_endpgm
7359 ; GFX10-CU-LABEL: global_workgroup_one_as_unordered_store:
7360 ; GFX10-CU: ; %bb.0: ; %entry
7361 ; GFX10-CU-NEXT: s_clause 0x1
7362 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x0
7363 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7364 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
7365 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7366 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
7367 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
7368 ; GFX10-CU-NEXT: s_endpgm
7370 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_unordered_store:
7371 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7372 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x0
7373 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
7374 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
7375 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
7376 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7377 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
7378 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
7379 ; SKIP-CACHE-INV-NEXT: s_endpgm
7381 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_unordered_store:
7382 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7383 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
7384 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7385 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7386 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7387 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
7388 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
7389 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7391 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_unordered_store:
7392 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7393 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
7394 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7395 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7396 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7397 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
7398 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
7399 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7401 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_unordered_store:
7402 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
7403 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
7404 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
7405 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7406 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7407 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s4
7408 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
7409 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
7411 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_unordered_store:
7412 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
7413 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
7414 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
7415 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7416 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7417 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s4
7418 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
7419 ; GFX940-TGSPLIT-NEXT: s_endpgm
7421 ; GFX11-WGP-LABEL: global_workgroup_one_as_unordered_store:
7422 ; GFX11-WGP: ; %bb.0: ; %entry
7423 ; GFX11-WGP-NEXT: s_clause 0x1
7424 ; GFX11-WGP-NEXT: s_load_b32 s2, s[0:1], 0x0
7425 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
7426 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
7427 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
7428 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
7429 ; GFX11-WGP-NEXT: s_nop 0
7430 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
7431 ; GFX11-WGP-NEXT: s_endpgm
7433 ; GFX11-CU-LABEL: global_workgroup_one_as_unordered_store:
7434 ; GFX11-CU: ; %bb.0: ; %entry
7435 ; GFX11-CU-NEXT: s_clause 0x1
7436 ; GFX11-CU-NEXT: s_load_b32 s2, s[0:1], 0x0
7437 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
7438 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
7439 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
7440 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
7441 ; GFX11-CU-NEXT: s_nop 0
7442 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
7443 ; GFX11-CU-NEXT: s_endpgm
7444 i32 %in, ptr addrspace(1) %out) {
7446 store atomic i32 %in, ptr addrspace(1) %out syncscope("workgroup-one-as") unordered, align 4
7450 define amdgpu_kernel void @global_workgroup_one_as_monotonic_store(
7451 ; GFX6-LABEL: global_workgroup_one_as_monotonic_store:
7452 ; GFX6: ; %bb.0: ; %entry
7453 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x0
7454 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
7455 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
7456 ; GFX6-NEXT: s_mov_b32 s2, -1
7457 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7458 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
7459 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
7460 ; GFX6-NEXT: s_endpgm
7462 ; GFX7-LABEL: global_workgroup_one_as_monotonic_store:
7463 ; GFX7: ; %bb.0: ; %entry
7464 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
7465 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x0
7466 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7467 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
7468 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
7469 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
7470 ; GFX7-NEXT: flat_store_dword v[0:1], v2
7471 ; GFX7-NEXT: s_endpgm
7473 ; GFX10-WGP-LABEL: global_workgroup_one_as_monotonic_store:
7474 ; GFX10-WGP: ; %bb.0: ; %entry
7475 ; GFX10-WGP-NEXT: s_clause 0x1
7476 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x0
7477 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7478 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
7479 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7480 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
7481 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
7482 ; GFX10-WGP-NEXT: s_endpgm
7484 ; GFX10-CU-LABEL: global_workgroup_one_as_monotonic_store:
7485 ; GFX10-CU: ; %bb.0: ; %entry
7486 ; GFX10-CU-NEXT: s_clause 0x1
7487 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x0
7488 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7489 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
7490 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7491 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
7492 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
7493 ; GFX10-CU-NEXT: s_endpgm
7495 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_monotonic_store:
7496 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7497 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x0
7498 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
7499 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
7500 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
7501 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7502 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
7503 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
7504 ; SKIP-CACHE-INV-NEXT: s_endpgm
7506 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_store:
7507 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7508 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
7509 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7510 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7511 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7512 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
7513 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
7514 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7516 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_store:
7517 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7518 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
7519 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7520 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7521 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7522 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
7523 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
7524 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7526 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_store:
7527 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
7528 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
7529 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
7530 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7531 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7532 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s4
7533 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
7534 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
7536 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_store:
7537 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
7538 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
7539 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
7540 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7541 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7542 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s4
7543 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
7544 ; GFX940-TGSPLIT-NEXT: s_endpgm
7546 ; GFX11-WGP-LABEL: global_workgroup_one_as_monotonic_store:
7547 ; GFX11-WGP: ; %bb.0: ; %entry
7548 ; GFX11-WGP-NEXT: s_clause 0x1
7549 ; GFX11-WGP-NEXT: s_load_b32 s2, s[0:1], 0x0
7550 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
7551 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
7552 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
7553 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
7554 ; GFX11-WGP-NEXT: s_nop 0
7555 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
7556 ; GFX11-WGP-NEXT: s_endpgm
7558 ; GFX11-CU-LABEL: global_workgroup_one_as_monotonic_store:
7559 ; GFX11-CU: ; %bb.0: ; %entry
7560 ; GFX11-CU-NEXT: s_clause 0x1
7561 ; GFX11-CU-NEXT: s_load_b32 s2, s[0:1], 0x0
7562 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
7563 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
7564 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
7565 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
7566 ; GFX11-CU-NEXT: s_nop 0
7567 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
7568 ; GFX11-CU-NEXT: s_endpgm
7569 i32 %in, ptr addrspace(1) %out) {
7571 store atomic i32 %in, ptr addrspace(1) %out syncscope("workgroup-one-as") monotonic, align 4
7575 define amdgpu_kernel void @global_workgroup_one_as_release_store(
7576 ; GFX6-LABEL: global_workgroup_one_as_release_store:
7577 ; GFX6: ; %bb.0: ; %entry
7578 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x0
7579 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
7580 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
7581 ; GFX6-NEXT: s_mov_b32 s2, -1
7582 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7583 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
7584 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
7585 ; GFX6-NEXT: s_endpgm
7587 ; GFX7-LABEL: global_workgroup_one_as_release_store:
7588 ; GFX7: ; %bb.0: ; %entry
7589 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
7590 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x0
7591 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7592 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
7593 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
7594 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
7595 ; GFX7-NEXT: flat_store_dword v[0:1], v2
7596 ; GFX7-NEXT: s_endpgm
7598 ; GFX10-WGP-LABEL: global_workgroup_one_as_release_store:
7599 ; GFX10-WGP: ; %bb.0: ; %entry
7600 ; GFX10-WGP-NEXT: s_clause 0x1
7601 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x0
7602 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7603 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
7604 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7605 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
7606 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
7607 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7608 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
7609 ; GFX10-WGP-NEXT: s_endpgm
7611 ; GFX10-CU-LABEL: global_workgroup_one_as_release_store:
7612 ; GFX10-CU: ; %bb.0: ; %entry
7613 ; GFX10-CU-NEXT: s_clause 0x1
7614 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x0
7615 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7616 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
7617 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7618 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
7619 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
7620 ; GFX10-CU-NEXT: s_endpgm
7622 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_release_store:
7623 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7624 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x0
7625 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
7626 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
7627 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
7628 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7629 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
7630 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
7631 ; SKIP-CACHE-INV-NEXT: s_endpgm
7633 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_store:
7634 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7635 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
7636 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7637 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7638 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7639 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
7640 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
7641 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7643 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_release_store:
7644 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7645 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
7646 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7647 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7648 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7649 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
7650 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7651 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
7652 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7654 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_store:
7655 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
7656 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
7657 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
7658 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7659 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7660 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s4
7661 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
7662 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
7664 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_release_store:
7665 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
7666 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
7667 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
7668 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7669 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7670 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s4
7671 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7672 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
7673 ; GFX940-TGSPLIT-NEXT: s_endpgm
7675 ; GFX11-WGP-LABEL: global_workgroup_one_as_release_store:
7676 ; GFX11-WGP: ; %bb.0: ; %entry
7677 ; GFX11-WGP-NEXT: s_clause 0x1
7678 ; GFX11-WGP-NEXT: s_load_b32 s2, s[0:1], 0x0
7679 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
7680 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
7681 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
7682 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
7683 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7684 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
7685 ; GFX11-WGP-NEXT: s_nop 0
7686 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
7687 ; GFX11-WGP-NEXT: s_endpgm
7689 ; GFX11-CU-LABEL: global_workgroup_one_as_release_store:
7690 ; GFX11-CU: ; %bb.0: ; %entry
7691 ; GFX11-CU-NEXT: s_clause 0x1
7692 ; GFX11-CU-NEXT: s_load_b32 s2, s[0:1], 0x0
7693 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
7694 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
7695 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
7696 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
7697 ; GFX11-CU-NEXT: s_nop 0
7698 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
7699 ; GFX11-CU-NEXT: s_endpgm
7700 i32 %in, ptr addrspace(1) %out) {
7702 store atomic i32 %in, ptr addrspace(1) %out syncscope("workgroup-one-as") release, align 4
7706 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_store(
7707 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_store:
7708 ; GFX6: ; %bb.0: ; %entry
7709 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x0
7710 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
7711 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
7712 ; GFX6-NEXT: s_mov_b32 s2, -1
7713 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7714 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
7715 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
7716 ; GFX6-NEXT: s_endpgm
7718 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_store:
7719 ; GFX7: ; %bb.0: ; %entry
7720 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
7721 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x0
7722 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7723 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
7724 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
7725 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
7726 ; GFX7-NEXT: flat_store_dword v[0:1], v2
7727 ; GFX7-NEXT: s_endpgm
7729 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_store:
7730 ; GFX10-WGP: ; %bb.0: ; %entry
7731 ; GFX10-WGP-NEXT: s_clause 0x1
7732 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x0
7733 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7734 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
7735 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7736 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
7737 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
7738 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7739 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
7740 ; GFX10-WGP-NEXT: s_endpgm
7742 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_store:
7743 ; GFX10-CU: ; %bb.0: ; %entry
7744 ; GFX10-CU-NEXT: s_clause 0x1
7745 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x0
7746 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7747 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
7748 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7749 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
7750 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
7751 ; GFX10-CU-NEXT: s_endpgm
7753 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_store:
7754 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7755 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x0
7756 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
7757 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
7758 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
7759 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7760 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
7761 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
7762 ; SKIP-CACHE-INV-NEXT: s_endpgm
7764 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_store:
7765 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7766 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
7767 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7768 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7769 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7770 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
7771 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
7772 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7774 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_store:
7775 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7776 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
7777 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7778 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7779 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7780 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
7781 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7782 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
7783 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7785 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_store:
7786 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
7787 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
7788 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
7789 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7790 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7791 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s4
7792 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
7793 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
7795 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_store:
7796 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
7797 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
7798 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
7799 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7800 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7801 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s4
7802 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7803 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
7804 ; GFX940-TGSPLIT-NEXT: s_endpgm
7806 ; GFX11-WGP-LABEL: global_workgroup_one_as_seq_cst_store:
7807 ; GFX11-WGP: ; %bb.0: ; %entry
7808 ; GFX11-WGP-NEXT: s_clause 0x1
7809 ; GFX11-WGP-NEXT: s_load_b32 s2, s[0:1], 0x0
7810 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
7811 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
7812 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
7813 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
7814 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7815 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
7816 ; GFX11-WGP-NEXT: s_nop 0
7817 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
7818 ; GFX11-WGP-NEXT: s_endpgm
7820 ; GFX11-CU-LABEL: global_workgroup_one_as_seq_cst_store:
7821 ; GFX11-CU: ; %bb.0: ; %entry
7822 ; GFX11-CU-NEXT: s_clause 0x1
7823 ; GFX11-CU-NEXT: s_load_b32 s2, s[0:1], 0x0
7824 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
7825 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
7826 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
7827 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
7828 ; GFX11-CU-NEXT: s_nop 0
7829 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
7830 ; GFX11-CU-NEXT: s_endpgm
7831 i32 %in, ptr addrspace(1) %out) {
7833 store atomic i32 %in, ptr addrspace(1) %out syncscope("workgroup-one-as") seq_cst, align 4
7837 define amdgpu_kernel void @global_workgroup_one_as_monotonic_atomicrmw(
7838 ; GFX6-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
7839 ; GFX6: ; %bb.0: ; %entry
7840 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x2
7841 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7842 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
7843 ; GFX6-NEXT: s_mov_b32 s2, -1
7844 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7845 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
7846 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
7847 ; GFX6-NEXT: s_endpgm
7849 ; GFX7-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
7850 ; GFX7: ; %bb.0: ; %entry
7851 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7852 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
7853 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7854 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
7855 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
7856 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
7857 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
7858 ; GFX7-NEXT: s_endpgm
7860 ; GFX10-WGP-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
7861 ; GFX10-WGP: ; %bb.0: ; %entry
7862 ; GFX10-WGP-NEXT: s_clause 0x1
7863 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
7864 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7865 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
7866 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7867 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
7868 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[0:1]
7869 ; GFX10-WGP-NEXT: s_endpgm
7871 ; GFX10-CU-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
7872 ; GFX10-CU: ; %bb.0: ; %entry
7873 ; GFX10-CU-NEXT: s_clause 0x1
7874 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
7875 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7876 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
7877 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7878 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
7879 ; GFX10-CU-NEXT: global_atomic_swap v0, v1, s[0:1]
7880 ; GFX10-CU-NEXT: s_endpgm
7882 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
7883 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7884 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x2
7885 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x0
7886 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
7887 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
7888 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7889 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
7890 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
7891 ; SKIP-CACHE-INV-NEXT: s_endpgm
7893 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
7894 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7895 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
7896 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7897 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7898 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7899 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
7900 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
7901 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7903 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
7904 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7905 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
7906 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7907 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7908 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7909 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
7910 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
7911 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7913 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
7914 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
7915 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
7916 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
7917 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7918 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7919 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s4
7920 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[2:3]
7921 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
7923 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
7924 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
7925 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
7926 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
7927 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7928 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7929 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s4
7930 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[2:3]
7931 ; GFX940-TGSPLIT-NEXT: s_endpgm
7933 ; GFX11-WGP-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
7934 ; GFX11-WGP: ; %bb.0: ; %entry
7935 ; GFX11-WGP-NEXT: s_clause 0x1
7936 ; GFX11-WGP-NEXT: s_load_b32 s2, s[0:1], 0x8
7937 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
7938 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
7939 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
7940 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
7941 ; GFX11-WGP-NEXT: s_nop 0
7942 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
7943 ; GFX11-WGP-NEXT: s_endpgm
7945 ; GFX11-CU-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
7946 ; GFX11-CU: ; %bb.0: ; %entry
7947 ; GFX11-CU-NEXT: s_clause 0x1
7948 ; GFX11-CU-NEXT: s_load_b32 s2, s[0:1], 0x8
7949 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
7950 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
7951 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
7952 ; GFX11-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
7953 ; GFX11-CU-NEXT: s_nop 0
7954 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
7955 ; GFX11-CU-NEXT: s_endpgm
7956 ptr addrspace(1) %out, i32 %in) {
7958 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup-one-as") monotonic
7962 define amdgpu_kernel void @global_workgroup_one_as_acquire_atomicrmw(
7963 ; GFX6-LABEL: global_workgroup_one_as_acquire_atomicrmw:
7964 ; GFX6: ; %bb.0: ; %entry
7965 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x2
7966 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7967 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
7968 ; GFX6-NEXT: s_mov_b32 s2, -1
7969 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7970 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
7971 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
7972 ; GFX6-NEXT: s_endpgm
7974 ; GFX7-LABEL: global_workgroup_one_as_acquire_atomicrmw:
7975 ; GFX7: ; %bb.0: ; %entry
7976 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7977 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
7978 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7979 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
7980 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
7981 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
7982 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
7983 ; GFX7-NEXT: s_endpgm
7985 ; GFX10-WGP-LABEL: global_workgroup_one_as_acquire_atomicrmw:
7986 ; GFX10-WGP: ; %bb.0: ; %entry
7987 ; GFX10-WGP-NEXT: s_clause 0x1
7988 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
7989 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7990 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
7991 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7992 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
7993 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[0:1]
7994 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7995 ; GFX10-WGP-NEXT: buffer_gl0_inv
7996 ; GFX10-WGP-NEXT: s_endpgm
7998 ; GFX10-CU-LABEL: global_workgroup_one_as_acquire_atomicrmw:
7999 ; GFX10-CU: ; %bb.0: ; %entry
8000 ; GFX10-CU-NEXT: s_clause 0x1
8001 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
8002 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8003 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
8004 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8005 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
8006 ; GFX10-CU-NEXT: global_atomic_swap v0, v1, s[0:1]
8007 ; GFX10-CU-NEXT: s_endpgm
8009 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acquire_atomicrmw:
8010 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8011 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x2
8012 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x0
8013 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
8014 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
8015 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8016 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
8017 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
8018 ; SKIP-CACHE-INV-NEXT: s_endpgm
8020 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_atomicrmw:
8021 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8022 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
8023 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8024 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8025 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8026 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
8027 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
8028 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8030 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acquire_atomicrmw:
8031 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8032 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
8033 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8034 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8035 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8036 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
8037 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
8038 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8039 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
8040 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8042 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_atomicrmw:
8043 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
8044 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
8045 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
8046 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8047 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8048 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s4
8049 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[2:3]
8050 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
8052 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acquire_atomicrmw:
8053 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
8054 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
8055 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
8056 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8057 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8058 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s4
8059 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[2:3]
8060 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8061 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
8062 ; GFX940-TGSPLIT-NEXT: s_endpgm
8064 ; GFX11-WGP-LABEL: global_workgroup_one_as_acquire_atomicrmw:
8065 ; GFX11-WGP: ; %bb.0: ; %entry
8066 ; GFX11-WGP-NEXT: s_clause 0x1
8067 ; GFX11-WGP-NEXT: s_load_b32 s2, s[0:1], 0x8
8068 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
8069 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
8070 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
8071 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
8072 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8073 ; GFX11-WGP-NEXT: buffer_gl0_inv
8074 ; GFX11-WGP-NEXT: s_endpgm
8076 ; GFX11-CU-LABEL: global_workgroup_one_as_acquire_atomicrmw:
8077 ; GFX11-CU: ; %bb.0: ; %entry
8078 ; GFX11-CU-NEXT: s_clause 0x1
8079 ; GFX11-CU-NEXT: s_load_b32 s2, s[0:1], 0x8
8080 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
8081 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
8082 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
8083 ; GFX11-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
8084 ; GFX11-CU-NEXT: s_nop 0
8085 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
8086 ; GFX11-CU-NEXT: s_endpgm
8087 ptr addrspace(1) %out, i32 %in) {
8089 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup-one-as") acquire
8093 define amdgpu_kernel void @global_workgroup_one_as_release_atomicrmw(
8094 ; GFX6-LABEL: global_workgroup_one_as_release_atomicrmw:
8095 ; GFX6: ; %bb.0: ; %entry
8096 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x2
8097 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8098 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
8099 ; GFX6-NEXT: s_mov_b32 s2, -1
8100 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8101 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
8102 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
8103 ; GFX6-NEXT: s_endpgm
8105 ; GFX7-LABEL: global_workgroup_one_as_release_atomicrmw:
8106 ; GFX7: ; %bb.0: ; %entry
8107 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8108 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
8109 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8110 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
8111 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
8112 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
8113 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
8114 ; GFX7-NEXT: s_endpgm
8116 ; GFX10-WGP-LABEL: global_workgroup_one_as_release_atomicrmw:
8117 ; GFX10-WGP: ; %bb.0: ; %entry
8118 ; GFX10-WGP-NEXT: s_clause 0x1
8119 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
8120 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8121 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
8122 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8123 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
8124 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8125 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8126 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[0:1]
8127 ; GFX10-WGP-NEXT: s_endpgm
8129 ; GFX10-CU-LABEL: global_workgroup_one_as_release_atomicrmw:
8130 ; GFX10-CU: ; %bb.0: ; %entry
8131 ; GFX10-CU-NEXT: s_clause 0x1
8132 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
8133 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8134 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
8135 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8136 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
8137 ; GFX10-CU-NEXT: global_atomic_swap v0, v1, s[0:1]
8138 ; GFX10-CU-NEXT: s_endpgm
8140 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_release_atomicrmw:
8141 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8142 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x2
8143 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x0
8144 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
8145 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
8146 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8147 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
8148 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
8149 ; SKIP-CACHE-INV-NEXT: s_endpgm
8151 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_atomicrmw:
8152 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8153 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
8154 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8155 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8156 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8157 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
8158 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
8159 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8161 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_release_atomicrmw:
8162 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8163 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
8164 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8165 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8166 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8167 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
8168 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8169 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
8170 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8172 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_atomicrmw:
8173 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
8174 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
8175 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
8176 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8177 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8178 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s4
8179 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[2:3]
8180 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
8182 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_release_atomicrmw:
8183 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
8184 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
8185 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
8186 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8187 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8188 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s4
8189 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8190 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[2:3]
8191 ; GFX940-TGSPLIT-NEXT: s_endpgm
8193 ; GFX11-WGP-LABEL: global_workgroup_one_as_release_atomicrmw:
8194 ; GFX11-WGP: ; %bb.0: ; %entry
8195 ; GFX11-WGP-NEXT: s_clause 0x1
8196 ; GFX11-WGP-NEXT: s_load_b32 s2, s[0:1], 0x8
8197 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
8198 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
8199 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
8200 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
8201 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8202 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
8203 ; GFX11-WGP-NEXT: s_nop 0
8204 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
8205 ; GFX11-WGP-NEXT: s_endpgm
8207 ; GFX11-CU-LABEL: global_workgroup_one_as_release_atomicrmw:
8208 ; GFX11-CU: ; %bb.0: ; %entry
8209 ; GFX11-CU-NEXT: s_clause 0x1
8210 ; GFX11-CU-NEXT: s_load_b32 s2, s[0:1], 0x8
8211 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
8212 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
8213 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
8214 ; GFX11-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
8215 ; GFX11-CU-NEXT: s_nop 0
8216 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
8217 ; GFX11-CU-NEXT: s_endpgm
8218 ptr addrspace(1) %out, i32 %in) {
8220 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup-one-as") release
8224 define amdgpu_kernel void @global_workgroup_one_as_acq_rel_atomicrmw(
8225 ; GFX6-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
8226 ; GFX6: ; %bb.0: ; %entry
8227 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x2
8228 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8229 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
8230 ; GFX6-NEXT: s_mov_b32 s2, -1
8231 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8232 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
8233 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
8234 ; GFX6-NEXT: s_endpgm
8236 ; GFX7-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
8237 ; GFX7: ; %bb.0: ; %entry
8238 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8239 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
8240 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8241 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
8242 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
8243 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
8244 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
8245 ; GFX7-NEXT: s_endpgm
8247 ; GFX10-WGP-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
8248 ; GFX10-WGP: ; %bb.0: ; %entry
8249 ; GFX10-WGP-NEXT: s_clause 0x1
8250 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
8251 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8252 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
8253 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8254 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
8255 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8256 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8257 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[0:1]
8258 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8259 ; GFX10-WGP-NEXT: buffer_gl0_inv
8260 ; GFX10-WGP-NEXT: s_endpgm
8262 ; GFX10-CU-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
8263 ; GFX10-CU: ; %bb.0: ; %entry
8264 ; GFX10-CU-NEXT: s_clause 0x1
8265 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
8266 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8267 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
8268 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8269 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
8270 ; GFX10-CU-NEXT: global_atomic_swap v0, v1, s[0:1]
8271 ; GFX10-CU-NEXT: s_endpgm
8273 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
8274 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8275 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x2
8276 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x0
8277 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
8278 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
8279 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8280 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
8281 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
8282 ; SKIP-CACHE-INV-NEXT: s_endpgm
8284 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
8285 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8286 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
8287 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8288 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8289 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8290 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
8291 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
8292 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8294 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
8295 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8296 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
8297 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8298 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8299 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8300 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
8301 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8302 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
8303 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8304 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
8305 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8307 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
8308 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
8309 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
8310 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
8311 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8312 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8313 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s4
8314 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[2:3]
8315 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
8317 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
8318 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
8319 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
8320 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
8321 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8322 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8323 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s4
8324 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8325 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[2:3]
8326 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8327 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
8328 ; GFX940-TGSPLIT-NEXT: s_endpgm
8330 ; GFX11-WGP-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
8331 ; GFX11-WGP: ; %bb.0: ; %entry
8332 ; GFX11-WGP-NEXT: s_clause 0x1
8333 ; GFX11-WGP-NEXT: s_load_b32 s2, s[0:1], 0x8
8334 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
8335 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
8336 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
8337 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
8338 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8339 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
8340 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8341 ; GFX11-WGP-NEXT: buffer_gl0_inv
8342 ; GFX11-WGP-NEXT: s_endpgm
8344 ; GFX11-CU-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
8345 ; GFX11-CU: ; %bb.0: ; %entry
8346 ; GFX11-CU-NEXT: s_clause 0x1
8347 ; GFX11-CU-NEXT: s_load_b32 s2, s[0:1], 0x8
8348 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
8349 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
8350 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
8351 ; GFX11-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
8352 ; GFX11-CU-NEXT: s_nop 0
8353 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
8354 ; GFX11-CU-NEXT: s_endpgm
8355 ptr addrspace(1) %out, i32 %in) {
8357 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup-one-as") acq_rel
8361 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_atomicrmw(
8362 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
8363 ; GFX6: ; %bb.0: ; %entry
8364 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x2
8365 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8366 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
8367 ; GFX6-NEXT: s_mov_b32 s2, -1
8368 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8369 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
8370 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
8371 ; GFX6-NEXT: s_endpgm
8373 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
8374 ; GFX7: ; %bb.0: ; %entry
8375 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8376 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
8377 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8378 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
8379 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
8380 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
8381 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
8382 ; GFX7-NEXT: s_endpgm
8384 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
8385 ; GFX10-WGP: ; %bb.0: ; %entry
8386 ; GFX10-WGP-NEXT: s_clause 0x1
8387 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
8388 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8389 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
8390 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8391 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
8392 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8393 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8394 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[0:1]
8395 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8396 ; GFX10-WGP-NEXT: buffer_gl0_inv
8397 ; GFX10-WGP-NEXT: s_endpgm
8399 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
8400 ; GFX10-CU: ; %bb.0: ; %entry
8401 ; GFX10-CU-NEXT: s_clause 0x1
8402 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
8403 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8404 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
8405 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8406 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
8407 ; GFX10-CU-NEXT: global_atomic_swap v0, v1, s[0:1]
8408 ; GFX10-CU-NEXT: s_endpgm
8410 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
8411 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8412 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x2
8413 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x0
8414 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
8415 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
8416 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8417 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
8418 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
8419 ; SKIP-CACHE-INV-NEXT: s_endpgm
8421 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
8422 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8423 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
8424 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8425 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8426 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8427 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
8428 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
8429 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8431 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
8432 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8433 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
8434 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8435 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8436 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8437 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
8438 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8439 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
8440 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8441 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
8442 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8444 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
8445 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
8446 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
8447 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
8448 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8449 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8450 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s4
8451 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[2:3]
8452 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
8454 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
8455 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
8456 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
8457 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
8458 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8459 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8460 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s4
8461 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8462 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[2:3]
8463 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8464 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
8465 ; GFX940-TGSPLIT-NEXT: s_endpgm
8467 ; GFX11-WGP-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
8468 ; GFX11-WGP: ; %bb.0: ; %entry
8469 ; GFX11-WGP-NEXT: s_clause 0x1
8470 ; GFX11-WGP-NEXT: s_load_b32 s2, s[0:1], 0x8
8471 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
8472 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
8473 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
8474 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
8475 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8476 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
8477 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8478 ; GFX11-WGP-NEXT: buffer_gl0_inv
8479 ; GFX11-WGP-NEXT: s_endpgm
8481 ; GFX11-CU-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
8482 ; GFX11-CU: ; %bb.0: ; %entry
8483 ; GFX11-CU-NEXT: s_clause 0x1
8484 ; GFX11-CU-NEXT: s_load_b32 s2, s[0:1], 0x8
8485 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
8486 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
8487 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
8488 ; GFX11-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
8489 ; GFX11-CU-NEXT: s_nop 0
8490 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
8491 ; GFX11-CU-NEXT: s_endpgm
8492 ptr addrspace(1) %out, i32 %in) {
8494 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup-one-as") seq_cst
8498 define amdgpu_kernel void @global_workgroup_one_as_acquire_ret_atomicrmw(
8499 ; GFX6-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
8500 ; GFX6: ; %bb.0: ; %entry
8501 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x2
8502 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8503 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
8504 ; GFX6-NEXT: s_mov_b32 s2, -1
8505 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8506 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
8507 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0 glc
8508 ; GFX6-NEXT: s_waitcnt vmcnt(0)
8509 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
8510 ; GFX6-NEXT: s_endpgm
8512 ; GFX7-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
8513 ; GFX7: ; %bb.0: ; %entry
8514 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8515 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
8516 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8517 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
8518 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
8519 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
8520 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
8521 ; GFX7-NEXT: s_waitcnt vmcnt(0)
8522 ; GFX7-NEXT: flat_store_dword v[0:1], v2
8523 ; GFX7-NEXT: s_endpgm
8525 ; GFX10-WGP-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
8526 ; GFX10-WGP: ; %bb.0: ; %entry
8527 ; GFX10-WGP-NEXT: s_clause 0x1
8528 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
8529 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8530 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
8531 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8532 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
8533 ; GFX10-WGP-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
8534 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8535 ; GFX10-WGP-NEXT: buffer_gl0_inv
8536 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
8537 ; GFX10-WGP-NEXT: s_endpgm
8539 ; GFX10-CU-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
8540 ; GFX10-CU: ; %bb.0: ; %entry
8541 ; GFX10-CU-NEXT: s_clause 0x1
8542 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
8543 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8544 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
8545 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8546 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
8547 ; GFX10-CU-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
8548 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
8549 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
8550 ; GFX10-CU-NEXT: s_endpgm
8552 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
8553 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8554 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x2
8555 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x0
8556 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
8557 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
8558 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8559 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
8560 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0 glc
8561 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
8562 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
8563 ; SKIP-CACHE-INV-NEXT: s_endpgm
8565 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
8566 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8567 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
8568 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8569 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8570 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8571 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
8572 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
8573 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
8574 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
8575 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8577 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
8578 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8579 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
8580 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8581 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8582 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8583 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
8584 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
8585 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8586 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
8587 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
8588 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8590 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
8591 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
8592 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
8593 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
8594 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8595 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8596 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s4
8597 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[2:3] sc0
8598 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
8599 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
8600 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
8602 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
8603 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
8604 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
8605 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
8606 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8607 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8608 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s4
8609 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[2:3] sc0
8610 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8611 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
8612 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
8613 ; GFX940-TGSPLIT-NEXT: s_endpgm
8615 ; GFX11-WGP-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
8616 ; GFX11-WGP: ; %bb.0: ; %entry
8617 ; GFX11-WGP-NEXT: s_clause 0x1
8618 ; GFX11-WGP-NEXT: s_load_b32 s2, s[0:1], 0x8
8619 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
8620 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
8621 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
8622 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] glc
8623 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
8624 ; GFX11-WGP-NEXT: buffer_gl0_inv
8625 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
8626 ; GFX11-WGP-NEXT: s_nop 0
8627 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
8628 ; GFX11-WGP-NEXT: s_endpgm
8630 ; GFX11-CU-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
8631 ; GFX11-CU: ; %bb.0: ; %entry
8632 ; GFX11-CU-NEXT: s_clause 0x1
8633 ; GFX11-CU-NEXT: s_load_b32 s2, s[0:1], 0x8
8634 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
8635 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
8636 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
8637 ; GFX11-CU-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] glc
8638 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
8639 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
8640 ; GFX11-CU-NEXT: s_nop 0
8641 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
8642 ; GFX11-CU-NEXT: s_endpgm
8643 ptr addrspace(1) %out, i32 %in) {
8645 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup-one-as") acquire
8646 store i32 %val, ptr addrspace(1) %out, align 4
8650 define amdgpu_kernel void @global_workgroup_one_as_acq_rel_ret_atomicrmw(
8651 ; GFX6-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
8652 ; GFX6: ; %bb.0: ; %entry
8653 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x2
8654 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8655 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
8656 ; GFX6-NEXT: s_mov_b32 s2, -1
8657 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8658 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
8659 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0 glc
8660 ; GFX6-NEXT: s_waitcnt vmcnt(0)
8661 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
8662 ; GFX6-NEXT: s_endpgm
8664 ; GFX7-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
8665 ; GFX7: ; %bb.0: ; %entry
8666 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8667 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
8668 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8669 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
8670 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
8671 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
8672 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
8673 ; GFX7-NEXT: s_waitcnt vmcnt(0)
8674 ; GFX7-NEXT: flat_store_dword v[0:1], v2
8675 ; GFX7-NEXT: s_endpgm
8677 ; GFX10-WGP-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
8678 ; GFX10-WGP: ; %bb.0: ; %entry
8679 ; GFX10-WGP-NEXT: s_clause 0x1
8680 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
8681 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8682 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
8683 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8684 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
8685 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8686 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8687 ; GFX10-WGP-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
8688 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8689 ; GFX10-WGP-NEXT: buffer_gl0_inv
8690 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
8691 ; GFX10-WGP-NEXT: s_endpgm
8693 ; GFX10-CU-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
8694 ; GFX10-CU: ; %bb.0: ; %entry
8695 ; GFX10-CU-NEXT: s_clause 0x1
8696 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
8697 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8698 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
8699 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8700 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
8701 ; GFX10-CU-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
8702 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
8703 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
8704 ; GFX10-CU-NEXT: s_endpgm
8706 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
8707 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8708 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x2
8709 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x0
8710 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
8711 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
8712 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8713 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
8714 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0 glc
8715 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
8716 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
8717 ; SKIP-CACHE-INV-NEXT: s_endpgm
8719 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
8720 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8721 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
8722 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8723 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8724 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8725 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
8726 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
8727 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
8728 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
8729 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8731 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
8732 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8733 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
8734 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8735 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8736 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8737 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
8738 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8739 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
8740 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8741 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
8742 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
8743 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8745 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
8746 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
8747 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
8748 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
8749 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8750 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8751 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s4
8752 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[2:3] sc0
8753 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
8754 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
8755 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
8757 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
8758 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
8759 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
8760 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
8761 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8762 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8763 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s4
8764 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8765 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[2:3] sc0
8766 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8767 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
8768 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
8769 ; GFX940-TGSPLIT-NEXT: s_endpgm
8771 ; GFX11-WGP-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
8772 ; GFX11-WGP: ; %bb.0: ; %entry
8773 ; GFX11-WGP-NEXT: s_clause 0x1
8774 ; GFX11-WGP-NEXT: s_load_b32 s2, s[0:1], 0x8
8775 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
8776 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
8777 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
8778 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
8779 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8780 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] glc
8781 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
8782 ; GFX11-WGP-NEXT: buffer_gl0_inv
8783 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
8784 ; GFX11-WGP-NEXT: s_nop 0
8785 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
8786 ; GFX11-WGP-NEXT: s_endpgm
8788 ; GFX11-CU-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
8789 ; GFX11-CU: ; %bb.0: ; %entry
8790 ; GFX11-CU-NEXT: s_clause 0x1
8791 ; GFX11-CU-NEXT: s_load_b32 s2, s[0:1], 0x8
8792 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
8793 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
8794 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
8795 ; GFX11-CU-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] glc
8796 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
8797 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
8798 ; GFX11-CU-NEXT: s_nop 0
8799 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
8800 ; GFX11-CU-NEXT: s_endpgm
8801 ptr addrspace(1) %out, i32 %in) {
8803 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup-one-as") acq_rel
8804 store i32 %val, ptr addrspace(1) %out, align 4
8808 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_ret_atomicrmw(
8809 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
8810 ; GFX6: ; %bb.0: ; %entry
8811 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x2
8812 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8813 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
8814 ; GFX6-NEXT: s_mov_b32 s2, -1
8815 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8816 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
8817 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0 glc
8818 ; GFX6-NEXT: s_waitcnt vmcnt(0)
8819 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
8820 ; GFX6-NEXT: s_endpgm
8822 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
8823 ; GFX7: ; %bb.0: ; %entry
8824 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8825 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
8826 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8827 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
8828 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
8829 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
8830 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
8831 ; GFX7-NEXT: s_waitcnt vmcnt(0)
8832 ; GFX7-NEXT: flat_store_dword v[0:1], v2
8833 ; GFX7-NEXT: s_endpgm
8835 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
8836 ; GFX10-WGP: ; %bb.0: ; %entry
8837 ; GFX10-WGP-NEXT: s_clause 0x1
8838 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
8839 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8840 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
8841 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8842 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
8843 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8844 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8845 ; GFX10-WGP-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
8846 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8847 ; GFX10-WGP-NEXT: buffer_gl0_inv
8848 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
8849 ; GFX10-WGP-NEXT: s_endpgm
8851 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
8852 ; GFX10-CU: ; %bb.0: ; %entry
8853 ; GFX10-CU-NEXT: s_clause 0x1
8854 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
8855 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8856 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
8857 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8858 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
8859 ; GFX10-CU-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
8860 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
8861 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
8862 ; GFX10-CU-NEXT: s_endpgm
8864 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
8865 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8866 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x2
8867 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x0
8868 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
8869 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
8870 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8871 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
8872 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0 glc
8873 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
8874 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
8875 ; SKIP-CACHE-INV-NEXT: s_endpgm
8877 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
8878 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8879 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
8880 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8881 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8882 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8883 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
8884 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
8885 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
8886 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
8887 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8889 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
8890 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8891 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
8892 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8893 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8894 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8895 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
8896 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8897 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
8898 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8899 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
8900 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
8901 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8903 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
8904 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
8905 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
8906 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
8907 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8908 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8909 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s4
8910 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[2:3] sc0
8911 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
8912 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
8913 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
8915 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
8916 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
8917 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
8918 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
8919 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8920 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8921 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s4
8922 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8923 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[2:3] sc0
8924 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8925 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
8926 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3] sc0 sc1
8927 ; GFX940-TGSPLIT-NEXT: s_endpgm
8929 ; GFX11-WGP-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
8930 ; GFX11-WGP: ; %bb.0: ; %entry
8931 ; GFX11-WGP-NEXT: s_clause 0x1
8932 ; GFX11-WGP-NEXT: s_load_b32 s2, s[0:1], 0x8
8933 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
8934 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
8935 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
8936 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
8937 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8938 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] glc
8939 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
8940 ; GFX11-WGP-NEXT: buffer_gl0_inv
8941 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
8942 ; GFX11-WGP-NEXT: s_nop 0
8943 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
8944 ; GFX11-WGP-NEXT: s_endpgm
8946 ; GFX11-CU-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
8947 ; GFX11-CU: ; %bb.0: ; %entry
8948 ; GFX11-CU-NEXT: s_clause 0x1
8949 ; GFX11-CU-NEXT: s_load_b32 s2, s[0:1], 0x8
8950 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
8951 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
8952 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
8953 ; GFX11-CU-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] glc
8954 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
8955 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
8956 ; GFX11-CU-NEXT: s_nop 0
8957 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
8958 ; GFX11-CU-NEXT: s_endpgm
8959 ptr addrspace(1) %out, i32 %in) {
8961 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup-one-as") seq_cst
8962 store i32 %val, ptr addrspace(1) %out, align 4
8966 define amdgpu_kernel void @global_workgroup_one_as_monotonic_monotonic_cmpxchg(
8967 ; GFX6-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
8968 ; GFX6: ; %bb.0: ; %entry
8969 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8970 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
8971 ; GFX6-NEXT: s_mov_b32 s6, -1
8972 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8973 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
8974 ; GFX6-NEXT: s_mov_b32 s4, s0
8975 ; GFX6-NEXT: s_mov_b32 s5, s1
8976 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
8977 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
8978 ; GFX6-NEXT: s_endpgm
8980 ; GFX7-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
8981 ; GFX7: ; %bb.0: ; %entry
8982 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8983 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8984 ; GFX7-NEXT: s_add_u32 s0, s0, 16
8985 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
8986 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
8987 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
8988 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
8989 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
8990 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8991 ; GFX7-NEXT: s_endpgm
8993 ; GFX10-WGP-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
8994 ; GFX10-WGP: ; %bb.0: ; %entry
8995 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8996 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
8997 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8998 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
8999 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
9000 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9001 ; GFX10-WGP-NEXT: s_endpgm
9003 ; GFX10-CU-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
9004 ; GFX10-CU: ; %bb.0: ; %entry
9005 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9006 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
9007 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9008 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
9009 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
9010 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9011 ; GFX10-CU-NEXT: s_endpgm
9013 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
9014 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
9015 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9016 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
9017 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
9018 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9019 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
9020 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
9021 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
9022 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
9023 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
9024 ; SKIP-CACHE-INV-NEXT: s_endpgm
9026 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
9027 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
9028 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9029 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9030 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9031 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9032 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9033 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
9035 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
9036 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
9037 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9038 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9039 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9040 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9041 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9042 ; GFX90A-TGSPLIT-NEXT: s_endpgm
9044 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
9045 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
9046 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9047 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9048 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9049 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
9050 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9051 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
9053 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
9054 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
9055 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9056 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9057 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9058 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
9059 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9060 ; GFX940-TGSPLIT-NEXT: s_endpgm
9062 ; GFX11-WGP-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
9063 ; GFX11-WGP: ; %bb.0: ; %entry
9064 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9065 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
9066 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
9067 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
9068 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
9069 ; GFX11-WGP-NEXT: s_nop 0
9070 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
9071 ; GFX11-WGP-NEXT: s_endpgm
9073 ; GFX11-CU-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
9074 ; GFX11-CU: ; %bb.0: ; %entry
9075 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9076 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
9077 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
9078 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
9079 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
9080 ; GFX11-CU-NEXT: s_nop 0
9081 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
9082 ; GFX11-CU-NEXT: s_endpgm
9083 ptr addrspace(1) %out, i32 %in, i32 %old) {
9085 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
9086 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") monotonic monotonic
9090 define amdgpu_kernel void @global_workgroup_one_as_acquire_monotonic_cmpxchg(
9091 ; GFX6-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
9092 ; GFX6: ; %bb.0: ; %entry
9093 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9094 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
9095 ; GFX6-NEXT: s_mov_b32 s6, -1
9096 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
9097 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
9098 ; GFX6-NEXT: s_mov_b32 s4, s0
9099 ; GFX6-NEXT: s_mov_b32 s5, s1
9100 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
9101 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
9102 ; GFX6-NEXT: s_endpgm
9104 ; GFX7-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
9105 ; GFX7: ; %bb.0: ; %entry
9106 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9107 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
9108 ; GFX7-NEXT: s_add_u32 s0, s0, 16
9109 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
9110 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
9111 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
9112 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
9113 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
9114 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9115 ; GFX7-NEXT: s_endpgm
9117 ; GFX10-WGP-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
9118 ; GFX10-WGP: ; %bb.0: ; %entry
9119 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9120 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
9121 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
9122 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
9123 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
9124 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9125 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9126 ; GFX10-WGP-NEXT: buffer_gl0_inv
9127 ; GFX10-WGP-NEXT: s_endpgm
9129 ; GFX10-CU-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
9130 ; GFX10-CU: ; %bb.0: ; %entry
9131 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9132 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
9133 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9134 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
9135 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
9136 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9137 ; GFX10-CU-NEXT: s_endpgm
9139 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
9140 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
9141 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9142 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
9143 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
9144 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9145 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
9146 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
9147 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
9148 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
9149 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
9150 ; SKIP-CACHE-INV-NEXT: s_endpgm
9152 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
9153 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
9154 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9155 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9156 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9157 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9158 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9159 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
9161 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
9162 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
9163 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9164 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9165 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9166 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9167 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9168 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9169 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
9170 ; GFX90A-TGSPLIT-NEXT: s_endpgm
9172 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
9173 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
9174 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9175 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9176 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9177 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
9178 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9179 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
9181 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
9182 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
9183 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9184 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9185 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9186 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
9187 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9188 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9189 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
9190 ; GFX940-TGSPLIT-NEXT: s_endpgm
9192 ; GFX11-WGP-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
9193 ; GFX11-WGP: ; %bb.0: ; %entry
9194 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9195 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
9196 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
9197 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
9198 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
9199 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9200 ; GFX11-WGP-NEXT: buffer_gl0_inv
9201 ; GFX11-WGP-NEXT: s_endpgm
9203 ; GFX11-CU-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
9204 ; GFX11-CU: ; %bb.0: ; %entry
9205 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9206 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
9207 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
9208 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
9209 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
9210 ; GFX11-CU-NEXT: s_nop 0
9211 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
9212 ; GFX11-CU-NEXT: s_endpgm
9213 ptr addrspace(1) %out, i32 %in, i32 %old) {
9215 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
9216 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acquire monotonic
9220 define amdgpu_kernel void @global_workgroup_one_as_release_monotonic_cmpxchg(
9221 ; GFX6-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
9222 ; GFX6: ; %bb.0: ; %entry
9223 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9224 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
9225 ; GFX6-NEXT: s_mov_b32 s6, -1
9226 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
9227 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
9228 ; GFX6-NEXT: s_mov_b32 s4, s0
9229 ; GFX6-NEXT: s_mov_b32 s5, s1
9230 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
9231 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
9232 ; GFX6-NEXT: s_endpgm
9234 ; GFX7-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
9235 ; GFX7: ; %bb.0: ; %entry
9236 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9237 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
9238 ; GFX7-NEXT: s_add_u32 s0, s0, 16
9239 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
9240 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
9241 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
9242 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
9243 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
9244 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9245 ; GFX7-NEXT: s_endpgm
9247 ; GFX10-WGP-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
9248 ; GFX10-WGP: ; %bb.0: ; %entry
9249 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9250 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
9251 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
9252 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
9253 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
9254 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
9255 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9256 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9257 ; GFX10-WGP-NEXT: s_endpgm
9259 ; GFX10-CU-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
9260 ; GFX10-CU: ; %bb.0: ; %entry
9261 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9262 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
9263 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9264 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
9265 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
9266 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9267 ; GFX10-CU-NEXT: s_endpgm
9269 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
9270 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
9271 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9272 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
9273 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
9274 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9275 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
9276 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
9277 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
9278 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
9279 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
9280 ; SKIP-CACHE-INV-NEXT: s_endpgm
9282 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
9283 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
9284 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9285 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9286 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9287 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9288 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9289 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
9291 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
9292 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
9293 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9294 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9295 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9296 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9297 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9298 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9299 ; GFX90A-TGSPLIT-NEXT: s_endpgm
9301 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
9302 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
9303 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9304 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9305 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9306 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
9307 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9308 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
9310 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
9311 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
9312 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9313 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9314 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9315 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
9316 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9317 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9318 ; GFX940-TGSPLIT-NEXT: s_endpgm
9320 ; GFX11-WGP-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
9321 ; GFX11-WGP: ; %bb.0: ; %entry
9322 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9323 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
9324 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
9325 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
9326 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
9327 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9328 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
9329 ; GFX11-WGP-NEXT: s_nop 0
9330 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
9331 ; GFX11-WGP-NEXT: s_endpgm
9333 ; GFX11-CU-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
9334 ; GFX11-CU: ; %bb.0: ; %entry
9335 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9336 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
9337 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
9338 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
9339 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
9340 ; GFX11-CU-NEXT: s_nop 0
9341 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
9342 ; GFX11-CU-NEXT: s_endpgm
9343 ptr addrspace(1) %out, i32 %in, i32 %old) {
9345 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
9346 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") release monotonic
9350 define amdgpu_kernel void @global_workgroup_one_as_acq_rel_monotonic_cmpxchg(
9351 ; GFX6-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
9352 ; GFX6: ; %bb.0: ; %entry
9353 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9354 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
9355 ; GFX6-NEXT: s_mov_b32 s6, -1
9356 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
9357 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
9358 ; GFX6-NEXT: s_mov_b32 s4, s0
9359 ; GFX6-NEXT: s_mov_b32 s5, s1
9360 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
9361 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
9362 ; GFX6-NEXT: s_endpgm
9364 ; GFX7-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
9365 ; GFX7: ; %bb.0: ; %entry
9366 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9367 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
9368 ; GFX7-NEXT: s_add_u32 s0, s0, 16
9369 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
9370 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
9371 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
9372 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
9373 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
9374 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9375 ; GFX7-NEXT: s_endpgm
9377 ; GFX10-WGP-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
9378 ; GFX10-WGP: ; %bb.0: ; %entry
9379 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9380 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
9381 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
9382 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
9383 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
9384 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
9385 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9386 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9387 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9388 ; GFX10-WGP-NEXT: buffer_gl0_inv
9389 ; GFX10-WGP-NEXT: s_endpgm
9391 ; GFX10-CU-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
9392 ; GFX10-CU: ; %bb.0: ; %entry
9393 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9394 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
9395 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9396 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
9397 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
9398 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9399 ; GFX10-CU-NEXT: s_endpgm
9401 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
9402 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
9403 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9404 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
9405 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
9406 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9407 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
9408 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
9409 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
9410 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
9411 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
9412 ; SKIP-CACHE-INV-NEXT: s_endpgm
9414 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
9415 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
9416 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9417 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9418 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9419 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9420 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9421 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
9423 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
9424 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
9425 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9426 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9427 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9428 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9429 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9430 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9431 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9432 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
9433 ; GFX90A-TGSPLIT-NEXT: s_endpgm
9435 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
9436 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
9437 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9438 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9439 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9440 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
9441 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9442 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
9444 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
9445 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
9446 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9447 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9448 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9449 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
9450 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9451 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9452 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9453 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
9454 ; GFX940-TGSPLIT-NEXT: s_endpgm
9456 ; GFX11-WGP-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
9457 ; GFX11-WGP: ; %bb.0: ; %entry
9458 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9459 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
9460 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
9461 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
9462 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
9463 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9464 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
9465 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9466 ; GFX11-WGP-NEXT: buffer_gl0_inv
9467 ; GFX11-WGP-NEXT: s_endpgm
9469 ; GFX11-CU-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
9470 ; GFX11-CU: ; %bb.0: ; %entry
9471 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9472 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
9473 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
9474 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
9475 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
9476 ; GFX11-CU-NEXT: s_nop 0
9477 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
9478 ; GFX11-CU-NEXT: s_endpgm
9479 ptr addrspace(1) %out, i32 %in, i32 %old) {
9481 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
9482 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acq_rel monotonic
9486 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_monotonic_cmpxchg(
9487 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
9488 ; GFX6: ; %bb.0: ; %entry
9489 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9490 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
9491 ; GFX6-NEXT: s_mov_b32 s6, -1
9492 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
9493 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
9494 ; GFX6-NEXT: s_mov_b32 s4, s0
9495 ; GFX6-NEXT: s_mov_b32 s5, s1
9496 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
9497 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
9498 ; GFX6-NEXT: s_endpgm
9500 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
9501 ; GFX7: ; %bb.0: ; %entry
9502 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9503 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
9504 ; GFX7-NEXT: s_add_u32 s0, s0, 16
9505 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
9506 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
9507 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
9508 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
9509 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
9510 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9511 ; GFX7-NEXT: s_endpgm
9513 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
9514 ; GFX10-WGP: ; %bb.0: ; %entry
9515 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9516 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
9517 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
9518 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
9519 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
9520 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
9521 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9522 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9523 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9524 ; GFX10-WGP-NEXT: buffer_gl0_inv
9525 ; GFX10-WGP-NEXT: s_endpgm
9527 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
9528 ; GFX10-CU: ; %bb.0: ; %entry
9529 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9530 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
9531 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9532 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
9533 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
9534 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9535 ; GFX10-CU-NEXT: s_endpgm
9537 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
9538 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
9539 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9540 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
9541 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
9542 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9543 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
9544 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
9545 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
9546 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
9547 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
9548 ; SKIP-CACHE-INV-NEXT: s_endpgm
9550 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
9551 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
9552 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9553 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9554 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9555 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9556 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9557 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
9559 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
9560 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
9561 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9562 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9563 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9564 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9565 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9566 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9567 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9568 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
9569 ; GFX90A-TGSPLIT-NEXT: s_endpgm
9571 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
9572 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
9573 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9574 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9575 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9576 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
9577 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9578 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
9580 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
9581 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
9582 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9583 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9584 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9585 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
9586 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9587 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9588 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9589 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
9590 ; GFX940-TGSPLIT-NEXT: s_endpgm
9592 ; GFX11-WGP-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
9593 ; GFX11-WGP: ; %bb.0: ; %entry
9594 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9595 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
9596 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
9597 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
9598 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
9599 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9600 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
9601 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9602 ; GFX11-WGP-NEXT: buffer_gl0_inv
9603 ; GFX11-WGP-NEXT: s_endpgm
9605 ; GFX11-CU-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
9606 ; GFX11-CU: ; %bb.0: ; %entry
9607 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9608 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
9609 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
9610 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
9611 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
9612 ; GFX11-CU-NEXT: s_nop 0
9613 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
9614 ; GFX11-CU-NEXT: s_endpgm
9615 ptr addrspace(1) %out, i32 %in, i32 %old) {
9617 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
9618 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") seq_cst monotonic
9622 define amdgpu_kernel void @global_workgroup_one_as_monotonic_acquire_cmpxchg(
9623 ; GFX6-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
9624 ; GFX6: ; %bb.0: ; %entry
9625 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9626 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
9627 ; GFX6-NEXT: s_mov_b32 s6, -1
9628 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
9629 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
9630 ; GFX6-NEXT: s_mov_b32 s4, s0
9631 ; GFX6-NEXT: s_mov_b32 s5, s1
9632 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
9633 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
9634 ; GFX6-NEXT: s_endpgm
9636 ; GFX7-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
9637 ; GFX7: ; %bb.0: ; %entry
9638 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9639 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
9640 ; GFX7-NEXT: s_add_u32 s0, s0, 16
9641 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
9642 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
9643 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
9644 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
9645 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
9646 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9647 ; GFX7-NEXT: s_endpgm
9649 ; GFX10-WGP-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
9650 ; GFX10-WGP: ; %bb.0: ; %entry
9651 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9652 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
9653 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
9654 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
9655 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
9656 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9657 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9658 ; GFX10-WGP-NEXT: buffer_gl0_inv
9659 ; GFX10-WGP-NEXT: s_endpgm
9661 ; GFX10-CU-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
9662 ; GFX10-CU: ; %bb.0: ; %entry
9663 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9664 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
9665 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9666 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
9667 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
9668 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9669 ; GFX10-CU-NEXT: s_endpgm
9671 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
9672 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
9673 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9674 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
9675 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
9676 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9677 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
9678 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
9679 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
9680 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
9681 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
9682 ; SKIP-CACHE-INV-NEXT: s_endpgm
9684 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
9685 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
9686 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9687 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9688 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9689 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9690 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9691 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
9693 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
9694 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
9695 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9696 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9697 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9698 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9699 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9700 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9701 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
9702 ; GFX90A-TGSPLIT-NEXT: s_endpgm
9704 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
9705 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
9706 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9707 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9708 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9709 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
9710 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9711 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
9713 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
9714 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
9715 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9716 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9717 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9718 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
9719 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9720 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9721 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
9722 ; GFX940-TGSPLIT-NEXT: s_endpgm
9724 ; GFX11-WGP-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
9725 ; GFX11-WGP: ; %bb.0: ; %entry
9726 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9727 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
9728 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
9729 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
9730 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
9731 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9732 ; GFX11-WGP-NEXT: buffer_gl0_inv
9733 ; GFX11-WGP-NEXT: s_endpgm
9735 ; GFX11-CU-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
9736 ; GFX11-CU: ; %bb.0: ; %entry
9737 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9738 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
9739 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
9740 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
9741 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
9742 ; GFX11-CU-NEXT: s_nop 0
9743 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
9744 ; GFX11-CU-NEXT: s_endpgm
9745 ptr addrspace(1) %out, i32 %in, i32 %old) {
9747 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
9748 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") monotonic acquire
9752 define amdgpu_kernel void @global_workgroup_one_as_acquire_acquire_cmpxchg(
9753 ; GFX6-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
9754 ; GFX6: ; %bb.0: ; %entry
9755 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9756 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
9757 ; GFX6-NEXT: s_mov_b32 s6, -1
9758 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
9759 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
9760 ; GFX6-NEXT: s_mov_b32 s4, s0
9761 ; GFX6-NEXT: s_mov_b32 s5, s1
9762 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
9763 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
9764 ; GFX6-NEXT: s_endpgm
9766 ; GFX7-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
9767 ; GFX7: ; %bb.0: ; %entry
9768 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9769 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
9770 ; GFX7-NEXT: s_add_u32 s0, s0, 16
9771 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
9772 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
9773 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
9774 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
9775 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
9776 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9777 ; GFX7-NEXT: s_endpgm
9779 ; GFX10-WGP-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
9780 ; GFX10-WGP: ; %bb.0: ; %entry
9781 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9782 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
9783 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
9784 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
9785 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
9786 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9787 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9788 ; GFX10-WGP-NEXT: buffer_gl0_inv
9789 ; GFX10-WGP-NEXT: s_endpgm
9791 ; GFX10-CU-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
9792 ; GFX10-CU: ; %bb.0: ; %entry
9793 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9794 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
9795 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9796 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
9797 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
9798 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9799 ; GFX10-CU-NEXT: s_endpgm
9801 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
9802 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
9803 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9804 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
9805 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
9806 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9807 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
9808 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
9809 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
9810 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
9811 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
9812 ; SKIP-CACHE-INV-NEXT: s_endpgm
9814 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
9815 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
9816 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9817 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9818 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9819 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9820 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9821 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
9823 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
9824 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
9825 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9826 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9827 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9828 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9829 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9830 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9831 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
9832 ; GFX90A-TGSPLIT-NEXT: s_endpgm
9834 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
9835 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
9836 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9837 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9838 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9839 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
9840 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9841 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
9843 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
9844 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
9845 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9846 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9847 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9848 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
9849 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9850 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9851 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
9852 ; GFX940-TGSPLIT-NEXT: s_endpgm
9854 ; GFX11-WGP-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
9855 ; GFX11-WGP: ; %bb.0: ; %entry
9856 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9857 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
9858 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
9859 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
9860 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
9861 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9862 ; GFX11-WGP-NEXT: buffer_gl0_inv
9863 ; GFX11-WGP-NEXT: s_endpgm
9865 ; GFX11-CU-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
9866 ; GFX11-CU: ; %bb.0: ; %entry
9867 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9868 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
9869 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
9870 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
9871 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
9872 ; GFX11-CU-NEXT: s_nop 0
9873 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
9874 ; GFX11-CU-NEXT: s_endpgm
9875 ptr addrspace(1) %out, i32 %in, i32 %old) {
9877 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
9878 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acquire acquire
9882 define amdgpu_kernel void @global_workgroup_one_as_release_acquire_cmpxchg(
9883 ; GFX6-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
9884 ; GFX6: ; %bb.0: ; %entry
9885 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9886 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
9887 ; GFX6-NEXT: s_mov_b32 s6, -1
9888 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
9889 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
9890 ; GFX6-NEXT: s_mov_b32 s4, s0
9891 ; GFX6-NEXT: s_mov_b32 s5, s1
9892 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
9893 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
9894 ; GFX6-NEXT: s_endpgm
9896 ; GFX7-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
9897 ; GFX7: ; %bb.0: ; %entry
9898 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9899 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
9900 ; GFX7-NEXT: s_add_u32 s0, s0, 16
9901 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
9902 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
9903 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
9904 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
9905 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
9906 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9907 ; GFX7-NEXT: s_endpgm
9909 ; GFX10-WGP-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
9910 ; GFX10-WGP: ; %bb.0: ; %entry
9911 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9912 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
9913 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
9914 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
9915 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
9916 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
9917 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9918 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9919 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9920 ; GFX10-WGP-NEXT: buffer_gl0_inv
9921 ; GFX10-WGP-NEXT: s_endpgm
9923 ; GFX10-CU-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
9924 ; GFX10-CU: ; %bb.0: ; %entry
9925 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9926 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
9927 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9928 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
9929 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
9930 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9931 ; GFX10-CU-NEXT: s_endpgm
9933 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
9934 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
9935 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9936 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
9937 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
9938 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9939 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
9940 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
9941 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
9942 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
9943 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
9944 ; SKIP-CACHE-INV-NEXT: s_endpgm
9946 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
9947 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
9948 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9949 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9950 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9951 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9952 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9953 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
9955 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
9956 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
9957 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9958 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9959 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9960 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9961 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9962 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9963 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9964 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
9965 ; GFX90A-TGSPLIT-NEXT: s_endpgm
9967 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
9968 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
9969 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9970 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9971 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9972 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
9973 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9974 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
9976 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
9977 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
9978 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9979 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9980 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9981 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
9982 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9983 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
9984 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9985 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
9986 ; GFX940-TGSPLIT-NEXT: s_endpgm
9988 ; GFX11-WGP-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
9989 ; GFX11-WGP: ; %bb.0: ; %entry
9990 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9991 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
9992 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
9993 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
9994 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
9995 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9996 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
9997 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9998 ; GFX11-WGP-NEXT: buffer_gl0_inv
9999 ; GFX11-WGP-NEXT: s_endpgm
10001 ; GFX11-CU-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
10002 ; GFX11-CU: ; %bb.0: ; %entry
10003 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10004 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
10005 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
10006 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
10007 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
10008 ; GFX11-CU-NEXT: s_nop 0
10009 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
10010 ; GFX11-CU-NEXT: s_endpgm
10011 ptr addrspace(1) %out, i32 %in, i32 %old) {
10013 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
10014 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") release acquire
10018 define amdgpu_kernel void @global_workgroup_one_as_acq_rel_acquire_cmpxchg(
10019 ; GFX6-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
10020 ; GFX6: ; %bb.0: ; %entry
10021 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10022 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
10023 ; GFX6-NEXT: s_mov_b32 s6, -1
10024 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
10025 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
10026 ; GFX6-NEXT: s_mov_b32 s4, s0
10027 ; GFX6-NEXT: s_mov_b32 s5, s1
10028 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
10029 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
10030 ; GFX6-NEXT: s_endpgm
10032 ; GFX7-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
10033 ; GFX7: ; %bb.0: ; %entry
10034 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10035 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
10036 ; GFX7-NEXT: s_add_u32 s0, s0, 16
10037 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
10038 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
10039 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
10040 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
10041 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
10042 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
10043 ; GFX7-NEXT: s_endpgm
10045 ; GFX10-WGP-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
10046 ; GFX10-WGP: ; %bb.0: ; %entry
10047 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10048 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
10049 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
10050 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
10051 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
10052 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
10053 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10054 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10055 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10056 ; GFX10-WGP-NEXT: buffer_gl0_inv
10057 ; GFX10-WGP-NEXT: s_endpgm
10059 ; GFX10-CU-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
10060 ; GFX10-CU: ; %bb.0: ; %entry
10061 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10062 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
10063 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
10064 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
10065 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
10066 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10067 ; GFX10-CU-NEXT: s_endpgm
10069 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
10070 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
10071 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10072 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
10073 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
10074 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
10075 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
10076 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
10077 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
10078 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
10079 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
10080 ; SKIP-CACHE-INV-NEXT: s_endpgm
10082 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
10083 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
10084 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10085 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
10086 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10087 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
10088 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10089 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
10091 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
10092 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
10093 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10094 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
10095 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10096 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
10097 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10098 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10099 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10100 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
10101 ; GFX90A-TGSPLIT-NEXT: s_endpgm
10103 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
10104 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
10105 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10106 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
10107 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10108 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
10109 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10110 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
10112 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
10113 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
10114 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10115 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
10116 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10117 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
10118 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10119 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10120 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10121 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
10122 ; GFX940-TGSPLIT-NEXT: s_endpgm
10124 ; GFX11-WGP-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
10125 ; GFX11-WGP: ; %bb.0: ; %entry
10126 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10127 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
10128 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10129 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
10130 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
10131 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10132 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
10133 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10134 ; GFX11-WGP-NEXT: buffer_gl0_inv
10135 ; GFX11-WGP-NEXT: s_endpgm
10137 ; GFX11-CU-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
10138 ; GFX11-CU: ; %bb.0: ; %entry
10139 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10140 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
10141 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
10142 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
10143 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
10144 ; GFX11-CU-NEXT: s_nop 0
10145 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
10146 ; GFX11-CU-NEXT: s_endpgm
10147 ptr addrspace(1) %out, i32 %in, i32 %old) {
10149 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
10150 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acq_rel acquire
10154 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_acquire_cmpxchg(
10155 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
10156 ; GFX6: ; %bb.0: ; %entry
10157 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10158 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
10159 ; GFX6-NEXT: s_mov_b32 s6, -1
10160 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
10161 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
10162 ; GFX6-NEXT: s_mov_b32 s4, s0
10163 ; GFX6-NEXT: s_mov_b32 s5, s1
10164 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
10165 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
10166 ; GFX6-NEXT: s_endpgm
10168 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
10169 ; GFX7: ; %bb.0: ; %entry
10170 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10171 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
10172 ; GFX7-NEXT: s_add_u32 s0, s0, 16
10173 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
10174 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
10175 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
10176 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
10177 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
10178 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
10179 ; GFX7-NEXT: s_endpgm
10181 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
10182 ; GFX10-WGP: ; %bb.0: ; %entry
10183 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10184 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
10185 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
10186 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
10187 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
10188 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
10189 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10190 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10191 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10192 ; GFX10-WGP-NEXT: buffer_gl0_inv
10193 ; GFX10-WGP-NEXT: s_endpgm
10195 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
10196 ; GFX10-CU: ; %bb.0: ; %entry
10197 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10198 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
10199 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
10200 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
10201 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
10202 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10203 ; GFX10-CU-NEXT: s_endpgm
10205 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
10206 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
10207 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10208 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
10209 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
10210 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
10211 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
10212 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
10213 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
10214 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
10215 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
10216 ; SKIP-CACHE-INV-NEXT: s_endpgm
10218 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
10219 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
10220 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10221 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
10222 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10223 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
10224 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10225 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
10227 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
10228 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
10229 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10230 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
10231 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10232 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
10233 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10234 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10235 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10236 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
10237 ; GFX90A-TGSPLIT-NEXT: s_endpgm
10239 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
10240 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
10241 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10242 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
10243 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10244 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
10245 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10246 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
10248 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
10249 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
10250 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10251 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
10252 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10253 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
10254 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10255 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10256 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10257 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
10258 ; GFX940-TGSPLIT-NEXT: s_endpgm
10260 ; GFX11-WGP-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
10261 ; GFX11-WGP: ; %bb.0: ; %entry
10262 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10263 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
10264 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10265 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
10266 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
10267 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10268 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
10269 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10270 ; GFX11-WGP-NEXT: buffer_gl0_inv
10271 ; GFX11-WGP-NEXT: s_endpgm
10273 ; GFX11-CU-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
10274 ; GFX11-CU: ; %bb.0: ; %entry
10275 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10276 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
10277 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
10278 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
10279 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
10280 ; GFX11-CU-NEXT: s_nop 0
10281 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
10282 ; GFX11-CU-NEXT: s_endpgm
10283 ptr addrspace(1) %out, i32 %in, i32 %old) {
10285 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
10286 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") seq_cst acquire
10290 define amdgpu_kernel void @global_workgroup_one_as_monotonic_seq_cst_cmpxchg(
10291 ; GFX6-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
10292 ; GFX6: ; %bb.0: ; %entry
10293 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10294 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
10295 ; GFX6-NEXT: s_mov_b32 s6, -1
10296 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
10297 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
10298 ; GFX6-NEXT: s_mov_b32 s4, s0
10299 ; GFX6-NEXT: s_mov_b32 s5, s1
10300 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
10301 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
10302 ; GFX6-NEXT: s_endpgm
10304 ; GFX7-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
10305 ; GFX7: ; %bb.0: ; %entry
10306 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10307 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
10308 ; GFX7-NEXT: s_add_u32 s0, s0, 16
10309 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
10310 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
10311 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
10312 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
10313 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
10314 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
10315 ; GFX7-NEXT: s_endpgm
10317 ; GFX10-WGP-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
10318 ; GFX10-WGP: ; %bb.0: ; %entry
10319 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10320 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
10321 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
10322 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
10323 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
10324 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
10325 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10326 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10327 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10328 ; GFX10-WGP-NEXT: buffer_gl0_inv
10329 ; GFX10-WGP-NEXT: s_endpgm
10331 ; GFX10-CU-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
10332 ; GFX10-CU: ; %bb.0: ; %entry
10333 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10334 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
10335 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
10336 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
10337 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
10338 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10339 ; GFX10-CU-NEXT: s_endpgm
10341 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
10342 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
10343 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10344 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
10345 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
10346 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
10347 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
10348 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
10349 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
10350 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
10351 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
10352 ; SKIP-CACHE-INV-NEXT: s_endpgm
10354 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
10355 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
10356 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10357 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
10358 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10359 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
10360 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10361 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
10363 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
10364 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
10365 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10366 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
10367 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10368 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
10369 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10370 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10371 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10372 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
10373 ; GFX90A-TGSPLIT-NEXT: s_endpgm
10375 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
10376 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
10377 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10378 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
10379 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10380 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
10381 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10382 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
10384 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
10385 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
10386 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10387 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
10388 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10389 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
10390 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10391 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10392 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10393 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
10394 ; GFX940-TGSPLIT-NEXT: s_endpgm
10396 ; GFX11-WGP-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
10397 ; GFX11-WGP: ; %bb.0: ; %entry
10398 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10399 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
10400 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10401 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
10402 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
10403 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10404 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
10405 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10406 ; GFX11-WGP-NEXT: buffer_gl0_inv
10407 ; GFX11-WGP-NEXT: s_endpgm
10409 ; GFX11-CU-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
10410 ; GFX11-CU: ; %bb.0: ; %entry
10411 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10412 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
10413 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
10414 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
10415 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
10416 ; GFX11-CU-NEXT: s_nop 0
10417 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
10418 ; GFX11-CU-NEXT: s_endpgm
10419 ptr addrspace(1) %out, i32 %in, i32 %old) {
10421 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
10422 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") monotonic seq_cst
10426 define amdgpu_kernel void @global_workgroup_one_as_acquire_seq_cst_cmpxchg(
10427 ; GFX6-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
10428 ; GFX6: ; %bb.0: ; %entry
10429 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10430 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
10431 ; GFX6-NEXT: s_mov_b32 s6, -1
10432 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
10433 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
10434 ; GFX6-NEXT: s_mov_b32 s4, s0
10435 ; GFX6-NEXT: s_mov_b32 s5, s1
10436 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
10437 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
10438 ; GFX6-NEXT: s_endpgm
10440 ; GFX7-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
10441 ; GFX7: ; %bb.0: ; %entry
10442 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10443 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
10444 ; GFX7-NEXT: s_add_u32 s0, s0, 16
10445 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
10446 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
10447 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
10448 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
10449 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
10450 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
10451 ; GFX7-NEXT: s_endpgm
10453 ; GFX10-WGP-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
10454 ; GFX10-WGP: ; %bb.0: ; %entry
10455 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10456 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
10457 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
10458 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
10459 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
10460 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
10461 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10462 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10463 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10464 ; GFX10-WGP-NEXT: buffer_gl0_inv
10465 ; GFX10-WGP-NEXT: s_endpgm
10467 ; GFX10-CU-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
10468 ; GFX10-CU: ; %bb.0: ; %entry
10469 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10470 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
10471 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
10472 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
10473 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
10474 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10475 ; GFX10-CU-NEXT: s_endpgm
10477 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
10478 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
10479 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10480 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
10481 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
10482 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
10483 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
10484 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
10485 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
10486 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
10487 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
10488 ; SKIP-CACHE-INV-NEXT: s_endpgm
10490 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
10491 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
10492 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10493 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
10494 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10495 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
10496 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10497 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
10499 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
10500 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
10501 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10502 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
10503 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10504 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
10505 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10506 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10507 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10508 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
10509 ; GFX90A-TGSPLIT-NEXT: s_endpgm
10511 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
10512 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
10513 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10514 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
10515 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10516 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
10517 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10518 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
10520 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
10521 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
10522 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10523 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
10524 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10525 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
10526 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10527 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10528 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10529 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
10530 ; GFX940-TGSPLIT-NEXT: s_endpgm
10532 ; GFX11-WGP-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
10533 ; GFX11-WGP: ; %bb.0: ; %entry
10534 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10535 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
10536 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10537 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
10538 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
10539 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10540 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
10541 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10542 ; GFX11-WGP-NEXT: buffer_gl0_inv
10543 ; GFX11-WGP-NEXT: s_endpgm
10545 ; GFX11-CU-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
10546 ; GFX11-CU: ; %bb.0: ; %entry
10547 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10548 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
10549 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
10550 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
10551 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
10552 ; GFX11-CU-NEXT: s_nop 0
10553 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
10554 ; GFX11-CU-NEXT: s_endpgm
10555 ptr addrspace(1) %out, i32 %in, i32 %old) {
10557 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
10558 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acquire seq_cst
10562 define amdgpu_kernel void @global_workgroup_one_as_release_seq_cst_cmpxchg(
10563 ; GFX6-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
10564 ; GFX6: ; %bb.0: ; %entry
10565 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10566 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
10567 ; GFX6-NEXT: s_mov_b32 s6, -1
10568 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
10569 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
10570 ; GFX6-NEXT: s_mov_b32 s4, s0
10571 ; GFX6-NEXT: s_mov_b32 s5, s1
10572 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
10573 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
10574 ; GFX6-NEXT: s_endpgm
10576 ; GFX7-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
10577 ; GFX7: ; %bb.0: ; %entry
10578 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10579 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
10580 ; GFX7-NEXT: s_add_u32 s0, s0, 16
10581 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
10582 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
10583 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
10584 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
10585 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
10586 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
10587 ; GFX7-NEXT: s_endpgm
10589 ; GFX10-WGP-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
10590 ; GFX10-WGP: ; %bb.0: ; %entry
10591 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10592 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
10593 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
10594 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
10595 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
10596 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
10597 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10598 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10599 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10600 ; GFX10-WGP-NEXT: buffer_gl0_inv
10601 ; GFX10-WGP-NEXT: s_endpgm
10603 ; GFX10-CU-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
10604 ; GFX10-CU: ; %bb.0: ; %entry
10605 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10606 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
10607 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
10608 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
10609 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
10610 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10611 ; GFX10-CU-NEXT: s_endpgm
10613 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
10614 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
10615 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10616 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
10617 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
10618 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
10619 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
10620 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
10621 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
10622 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
10623 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
10624 ; SKIP-CACHE-INV-NEXT: s_endpgm
10626 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
10627 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
10628 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10629 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
10630 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10631 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
10632 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10633 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
10635 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
10636 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
10637 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10638 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
10639 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10640 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
10641 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10642 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10643 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10644 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
10645 ; GFX90A-TGSPLIT-NEXT: s_endpgm
10647 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
10648 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
10649 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10650 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
10651 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10652 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
10653 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10654 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
10656 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
10657 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
10658 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10659 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
10660 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10661 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
10662 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10663 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10664 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10665 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
10666 ; GFX940-TGSPLIT-NEXT: s_endpgm
10668 ; GFX11-WGP-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
10669 ; GFX11-WGP: ; %bb.0: ; %entry
10670 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10671 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
10672 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10673 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
10674 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
10675 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10676 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
10677 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10678 ; GFX11-WGP-NEXT: buffer_gl0_inv
10679 ; GFX11-WGP-NEXT: s_endpgm
10681 ; GFX11-CU-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
10682 ; GFX11-CU: ; %bb.0: ; %entry
10683 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10684 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
10685 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
10686 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
10687 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
10688 ; GFX11-CU-NEXT: s_nop 0
10689 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
10690 ; GFX11-CU-NEXT: s_endpgm
10691 ptr addrspace(1) %out, i32 %in, i32 %old) {
10693 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
10694 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") release seq_cst
10698 define amdgpu_kernel void @global_workgroup_one_as_acq_rel_seq_cst_cmpxchg(
10699 ; GFX6-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
10700 ; GFX6: ; %bb.0: ; %entry
10701 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10702 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
10703 ; GFX6-NEXT: s_mov_b32 s6, -1
10704 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
10705 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
10706 ; GFX6-NEXT: s_mov_b32 s4, s0
10707 ; GFX6-NEXT: s_mov_b32 s5, s1
10708 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
10709 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
10710 ; GFX6-NEXT: s_endpgm
10712 ; GFX7-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
10713 ; GFX7: ; %bb.0: ; %entry
10714 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10715 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
10716 ; GFX7-NEXT: s_add_u32 s0, s0, 16
10717 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
10718 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
10719 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
10720 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
10721 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
10722 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
10723 ; GFX7-NEXT: s_endpgm
10725 ; GFX10-WGP-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
10726 ; GFX10-WGP: ; %bb.0: ; %entry
10727 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10728 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
10729 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
10730 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
10731 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
10732 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
10733 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10734 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10735 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10736 ; GFX10-WGP-NEXT: buffer_gl0_inv
10737 ; GFX10-WGP-NEXT: s_endpgm
10739 ; GFX10-CU-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
10740 ; GFX10-CU: ; %bb.0: ; %entry
10741 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10742 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
10743 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
10744 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
10745 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
10746 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10747 ; GFX10-CU-NEXT: s_endpgm
10749 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
10750 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
10751 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10752 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
10753 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
10754 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
10755 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
10756 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
10757 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
10758 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
10759 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
10760 ; SKIP-CACHE-INV-NEXT: s_endpgm
10762 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
10763 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
10764 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10765 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
10766 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10767 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
10768 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10769 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
10771 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
10772 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
10773 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10774 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
10775 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10776 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
10777 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10778 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10779 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10780 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
10781 ; GFX90A-TGSPLIT-NEXT: s_endpgm
10783 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
10784 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
10785 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10786 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
10787 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10788 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
10789 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10790 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
10792 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
10793 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
10794 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10795 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
10796 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10797 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
10798 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10799 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10800 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10801 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
10802 ; GFX940-TGSPLIT-NEXT: s_endpgm
10804 ; GFX11-WGP-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
10805 ; GFX11-WGP: ; %bb.0: ; %entry
10806 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10807 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
10808 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10809 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
10810 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
10811 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10812 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
10813 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10814 ; GFX11-WGP-NEXT: buffer_gl0_inv
10815 ; GFX11-WGP-NEXT: s_endpgm
10817 ; GFX11-CU-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
10818 ; GFX11-CU: ; %bb.0: ; %entry
10819 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10820 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
10821 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
10822 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
10823 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
10824 ; GFX11-CU-NEXT: s_nop 0
10825 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
10826 ; GFX11-CU-NEXT: s_endpgm
10827 ptr addrspace(1) %out, i32 %in, i32 %old) {
10829 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
10830 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acq_rel seq_cst
10834 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_seq_cst_cmpxchg(
10835 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
10836 ; GFX6: ; %bb.0: ; %entry
10837 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10838 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
10839 ; GFX6-NEXT: s_mov_b32 s6, -1
10840 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
10841 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
10842 ; GFX6-NEXT: s_mov_b32 s4, s0
10843 ; GFX6-NEXT: s_mov_b32 s5, s1
10844 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
10845 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
10846 ; GFX6-NEXT: s_endpgm
10848 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
10849 ; GFX7: ; %bb.0: ; %entry
10850 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10851 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
10852 ; GFX7-NEXT: s_add_u32 s0, s0, 16
10853 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
10854 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
10855 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
10856 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
10857 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
10858 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
10859 ; GFX7-NEXT: s_endpgm
10861 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
10862 ; GFX10-WGP: ; %bb.0: ; %entry
10863 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10864 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
10865 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
10866 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
10867 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
10868 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
10869 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10870 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10871 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10872 ; GFX10-WGP-NEXT: buffer_gl0_inv
10873 ; GFX10-WGP-NEXT: s_endpgm
10875 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
10876 ; GFX10-CU: ; %bb.0: ; %entry
10877 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10878 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
10879 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
10880 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
10881 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
10882 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10883 ; GFX10-CU-NEXT: s_endpgm
10885 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
10886 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
10887 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10888 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
10889 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
10890 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
10891 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
10892 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
10893 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
10894 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
10895 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
10896 ; SKIP-CACHE-INV-NEXT: s_endpgm
10898 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
10899 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
10900 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10901 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
10902 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10903 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
10904 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10905 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
10907 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
10908 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
10909 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10910 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
10911 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10912 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
10913 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10914 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10915 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10916 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
10917 ; GFX90A-TGSPLIT-NEXT: s_endpgm
10919 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
10920 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
10921 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10922 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
10923 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10924 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
10925 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10926 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
10928 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
10929 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
10930 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10931 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
10932 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10933 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
10934 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10935 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
10936 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10937 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
10938 ; GFX940-TGSPLIT-NEXT: s_endpgm
10940 ; GFX11-WGP-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
10941 ; GFX11-WGP: ; %bb.0: ; %entry
10942 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10943 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
10944 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10945 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
10946 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
10947 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10948 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
10949 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10950 ; GFX11-WGP-NEXT: buffer_gl0_inv
10951 ; GFX11-WGP-NEXT: s_endpgm
10953 ; GFX11-CU-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
10954 ; GFX11-CU: ; %bb.0: ; %entry
10955 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10956 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
10957 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
10958 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
10959 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v2, v[0:1], s[0:1] offset:16
10960 ; GFX11-CU-NEXT: s_nop 0
10961 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
10962 ; GFX11-CU-NEXT: s_endpgm
10963 ptr addrspace(1) %out, i32 %in, i32 %old) {
10965 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
10966 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") seq_cst seq_cst
10970 define amdgpu_kernel void @global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg(
10971 ; GFX6-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
10972 ; GFX6: ; %bb.0: ; %entry
10973 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10974 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
10975 ; GFX6-NEXT: s_mov_b32 s6, -1
10976 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
10977 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
10978 ; GFX6-NEXT: s_mov_b32 s4, s0
10979 ; GFX6-NEXT: s_mov_b32 s5, s1
10980 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
10981 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
10982 ; GFX6-NEXT: s_waitcnt vmcnt(0)
10983 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
10984 ; GFX6-NEXT: s_endpgm
10986 ; GFX7-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
10987 ; GFX7: ; %bb.0: ; %entry
10988 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10989 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
10990 ; GFX7-NEXT: s_add_u32 s4, s0, 16
10991 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
10992 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
10993 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
10994 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
10995 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
10996 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
10997 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
10998 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
10999 ; GFX7-NEXT: s_waitcnt vmcnt(0)
11000 ; GFX7-NEXT: flat_store_dword v[0:1], v2
11001 ; GFX7-NEXT: s_endpgm
11003 ; GFX10-WGP-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
11004 ; GFX10-WGP: ; %bb.0: ; %entry
11005 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11006 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
11007 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11008 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
11009 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
11010 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
11011 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
11012 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
11013 ; GFX10-WGP-NEXT: s_endpgm
11015 ; GFX10-CU-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
11016 ; GFX10-CU: ; %bb.0: ; %entry
11017 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11018 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
11019 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
11020 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
11021 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
11022 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
11023 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
11024 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
11025 ; GFX10-CU-NEXT: s_endpgm
11027 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
11028 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
11029 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11030 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
11031 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
11032 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
11033 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
11034 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
11035 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
11036 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
11037 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
11038 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
11039 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
11040 ; SKIP-CACHE-INV-NEXT: s_endpgm
11042 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
11043 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
11044 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11045 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
11046 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11047 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
11048 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
11049 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
11050 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
11051 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
11053 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
11054 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
11055 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11056 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
11057 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11058 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
11059 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
11060 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11061 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
11062 ; GFX90A-TGSPLIT-NEXT: s_endpgm
11064 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
11065 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
11066 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11067 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
11068 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11069 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
11070 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
11071 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
11072 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
11073 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
11075 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
11076 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
11077 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11078 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
11079 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11080 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
11081 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
11082 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11083 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
11084 ; GFX940-TGSPLIT-NEXT: s_endpgm
11086 ; GFX11-WGP-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
11087 ; GFX11-WGP: ; %bb.0: ; %entry
11088 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
11089 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
11090 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11091 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
11092 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
11093 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
11094 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
11095 ; GFX11-WGP-NEXT: s_nop 0
11096 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
11097 ; GFX11-WGP-NEXT: s_endpgm
11099 ; GFX11-CU-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
11100 ; GFX11-CU: ; %bb.0: ; %entry
11101 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
11102 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
11103 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
11104 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
11105 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
11106 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
11107 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
11108 ; GFX11-CU-NEXT: s_nop 0
11109 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
11110 ; GFX11-CU-NEXT: s_endpgm
11111 ptr addrspace(1) %out, i32 %in, i32 %old) {
11113 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
11114 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") monotonic monotonic
11115 %val0 = extractvalue { i32, i1 } %val, 0
11116 store i32 %val0, ptr addrspace(1) %out, align 4
11120 define amdgpu_kernel void @global_workgroup_one_as_acquire_monotonic_ret_cmpxchg(
11121 ; GFX6-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
11122 ; GFX6: ; %bb.0: ; %entry
11123 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11124 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
11125 ; GFX6-NEXT: s_mov_b32 s6, -1
11126 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
11127 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
11128 ; GFX6-NEXT: s_mov_b32 s4, s0
11129 ; GFX6-NEXT: s_mov_b32 s5, s1
11130 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
11131 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
11132 ; GFX6-NEXT: s_waitcnt vmcnt(0)
11133 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
11134 ; GFX6-NEXT: s_endpgm
11136 ; GFX7-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
11137 ; GFX7: ; %bb.0: ; %entry
11138 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11139 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
11140 ; GFX7-NEXT: s_add_u32 s4, s0, 16
11141 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
11142 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
11143 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
11144 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
11145 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
11146 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11147 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
11148 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
11149 ; GFX7-NEXT: s_waitcnt vmcnt(0)
11150 ; GFX7-NEXT: flat_store_dword v[0:1], v2
11151 ; GFX7-NEXT: s_endpgm
11153 ; GFX10-WGP-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
11154 ; GFX10-WGP: ; %bb.0: ; %entry
11155 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11156 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
11157 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11158 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
11159 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
11160 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
11161 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
11162 ; GFX10-WGP-NEXT: buffer_gl0_inv
11163 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
11164 ; GFX10-WGP-NEXT: s_endpgm
11166 ; GFX10-CU-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
11167 ; GFX10-CU: ; %bb.0: ; %entry
11168 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11169 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
11170 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
11171 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
11172 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
11173 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
11174 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
11175 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
11176 ; GFX10-CU-NEXT: s_endpgm
11178 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
11179 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
11180 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11181 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
11182 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
11183 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
11184 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
11185 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
11186 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
11187 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
11188 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
11189 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
11190 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
11191 ; SKIP-CACHE-INV-NEXT: s_endpgm
11193 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
11194 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
11195 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11196 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
11197 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11198 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
11199 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
11200 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
11201 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
11202 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
11204 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
11205 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
11206 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11207 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
11208 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11209 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
11210 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
11211 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11212 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
11213 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
11214 ; GFX90A-TGSPLIT-NEXT: s_endpgm
11216 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
11217 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
11218 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11219 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
11220 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11221 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
11222 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
11223 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
11224 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
11225 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
11227 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
11228 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
11229 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11230 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
11231 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11232 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
11233 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
11234 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11235 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
11236 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
11237 ; GFX940-TGSPLIT-NEXT: s_endpgm
11239 ; GFX11-WGP-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
11240 ; GFX11-WGP: ; %bb.0: ; %entry
11241 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
11242 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
11243 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11244 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
11245 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
11246 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
11247 ; GFX11-WGP-NEXT: buffer_gl0_inv
11248 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
11249 ; GFX11-WGP-NEXT: s_nop 0
11250 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
11251 ; GFX11-WGP-NEXT: s_endpgm
11253 ; GFX11-CU-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
11254 ; GFX11-CU: ; %bb.0: ; %entry
11255 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
11256 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
11257 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
11258 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
11259 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
11260 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
11261 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
11262 ; GFX11-CU-NEXT: s_nop 0
11263 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
11264 ; GFX11-CU-NEXT: s_endpgm
11265 ptr addrspace(1) %out, i32 %in, i32 %old) {
11267 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
11268 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acquire monotonic
11269 %val0 = extractvalue { i32, i1 } %val, 0
11270 store i32 %val0, ptr addrspace(1) %out, align 4
11274 define amdgpu_kernel void @global_workgroup_one_as_release_monotonic_ret_cmpxchg(
11275 ; GFX6-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
11276 ; GFX6: ; %bb.0: ; %entry
11277 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11278 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
11279 ; GFX6-NEXT: s_mov_b32 s6, -1
11280 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
11281 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
11282 ; GFX6-NEXT: s_mov_b32 s4, s0
11283 ; GFX6-NEXT: s_mov_b32 s5, s1
11284 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
11285 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
11286 ; GFX6-NEXT: s_waitcnt vmcnt(0)
11287 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
11288 ; GFX6-NEXT: s_endpgm
11290 ; GFX7-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
11291 ; GFX7: ; %bb.0: ; %entry
11292 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11293 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
11294 ; GFX7-NEXT: s_add_u32 s4, s0, 16
11295 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
11296 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
11297 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
11298 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
11299 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
11300 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11301 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
11302 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
11303 ; GFX7-NEXT: s_waitcnt vmcnt(0)
11304 ; GFX7-NEXT: flat_store_dword v[0:1], v2
11305 ; GFX7-NEXT: s_endpgm
11307 ; GFX10-WGP-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
11308 ; GFX10-WGP: ; %bb.0: ; %entry
11309 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11310 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
11311 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11312 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
11313 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
11314 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
11315 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
11316 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
11317 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
11318 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
11319 ; GFX10-WGP-NEXT: s_endpgm
11321 ; GFX10-CU-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
11322 ; GFX10-CU: ; %bb.0: ; %entry
11323 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11324 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
11325 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
11326 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
11327 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
11328 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
11329 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
11330 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
11331 ; GFX10-CU-NEXT: s_endpgm
11333 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
11334 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
11335 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11336 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
11337 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
11338 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
11339 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
11340 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
11341 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
11342 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
11343 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
11344 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
11345 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
11346 ; SKIP-CACHE-INV-NEXT: s_endpgm
11348 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
11349 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
11350 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11351 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
11352 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11353 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
11354 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
11355 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
11356 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
11357 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
11359 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
11360 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
11361 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11362 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
11363 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11364 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
11365 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11366 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
11367 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11368 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
11369 ; GFX90A-TGSPLIT-NEXT: s_endpgm
11371 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
11372 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
11373 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11374 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
11375 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11376 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
11377 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
11378 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
11379 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
11380 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
11382 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
11383 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
11384 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11385 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
11386 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11387 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
11388 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11389 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
11390 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11391 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
11392 ; GFX940-TGSPLIT-NEXT: s_endpgm
11394 ; GFX11-WGP-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
11395 ; GFX11-WGP: ; %bb.0: ; %entry
11396 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
11397 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
11398 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11399 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
11400 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
11401 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
11402 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
11403 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
11404 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
11405 ; GFX11-WGP-NEXT: s_nop 0
11406 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
11407 ; GFX11-WGP-NEXT: s_endpgm
11409 ; GFX11-CU-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
11410 ; GFX11-CU: ; %bb.0: ; %entry
11411 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
11412 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
11413 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
11414 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
11415 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
11416 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
11417 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
11418 ; GFX11-CU-NEXT: s_nop 0
11419 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
11420 ; GFX11-CU-NEXT: s_endpgm
11421 ptr addrspace(1) %out, i32 %in, i32 %old) {
11423 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
11424 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") release monotonic
11425 %val0 = extractvalue { i32, i1 } %val, 0
11426 store i32 %val0, ptr addrspace(1) %out, align 4
11430 define amdgpu_kernel void @global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg(
11431 ; GFX6-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
11432 ; GFX6: ; %bb.0: ; %entry
11433 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11434 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
11435 ; GFX6-NEXT: s_mov_b32 s6, -1
11436 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
11437 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
11438 ; GFX6-NEXT: s_mov_b32 s4, s0
11439 ; GFX6-NEXT: s_mov_b32 s5, s1
11440 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
11441 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
11442 ; GFX6-NEXT: s_waitcnt vmcnt(0)
11443 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
11444 ; GFX6-NEXT: s_endpgm
11446 ; GFX7-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
11447 ; GFX7: ; %bb.0: ; %entry
11448 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11449 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
11450 ; GFX7-NEXT: s_add_u32 s4, s0, 16
11451 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
11452 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
11453 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
11454 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
11455 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
11456 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11457 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
11458 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
11459 ; GFX7-NEXT: s_waitcnt vmcnt(0)
11460 ; GFX7-NEXT: flat_store_dword v[0:1], v2
11461 ; GFX7-NEXT: s_endpgm
11463 ; GFX10-WGP-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
11464 ; GFX10-WGP: ; %bb.0: ; %entry
11465 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11466 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
11467 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11468 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
11469 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
11470 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
11471 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
11472 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
11473 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
11474 ; GFX10-WGP-NEXT: buffer_gl0_inv
11475 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
11476 ; GFX10-WGP-NEXT: s_endpgm
11478 ; GFX10-CU-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
11479 ; GFX10-CU: ; %bb.0: ; %entry
11480 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11481 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
11482 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
11483 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
11484 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
11485 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
11486 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
11487 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
11488 ; GFX10-CU-NEXT: s_endpgm
11490 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
11491 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
11492 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11493 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
11494 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
11495 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
11496 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
11497 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
11498 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
11499 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
11500 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
11501 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
11502 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
11503 ; SKIP-CACHE-INV-NEXT: s_endpgm
11505 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
11506 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
11507 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11508 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
11509 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11510 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
11511 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
11512 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
11513 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
11514 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
11516 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
11517 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
11518 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11519 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
11520 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11521 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
11522 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11523 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
11524 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11525 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
11526 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
11527 ; GFX90A-TGSPLIT-NEXT: s_endpgm
11529 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
11530 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
11531 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11532 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
11533 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11534 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
11535 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
11536 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
11537 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
11538 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
11540 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
11541 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
11542 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11543 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
11544 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11545 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
11546 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11547 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
11548 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11549 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
11550 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
11551 ; GFX940-TGSPLIT-NEXT: s_endpgm
11553 ; GFX11-WGP-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
11554 ; GFX11-WGP: ; %bb.0: ; %entry
11555 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
11556 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
11557 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11558 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
11559 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
11560 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
11561 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
11562 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
11563 ; GFX11-WGP-NEXT: buffer_gl0_inv
11564 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
11565 ; GFX11-WGP-NEXT: s_nop 0
11566 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
11567 ; GFX11-WGP-NEXT: s_endpgm
11569 ; GFX11-CU-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
11570 ; GFX11-CU: ; %bb.0: ; %entry
11571 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
11572 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
11573 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
11574 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
11575 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
11576 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
11577 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
11578 ; GFX11-CU-NEXT: s_nop 0
11579 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
11580 ; GFX11-CU-NEXT: s_endpgm
11581 ptr addrspace(1) %out, i32 %in, i32 %old) {
11583 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
11584 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acq_rel monotonic
11585 %val0 = extractvalue { i32, i1 } %val, 0
11586 store i32 %val0, ptr addrspace(1) %out, align 4
11590 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg(
11591 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
11592 ; GFX6: ; %bb.0: ; %entry
11593 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11594 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
11595 ; GFX6-NEXT: s_mov_b32 s6, -1
11596 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
11597 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
11598 ; GFX6-NEXT: s_mov_b32 s4, s0
11599 ; GFX6-NEXT: s_mov_b32 s5, s1
11600 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
11601 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
11602 ; GFX6-NEXT: s_waitcnt vmcnt(0)
11603 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
11604 ; GFX6-NEXT: s_endpgm
11606 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
11607 ; GFX7: ; %bb.0: ; %entry
11608 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11609 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
11610 ; GFX7-NEXT: s_add_u32 s4, s0, 16
11611 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
11612 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
11613 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
11614 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
11615 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
11616 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11617 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
11618 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
11619 ; GFX7-NEXT: s_waitcnt vmcnt(0)
11620 ; GFX7-NEXT: flat_store_dword v[0:1], v2
11621 ; GFX7-NEXT: s_endpgm
11623 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
11624 ; GFX10-WGP: ; %bb.0: ; %entry
11625 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11626 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
11627 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11628 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
11629 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
11630 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
11631 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
11632 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
11633 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
11634 ; GFX10-WGP-NEXT: buffer_gl0_inv
11635 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
11636 ; GFX10-WGP-NEXT: s_endpgm
11638 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
11639 ; GFX10-CU: ; %bb.0: ; %entry
11640 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11641 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
11642 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
11643 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
11644 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
11645 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
11646 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
11647 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
11648 ; GFX10-CU-NEXT: s_endpgm
11650 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
11651 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
11652 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11653 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
11654 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
11655 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
11656 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
11657 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
11658 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
11659 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
11660 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
11661 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
11662 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
11663 ; SKIP-CACHE-INV-NEXT: s_endpgm
11665 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
11666 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
11667 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11668 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
11669 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11670 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
11671 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
11672 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
11673 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
11674 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
11676 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
11677 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
11678 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11679 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
11680 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11681 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
11682 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11683 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
11684 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11685 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
11686 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
11687 ; GFX90A-TGSPLIT-NEXT: s_endpgm
11689 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
11690 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
11691 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11692 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
11693 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11694 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
11695 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
11696 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
11697 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
11698 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
11700 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
11701 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
11702 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11703 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
11704 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11705 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
11706 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11707 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
11708 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11709 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
11710 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
11711 ; GFX940-TGSPLIT-NEXT: s_endpgm
11713 ; GFX11-WGP-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
11714 ; GFX11-WGP: ; %bb.0: ; %entry
11715 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
11716 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
11717 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11718 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
11719 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
11720 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
11721 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
11722 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
11723 ; GFX11-WGP-NEXT: buffer_gl0_inv
11724 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
11725 ; GFX11-WGP-NEXT: s_nop 0
11726 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
11727 ; GFX11-WGP-NEXT: s_endpgm
11729 ; GFX11-CU-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
11730 ; GFX11-CU: ; %bb.0: ; %entry
11731 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
11732 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
11733 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
11734 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
11735 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
11736 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
11737 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
11738 ; GFX11-CU-NEXT: s_nop 0
11739 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
11740 ; GFX11-CU-NEXT: s_endpgm
11741 ptr addrspace(1) %out, i32 %in, i32 %old) {
11743 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
11744 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") seq_cst monotonic
11745 %val0 = extractvalue { i32, i1 } %val, 0
11746 store i32 %val0, ptr addrspace(1) %out, align 4
11750 define amdgpu_kernel void @global_workgroup_one_as_monotonic_acquire_ret_cmpxchg(
11751 ; GFX6-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
11752 ; GFX6: ; %bb.0: ; %entry
11753 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11754 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
11755 ; GFX6-NEXT: s_mov_b32 s6, -1
11756 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
11757 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
11758 ; GFX6-NEXT: s_mov_b32 s4, s0
11759 ; GFX6-NEXT: s_mov_b32 s5, s1
11760 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
11761 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
11762 ; GFX6-NEXT: s_waitcnt vmcnt(0)
11763 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
11764 ; GFX6-NEXT: s_endpgm
11766 ; GFX7-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
11767 ; GFX7: ; %bb.0: ; %entry
11768 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11769 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
11770 ; GFX7-NEXT: s_add_u32 s4, s0, 16
11771 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
11772 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
11773 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
11774 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
11775 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
11776 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11777 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
11778 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
11779 ; GFX7-NEXT: s_waitcnt vmcnt(0)
11780 ; GFX7-NEXT: flat_store_dword v[0:1], v2
11781 ; GFX7-NEXT: s_endpgm
11783 ; GFX10-WGP-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
11784 ; GFX10-WGP: ; %bb.0: ; %entry
11785 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11786 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
11787 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11788 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
11789 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
11790 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
11791 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
11792 ; GFX10-WGP-NEXT: buffer_gl0_inv
11793 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
11794 ; GFX10-WGP-NEXT: s_endpgm
11796 ; GFX10-CU-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
11797 ; GFX10-CU: ; %bb.0: ; %entry
11798 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11799 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
11800 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
11801 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
11802 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
11803 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
11804 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
11805 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
11806 ; GFX10-CU-NEXT: s_endpgm
11808 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
11809 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
11810 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11811 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
11812 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
11813 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
11814 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
11815 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
11816 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
11817 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
11818 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
11819 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
11820 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
11821 ; SKIP-CACHE-INV-NEXT: s_endpgm
11823 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
11824 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
11825 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11826 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
11827 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11828 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
11829 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
11830 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
11831 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
11832 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
11834 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
11835 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
11836 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11837 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
11838 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11839 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
11840 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
11841 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11842 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
11843 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
11844 ; GFX90A-TGSPLIT-NEXT: s_endpgm
11846 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
11847 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
11848 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11849 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
11850 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11851 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
11852 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
11853 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
11854 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
11855 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
11857 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
11858 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
11859 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11860 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
11861 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11862 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
11863 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
11864 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11865 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
11866 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
11867 ; GFX940-TGSPLIT-NEXT: s_endpgm
11869 ; GFX11-WGP-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
11870 ; GFX11-WGP: ; %bb.0: ; %entry
11871 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
11872 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
11873 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11874 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
11875 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
11876 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
11877 ; GFX11-WGP-NEXT: buffer_gl0_inv
11878 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
11879 ; GFX11-WGP-NEXT: s_nop 0
11880 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
11881 ; GFX11-WGP-NEXT: s_endpgm
11883 ; GFX11-CU-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
11884 ; GFX11-CU: ; %bb.0: ; %entry
11885 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
11886 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
11887 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
11888 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
11889 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
11890 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
11891 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
11892 ; GFX11-CU-NEXT: s_nop 0
11893 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
11894 ; GFX11-CU-NEXT: s_endpgm
11895 ptr addrspace(1) %out, i32 %in, i32 %old) {
11897 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
11898 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") monotonic acquire
11899 %val0 = extractvalue { i32, i1 } %val, 0
11900 store i32 %val0, ptr addrspace(1) %out, align 4
11904 define amdgpu_kernel void @global_workgroup_one_as_acquire_acquire_ret_cmpxchg(
11905 ; GFX6-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
11906 ; GFX6: ; %bb.0: ; %entry
11907 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11908 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
11909 ; GFX6-NEXT: s_mov_b32 s6, -1
11910 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
11911 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
11912 ; GFX6-NEXT: s_mov_b32 s4, s0
11913 ; GFX6-NEXT: s_mov_b32 s5, s1
11914 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
11915 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
11916 ; GFX6-NEXT: s_waitcnt vmcnt(0)
11917 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
11918 ; GFX6-NEXT: s_endpgm
11920 ; GFX7-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
11921 ; GFX7: ; %bb.0: ; %entry
11922 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11923 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
11924 ; GFX7-NEXT: s_add_u32 s4, s0, 16
11925 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
11926 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
11927 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
11928 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
11929 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
11930 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11931 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
11932 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
11933 ; GFX7-NEXT: s_waitcnt vmcnt(0)
11934 ; GFX7-NEXT: flat_store_dword v[0:1], v2
11935 ; GFX7-NEXT: s_endpgm
11937 ; GFX10-WGP-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
11938 ; GFX10-WGP: ; %bb.0: ; %entry
11939 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11940 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
11941 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11942 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
11943 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
11944 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
11945 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
11946 ; GFX10-WGP-NEXT: buffer_gl0_inv
11947 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
11948 ; GFX10-WGP-NEXT: s_endpgm
11950 ; GFX10-CU-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
11951 ; GFX10-CU: ; %bb.0: ; %entry
11952 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11953 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
11954 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
11955 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
11956 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
11957 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
11958 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
11959 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
11960 ; GFX10-CU-NEXT: s_endpgm
11962 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
11963 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
11964 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11965 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
11966 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
11967 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
11968 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
11969 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
11970 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
11971 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
11972 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
11973 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
11974 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
11975 ; SKIP-CACHE-INV-NEXT: s_endpgm
11977 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
11978 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
11979 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11980 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
11981 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11982 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
11983 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
11984 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
11985 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
11986 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
11988 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
11989 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
11990 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11991 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
11992 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11993 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
11994 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
11995 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11996 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
11997 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
11998 ; GFX90A-TGSPLIT-NEXT: s_endpgm
12000 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
12001 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
12002 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
12003 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
12004 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12005 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
12006 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
12007 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
12008 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
12009 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
12011 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
12012 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
12013 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
12014 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
12015 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12016 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
12017 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
12018 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12019 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
12020 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
12021 ; GFX940-TGSPLIT-NEXT: s_endpgm
12023 ; GFX11-WGP-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
12024 ; GFX11-WGP: ; %bb.0: ; %entry
12025 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
12026 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
12027 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
12028 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
12029 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
12030 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
12031 ; GFX11-WGP-NEXT: buffer_gl0_inv
12032 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
12033 ; GFX11-WGP-NEXT: s_nop 0
12034 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
12035 ; GFX11-WGP-NEXT: s_endpgm
12037 ; GFX11-CU-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
12038 ; GFX11-CU: ; %bb.0: ; %entry
12039 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
12040 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
12041 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
12042 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
12043 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
12044 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
12045 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
12046 ; GFX11-CU-NEXT: s_nop 0
12047 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
12048 ; GFX11-CU-NEXT: s_endpgm
12049 ptr addrspace(1) %out, i32 %in, i32 %old) {
12051 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
12052 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acquire acquire
12053 %val0 = extractvalue { i32, i1 } %val, 0
12054 store i32 %val0, ptr addrspace(1) %out, align 4
12058 define amdgpu_kernel void @global_workgroup_one_as_release_acquire_ret_cmpxchg(
12059 ; GFX6-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
12060 ; GFX6: ; %bb.0: ; %entry
12061 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12062 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
12063 ; GFX6-NEXT: s_mov_b32 s6, -1
12064 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
12065 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
12066 ; GFX6-NEXT: s_mov_b32 s4, s0
12067 ; GFX6-NEXT: s_mov_b32 s5, s1
12068 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
12069 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
12070 ; GFX6-NEXT: s_waitcnt vmcnt(0)
12071 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
12072 ; GFX6-NEXT: s_endpgm
12074 ; GFX7-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
12075 ; GFX7: ; %bb.0: ; %entry
12076 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12077 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
12078 ; GFX7-NEXT: s_add_u32 s4, s0, 16
12079 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
12080 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
12081 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
12082 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
12083 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
12084 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
12085 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
12086 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
12087 ; GFX7-NEXT: s_waitcnt vmcnt(0)
12088 ; GFX7-NEXT: flat_store_dword v[0:1], v2
12089 ; GFX7-NEXT: s_endpgm
12091 ; GFX10-WGP-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
12092 ; GFX10-WGP: ; %bb.0: ; %entry
12093 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12094 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
12095 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
12096 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
12097 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
12098 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
12099 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
12100 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
12101 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
12102 ; GFX10-WGP-NEXT: buffer_gl0_inv
12103 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
12104 ; GFX10-WGP-NEXT: s_endpgm
12106 ; GFX10-CU-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
12107 ; GFX10-CU: ; %bb.0: ; %entry
12108 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12109 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
12110 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
12111 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
12112 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
12113 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
12114 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
12115 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
12116 ; GFX10-CU-NEXT: s_endpgm
12118 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
12119 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
12120 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
12121 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
12122 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
12123 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
12124 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
12125 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
12126 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
12127 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
12128 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
12129 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
12130 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
12131 ; SKIP-CACHE-INV-NEXT: s_endpgm
12133 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
12134 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
12135 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12136 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
12137 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12138 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
12139 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
12140 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
12141 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
12142 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
12144 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
12145 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
12146 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12147 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
12148 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12149 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
12150 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12151 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
12152 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12153 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
12154 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
12155 ; GFX90A-TGSPLIT-NEXT: s_endpgm
12157 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
12158 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
12159 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
12160 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
12161 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12162 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
12163 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
12164 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
12165 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
12166 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
12168 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
12169 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
12170 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
12171 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
12172 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12173 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
12174 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12175 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
12176 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12177 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
12178 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
12179 ; GFX940-TGSPLIT-NEXT: s_endpgm
12181 ; GFX11-WGP-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
12182 ; GFX11-WGP: ; %bb.0: ; %entry
12183 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
12184 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
12185 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
12186 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
12187 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
12188 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
12189 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
12190 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
12191 ; GFX11-WGP-NEXT: buffer_gl0_inv
12192 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
12193 ; GFX11-WGP-NEXT: s_nop 0
12194 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
12195 ; GFX11-WGP-NEXT: s_endpgm
12197 ; GFX11-CU-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
12198 ; GFX11-CU: ; %bb.0: ; %entry
12199 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
12200 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
12201 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
12202 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
12203 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
12204 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
12205 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
12206 ; GFX11-CU-NEXT: s_nop 0
12207 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
12208 ; GFX11-CU-NEXT: s_endpgm
12209 ptr addrspace(1) %out, i32 %in, i32 %old) {
12211 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
12212 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") release acquire
12213 %val0 = extractvalue { i32, i1 } %val, 0
12214 store i32 %val0, ptr addrspace(1) %out, align 4
12218 define amdgpu_kernel void @global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg(
12219 ; GFX6-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
12220 ; GFX6: ; %bb.0: ; %entry
12221 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12222 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
12223 ; GFX6-NEXT: s_mov_b32 s6, -1
12224 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
12225 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
12226 ; GFX6-NEXT: s_mov_b32 s4, s0
12227 ; GFX6-NEXT: s_mov_b32 s5, s1
12228 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
12229 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
12230 ; GFX6-NEXT: s_waitcnt vmcnt(0)
12231 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
12232 ; GFX6-NEXT: s_endpgm
12234 ; GFX7-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
12235 ; GFX7: ; %bb.0: ; %entry
12236 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12237 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
12238 ; GFX7-NEXT: s_add_u32 s4, s0, 16
12239 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
12240 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
12241 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
12242 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
12243 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
12244 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
12245 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
12246 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
12247 ; GFX7-NEXT: s_waitcnt vmcnt(0)
12248 ; GFX7-NEXT: flat_store_dword v[0:1], v2
12249 ; GFX7-NEXT: s_endpgm
12251 ; GFX10-WGP-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
12252 ; GFX10-WGP: ; %bb.0: ; %entry
12253 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12254 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
12255 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
12256 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
12257 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
12258 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
12259 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
12260 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
12261 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
12262 ; GFX10-WGP-NEXT: buffer_gl0_inv
12263 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
12264 ; GFX10-WGP-NEXT: s_endpgm
12266 ; GFX10-CU-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
12267 ; GFX10-CU: ; %bb.0: ; %entry
12268 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12269 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
12270 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
12271 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
12272 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
12273 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
12274 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
12275 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
12276 ; GFX10-CU-NEXT: s_endpgm
12278 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
12279 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
12280 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
12281 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
12282 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
12283 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
12284 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
12285 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
12286 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
12287 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
12288 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
12289 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
12290 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
12291 ; SKIP-CACHE-INV-NEXT: s_endpgm
12293 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
12294 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
12295 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12296 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
12297 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12298 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
12299 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
12300 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
12301 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
12302 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
12304 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
12305 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
12306 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12307 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
12308 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12309 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
12310 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12311 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
12312 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12313 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
12314 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
12315 ; GFX90A-TGSPLIT-NEXT: s_endpgm
12317 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
12318 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
12319 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
12320 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
12321 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12322 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
12323 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
12324 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
12325 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
12326 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
12328 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
12329 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
12330 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
12331 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
12332 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12333 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
12334 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12335 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
12336 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12337 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
12338 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
12339 ; GFX940-TGSPLIT-NEXT: s_endpgm
12341 ; GFX11-WGP-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
12342 ; GFX11-WGP: ; %bb.0: ; %entry
12343 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
12344 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
12345 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
12346 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
12347 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
12348 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
12349 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
12350 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
12351 ; GFX11-WGP-NEXT: buffer_gl0_inv
12352 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
12353 ; GFX11-WGP-NEXT: s_nop 0
12354 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
12355 ; GFX11-WGP-NEXT: s_endpgm
12357 ; GFX11-CU-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
12358 ; GFX11-CU: ; %bb.0: ; %entry
12359 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
12360 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
12361 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
12362 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
12363 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
12364 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
12365 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
12366 ; GFX11-CU-NEXT: s_nop 0
12367 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
12368 ; GFX11-CU-NEXT: s_endpgm
12369 ptr addrspace(1) %out, i32 %in, i32 %old) {
12371 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
12372 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acq_rel acquire
12373 %val0 = extractvalue { i32, i1 } %val, 0
12374 store i32 %val0, ptr addrspace(1) %out, align 4
12378 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg(
12379 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
12380 ; GFX6: ; %bb.0: ; %entry
12381 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12382 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
12383 ; GFX6-NEXT: s_mov_b32 s6, -1
12384 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
12385 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
12386 ; GFX6-NEXT: s_mov_b32 s4, s0
12387 ; GFX6-NEXT: s_mov_b32 s5, s1
12388 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
12389 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
12390 ; GFX6-NEXT: s_waitcnt vmcnt(0)
12391 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
12392 ; GFX6-NEXT: s_endpgm
12394 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
12395 ; GFX7: ; %bb.0: ; %entry
12396 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12397 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
12398 ; GFX7-NEXT: s_add_u32 s4, s0, 16
12399 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
12400 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
12401 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
12402 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
12403 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
12404 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
12405 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
12406 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
12407 ; GFX7-NEXT: s_waitcnt vmcnt(0)
12408 ; GFX7-NEXT: flat_store_dword v[0:1], v2
12409 ; GFX7-NEXT: s_endpgm
12411 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
12412 ; GFX10-WGP: ; %bb.0: ; %entry
12413 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12414 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
12415 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
12416 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
12417 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
12418 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
12419 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
12420 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
12421 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
12422 ; GFX10-WGP-NEXT: buffer_gl0_inv
12423 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
12424 ; GFX10-WGP-NEXT: s_endpgm
12426 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
12427 ; GFX10-CU: ; %bb.0: ; %entry
12428 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12429 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
12430 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
12431 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
12432 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
12433 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
12434 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
12435 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
12436 ; GFX10-CU-NEXT: s_endpgm
12438 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
12439 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
12440 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
12441 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
12442 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
12443 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
12444 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
12445 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
12446 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
12447 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
12448 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
12449 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
12450 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
12451 ; SKIP-CACHE-INV-NEXT: s_endpgm
12453 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
12454 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
12455 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12456 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
12457 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12458 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
12459 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
12460 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
12461 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
12462 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
12464 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
12465 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
12466 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12467 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
12468 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12469 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
12470 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12471 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
12472 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12473 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
12474 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
12475 ; GFX90A-TGSPLIT-NEXT: s_endpgm
12477 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
12478 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
12479 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
12480 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
12481 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12482 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
12483 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
12484 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
12485 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
12486 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
12488 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
12489 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
12490 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
12491 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
12492 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12493 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
12494 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12495 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
12496 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12497 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
12498 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
12499 ; GFX940-TGSPLIT-NEXT: s_endpgm
12501 ; GFX11-WGP-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
12502 ; GFX11-WGP: ; %bb.0: ; %entry
12503 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
12504 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
12505 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
12506 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
12507 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
12508 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
12509 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
12510 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
12511 ; GFX11-WGP-NEXT: buffer_gl0_inv
12512 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
12513 ; GFX11-WGP-NEXT: s_nop 0
12514 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
12515 ; GFX11-WGP-NEXT: s_endpgm
12517 ; GFX11-CU-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
12518 ; GFX11-CU: ; %bb.0: ; %entry
12519 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
12520 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
12521 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
12522 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
12523 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
12524 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
12525 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
12526 ; GFX11-CU-NEXT: s_nop 0
12527 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
12528 ; GFX11-CU-NEXT: s_endpgm
12529 ptr addrspace(1) %out, i32 %in, i32 %old) {
12531 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
12532 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") seq_cst acquire
12533 %val0 = extractvalue { i32, i1 } %val, 0
12534 store i32 %val0, ptr addrspace(1) %out, align 4
12538 define amdgpu_kernel void @global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg(
12539 ; GFX6-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
12540 ; GFX6: ; %bb.0: ; %entry
12541 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12542 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
12543 ; GFX6-NEXT: s_mov_b32 s6, -1
12544 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
12545 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
12546 ; GFX6-NEXT: s_mov_b32 s4, s0
12547 ; GFX6-NEXT: s_mov_b32 s5, s1
12548 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
12549 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
12550 ; GFX6-NEXT: s_waitcnt vmcnt(0)
12551 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
12552 ; GFX6-NEXT: s_endpgm
12554 ; GFX7-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
12555 ; GFX7: ; %bb.0: ; %entry
12556 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12557 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
12558 ; GFX7-NEXT: s_add_u32 s4, s0, 16
12559 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
12560 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
12561 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
12562 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
12563 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
12564 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
12565 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
12566 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
12567 ; GFX7-NEXT: s_waitcnt vmcnt(0)
12568 ; GFX7-NEXT: flat_store_dword v[0:1], v2
12569 ; GFX7-NEXT: s_endpgm
12571 ; GFX10-WGP-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
12572 ; GFX10-WGP: ; %bb.0: ; %entry
12573 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12574 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
12575 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
12576 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
12577 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
12578 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
12579 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
12580 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
12581 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
12582 ; GFX10-WGP-NEXT: buffer_gl0_inv
12583 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
12584 ; GFX10-WGP-NEXT: s_endpgm
12586 ; GFX10-CU-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
12587 ; GFX10-CU: ; %bb.0: ; %entry
12588 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12589 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
12590 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
12591 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
12592 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
12593 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
12594 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
12595 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
12596 ; GFX10-CU-NEXT: s_endpgm
12598 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
12599 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
12600 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
12601 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
12602 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
12603 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
12604 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
12605 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
12606 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
12607 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
12608 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
12609 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
12610 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
12611 ; SKIP-CACHE-INV-NEXT: s_endpgm
12613 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
12614 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
12615 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12616 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
12617 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12618 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
12619 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
12620 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
12621 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
12622 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
12624 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
12625 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
12626 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12627 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
12628 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12629 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
12630 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12631 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
12632 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12633 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
12634 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
12635 ; GFX90A-TGSPLIT-NEXT: s_endpgm
12637 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
12638 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
12639 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
12640 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
12641 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12642 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
12643 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
12644 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
12645 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
12646 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
12648 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
12649 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
12650 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
12651 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
12652 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12653 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
12654 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12655 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
12656 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12657 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
12658 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
12659 ; GFX940-TGSPLIT-NEXT: s_endpgm
12661 ; GFX11-WGP-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
12662 ; GFX11-WGP: ; %bb.0: ; %entry
12663 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
12664 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
12665 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
12666 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
12667 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
12668 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
12669 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
12670 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
12671 ; GFX11-WGP-NEXT: buffer_gl0_inv
12672 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
12673 ; GFX11-WGP-NEXT: s_nop 0
12674 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
12675 ; GFX11-WGP-NEXT: s_endpgm
12677 ; GFX11-CU-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
12678 ; GFX11-CU: ; %bb.0: ; %entry
12679 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
12680 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
12681 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
12682 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
12683 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
12684 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
12685 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
12686 ; GFX11-CU-NEXT: s_nop 0
12687 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
12688 ; GFX11-CU-NEXT: s_endpgm
12689 ptr addrspace(1) %out, i32 %in, i32 %old) {
12691 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
12692 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") monotonic seq_cst
12693 %val0 = extractvalue { i32, i1 } %val, 0
12694 store i32 %val0, ptr addrspace(1) %out, align 4
12698 define amdgpu_kernel void @global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg(
12699 ; GFX6-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
12700 ; GFX6: ; %bb.0: ; %entry
12701 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12702 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
12703 ; GFX6-NEXT: s_mov_b32 s6, -1
12704 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
12705 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
12706 ; GFX6-NEXT: s_mov_b32 s4, s0
12707 ; GFX6-NEXT: s_mov_b32 s5, s1
12708 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
12709 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
12710 ; GFX6-NEXT: s_waitcnt vmcnt(0)
12711 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
12712 ; GFX6-NEXT: s_endpgm
12714 ; GFX7-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
12715 ; GFX7: ; %bb.0: ; %entry
12716 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12717 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
12718 ; GFX7-NEXT: s_add_u32 s4, s0, 16
12719 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
12720 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
12721 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
12722 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
12723 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
12724 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
12725 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
12726 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
12727 ; GFX7-NEXT: s_waitcnt vmcnt(0)
12728 ; GFX7-NEXT: flat_store_dword v[0:1], v2
12729 ; GFX7-NEXT: s_endpgm
12731 ; GFX10-WGP-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
12732 ; GFX10-WGP: ; %bb.0: ; %entry
12733 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12734 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
12735 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
12736 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
12737 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
12738 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
12739 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
12740 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
12741 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
12742 ; GFX10-WGP-NEXT: buffer_gl0_inv
12743 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
12744 ; GFX10-WGP-NEXT: s_endpgm
12746 ; GFX10-CU-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
12747 ; GFX10-CU: ; %bb.0: ; %entry
12748 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12749 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
12750 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
12751 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
12752 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
12753 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
12754 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
12755 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
12756 ; GFX10-CU-NEXT: s_endpgm
12758 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
12759 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
12760 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
12761 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
12762 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
12763 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
12764 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
12765 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
12766 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
12767 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
12768 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
12769 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
12770 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
12771 ; SKIP-CACHE-INV-NEXT: s_endpgm
12773 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
12774 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
12775 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12776 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
12777 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12778 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
12779 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
12780 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
12781 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
12782 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
12784 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
12785 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
12786 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12787 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
12788 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12789 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
12790 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12791 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
12792 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12793 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
12794 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
12795 ; GFX90A-TGSPLIT-NEXT: s_endpgm
12797 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
12798 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
12799 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
12800 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
12801 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12802 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
12803 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
12804 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
12805 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
12806 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
12808 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
12809 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
12810 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
12811 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
12812 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12813 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
12814 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12815 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
12816 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12817 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
12818 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
12819 ; GFX940-TGSPLIT-NEXT: s_endpgm
12821 ; GFX11-WGP-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
12822 ; GFX11-WGP: ; %bb.0: ; %entry
12823 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
12824 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
12825 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
12826 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
12827 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
12828 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
12829 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
12830 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
12831 ; GFX11-WGP-NEXT: buffer_gl0_inv
12832 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
12833 ; GFX11-WGP-NEXT: s_nop 0
12834 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
12835 ; GFX11-WGP-NEXT: s_endpgm
12837 ; GFX11-CU-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
12838 ; GFX11-CU: ; %bb.0: ; %entry
12839 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
12840 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
12841 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
12842 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
12843 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
12844 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
12845 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
12846 ; GFX11-CU-NEXT: s_nop 0
12847 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
12848 ; GFX11-CU-NEXT: s_endpgm
12849 ptr addrspace(1) %out, i32 %in, i32 %old) {
12851 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
12852 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acquire seq_cst
12853 %val0 = extractvalue { i32, i1 } %val, 0
12854 store i32 %val0, ptr addrspace(1) %out, align 4
12858 define amdgpu_kernel void @global_workgroup_one_as_release_seq_cst_ret_cmpxchg(
12859 ; GFX6-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
12860 ; GFX6: ; %bb.0: ; %entry
12861 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12862 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
12863 ; GFX6-NEXT: s_mov_b32 s6, -1
12864 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
12865 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
12866 ; GFX6-NEXT: s_mov_b32 s4, s0
12867 ; GFX6-NEXT: s_mov_b32 s5, s1
12868 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
12869 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
12870 ; GFX6-NEXT: s_waitcnt vmcnt(0)
12871 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
12872 ; GFX6-NEXT: s_endpgm
12874 ; GFX7-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
12875 ; GFX7: ; %bb.0: ; %entry
12876 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12877 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
12878 ; GFX7-NEXT: s_add_u32 s4, s0, 16
12879 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
12880 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
12881 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
12882 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
12883 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
12884 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
12885 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
12886 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
12887 ; GFX7-NEXT: s_waitcnt vmcnt(0)
12888 ; GFX7-NEXT: flat_store_dword v[0:1], v2
12889 ; GFX7-NEXT: s_endpgm
12891 ; GFX10-WGP-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
12892 ; GFX10-WGP: ; %bb.0: ; %entry
12893 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12894 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
12895 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
12896 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
12897 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
12898 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
12899 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
12900 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
12901 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
12902 ; GFX10-WGP-NEXT: buffer_gl0_inv
12903 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
12904 ; GFX10-WGP-NEXT: s_endpgm
12906 ; GFX10-CU-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
12907 ; GFX10-CU: ; %bb.0: ; %entry
12908 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12909 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
12910 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
12911 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
12912 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
12913 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
12914 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
12915 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
12916 ; GFX10-CU-NEXT: s_endpgm
12918 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
12919 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
12920 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
12921 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
12922 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
12923 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
12924 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
12925 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
12926 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
12927 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
12928 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
12929 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
12930 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
12931 ; SKIP-CACHE-INV-NEXT: s_endpgm
12933 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
12934 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
12935 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12936 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
12937 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12938 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
12939 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
12940 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
12941 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
12942 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
12944 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
12945 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
12946 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12947 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
12948 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12949 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
12950 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12951 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
12952 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12953 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
12954 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
12955 ; GFX90A-TGSPLIT-NEXT: s_endpgm
12957 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
12958 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
12959 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
12960 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
12961 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12962 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
12963 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
12964 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
12965 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
12966 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
12968 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
12969 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
12970 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
12971 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
12972 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12973 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
12974 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12975 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
12976 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12977 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
12978 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
12979 ; GFX940-TGSPLIT-NEXT: s_endpgm
12981 ; GFX11-WGP-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
12982 ; GFX11-WGP: ; %bb.0: ; %entry
12983 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
12984 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
12985 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
12986 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
12987 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
12988 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
12989 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
12990 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
12991 ; GFX11-WGP-NEXT: buffer_gl0_inv
12992 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
12993 ; GFX11-WGP-NEXT: s_nop 0
12994 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
12995 ; GFX11-WGP-NEXT: s_endpgm
12997 ; GFX11-CU-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
12998 ; GFX11-CU: ; %bb.0: ; %entry
12999 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
13000 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
13001 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
13002 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
13003 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
13004 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
13005 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
13006 ; GFX11-CU-NEXT: s_nop 0
13007 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
13008 ; GFX11-CU-NEXT: s_endpgm
13009 ptr addrspace(1) %out, i32 %in, i32 %old) {
13011 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
13012 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") release seq_cst
13013 %val0 = extractvalue { i32, i1 } %val, 0
13014 store i32 %val0, ptr addrspace(1) %out, align 4
13018 define amdgpu_kernel void @global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg(
13019 ; GFX6-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
13020 ; GFX6: ; %bb.0: ; %entry
13021 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
13022 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
13023 ; GFX6-NEXT: s_mov_b32 s6, -1
13024 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
13025 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
13026 ; GFX6-NEXT: s_mov_b32 s4, s0
13027 ; GFX6-NEXT: s_mov_b32 s5, s1
13028 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
13029 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
13030 ; GFX6-NEXT: s_waitcnt vmcnt(0)
13031 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
13032 ; GFX6-NEXT: s_endpgm
13034 ; GFX7-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
13035 ; GFX7: ; %bb.0: ; %entry
13036 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
13037 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
13038 ; GFX7-NEXT: s_add_u32 s4, s0, 16
13039 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
13040 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
13041 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
13042 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
13043 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
13044 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
13045 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
13046 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
13047 ; GFX7-NEXT: s_waitcnt vmcnt(0)
13048 ; GFX7-NEXT: flat_store_dword v[0:1], v2
13049 ; GFX7-NEXT: s_endpgm
13051 ; GFX10-WGP-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
13052 ; GFX10-WGP: ; %bb.0: ; %entry
13053 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
13054 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
13055 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
13056 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
13057 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
13058 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
13059 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
13060 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
13061 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
13062 ; GFX10-WGP-NEXT: buffer_gl0_inv
13063 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
13064 ; GFX10-WGP-NEXT: s_endpgm
13066 ; GFX10-CU-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
13067 ; GFX10-CU: ; %bb.0: ; %entry
13068 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
13069 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
13070 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
13071 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
13072 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
13073 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
13074 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
13075 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
13076 ; GFX10-CU-NEXT: s_endpgm
13078 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
13079 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
13080 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
13081 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
13082 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
13083 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
13084 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
13085 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
13086 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
13087 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
13088 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
13089 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
13090 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
13091 ; SKIP-CACHE-INV-NEXT: s_endpgm
13093 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
13094 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
13095 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
13096 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
13097 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13098 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
13099 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
13100 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
13101 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
13102 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
13104 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
13105 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
13106 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
13107 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
13108 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13109 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
13110 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
13111 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
13112 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
13113 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
13114 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
13115 ; GFX90A-TGSPLIT-NEXT: s_endpgm
13117 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
13118 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
13119 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
13120 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
13121 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13122 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
13123 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
13124 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
13125 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
13126 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
13128 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
13129 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
13130 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
13131 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
13132 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13133 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
13134 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
13135 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
13136 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
13137 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
13138 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
13139 ; GFX940-TGSPLIT-NEXT: s_endpgm
13141 ; GFX11-WGP-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
13142 ; GFX11-WGP: ; %bb.0: ; %entry
13143 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
13144 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
13145 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
13146 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
13147 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
13148 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
13149 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
13150 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
13151 ; GFX11-WGP-NEXT: buffer_gl0_inv
13152 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
13153 ; GFX11-WGP-NEXT: s_nop 0
13154 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
13155 ; GFX11-WGP-NEXT: s_endpgm
13157 ; GFX11-CU-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
13158 ; GFX11-CU: ; %bb.0: ; %entry
13159 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
13160 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
13161 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
13162 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
13163 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
13164 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
13165 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
13166 ; GFX11-CU-NEXT: s_nop 0
13167 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
13168 ; GFX11-CU-NEXT: s_endpgm
13169 ptr addrspace(1) %out, i32 %in, i32 %old) {
13171 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
13172 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acq_rel seq_cst
13173 %val0 = extractvalue { i32, i1 } %val, 0
13174 store i32 %val0, ptr addrspace(1) %out, align 4
13178 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg(
13179 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
13180 ; GFX6: ; %bb.0: ; %entry
13181 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
13182 ; GFX6-NEXT: s_mov_b32 s7, 0x100f000
13183 ; GFX6-NEXT: s_mov_b32 s6, -1
13184 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
13185 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
13186 ; GFX6-NEXT: s_mov_b32 s4, s0
13187 ; GFX6-NEXT: s_mov_b32 s5, s1
13188 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
13189 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
13190 ; GFX6-NEXT: s_waitcnt vmcnt(0)
13191 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
13192 ; GFX6-NEXT: s_endpgm
13194 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
13195 ; GFX7: ; %bb.0: ; %entry
13196 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
13197 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
13198 ; GFX7-NEXT: s_add_u32 s4, s0, 16
13199 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
13200 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
13201 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
13202 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
13203 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
13204 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
13205 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
13206 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
13207 ; GFX7-NEXT: s_waitcnt vmcnt(0)
13208 ; GFX7-NEXT: flat_store_dword v[0:1], v2
13209 ; GFX7-NEXT: s_endpgm
13211 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
13212 ; GFX10-WGP: ; %bb.0: ; %entry
13213 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
13214 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
13215 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
13216 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
13217 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
13218 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
13219 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
13220 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
13221 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
13222 ; GFX10-WGP-NEXT: buffer_gl0_inv
13223 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[0:1]
13224 ; GFX10-WGP-NEXT: s_endpgm
13226 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
13227 ; GFX10-CU: ; %bb.0: ; %entry
13228 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
13229 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
13230 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
13231 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
13232 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
13233 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
13234 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
13235 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[0:1]
13236 ; GFX10-CU-NEXT: s_endpgm
13238 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
13239 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
13240 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
13241 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
13242 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
13243 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
13244 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
13245 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s0
13246 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s1
13247 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
13248 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
13249 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
13250 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
13251 ; SKIP-CACHE-INV-NEXT: s_endpgm
13253 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
13254 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
13255 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
13256 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
13257 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13258 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
13259 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
13260 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
13261 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
13262 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
13264 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
13265 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
13266 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
13267 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
13268 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13269 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
13270 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
13271 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
13272 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
13273 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
13274 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
13275 ; GFX90A-TGSPLIT-NEXT: s_endpgm
13277 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
13278 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
13279 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
13280 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
13281 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13282 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
13283 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
13284 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
13285 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
13286 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
13288 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
13289 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
13290 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
13291 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
13292 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13293 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
13294 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
13295 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 sc0
13296 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
13297 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
13298 ; GFX940-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1] sc0 sc1
13299 ; GFX940-TGSPLIT-NEXT: s_endpgm
13301 ; GFX11-WGP-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
13302 ; GFX11-WGP: ; %bb.0: ; %entry
13303 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
13304 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, 0
13305 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
13306 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
13307 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
13308 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
13309 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
13310 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
13311 ; GFX11-WGP-NEXT: buffer_gl0_inv
13312 ; GFX11-WGP-NEXT: global_store_b32 v2, v0, s[0:1]
13313 ; GFX11-WGP-NEXT: s_nop 0
13314 ; GFX11-WGP-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
13315 ; GFX11-WGP-NEXT: s_endpgm
13317 ; GFX11-CU-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
13318 ; GFX11-CU: ; %bb.0: ; %entry
13319 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
13320 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, 0
13321 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
13322 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
13323 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v2, v[0:1], s[0:1] offset:16 glc
13324 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
13325 ; GFX11-CU-NEXT: global_store_b32 v2, v0, s[0:1]
13326 ; GFX11-CU-NEXT: s_nop 0
13327 ; GFX11-CU-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
13328 ; GFX11-CU-NEXT: s_endpgm
13329 ptr addrspace(1) %out, i32 %in, i32 %old) {
13331 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
13332 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") seq_cst seq_cst
13333 %val0 = extractvalue { i32, i1 } %val, 0
13334 store i32 %val0, ptr addrspace(1) %out, align 4