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
10 define amdgpu_kernel void @global_workgroup_unordered_load(
11 ; GFX6-LABEL: global_workgroup_unordered_load:
12 ; GFX6: ; %bb.0: ; %entry
13 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[4:5], 0x0
14 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
15 ; GFX6-NEXT: s_mov_b32 s2, -1
16 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
17 ; GFX6-NEXT: s_mov_b32 s0, s4
18 ; GFX6-NEXT: s_mov_b32 s1, s5
19 ; GFX6-NEXT: buffer_load_dword v0, off, s[0:3], 0
20 ; GFX6-NEXT: s_mov_b32 s4, s6
21 ; GFX6-NEXT: s_mov_b32 s5, s7
22 ; GFX6-NEXT: s_mov_b32 s6, s2
23 ; GFX6-NEXT: s_mov_b32 s7, s3
24 ; GFX6-NEXT: s_waitcnt vmcnt(0)
25 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
28 ; GFX7-LABEL: global_workgroup_unordered_load:
29 ; GFX7: ; %bb.0: ; %entry
30 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
31 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
32 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
33 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
34 ; GFX7-NEXT: flat_load_dword v0, v[0:1]
35 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
36 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
37 ; GFX7-NEXT: s_waitcnt vmcnt(0)
38 ; GFX7-NEXT: flat_store_dword v[2:3], v0
41 ; GFX10-WGP-LABEL: global_workgroup_unordered_load:
42 ; GFX10-WGP: ; %bb.0: ; %entry
43 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
44 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
45 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
46 ; GFX10-WGP-NEXT: global_load_dword v1, v0, s[0:1]
47 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
48 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[2:3]
49 ; GFX10-WGP-NEXT: s_endpgm
51 ; GFX10-CU-LABEL: global_workgroup_unordered_load:
52 ; GFX10-CU: ; %bb.0: ; %entry
53 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
54 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
55 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
56 ; GFX10-CU-NEXT: global_load_dword v1, v0, s[0:1]
57 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
58 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[2:3]
59 ; GFX10-CU-NEXT: s_endpgm
61 ; SKIP-CACHE-INV-LABEL: global_workgroup_unordered_load:
62 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
63 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
64 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
65 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
66 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
67 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
68 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
69 ; SKIP-CACHE-INV-NEXT: buffer_load_dword v0, off, s[0:3], 0
70 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s6
71 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s7
72 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s2
73 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 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
97 i32 addrspace(1)* %in, i32 addrspace(1)* %out) {
99 %val = load atomic i32, i32 addrspace(1)* %in syncscope("workgroup") unordered, align 4
100 store i32 %val, i32 addrspace(1)* %out
104 define amdgpu_kernel void @global_workgroup_monotonic_load(
105 ; GFX6-LABEL: global_workgroup_monotonic_load:
106 ; GFX6: ; %bb.0: ; %entry
107 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[4:5], 0x0
108 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
109 ; GFX6-NEXT: s_mov_b32 s2, -1
110 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
111 ; GFX6-NEXT: s_mov_b32 s0, s4
112 ; GFX6-NEXT: s_mov_b32 s1, s5
113 ; GFX6-NEXT: buffer_load_dword v0, off, s[0:3], 0
114 ; GFX6-NEXT: s_mov_b32 s4, s6
115 ; GFX6-NEXT: s_mov_b32 s5, s7
116 ; GFX6-NEXT: s_mov_b32 s6, s2
117 ; GFX6-NEXT: s_mov_b32 s7, s3
118 ; GFX6-NEXT: s_waitcnt vmcnt(0)
119 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
120 ; GFX6-NEXT: s_endpgm
122 ; GFX7-LABEL: global_workgroup_monotonic_load:
123 ; GFX7: ; %bb.0: ; %entry
124 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
125 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
126 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
127 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
128 ; GFX7-NEXT: flat_load_dword v0, v[0:1]
129 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
130 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
131 ; GFX7-NEXT: s_waitcnt vmcnt(0)
132 ; GFX7-NEXT: flat_store_dword v[2:3], v0
133 ; GFX7-NEXT: s_endpgm
135 ; GFX10-WGP-LABEL: global_workgroup_monotonic_load:
136 ; GFX10-WGP: ; %bb.0: ; %entry
137 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
138 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
139 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
140 ; GFX10-WGP-NEXT: global_load_dword v1, v0, s[0:1] glc
141 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
142 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[2:3]
143 ; GFX10-WGP-NEXT: s_endpgm
145 ; GFX10-CU-LABEL: global_workgroup_monotonic_load:
146 ; GFX10-CU: ; %bb.0: ; %entry
147 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
148 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
149 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
150 ; GFX10-CU-NEXT: global_load_dword v1, v0, s[0:1]
151 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
152 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[2:3]
153 ; GFX10-CU-NEXT: s_endpgm
155 ; SKIP-CACHE-INV-LABEL: global_workgroup_monotonic_load:
156 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
157 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
158 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
159 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
160 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
161 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
162 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
163 ; SKIP-CACHE-INV-NEXT: buffer_load_dword v0, off, s[0:3], 0
164 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s6
165 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s7
166 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s2
167 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s3
168 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
169 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
170 ; SKIP-CACHE-INV-NEXT: s_endpgm
172 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_monotonic_load:
173 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
174 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
175 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
176 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
177 ; GFX90A-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[0:1]
178 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
179 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
180 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
182 ; GFX90A-TGSPLIT-LABEL: global_workgroup_monotonic_load:
183 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
184 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
185 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
186 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
187 ; GFX90A-TGSPLIT-NEXT: global_load_dword v1, v0, s[0:1] glc
188 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
189 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
190 ; GFX90A-TGSPLIT-NEXT: s_endpgm
191 i32 addrspace(1)* %in, i32 addrspace(1)* %out) {
193 %val = load atomic i32, i32 addrspace(1)* %in syncscope("workgroup") monotonic, align 4
194 store i32 %val, i32 addrspace(1)* %out
198 define amdgpu_kernel void @global_workgroup_acquire_load(
199 ; GFX6-LABEL: global_workgroup_acquire_load:
200 ; GFX6: ; %bb.0: ; %entry
201 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[4:5], 0x0
202 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
203 ; GFX6-NEXT: s_mov_b32 s2, -1
204 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
205 ; GFX6-NEXT: s_mov_b32 s0, s4
206 ; GFX6-NEXT: s_mov_b32 s1, s5
207 ; GFX6-NEXT: buffer_load_dword v0, off, s[0:3], 0
208 ; GFX6-NEXT: s_mov_b32 s4, s6
209 ; GFX6-NEXT: s_mov_b32 s5, s7
210 ; GFX6-NEXT: s_mov_b32 s6, s2
211 ; GFX6-NEXT: s_mov_b32 s7, s3
212 ; GFX6-NEXT: s_waitcnt vmcnt(0)
213 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
214 ; GFX6-NEXT: s_endpgm
216 ; GFX7-LABEL: global_workgroup_acquire_load:
217 ; GFX7: ; %bb.0: ; %entry
218 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
219 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
220 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
221 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
222 ; GFX7-NEXT: flat_load_dword v0, v[0:1]
223 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
224 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
225 ; GFX7-NEXT: s_waitcnt vmcnt(0)
226 ; GFX7-NEXT: flat_store_dword v[2:3], v0
227 ; GFX7-NEXT: s_endpgm
229 ; GFX10-WGP-LABEL: global_workgroup_acquire_load:
230 ; GFX10-WGP: ; %bb.0: ; %entry
231 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
232 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
233 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
234 ; GFX10-WGP-NEXT: global_load_dword v1, v0, s[0:1] glc
235 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
236 ; GFX10-WGP-NEXT: buffer_gl0_inv
237 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[2:3]
238 ; GFX10-WGP-NEXT: s_endpgm
240 ; GFX10-CU-LABEL: global_workgroup_acquire_load:
241 ; GFX10-CU: ; %bb.0: ; %entry
242 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
243 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
244 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
245 ; GFX10-CU-NEXT: global_load_dword v1, v0, s[0:1]
246 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
247 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[2:3]
248 ; GFX10-CU-NEXT: s_endpgm
250 ; SKIP-CACHE-INV-LABEL: global_workgroup_acquire_load:
251 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
252 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
253 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
254 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
255 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
256 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
257 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
258 ; SKIP-CACHE-INV-NEXT: buffer_load_dword v0, off, s[0:3], 0
259 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s6
260 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s7
261 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s2
262 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s3
263 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
264 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
265 ; SKIP-CACHE-INV-NEXT: s_endpgm
267 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acquire_load:
268 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
269 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
270 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
271 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
272 ; GFX90A-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[0:1]
273 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
274 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
275 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
277 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acquire_load:
278 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
279 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
280 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
281 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
282 ; GFX90A-TGSPLIT-NEXT: global_load_dword v1, v0, s[0:1] glc
283 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
284 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
285 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
286 ; GFX90A-TGSPLIT-NEXT: s_endpgm
287 i32 addrspace(1)* %in, i32 addrspace(1)* %out) {
289 %val = load atomic i32, i32 addrspace(1)* %in syncscope("workgroup") acquire, align 4
290 store i32 %val, i32 addrspace(1)* %out
294 define amdgpu_kernel void @global_workgroup_seq_cst_load(
295 ; GFX6-LABEL: global_workgroup_seq_cst_load:
296 ; GFX6: ; %bb.0: ; %entry
297 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[4:5], 0x0
298 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
299 ; GFX6-NEXT: s_mov_b32 s2, -1
300 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
301 ; GFX6-NEXT: s_mov_b32 s0, s4
302 ; GFX6-NEXT: s_mov_b32 s1, s5
303 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
304 ; GFX6-NEXT: buffer_load_dword v0, off, s[0:3], 0
305 ; GFX6-NEXT: s_mov_b32 s4, s6
306 ; GFX6-NEXT: s_mov_b32 s5, s7
307 ; GFX6-NEXT: s_mov_b32 s6, s2
308 ; GFX6-NEXT: s_mov_b32 s7, s3
309 ; GFX6-NEXT: s_waitcnt vmcnt(0)
310 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
311 ; GFX6-NEXT: s_endpgm
313 ; GFX7-LABEL: global_workgroup_seq_cst_load:
314 ; GFX7: ; %bb.0: ; %entry
315 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
316 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
317 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
318 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
319 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
320 ; GFX7-NEXT: flat_load_dword v0, v[0:1]
321 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
322 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
323 ; GFX7-NEXT: s_waitcnt vmcnt(0)
324 ; GFX7-NEXT: flat_store_dword v[2:3], v0
325 ; GFX7-NEXT: s_endpgm
327 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_load:
328 ; GFX10-WGP: ; %bb.0: ; %entry
329 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
330 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
331 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
332 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
333 ; GFX10-WGP-NEXT: global_load_dword v1, v0, s[0:1] glc
334 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
335 ; GFX10-WGP-NEXT: buffer_gl0_inv
336 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[2:3]
337 ; GFX10-WGP-NEXT: s_endpgm
339 ; GFX10-CU-LABEL: global_workgroup_seq_cst_load:
340 ; GFX10-CU: ; %bb.0: ; %entry
341 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
342 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
343 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
344 ; GFX10-CU-NEXT: global_load_dword v1, v0, s[0:1]
345 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
346 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[2:3]
347 ; GFX10-CU-NEXT: s_endpgm
349 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_load:
350 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
351 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
352 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
353 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
354 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
355 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
356 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
357 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
358 ; SKIP-CACHE-INV-NEXT: buffer_load_dword v0, off, s[0:3], 0
359 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s6
360 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s7
361 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s2
362 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s3
363 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
364 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
365 ; SKIP-CACHE-INV-NEXT: s_endpgm
367 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_load:
368 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
369 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
370 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
371 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
372 ; GFX90A-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[0:1]
373 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
374 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
375 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
377 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_load:
378 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
379 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
380 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
381 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
382 ; GFX90A-TGSPLIT-NEXT: global_load_dword v1, v0, s[0:1] glc
383 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
384 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
385 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
386 ; GFX90A-TGSPLIT-NEXT: s_endpgm
387 i32 addrspace(1)* %in, i32 addrspace(1)* %out) {
389 %val = load atomic i32, i32 addrspace(1)* %in syncscope("workgroup") seq_cst, align 4
390 store i32 %val, i32 addrspace(1)* %out
394 define amdgpu_kernel void @global_workgroup_unordered_store(
395 ; GFX6-LABEL: global_workgroup_unordered_store:
396 ; GFX6: ; %bb.0: ; %entry
397 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x0
398 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
399 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
400 ; GFX6-NEXT: s_mov_b32 s2, -1
401 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
402 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
403 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
404 ; GFX6-NEXT: s_endpgm
406 ; GFX7-LABEL: global_workgroup_unordered_store:
407 ; GFX7: ; %bb.0: ; %entry
408 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x0
409 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
410 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
411 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
412 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
413 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
414 ; GFX7-NEXT: flat_store_dword v[0:1], v2
415 ; GFX7-NEXT: s_endpgm
417 ; GFX10-WGP-LABEL: global_workgroup_unordered_store:
418 ; GFX10-WGP: ; %bb.0: ; %entry
419 ; GFX10-WGP-NEXT: s_clause 0x1
420 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x0
421 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
422 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
423 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
424 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
425 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
426 ; GFX10-WGP-NEXT: s_endpgm
428 ; GFX10-CU-LABEL: global_workgroup_unordered_store:
429 ; GFX10-CU: ; %bb.0: ; %entry
430 ; GFX10-CU-NEXT: s_clause 0x1
431 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x0
432 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
433 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
434 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
435 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
436 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
437 ; GFX10-CU-NEXT: s_endpgm
439 ; SKIP-CACHE-INV-LABEL: global_workgroup_unordered_store:
440 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
441 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x9
442 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
443 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
444 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
445 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
446 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
447 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
448 ; SKIP-CACHE-INV-NEXT: s_endpgm
450 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_unordered_store:
451 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
452 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
453 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
454 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
455 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
456 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
457 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
458 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
460 ; GFX90A-TGSPLIT-LABEL: global_workgroup_unordered_store:
461 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
462 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
463 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
464 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
465 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
466 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
467 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
468 ; GFX90A-TGSPLIT-NEXT: s_endpgm
469 i32 %in, i32 addrspace(1)* %out) {
471 store atomic i32 %in, i32 addrspace(1)* %out syncscope("workgroup") unordered, align 4
475 define amdgpu_kernel void @global_workgroup_monotonic_store(
476 ; GFX6-LABEL: global_workgroup_monotonic_store:
477 ; GFX6: ; %bb.0: ; %entry
478 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x0
479 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
480 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
481 ; GFX6-NEXT: s_mov_b32 s2, -1
482 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
483 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
484 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
485 ; GFX6-NEXT: s_endpgm
487 ; GFX7-LABEL: global_workgroup_monotonic_store:
488 ; GFX7: ; %bb.0: ; %entry
489 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x0
490 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
491 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
492 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
493 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
494 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
495 ; GFX7-NEXT: flat_store_dword v[0:1], v2
496 ; GFX7-NEXT: s_endpgm
498 ; GFX10-WGP-LABEL: global_workgroup_monotonic_store:
499 ; GFX10-WGP: ; %bb.0: ; %entry
500 ; GFX10-WGP-NEXT: s_clause 0x1
501 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x0
502 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
503 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
504 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
505 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
506 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
507 ; GFX10-WGP-NEXT: s_endpgm
509 ; GFX10-CU-LABEL: global_workgroup_monotonic_store:
510 ; GFX10-CU: ; %bb.0: ; %entry
511 ; GFX10-CU-NEXT: s_clause 0x1
512 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x0
513 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
514 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
515 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
516 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
517 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
518 ; GFX10-CU-NEXT: s_endpgm
520 ; SKIP-CACHE-INV-LABEL: global_workgroup_monotonic_store:
521 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
522 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x9
523 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
524 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
525 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
526 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
527 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
528 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
529 ; SKIP-CACHE-INV-NEXT: s_endpgm
531 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_monotonic_store:
532 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
533 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
534 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
535 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
536 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
537 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
538 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
539 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
541 ; GFX90A-TGSPLIT-LABEL: global_workgroup_monotonic_store:
542 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
543 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
544 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
545 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
546 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
547 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
548 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
549 ; GFX90A-TGSPLIT-NEXT: s_endpgm
550 i32 %in, i32 addrspace(1)* %out) {
552 store atomic i32 %in, i32 addrspace(1)* %out syncscope("workgroup") monotonic, align 4
556 define amdgpu_kernel void @global_workgroup_release_store(
557 ; GFX6-LABEL: global_workgroup_release_store:
558 ; GFX6: ; %bb.0: ; %entry
559 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x0
560 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
561 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
562 ; GFX6-NEXT: s_mov_b32 s2, -1
563 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
564 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
565 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
566 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
567 ; GFX6-NEXT: s_endpgm
569 ; GFX7-LABEL: global_workgroup_release_store:
570 ; GFX7: ; %bb.0: ; %entry
571 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x0
572 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
573 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
574 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
575 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
576 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
577 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
578 ; GFX7-NEXT: flat_store_dword v[0:1], v2
579 ; GFX7-NEXT: s_endpgm
581 ; GFX10-WGP-LABEL: global_workgroup_release_store:
582 ; GFX10-WGP: ; %bb.0: ; %entry
583 ; GFX10-WGP-NEXT: s_clause 0x1
584 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x0
585 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
586 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
587 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
588 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
589 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
590 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
591 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
592 ; GFX10-WGP-NEXT: s_endpgm
594 ; GFX10-CU-LABEL: global_workgroup_release_store:
595 ; GFX10-CU: ; %bb.0: ; %entry
596 ; GFX10-CU-NEXT: s_clause 0x1
597 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x0
598 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
599 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
600 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
601 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
602 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
603 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
604 ; GFX10-CU-NEXT: s_endpgm
606 ; SKIP-CACHE-INV-LABEL: global_workgroup_release_store:
607 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
608 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x9
609 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
610 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
611 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
612 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
613 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
614 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
615 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
616 ; SKIP-CACHE-INV-NEXT: s_endpgm
618 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_release_store:
619 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
620 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
621 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
622 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
623 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
624 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
625 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
626 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
627 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
629 ; GFX90A-TGSPLIT-LABEL: global_workgroup_release_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: s_waitcnt vmcnt(0) lgkmcnt(0)
637 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
638 ; GFX90A-TGSPLIT-NEXT: s_endpgm
639 i32 %in, i32 addrspace(1)* %out) {
641 store atomic i32 %in, i32 addrspace(1)* %out syncscope("workgroup") release, align 4
645 define amdgpu_kernel void @global_workgroup_seq_cst_store(
646 ; GFX6-LABEL: global_workgroup_seq_cst_store:
647 ; GFX6: ; %bb.0: ; %entry
648 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x0
649 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
650 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
651 ; GFX6-NEXT: s_mov_b32 s2, -1
652 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
653 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
654 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
655 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
656 ; GFX6-NEXT: s_endpgm
658 ; GFX7-LABEL: global_workgroup_seq_cst_store:
659 ; GFX7: ; %bb.0: ; %entry
660 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x0
661 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
662 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
663 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
664 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
665 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
666 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
667 ; GFX7-NEXT: flat_store_dword v[0:1], v2
668 ; GFX7-NEXT: s_endpgm
670 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_store:
671 ; GFX10-WGP: ; %bb.0: ; %entry
672 ; GFX10-WGP-NEXT: s_clause 0x1
673 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x0
674 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
675 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
676 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
677 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
678 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
679 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
680 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
681 ; GFX10-WGP-NEXT: s_endpgm
683 ; GFX10-CU-LABEL: global_workgroup_seq_cst_store:
684 ; GFX10-CU: ; %bb.0: ; %entry
685 ; GFX10-CU-NEXT: s_clause 0x1
686 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x0
687 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
688 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
689 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
690 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
691 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
692 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
693 ; GFX10-CU-NEXT: s_endpgm
695 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_store:
696 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
697 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x9
698 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
699 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
700 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
701 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
702 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
703 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
704 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
705 ; SKIP-CACHE-INV-NEXT: s_endpgm
707 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_store:
708 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
709 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
710 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
711 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
712 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
713 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
714 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
715 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
716 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
718 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_store:
719 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
720 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
721 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
722 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
723 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
724 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
725 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
726 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
727 ; GFX90A-TGSPLIT-NEXT: s_endpgm
728 i32 %in, i32 addrspace(1)* %out) {
730 store atomic i32 %in, i32 addrspace(1)* %out syncscope("workgroup") seq_cst, align 4
734 define amdgpu_kernel void @global_workgroup_monotonic_atomicrmw(
735 ; GFX6-LABEL: global_workgroup_monotonic_atomicrmw:
736 ; GFX6: ; %bb.0: ; %entry
737 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
738 ; GFX6-NEXT: s_load_dword s4, s[4:5], 0x2
739 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
740 ; GFX6-NEXT: s_mov_b32 s2, -1
741 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
742 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
743 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
744 ; GFX6-NEXT: s_endpgm
746 ; GFX7-LABEL: global_workgroup_monotonic_atomicrmw:
747 ; GFX7: ; %bb.0: ; %entry
748 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
749 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
750 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
751 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
752 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
753 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
754 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
755 ; GFX7-NEXT: s_endpgm
757 ; GFX10-WGP-LABEL: global_workgroup_monotonic_atomicrmw:
758 ; GFX10-WGP: ; %bb.0: ; %entry
759 ; GFX10-WGP-NEXT: s_clause 0x1
760 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
761 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
762 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
763 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
764 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
765 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[0:1]
766 ; GFX10-WGP-NEXT: s_endpgm
768 ; GFX10-CU-LABEL: global_workgroup_monotonic_atomicrmw:
769 ; GFX10-CU: ; %bb.0: ; %entry
770 ; GFX10-CU-NEXT: s_clause 0x1
771 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
772 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
773 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
774 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
775 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
776 ; GFX10-CU-NEXT: global_atomic_swap v0, v1, s[0:1]
777 ; GFX10-CU-NEXT: s_endpgm
779 ; SKIP-CACHE-INV-LABEL: global_workgroup_monotonic_atomicrmw:
780 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
781 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
782 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0xb
783 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
784 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
785 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
786 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
787 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[4:7], 0
788 ; SKIP-CACHE-INV-NEXT: s_endpgm
790 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_monotonic_atomicrmw:
791 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
792 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
793 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
794 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
795 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
796 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
797 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
798 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
800 ; GFX90A-TGSPLIT-LABEL: global_workgroup_monotonic_atomicrmw:
801 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
802 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
803 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
804 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
805 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
806 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
807 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
808 ; GFX90A-TGSPLIT-NEXT: s_endpgm
809 i32 addrspace(1)* %out, i32 %in) {
811 %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("workgroup") monotonic
815 define amdgpu_kernel void @global_workgroup_acquire_atomicrmw(
816 ; GFX6-LABEL: global_workgroup_acquire_atomicrmw:
817 ; GFX6: ; %bb.0: ; %entry
818 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
819 ; GFX6-NEXT: s_load_dword s4, s[4:5], 0x2
820 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
821 ; GFX6-NEXT: s_mov_b32 s2, -1
822 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
823 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
824 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
825 ; GFX6-NEXT: s_endpgm
827 ; GFX7-LABEL: global_workgroup_acquire_atomicrmw:
828 ; GFX7: ; %bb.0: ; %entry
829 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
830 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
831 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
832 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
833 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
834 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
835 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
836 ; GFX7-NEXT: s_endpgm
838 ; GFX10-WGP-LABEL: global_workgroup_acquire_atomicrmw:
839 ; GFX10-WGP: ; %bb.0: ; %entry
840 ; GFX10-WGP-NEXT: s_clause 0x1
841 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
842 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
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: global_atomic_swap v0, v1, s[0:1]
847 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
848 ; GFX10-WGP-NEXT: buffer_gl0_inv
849 ; GFX10-WGP-NEXT: s_endpgm
851 ; GFX10-CU-LABEL: global_workgroup_acquire_atomicrmw:
852 ; GFX10-CU: ; %bb.0: ; %entry
853 ; GFX10-CU-NEXT: s_clause 0x1
854 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
855 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
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: global_atomic_swap v0, v1, s[0:1]
860 ; GFX10-CU-NEXT: s_endpgm
862 ; SKIP-CACHE-INV-LABEL: global_workgroup_acquire_atomicrmw:
863 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
864 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
865 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0xb
866 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
867 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
868 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
869 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
870 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[4:7], 0
871 ; SKIP-CACHE-INV-NEXT: s_endpgm
873 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acquire_atomicrmw:
874 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
875 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
876 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
877 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
878 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
879 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
880 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
881 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
883 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acquire_atomicrmw:
884 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
885 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
886 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
887 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
888 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
889 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
890 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
891 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
892 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
893 ; GFX90A-TGSPLIT-NEXT: s_endpgm
894 i32 addrspace(1)* %out, i32 %in) {
896 %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("workgroup") acquire
900 define amdgpu_kernel void @global_workgroup_release_atomicrmw(
901 ; GFX6-LABEL: global_workgroup_release_atomicrmw:
902 ; GFX6: ; %bb.0: ; %entry
903 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
904 ; GFX6-NEXT: s_load_dword s4, s[4:5], 0x2
905 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
906 ; GFX6-NEXT: s_mov_b32 s2, -1
907 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
908 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
909 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
910 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
911 ; GFX6-NEXT: s_endpgm
913 ; GFX7-LABEL: global_workgroup_release_atomicrmw:
914 ; GFX7: ; %bb.0: ; %entry
915 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
916 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
917 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
918 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
919 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
920 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
921 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
922 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
923 ; GFX7-NEXT: s_endpgm
925 ; GFX10-WGP-LABEL: global_workgroup_release_atomicrmw:
926 ; GFX10-WGP: ; %bb.0: ; %entry
927 ; GFX10-WGP-NEXT: s_clause 0x1
928 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
929 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
930 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
931 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
932 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
933 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
934 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
935 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[0:1]
936 ; GFX10-WGP-NEXT: s_endpgm
938 ; GFX10-CU-LABEL: global_workgroup_release_atomicrmw:
939 ; GFX10-CU: ; %bb.0: ; %entry
940 ; GFX10-CU-NEXT: s_clause 0x1
941 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
942 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
943 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
944 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
945 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
946 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
947 ; GFX10-CU-NEXT: global_atomic_swap v0, v1, s[0:1]
948 ; GFX10-CU-NEXT: s_endpgm
950 ; SKIP-CACHE-INV-LABEL: global_workgroup_release_atomicrmw:
951 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
952 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
953 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0xb
954 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
955 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
956 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
957 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
958 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
959 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[4:7], 0
960 ; SKIP-CACHE-INV-NEXT: s_endpgm
962 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_release_atomicrmw:
963 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
964 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
965 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
966 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
967 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
968 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
969 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
970 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
971 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
973 ; GFX90A-TGSPLIT-LABEL: global_workgroup_release_atomicrmw:
974 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
975 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
976 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
977 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
978 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
979 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
980 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
981 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
982 ; GFX90A-TGSPLIT-NEXT: s_endpgm
983 i32 addrspace(1)* %out, i32 %in) {
985 %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("workgroup") release
989 define amdgpu_kernel void @global_workgroup_acq_rel_atomicrmw(
990 ; GFX6-LABEL: global_workgroup_acq_rel_atomicrmw:
991 ; GFX6: ; %bb.0: ; %entry
992 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
993 ; GFX6-NEXT: s_load_dword s4, s[4:5], 0x2
994 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
995 ; GFX6-NEXT: s_mov_b32 s2, -1
996 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
997 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
998 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
999 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
1000 ; GFX6-NEXT: s_endpgm
1002 ; GFX7-LABEL: global_workgroup_acq_rel_atomicrmw:
1003 ; GFX7: ; %bb.0: ; %entry
1004 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1005 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
1006 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1007 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
1008 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
1009 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
1010 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1011 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
1012 ; GFX7-NEXT: s_endpgm
1014 ; GFX10-WGP-LABEL: global_workgroup_acq_rel_atomicrmw:
1015 ; GFX10-WGP: ; %bb.0: ; %entry
1016 ; GFX10-WGP-NEXT: s_clause 0x1
1017 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
1018 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1019 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
1020 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1021 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
1022 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1023 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1024 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[0:1]
1025 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1026 ; GFX10-WGP-NEXT: buffer_gl0_inv
1027 ; GFX10-WGP-NEXT: s_endpgm
1029 ; GFX10-CU-LABEL: global_workgroup_acq_rel_atomicrmw:
1030 ; GFX10-CU: ; %bb.0: ; %entry
1031 ; GFX10-CU-NEXT: s_clause 0x1
1032 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
1033 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1034 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
1035 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1036 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
1037 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1038 ; GFX10-CU-NEXT: global_atomic_swap v0, v1, s[0:1]
1039 ; GFX10-CU-NEXT: s_endpgm
1041 ; SKIP-CACHE-INV-LABEL: global_workgroup_acq_rel_atomicrmw:
1042 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1043 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
1044 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0xb
1045 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
1046 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
1047 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1048 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
1049 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1050 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[4:7], 0
1051 ; SKIP-CACHE-INV-NEXT: s_endpgm
1053 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_atomicrmw:
1054 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1055 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1056 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1057 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1058 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1059 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1060 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1061 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
1062 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1064 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acq_rel_atomicrmw:
1065 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1066 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1067 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1068 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1069 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1070 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1071 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1072 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
1073 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1074 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
1075 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1076 i32 addrspace(1)* %out, i32 %in) {
1078 %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("workgroup") acq_rel
1082 define amdgpu_kernel void @global_workgroup_seq_cst_atomicrmw(
1083 ; GFX6-LABEL: global_workgroup_seq_cst_atomicrmw:
1084 ; GFX6: ; %bb.0: ; %entry
1085 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1086 ; GFX6-NEXT: s_load_dword s4, s[4:5], 0x2
1087 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
1088 ; GFX6-NEXT: s_mov_b32 s2, -1
1089 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1090 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
1091 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1092 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
1093 ; GFX6-NEXT: s_endpgm
1095 ; GFX7-LABEL: global_workgroup_seq_cst_atomicrmw:
1096 ; GFX7: ; %bb.0: ; %entry
1097 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1098 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
1099 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1100 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
1101 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
1102 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
1103 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1104 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
1105 ; GFX7-NEXT: s_endpgm
1107 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_atomicrmw:
1108 ; GFX10-WGP: ; %bb.0: ; %entry
1109 ; GFX10-WGP-NEXT: s_clause 0x1
1110 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
1111 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1112 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
1113 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1114 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
1115 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1116 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1117 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[0:1]
1118 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1119 ; GFX10-WGP-NEXT: buffer_gl0_inv
1120 ; GFX10-WGP-NEXT: s_endpgm
1122 ; GFX10-CU-LABEL: global_workgroup_seq_cst_atomicrmw:
1123 ; GFX10-CU: ; %bb.0: ; %entry
1124 ; GFX10-CU-NEXT: s_clause 0x1
1125 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
1126 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1127 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
1128 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1129 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
1130 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
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_seq_cst_atomicrmw:
1135 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1136 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
1137 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0xb
1138 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
1139 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
1140 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1141 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
1142 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1143 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[4:7], 0
1144 ; SKIP-CACHE-INV-NEXT: s_endpgm
1146 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_atomicrmw:
1147 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1148 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1149 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1150 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1151 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1152 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1153 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1154 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
1155 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1157 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_atomicrmw:
1158 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1159 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1160 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1161 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1162 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1163 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1164 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1165 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
1166 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1167 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
1168 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1169 i32 addrspace(1)* %out, i32 %in) {
1171 %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("workgroup") seq_cst
1175 define amdgpu_kernel void @global_workgroup_acquire_ret_atomicrmw(
1176 ; GFX6-LABEL: global_workgroup_acquire_ret_atomicrmw:
1177 ; GFX6: ; %bb.0: ; %entry
1178 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1179 ; GFX6-NEXT: s_load_dword s4, s[4:5], 0x2
1180 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
1181 ; GFX6-NEXT: s_mov_b32 s2, -1
1182 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1183 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
1184 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0 glc
1185 ; GFX6-NEXT: s_waitcnt vmcnt(0)
1186 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
1187 ; GFX6-NEXT: s_endpgm
1189 ; GFX7-LABEL: global_workgroup_acquire_ret_atomicrmw:
1190 ; GFX7: ; %bb.0: ; %entry
1191 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1192 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
1193 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1194 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
1195 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
1196 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
1197 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
1198 ; GFX7-NEXT: s_waitcnt vmcnt(0)
1199 ; GFX7-NEXT: flat_store_dword v[0:1], v2
1200 ; GFX7-NEXT: s_endpgm
1202 ; GFX10-WGP-LABEL: global_workgroup_acquire_ret_atomicrmw:
1203 ; GFX10-WGP: ; %bb.0: ; %entry
1204 ; GFX10-WGP-NEXT: s_clause 0x1
1205 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
1206 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1207 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
1208 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1209 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
1210 ; GFX10-WGP-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
1211 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
1212 ; GFX10-WGP-NEXT: buffer_gl0_inv
1213 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
1214 ; GFX10-WGP-NEXT: s_endpgm
1216 ; GFX10-CU-LABEL: global_workgroup_acquire_ret_atomicrmw:
1217 ; GFX10-CU: ; %bb.0: ; %entry
1218 ; GFX10-CU-NEXT: s_clause 0x1
1219 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
1220 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1221 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
1222 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1223 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
1224 ; GFX10-CU-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
1225 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
1226 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
1227 ; GFX10-CU-NEXT: s_endpgm
1229 ; SKIP-CACHE-INV-LABEL: global_workgroup_acquire_ret_atomicrmw:
1230 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1231 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
1232 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0xb
1233 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
1234 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
1235 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1236 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
1237 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[4:7], 0 glc
1238 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
1239 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
1240 ; SKIP-CACHE-INV-NEXT: s_endpgm
1242 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acquire_ret_atomicrmw:
1243 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1244 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1245 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1246 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1247 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1248 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1249 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
1250 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
1251 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
1252 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1254 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acquire_ret_atomicrmw:
1255 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1256 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1257 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1258 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1259 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1260 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1261 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
1262 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1263 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
1264 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
1265 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1266 i32 addrspace(1)* %out, i32 %in) {
1268 %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("workgroup") acquire
1269 store i32 %val, i32 addrspace(1)* %out, align 4
1273 define amdgpu_kernel void @global_workgroup_acq_rel_ret_atomicrmw(
1274 ; GFX6-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
1275 ; GFX6: ; %bb.0: ; %entry
1276 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1277 ; GFX6-NEXT: s_load_dword s4, s[4:5], 0x2
1278 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
1279 ; GFX6-NEXT: s_mov_b32 s2, -1
1280 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1281 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
1282 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1283 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0 glc
1284 ; GFX6-NEXT: s_waitcnt vmcnt(0)
1285 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
1286 ; GFX6-NEXT: s_endpgm
1288 ; GFX7-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
1289 ; GFX7: ; %bb.0: ; %entry
1290 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1291 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
1292 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1293 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
1294 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
1295 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
1296 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1297 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
1298 ; GFX7-NEXT: s_waitcnt vmcnt(0)
1299 ; GFX7-NEXT: flat_store_dword v[0:1], v2
1300 ; GFX7-NEXT: s_endpgm
1302 ; GFX10-WGP-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
1303 ; GFX10-WGP: ; %bb.0: ; %entry
1304 ; GFX10-WGP-NEXT: s_clause 0x1
1305 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
1306 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1307 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
1308 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1309 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
1310 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1311 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1312 ; GFX10-WGP-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
1313 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
1314 ; GFX10-WGP-NEXT: buffer_gl0_inv
1315 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
1316 ; GFX10-WGP-NEXT: s_endpgm
1318 ; GFX10-CU-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
1319 ; GFX10-CU: ; %bb.0: ; %entry
1320 ; GFX10-CU-NEXT: s_clause 0x1
1321 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
1322 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1323 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
1324 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1325 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
1326 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1327 ; GFX10-CU-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
1328 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
1329 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
1330 ; GFX10-CU-NEXT: s_endpgm
1332 ; SKIP-CACHE-INV-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
1333 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1334 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
1335 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0xb
1336 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
1337 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
1338 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1339 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
1340 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1341 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[4:7], 0 glc
1342 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
1343 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
1344 ; SKIP-CACHE-INV-NEXT: s_endpgm
1346 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
1347 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1348 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1349 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1350 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1351 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1352 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1353 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1354 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
1355 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
1356 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
1357 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1359 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
1360 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1361 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1362 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1363 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1364 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1365 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1366 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1367 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
1368 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1369 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
1370 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
1371 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1372 i32 addrspace(1)* %out, i32 %in) {
1374 %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("workgroup") acq_rel
1375 store i32 %val, i32 addrspace(1)* %out, align 4
1379 define amdgpu_kernel void @global_workgroup_seq_cst_ret_atomicrmw(
1380 ; GFX6-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
1381 ; GFX6: ; %bb.0: ; %entry
1382 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1383 ; GFX6-NEXT: s_load_dword s4, s[4:5], 0x2
1384 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
1385 ; GFX6-NEXT: s_mov_b32 s2, -1
1386 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1387 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
1388 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1389 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0 glc
1390 ; GFX6-NEXT: s_waitcnt vmcnt(0)
1391 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
1392 ; GFX6-NEXT: s_endpgm
1394 ; GFX7-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
1395 ; GFX7: ; %bb.0: ; %entry
1396 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1397 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
1398 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1399 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
1400 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
1401 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
1402 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1403 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
1404 ; GFX7-NEXT: s_waitcnt vmcnt(0)
1405 ; GFX7-NEXT: flat_store_dword v[0:1], v2
1406 ; GFX7-NEXT: s_endpgm
1408 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
1409 ; GFX10-WGP: ; %bb.0: ; %entry
1410 ; GFX10-WGP-NEXT: s_clause 0x1
1411 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
1412 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1413 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
1414 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1415 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
1416 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1417 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1418 ; GFX10-WGP-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
1419 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
1420 ; GFX10-WGP-NEXT: buffer_gl0_inv
1421 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
1422 ; GFX10-WGP-NEXT: s_endpgm
1424 ; GFX10-CU-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
1425 ; GFX10-CU: ; %bb.0: ; %entry
1426 ; GFX10-CU-NEXT: s_clause 0x1
1427 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
1428 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1429 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
1430 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1431 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
1432 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1433 ; GFX10-CU-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
1434 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
1435 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
1436 ; GFX10-CU-NEXT: s_endpgm
1438 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
1439 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1440 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
1441 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0xb
1442 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
1443 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
1444 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1445 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
1446 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1447 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[4:7], 0 glc
1448 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
1449 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
1450 ; SKIP-CACHE-INV-NEXT: s_endpgm
1452 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
1453 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1454 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1455 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1456 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1457 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1458 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1459 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1460 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
1461 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
1462 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
1463 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1465 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
1466 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1467 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1468 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1469 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1470 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1471 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1472 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1473 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
1474 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1475 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
1476 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
1477 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1478 i32 addrspace(1)* %out, i32 %in) {
1480 %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("workgroup") seq_cst
1481 store i32 %val, i32 addrspace(1)* %out, align 4
1485 define amdgpu_kernel void @global_workgroup_monotonic_monotonic_cmpxchg(
1486 ; GFX6-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
1487 ; GFX6: ; %bb.0: ; %entry
1488 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1489 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
1490 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
1491 ; GFX6-NEXT: s_mov_b32 s2, -1
1492 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1493 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
1494 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
1495 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
1496 ; GFX6-NEXT: s_endpgm
1498 ; GFX7-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
1499 ; GFX7: ; %bb.0: ; %entry
1500 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1501 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
1502 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1503 ; GFX7-NEXT: s_add_u32 s0, s0, 16
1504 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
1505 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
1506 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
1507 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
1508 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
1509 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
1510 ; GFX7-NEXT: s_endpgm
1512 ; GFX10-WGP-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
1513 ; GFX10-WGP: ; %bb.0: ; %entry
1514 ; GFX10-WGP-NEXT: s_clause 0x1
1515 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
1516 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
1517 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
1518 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1519 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
1520 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
1521 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
1522 ; GFX10-WGP-NEXT: s_endpgm
1524 ; GFX10-CU-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
1525 ; GFX10-CU: ; %bb.0: ; %entry
1526 ; GFX10-CU-NEXT: s_clause 0x1
1527 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
1528 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
1529 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
1530 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1531 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
1532 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
1533 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
1534 ; GFX10-CU-NEXT: s_endpgm
1536 ; SKIP-CACHE-INV-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
1537 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1538 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
1539 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
1540 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
1541 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
1542 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1543 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
1544 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
1545 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
1546 ; SKIP-CACHE-INV-NEXT: s_endpgm
1548 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
1549 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1550 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1551 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
1552 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
1553 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1554 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
1555 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
1556 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1558 ; GFX90A-TGSPLIT-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
1559 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1560 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1561 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
1562 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
1563 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1564 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
1565 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
1566 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1567 i32 addrspace(1)* %out, i32 %in, i32 %old) {
1569 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
1570 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") monotonic monotonic
1574 define amdgpu_kernel void @global_workgroup_acquire_monotonic_cmpxchg(
1575 ; GFX6-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
1576 ; GFX6: ; %bb.0: ; %entry
1577 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1578 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
1579 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
1580 ; GFX6-NEXT: s_mov_b32 s2, -1
1581 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1582 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
1583 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
1584 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
1585 ; GFX6-NEXT: s_endpgm
1587 ; GFX7-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
1588 ; GFX7: ; %bb.0: ; %entry
1589 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1590 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
1591 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1592 ; GFX7-NEXT: s_add_u32 s0, s0, 16
1593 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
1594 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
1595 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
1596 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
1597 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
1598 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
1599 ; GFX7-NEXT: s_endpgm
1601 ; GFX10-WGP-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
1602 ; GFX10-WGP: ; %bb.0: ; %entry
1603 ; GFX10-WGP-NEXT: s_clause 0x1
1604 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
1605 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
1606 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
1607 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1608 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
1609 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
1610 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
1611 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1612 ; GFX10-WGP-NEXT: buffer_gl0_inv
1613 ; GFX10-WGP-NEXT: s_endpgm
1615 ; GFX10-CU-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
1616 ; GFX10-CU: ; %bb.0: ; %entry
1617 ; GFX10-CU-NEXT: s_clause 0x1
1618 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
1619 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
1620 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
1621 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1622 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
1623 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
1624 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
1625 ; GFX10-CU-NEXT: s_endpgm
1627 ; SKIP-CACHE-INV-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
1628 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1629 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
1630 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
1631 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
1632 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
1633 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1634 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
1635 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
1636 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
1637 ; SKIP-CACHE-INV-NEXT: s_endpgm
1639 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
1640 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1641 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1642 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
1643 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
1644 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1645 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
1646 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
1647 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1649 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
1650 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1651 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1652 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
1653 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
1654 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1655 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
1656 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
1657 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1658 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
1659 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1660 i32 addrspace(1)* %out, i32 %in, i32 %old) {
1662 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
1663 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") acquire monotonic
1667 define amdgpu_kernel void @global_workgroup_release_monotonic_cmpxchg(
1668 ; GFX6-LABEL: global_workgroup_release_monotonic_cmpxchg:
1669 ; GFX6: ; %bb.0: ; %entry
1670 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1671 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
1672 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
1673 ; GFX6-NEXT: s_mov_b32 s2, -1
1674 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1675 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
1676 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
1677 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1678 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
1679 ; GFX6-NEXT: s_endpgm
1681 ; GFX7-LABEL: global_workgroup_release_monotonic_cmpxchg:
1682 ; GFX7: ; %bb.0: ; %entry
1683 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1684 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
1685 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1686 ; GFX7-NEXT: s_add_u32 s0, s0, 16
1687 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
1688 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
1689 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
1690 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
1691 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
1692 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1693 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
1694 ; GFX7-NEXT: s_endpgm
1696 ; GFX10-WGP-LABEL: global_workgroup_release_monotonic_cmpxchg:
1697 ; GFX10-WGP: ; %bb.0: ; %entry
1698 ; GFX10-WGP-NEXT: s_clause 0x1
1699 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
1700 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
1701 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
1702 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1703 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
1704 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
1705 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1706 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1707 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
1708 ; GFX10-WGP-NEXT: s_endpgm
1710 ; GFX10-CU-LABEL: global_workgroup_release_monotonic_cmpxchg:
1711 ; GFX10-CU: ; %bb.0: ; %entry
1712 ; GFX10-CU-NEXT: s_clause 0x1
1713 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
1714 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
1715 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
1716 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1717 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
1718 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
1719 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1720 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
1721 ; GFX10-CU-NEXT: s_endpgm
1723 ; SKIP-CACHE-INV-LABEL: global_workgroup_release_monotonic_cmpxchg:
1724 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1725 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
1726 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
1727 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
1728 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
1729 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1730 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
1731 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
1732 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1733 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
1734 ; SKIP-CACHE-INV-NEXT: s_endpgm
1736 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_release_monotonic_cmpxchg:
1737 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1738 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1739 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
1740 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
1741 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1742 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
1743 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1744 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
1745 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1747 ; GFX90A-TGSPLIT-LABEL: global_workgroup_release_monotonic_cmpxchg:
1748 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1749 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1750 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
1751 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
1752 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1753 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
1754 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1755 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
1756 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1757 i32 addrspace(1)* %out, i32 %in, i32 %old) {
1759 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
1760 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") release monotonic
1764 define amdgpu_kernel void @global_workgroup_acq_rel_monotonic_cmpxchg(
1765 ; GFX6-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
1766 ; GFX6: ; %bb.0: ; %entry
1767 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1768 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
1769 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
1770 ; GFX6-NEXT: s_mov_b32 s2, -1
1771 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1772 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
1773 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
1774 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1775 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
1776 ; GFX6-NEXT: s_endpgm
1778 ; GFX7-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
1779 ; GFX7: ; %bb.0: ; %entry
1780 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1781 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
1782 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1783 ; GFX7-NEXT: s_add_u32 s0, s0, 16
1784 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
1785 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
1786 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
1787 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
1788 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
1789 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1790 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
1791 ; GFX7-NEXT: s_endpgm
1793 ; GFX10-WGP-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
1794 ; GFX10-WGP: ; %bb.0: ; %entry
1795 ; GFX10-WGP-NEXT: s_clause 0x1
1796 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
1797 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
1798 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
1799 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1800 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
1801 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
1802 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1803 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1804 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
1805 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1806 ; GFX10-WGP-NEXT: buffer_gl0_inv
1807 ; GFX10-WGP-NEXT: s_endpgm
1809 ; GFX10-CU-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
1810 ; GFX10-CU: ; %bb.0: ; %entry
1811 ; GFX10-CU-NEXT: s_clause 0x1
1812 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
1813 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
1814 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
1815 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1816 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
1817 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
1818 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1819 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
1820 ; GFX10-CU-NEXT: s_endpgm
1822 ; SKIP-CACHE-INV-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
1823 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1824 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
1825 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
1826 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
1827 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
1828 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1829 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
1830 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
1831 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1832 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
1833 ; SKIP-CACHE-INV-NEXT: s_endpgm
1835 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
1836 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1837 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1838 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
1839 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
1840 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1841 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
1842 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1843 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
1844 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1846 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
1847 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1848 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1849 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
1850 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
1851 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1852 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
1853 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1854 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
1855 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1856 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
1857 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1858 i32 addrspace(1)* %out, i32 %in, i32 %old) {
1860 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
1861 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") acq_rel monotonic
1865 define amdgpu_kernel void @global_workgroup_seq_cst_monotonic_cmpxchg(
1866 ; GFX6-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
1867 ; GFX6: ; %bb.0: ; %entry
1868 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1869 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
1870 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
1871 ; GFX6-NEXT: s_mov_b32 s2, -1
1872 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1873 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
1874 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
1875 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1876 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
1877 ; GFX6-NEXT: s_endpgm
1879 ; GFX7-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
1880 ; GFX7: ; %bb.0: ; %entry
1881 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1882 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
1883 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1884 ; GFX7-NEXT: s_add_u32 s0, s0, 16
1885 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
1886 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
1887 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
1888 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
1889 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
1890 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1891 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
1892 ; GFX7-NEXT: s_endpgm
1894 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
1895 ; GFX10-WGP: ; %bb.0: ; %entry
1896 ; GFX10-WGP-NEXT: s_clause 0x1
1897 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
1898 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
1899 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
1900 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1901 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
1902 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
1903 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1904 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1905 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
1906 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1907 ; GFX10-WGP-NEXT: buffer_gl0_inv
1908 ; GFX10-WGP-NEXT: s_endpgm
1910 ; GFX10-CU-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
1911 ; GFX10-CU: ; %bb.0: ; %entry
1912 ; GFX10-CU-NEXT: s_clause 0x1
1913 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
1914 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
1915 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
1916 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1917 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
1918 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
1919 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1920 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
1921 ; GFX10-CU-NEXT: s_endpgm
1923 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
1924 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1925 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
1926 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
1927 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
1928 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
1929 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1930 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
1931 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
1932 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1933 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
1934 ; SKIP-CACHE-INV-NEXT: s_endpgm
1936 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
1937 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1938 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1939 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
1940 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
1941 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1942 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
1943 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1944 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
1945 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1947 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
1948 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1949 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1950 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
1951 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
1952 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1953 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
1954 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1955 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
1956 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1957 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
1958 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1959 i32 addrspace(1)* %out, i32 %in, i32 %old) {
1961 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
1962 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") seq_cst monotonic
1966 define amdgpu_kernel void @global_workgroup_monotonic_acquire_cmpxchg(
1967 ; GFX6-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
1968 ; GFX6: ; %bb.0: ; %entry
1969 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1970 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
1971 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
1972 ; GFX6-NEXT: s_mov_b32 s2, -1
1973 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1974 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
1975 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
1976 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
1977 ; GFX6-NEXT: s_endpgm
1979 ; GFX7-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
1980 ; GFX7: ; %bb.0: ; %entry
1981 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1982 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
1983 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1984 ; GFX7-NEXT: s_add_u32 s0, s0, 16
1985 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
1986 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
1987 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
1988 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
1989 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
1990 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
1991 ; GFX7-NEXT: s_endpgm
1993 ; GFX10-WGP-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
1994 ; GFX10-WGP: ; %bb.0: ; %entry
1995 ; GFX10-WGP-NEXT: s_clause 0x1
1996 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
1997 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
1998 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
1999 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2000 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
2001 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
2002 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2003 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2004 ; GFX10-WGP-NEXT: buffer_gl0_inv
2005 ; GFX10-WGP-NEXT: s_endpgm
2007 ; GFX10-CU-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
2008 ; GFX10-CU: ; %bb.0: ; %entry
2009 ; GFX10-CU-NEXT: s_clause 0x1
2010 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
2011 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
2012 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
2013 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2014 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
2015 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
2016 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2017 ; GFX10-CU-NEXT: s_endpgm
2019 ; SKIP-CACHE-INV-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
2020 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2021 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
2022 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
2023 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
2024 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
2025 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2026 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
2027 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
2028 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2029 ; SKIP-CACHE-INV-NEXT: s_endpgm
2031 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
2032 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2033 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2034 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
2035 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2036 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2037 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2038 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2039 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2041 ; GFX90A-TGSPLIT-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
2042 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2043 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2044 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
2045 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2046 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2047 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2048 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2049 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2050 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
2051 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2052 i32 addrspace(1)* %out, i32 %in, i32 %old) {
2054 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
2055 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") monotonic acquire
2059 define amdgpu_kernel void @global_workgroup_acquire_acquire_cmpxchg(
2060 ; GFX6-LABEL: global_workgroup_acquire_acquire_cmpxchg:
2061 ; GFX6: ; %bb.0: ; %entry
2062 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2063 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
2064 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
2065 ; GFX6-NEXT: s_mov_b32 s2, -1
2066 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2067 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
2068 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
2069 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
2070 ; GFX6-NEXT: s_endpgm
2072 ; GFX7-LABEL: global_workgroup_acquire_acquire_cmpxchg:
2073 ; GFX7: ; %bb.0: ; %entry
2074 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2075 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
2076 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2077 ; GFX7-NEXT: s_add_u32 s0, s0, 16
2078 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
2079 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
2080 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
2081 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
2082 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
2083 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2084 ; GFX7-NEXT: s_endpgm
2086 ; GFX10-WGP-LABEL: global_workgroup_acquire_acquire_cmpxchg:
2087 ; GFX10-WGP: ; %bb.0: ; %entry
2088 ; GFX10-WGP-NEXT: s_clause 0x1
2089 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
2090 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
2091 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
2092 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2093 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
2094 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
2095 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2096 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2097 ; GFX10-WGP-NEXT: buffer_gl0_inv
2098 ; GFX10-WGP-NEXT: s_endpgm
2100 ; GFX10-CU-LABEL: global_workgroup_acquire_acquire_cmpxchg:
2101 ; GFX10-CU: ; %bb.0: ; %entry
2102 ; GFX10-CU-NEXT: s_clause 0x1
2103 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
2104 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
2105 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
2106 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2107 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
2108 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
2109 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2110 ; GFX10-CU-NEXT: s_endpgm
2112 ; SKIP-CACHE-INV-LABEL: global_workgroup_acquire_acquire_cmpxchg:
2113 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2114 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
2115 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
2116 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
2117 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
2118 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2119 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
2120 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
2121 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2122 ; SKIP-CACHE-INV-NEXT: s_endpgm
2124 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acquire_acquire_cmpxchg:
2125 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2126 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2127 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
2128 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2129 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2130 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2131 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2132 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2134 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acquire_acquire_cmpxchg:
2135 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2136 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2137 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
2138 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2139 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2140 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2141 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2142 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2143 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
2144 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2145 i32 addrspace(1)* %out, i32 %in, i32 %old) {
2147 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
2148 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") acquire acquire
2152 define amdgpu_kernel void @global_workgroup_release_acquire_cmpxchg(
2153 ; GFX6-LABEL: global_workgroup_release_acquire_cmpxchg:
2154 ; GFX6: ; %bb.0: ; %entry
2155 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2156 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
2157 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
2158 ; GFX6-NEXT: s_mov_b32 s2, -1
2159 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2160 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
2161 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
2162 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2163 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
2164 ; GFX6-NEXT: s_endpgm
2166 ; GFX7-LABEL: global_workgroup_release_acquire_cmpxchg:
2167 ; GFX7: ; %bb.0: ; %entry
2168 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2169 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
2170 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2171 ; GFX7-NEXT: s_add_u32 s0, s0, 16
2172 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
2173 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
2174 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
2175 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
2176 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
2177 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2178 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2179 ; GFX7-NEXT: s_endpgm
2181 ; GFX10-WGP-LABEL: global_workgroup_release_acquire_cmpxchg:
2182 ; GFX10-WGP: ; %bb.0: ; %entry
2183 ; GFX10-WGP-NEXT: s_clause 0x1
2184 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
2185 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
2186 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
2187 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2188 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
2189 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
2190 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2191 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2192 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2193 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2194 ; GFX10-WGP-NEXT: buffer_gl0_inv
2195 ; GFX10-WGP-NEXT: s_endpgm
2197 ; GFX10-CU-LABEL: global_workgroup_release_acquire_cmpxchg:
2198 ; GFX10-CU: ; %bb.0: ; %entry
2199 ; GFX10-CU-NEXT: s_clause 0x1
2200 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
2201 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
2202 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
2203 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2204 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
2205 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
2206 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2207 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2208 ; GFX10-CU-NEXT: s_endpgm
2210 ; SKIP-CACHE-INV-LABEL: global_workgroup_release_acquire_cmpxchg:
2211 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2212 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
2213 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
2214 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
2215 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
2216 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2217 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
2218 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
2219 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2220 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2221 ; SKIP-CACHE-INV-NEXT: s_endpgm
2223 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_release_acquire_cmpxchg:
2224 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2225 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2226 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
2227 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2228 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2229 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2230 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2231 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2232 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2234 ; GFX90A-TGSPLIT-LABEL: global_workgroup_release_acquire_cmpxchg:
2235 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2236 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2237 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
2238 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2239 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2240 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2241 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2242 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2243 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2244 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
2245 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2246 i32 addrspace(1)* %out, i32 %in, i32 %old) {
2248 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
2249 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") release acquire
2253 define amdgpu_kernel void @global_workgroup_acq_rel_acquire_cmpxchg(
2254 ; GFX6-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
2255 ; GFX6: ; %bb.0: ; %entry
2256 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2257 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
2258 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
2259 ; GFX6-NEXT: s_mov_b32 s2, -1
2260 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2261 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
2262 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
2263 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2264 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
2265 ; GFX6-NEXT: s_endpgm
2267 ; GFX7-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
2268 ; GFX7: ; %bb.0: ; %entry
2269 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2270 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
2271 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2272 ; GFX7-NEXT: s_add_u32 s0, s0, 16
2273 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
2274 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
2275 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
2276 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
2277 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
2278 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2279 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2280 ; GFX7-NEXT: s_endpgm
2282 ; GFX10-WGP-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
2283 ; GFX10-WGP: ; %bb.0: ; %entry
2284 ; GFX10-WGP-NEXT: s_clause 0x1
2285 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
2286 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
2287 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
2288 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2289 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
2290 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
2291 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2292 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2293 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2294 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2295 ; GFX10-WGP-NEXT: buffer_gl0_inv
2296 ; GFX10-WGP-NEXT: s_endpgm
2298 ; GFX10-CU-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
2299 ; GFX10-CU: ; %bb.0: ; %entry
2300 ; GFX10-CU-NEXT: s_clause 0x1
2301 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
2302 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
2303 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
2304 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2305 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
2306 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
2307 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2308 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2309 ; GFX10-CU-NEXT: s_endpgm
2311 ; SKIP-CACHE-INV-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
2312 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2313 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
2314 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
2315 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
2316 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
2317 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2318 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
2319 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
2320 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2321 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2322 ; SKIP-CACHE-INV-NEXT: s_endpgm
2324 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
2325 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2326 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2327 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
2328 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2329 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2330 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2331 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2332 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2333 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2335 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
2336 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2337 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2338 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
2339 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2340 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2341 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2342 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2343 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2344 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2345 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
2346 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2347 i32 addrspace(1)* %out, i32 %in, i32 %old) {
2349 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
2350 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") acq_rel acquire
2354 define amdgpu_kernel void @global_workgroup_seq_cst_acquire_cmpxchg(
2355 ; GFX6-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
2356 ; GFX6: ; %bb.0: ; %entry
2357 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2358 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
2359 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
2360 ; GFX6-NEXT: s_mov_b32 s2, -1
2361 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2362 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
2363 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
2364 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2365 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
2366 ; GFX6-NEXT: s_endpgm
2368 ; GFX7-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
2369 ; GFX7: ; %bb.0: ; %entry
2370 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2371 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
2372 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2373 ; GFX7-NEXT: s_add_u32 s0, s0, 16
2374 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
2375 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
2376 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
2377 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
2378 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
2379 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2380 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2381 ; GFX7-NEXT: s_endpgm
2383 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
2384 ; GFX10-WGP: ; %bb.0: ; %entry
2385 ; GFX10-WGP-NEXT: s_clause 0x1
2386 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
2387 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
2388 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
2389 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2390 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
2391 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
2392 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2393 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2394 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2395 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2396 ; GFX10-WGP-NEXT: buffer_gl0_inv
2397 ; GFX10-WGP-NEXT: s_endpgm
2399 ; GFX10-CU-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
2400 ; GFX10-CU: ; %bb.0: ; %entry
2401 ; GFX10-CU-NEXT: s_clause 0x1
2402 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
2403 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
2404 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
2405 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2406 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
2407 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
2408 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2409 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2410 ; GFX10-CU-NEXT: s_endpgm
2412 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
2413 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2414 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
2415 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
2416 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
2417 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
2418 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2419 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
2420 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
2421 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2422 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2423 ; SKIP-CACHE-INV-NEXT: s_endpgm
2425 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
2426 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2427 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2428 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
2429 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2430 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2431 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2432 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2433 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2434 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2436 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
2437 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2438 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2439 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
2440 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2441 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2442 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2443 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2444 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2445 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2446 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
2447 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2448 i32 addrspace(1)* %out, i32 %in, i32 %old) {
2450 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
2451 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") seq_cst acquire
2455 define amdgpu_kernel void @global_workgroup_monotonic_seq_cst_cmpxchg(
2456 ; GFX6-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
2457 ; GFX6: ; %bb.0: ; %entry
2458 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2459 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
2460 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
2461 ; GFX6-NEXT: s_mov_b32 s2, -1
2462 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2463 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
2464 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
2465 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2466 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
2467 ; GFX6-NEXT: s_endpgm
2469 ; GFX7-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
2470 ; GFX7: ; %bb.0: ; %entry
2471 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2472 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
2473 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2474 ; GFX7-NEXT: s_add_u32 s0, s0, 16
2475 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
2476 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
2477 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
2478 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
2479 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
2480 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2481 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2482 ; GFX7-NEXT: s_endpgm
2484 ; GFX10-WGP-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
2485 ; GFX10-WGP: ; %bb.0: ; %entry
2486 ; GFX10-WGP-NEXT: s_clause 0x1
2487 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
2488 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
2489 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
2490 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2491 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
2492 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
2493 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2494 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2495 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2496 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2497 ; GFX10-WGP-NEXT: buffer_gl0_inv
2498 ; GFX10-WGP-NEXT: s_endpgm
2500 ; GFX10-CU-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
2501 ; GFX10-CU: ; %bb.0: ; %entry
2502 ; GFX10-CU-NEXT: s_clause 0x1
2503 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
2504 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
2505 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
2506 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2507 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
2508 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
2509 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2510 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2511 ; GFX10-CU-NEXT: s_endpgm
2513 ; SKIP-CACHE-INV-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
2514 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2515 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
2516 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
2517 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
2518 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
2519 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2520 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
2521 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
2522 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2523 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2524 ; SKIP-CACHE-INV-NEXT: s_endpgm
2526 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
2527 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2528 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2529 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
2530 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2531 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2532 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2533 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2534 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2535 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2537 ; GFX90A-TGSPLIT-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
2538 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2539 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2540 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
2541 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2542 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2543 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2544 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2545 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2546 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2547 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
2548 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2549 i32 addrspace(1)* %out, i32 %in, i32 %old) {
2551 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
2552 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") monotonic seq_cst
2556 define amdgpu_kernel void @global_workgroup_acquire_seq_cst_cmpxchg(
2557 ; GFX6-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
2558 ; GFX6: ; %bb.0: ; %entry
2559 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2560 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
2561 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
2562 ; GFX6-NEXT: s_mov_b32 s2, -1
2563 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2564 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
2565 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
2566 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2567 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
2568 ; GFX6-NEXT: s_endpgm
2570 ; GFX7-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
2571 ; GFX7: ; %bb.0: ; %entry
2572 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2573 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
2574 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2575 ; GFX7-NEXT: s_add_u32 s0, s0, 16
2576 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
2577 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
2578 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
2579 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
2580 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
2581 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2582 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2583 ; GFX7-NEXT: s_endpgm
2585 ; GFX10-WGP-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
2586 ; GFX10-WGP: ; %bb.0: ; %entry
2587 ; GFX10-WGP-NEXT: s_clause 0x1
2588 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
2589 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
2590 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
2591 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2592 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
2593 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
2594 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2595 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2596 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2597 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2598 ; GFX10-WGP-NEXT: buffer_gl0_inv
2599 ; GFX10-WGP-NEXT: s_endpgm
2601 ; GFX10-CU-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
2602 ; GFX10-CU: ; %bb.0: ; %entry
2603 ; GFX10-CU-NEXT: s_clause 0x1
2604 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
2605 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
2606 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
2607 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2608 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
2609 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
2610 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2611 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2612 ; GFX10-CU-NEXT: s_endpgm
2614 ; SKIP-CACHE-INV-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
2615 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2616 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
2617 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
2618 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
2619 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
2620 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2621 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
2622 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
2623 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2624 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2625 ; SKIP-CACHE-INV-NEXT: s_endpgm
2627 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
2628 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2629 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2630 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
2631 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2632 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2633 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2634 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2635 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2636 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2638 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
2639 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2640 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2641 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
2642 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2643 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2644 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2645 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2646 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2647 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2648 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
2649 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2650 i32 addrspace(1)* %out, i32 %in, i32 %old) {
2652 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
2653 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") acquire seq_cst
2657 define amdgpu_kernel void @global_workgroup_release_seq_cst_cmpxchg(
2658 ; GFX6-LABEL: global_workgroup_release_seq_cst_cmpxchg:
2659 ; GFX6: ; %bb.0: ; %entry
2660 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2661 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
2662 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
2663 ; GFX6-NEXT: s_mov_b32 s2, -1
2664 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2665 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
2666 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
2667 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2668 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
2669 ; GFX6-NEXT: s_endpgm
2671 ; GFX7-LABEL: global_workgroup_release_seq_cst_cmpxchg:
2672 ; GFX7: ; %bb.0: ; %entry
2673 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2674 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
2675 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2676 ; GFX7-NEXT: s_add_u32 s0, s0, 16
2677 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
2678 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
2679 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
2680 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
2681 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
2682 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2683 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2684 ; GFX7-NEXT: s_endpgm
2686 ; GFX10-WGP-LABEL: global_workgroup_release_seq_cst_cmpxchg:
2687 ; GFX10-WGP: ; %bb.0: ; %entry
2688 ; GFX10-WGP-NEXT: s_clause 0x1
2689 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
2690 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
2691 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
2692 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2693 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
2694 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
2695 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2696 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2697 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2698 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2699 ; GFX10-WGP-NEXT: buffer_gl0_inv
2700 ; GFX10-WGP-NEXT: s_endpgm
2702 ; GFX10-CU-LABEL: global_workgroup_release_seq_cst_cmpxchg:
2703 ; GFX10-CU: ; %bb.0: ; %entry
2704 ; GFX10-CU-NEXT: s_clause 0x1
2705 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
2706 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
2707 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
2708 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2709 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
2710 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
2711 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2712 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2713 ; GFX10-CU-NEXT: s_endpgm
2715 ; SKIP-CACHE-INV-LABEL: global_workgroup_release_seq_cst_cmpxchg:
2716 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2717 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
2718 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
2719 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
2720 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
2721 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2722 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
2723 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
2724 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2725 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2726 ; SKIP-CACHE-INV-NEXT: s_endpgm
2728 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_release_seq_cst_cmpxchg:
2729 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2730 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2731 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
2732 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2733 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2734 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2735 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2736 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2737 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2739 ; GFX90A-TGSPLIT-LABEL: global_workgroup_release_seq_cst_cmpxchg:
2740 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2741 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2742 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
2743 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2744 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2745 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2746 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2747 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2748 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2749 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
2750 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2751 i32 addrspace(1)* %out, i32 %in, i32 %old) {
2753 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
2754 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") release seq_cst
2758 define amdgpu_kernel void @global_workgroup_acq_rel_seq_cst_cmpxchg(
2759 ; GFX6-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
2760 ; GFX6: ; %bb.0: ; %entry
2761 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2762 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
2763 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
2764 ; GFX6-NEXT: s_mov_b32 s2, -1
2765 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2766 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
2767 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
2768 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2769 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
2770 ; GFX6-NEXT: s_endpgm
2772 ; GFX7-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
2773 ; GFX7: ; %bb.0: ; %entry
2774 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2775 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
2776 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2777 ; GFX7-NEXT: s_add_u32 s0, s0, 16
2778 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
2779 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
2780 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
2781 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
2782 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
2783 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2784 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2785 ; GFX7-NEXT: s_endpgm
2787 ; GFX10-WGP-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
2788 ; GFX10-WGP: ; %bb.0: ; %entry
2789 ; GFX10-WGP-NEXT: s_clause 0x1
2790 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
2791 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
2792 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
2793 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2794 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
2795 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
2796 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2797 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2798 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2799 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2800 ; GFX10-WGP-NEXT: buffer_gl0_inv
2801 ; GFX10-WGP-NEXT: s_endpgm
2803 ; GFX10-CU-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
2804 ; GFX10-CU: ; %bb.0: ; %entry
2805 ; GFX10-CU-NEXT: s_clause 0x1
2806 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
2807 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
2808 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
2809 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2810 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
2811 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
2812 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2813 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2814 ; GFX10-CU-NEXT: s_endpgm
2816 ; SKIP-CACHE-INV-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
2817 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2818 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
2819 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
2820 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
2821 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
2822 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2823 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
2824 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
2825 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2826 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2827 ; SKIP-CACHE-INV-NEXT: s_endpgm
2829 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
2830 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2831 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2832 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
2833 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2834 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2835 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2836 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2837 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2838 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2840 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
2841 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2842 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2843 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
2844 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2845 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2846 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2847 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2848 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2849 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2850 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
2851 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2852 i32 addrspace(1)* %out, i32 %in, i32 %old) {
2854 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
2855 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") acq_rel seq_cst
2859 define amdgpu_kernel void @global_workgroup_seq_cst_seq_cst_cmpxchg(
2860 ; GFX6-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
2861 ; GFX6: ; %bb.0: ; %entry
2862 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2863 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
2864 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
2865 ; GFX6-NEXT: s_mov_b32 s2, -1
2866 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2867 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
2868 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
2869 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2870 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
2871 ; GFX6-NEXT: s_endpgm
2873 ; GFX7-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
2874 ; GFX7: ; %bb.0: ; %entry
2875 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2876 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
2877 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2878 ; GFX7-NEXT: s_add_u32 s0, s0, 16
2879 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
2880 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
2881 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
2882 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
2883 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
2884 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2885 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2886 ; GFX7-NEXT: s_endpgm
2888 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
2889 ; GFX10-WGP: ; %bb.0: ; %entry
2890 ; GFX10-WGP-NEXT: s_clause 0x1
2891 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
2892 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
2893 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
2894 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2895 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
2896 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
2897 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2898 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2899 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2900 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2901 ; GFX10-WGP-NEXT: buffer_gl0_inv
2902 ; GFX10-WGP-NEXT: s_endpgm
2904 ; GFX10-CU-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
2905 ; GFX10-CU: ; %bb.0: ; %entry
2906 ; GFX10-CU-NEXT: s_clause 0x1
2907 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
2908 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
2909 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
2910 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2911 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
2912 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
2913 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2914 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2915 ; GFX10-CU-NEXT: s_endpgm
2917 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
2918 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2919 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
2920 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
2921 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
2922 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
2923 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2924 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
2925 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
2926 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2927 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2928 ; SKIP-CACHE-INV-NEXT: s_endpgm
2930 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
2931 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2932 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2933 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
2934 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2935 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2936 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2937 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2938 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2939 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2941 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
2942 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2943 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2944 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
2945 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
2946 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2947 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2948 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2949 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2950 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2951 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
2952 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2953 i32 addrspace(1)* %out, i32 %in, i32 %old) {
2955 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
2956 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") seq_cst seq_cst
2960 define amdgpu_kernel void @global_workgroup_monotonic_monotonic_ret_cmpxchg(
2961 ; GFX6-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
2962 ; GFX6: ; %bb.0: ; %entry
2963 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2964 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
2965 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
2966 ; GFX6-NEXT: s_mov_b32 s2, -1
2967 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2968 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
2969 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
2970 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
2971 ; GFX6-NEXT: s_waitcnt vmcnt(0)
2972 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
2973 ; GFX6-NEXT: s_endpgm
2975 ; GFX7-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
2976 ; GFX7: ; %bb.0: ; %entry
2977 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2978 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
2979 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2980 ; GFX7-NEXT: s_add_u32 s4, s0, 16
2981 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
2982 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
2983 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
2984 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
2985 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
2986 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
2987 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
2988 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
2989 ; GFX7-NEXT: s_waitcnt vmcnt(0)
2990 ; GFX7-NEXT: flat_store_dword v[0:1], v2
2991 ; GFX7-NEXT: s_endpgm
2993 ; GFX10-WGP-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
2994 ; GFX10-WGP: ; %bb.0: ; %entry
2995 ; GFX10-WGP-NEXT: s_clause 0x1
2996 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
2997 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
2998 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
2999 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3000 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
3001 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
3002 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3003 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
3004 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
3005 ; GFX10-WGP-NEXT: s_endpgm
3007 ; GFX10-CU-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
3008 ; GFX10-CU: ; %bb.0: ; %entry
3009 ; GFX10-CU-NEXT: s_clause 0x1
3010 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
3011 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
3012 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
3013 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3014 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
3015 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
3016 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3017 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
3018 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
3019 ; GFX10-CU-NEXT: s_endpgm
3021 ; SKIP-CACHE-INV-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
3022 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3023 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
3024 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
3025 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
3026 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
3027 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3028 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
3029 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
3030 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
3031 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
3032 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
3033 ; SKIP-CACHE-INV-NEXT: s_endpgm
3035 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
3036 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3037 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3038 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
3039 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3040 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3041 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3042 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3043 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
3044 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
3045 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3047 ; GFX90A-TGSPLIT-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
3048 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3049 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3050 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
3051 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3052 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3053 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3054 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3055 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3056 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
3057 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3058 i32 addrspace(1)* %out, i32 %in, i32 %old) {
3060 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
3061 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") monotonic monotonic
3062 %val0 = extractvalue { i32, i1 } %val, 0
3063 store i32 %val0, i32 addrspace(1)* %out, align 4
3067 define amdgpu_kernel void @global_workgroup_acquire_monotonic_ret_cmpxchg(
3068 ; GFX6-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
3069 ; GFX6: ; %bb.0: ; %entry
3070 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3071 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
3072 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
3073 ; GFX6-NEXT: s_mov_b32 s2, -1
3074 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3075 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
3076 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
3077 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
3078 ; GFX6-NEXT: s_waitcnt vmcnt(0)
3079 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
3080 ; GFX6-NEXT: s_endpgm
3082 ; GFX7-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
3083 ; GFX7: ; %bb.0: ; %entry
3084 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3085 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
3086 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3087 ; GFX7-NEXT: s_add_u32 s4, s0, 16
3088 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
3089 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
3090 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
3091 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
3092 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
3093 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
3094 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
3095 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
3096 ; GFX7-NEXT: s_waitcnt vmcnt(0)
3097 ; GFX7-NEXT: flat_store_dword v[0:1], v2
3098 ; GFX7-NEXT: s_endpgm
3100 ; GFX10-WGP-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
3101 ; GFX10-WGP: ; %bb.0: ; %entry
3102 ; GFX10-WGP-NEXT: s_clause 0x1
3103 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
3104 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
3105 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
3106 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3107 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
3108 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
3109 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3110 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
3111 ; GFX10-WGP-NEXT: buffer_gl0_inv
3112 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
3113 ; GFX10-WGP-NEXT: s_endpgm
3115 ; GFX10-CU-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
3116 ; GFX10-CU: ; %bb.0: ; %entry
3117 ; GFX10-CU-NEXT: s_clause 0x1
3118 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
3119 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
3120 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
3121 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3122 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
3123 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
3124 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3125 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
3126 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
3127 ; GFX10-CU-NEXT: s_endpgm
3129 ; SKIP-CACHE-INV-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
3130 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3131 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
3132 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
3133 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
3134 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
3135 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3136 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
3137 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
3138 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
3139 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
3140 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
3141 ; SKIP-CACHE-INV-NEXT: s_endpgm
3143 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
3144 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3145 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3146 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
3147 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3148 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3149 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3150 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3151 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
3152 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
3153 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3155 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
3156 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3157 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3158 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
3159 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3160 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3161 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3162 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3163 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3164 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
3165 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
3166 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3167 i32 addrspace(1)* %out, i32 %in, i32 %old) {
3169 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
3170 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") acquire monotonic
3171 %val0 = extractvalue { i32, i1 } %val, 0
3172 store i32 %val0, i32 addrspace(1)* %out, align 4
3176 define amdgpu_kernel void @global_workgroup_release_monotonic_ret_cmpxchg(
3177 ; GFX6-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
3178 ; GFX6: ; %bb.0: ; %entry
3179 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3180 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
3181 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
3182 ; GFX6-NEXT: s_mov_b32 s2, -1
3183 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3184 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
3185 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
3186 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3187 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
3188 ; GFX6-NEXT: s_waitcnt vmcnt(0)
3189 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
3190 ; GFX6-NEXT: s_endpgm
3192 ; GFX7-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
3193 ; GFX7: ; %bb.0: ; %entry
3194 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3195 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
3196 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3197 ; GFX7-NEXT: s_add_u32 s4, s0, 16
3198 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
3199 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
3200 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
3201 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
3202 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
3203 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3204 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
3205 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
3206 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
3207 ; GFX7-NEXT: s_waitcnt vmcnt(0)
3208 ; GFX7-NEXT: flat_store_dword v[0:1], v2
3209 ; GFX7-NEXT: s_endpgm
3211 ; GFX10-WGP-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
3212 ; GFX10-WGP: ; %bb.0: ; %entry
3213 ; GFX10-WGP-NEXT: s_clause 0x1
3214 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
3215 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
3216 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
3217 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3218 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
3219 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
3220 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3221 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3222 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3223 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
3224 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
3225 ; GFX10-WGP-NEXT: s_endpgm
3227 ; GFX10-CU-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
3228 ; GFX10-CU: ; %bb.0: ; %entry
3229 ; GFX10-CU-NEXT: s_clause 0x1
3230 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
3231 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
3232 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
3233 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3234 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
3235 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
3236 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3237 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3238 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
3239 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
3240 ; GFX10-CU-NEXT: s_endpgm
3242 ; SKIP-CACHE-INV-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
3243 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3244 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
3245 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
3246 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
3247 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
3248 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3249 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
3250 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
3251 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3252 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
3253 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
3254 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
3255 ; SKIP-CACHE-INV-NEXT: s_endpgm
3257 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
3258 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3259 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3260 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
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 v0, v2, v[0:1], s[0:1] offset:16 glc
3266 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
3267 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
3268 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3270 ; GFX90A-TGSPLIT-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
3271 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3272 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3273 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
3274 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3275 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3276 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3277 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3278 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3279 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3280 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
3281 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3282 i32 addrspace(1)* %out, i32 %in, i32 %old) {
3284 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
3285 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") release monotonic
3286 %val0 = extractvalue { i32, i1 } %val, 0
3287 store i32 %val0, i32 addrspace(1)* %out, align 4
3291 define amdgpu_kernel void @global_workgroup_acq_rel_monotonic_ret_cmpxchg(
3292 ; GFX6-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
3293 ; GFX6: ; %bb.0: ; %entry
3294 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3295 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
3296 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
3297 ; GFX6-NEXT: s_mov_b32 s2, -1
3298 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3299 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
3300 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
3301 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3302 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
3303 ; GFX6-NEXT: s_waitcnt vmcnt(0)
3304 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
3305 ; GFX6-NEXT: s_endpgm
3307 ; GFX7-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
3308 ; GFX7: ; %bb.0: ; %entry
3309 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3310 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
3311 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3312 ; GFX7-NEXT: s_add_u32 s4, s0, 16
3313 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
3314 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
3315 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
3316 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
3317 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
3318 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3319 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
3320 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
3321 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
3322 ; GFX7-NEXT: s_waitcnt vmcnt(0)
3323 ; GFX7-NEXT: flat_store_dword v[0:1], v2
3324 ; GFX7-NEXT: s_endpgm
3326 ; GFX10-WGP-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
3327 ; GFX10-WGP: ; %bb.0: ; %entry
3328 ; GFX10-WGP-NEXT: s_clause 0x1
3329 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
3330 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
3331 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
3332 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3333 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
3334 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
3335 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3336 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3337 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3338 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
3339 ; GFX10-WGP-NEXT: buffer_gl0_inv
3340 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
3341 ; GFX10-WGP-NEXT: s_endpgm
3343 ; GFX10-CU-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
3344 ; GFX10-CU: ; %bb.0: ; %entry
3345 ; GFX10-CU-NEXT: s_clause 0x1
3346 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
3347 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
3348 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
3349 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3350 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
3351 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
3352 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3353 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3354 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
3355 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
3356 ; GFX10-CU-NEXT: s_endpgm
3358 ; SKIP-CACHE-INV-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
3359 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3360 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
3361 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
3362 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
3363 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
3364 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3365 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
3366 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
3367 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3368 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
3369 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
3370 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
3371 ; SKIP-CACHE-INV-NEXT: s_endpgm
3373 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
3374 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3375 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3376 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
3377 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3378 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3379 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3380 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3381 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3382 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
3383 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
3384 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3386 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
3387 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3388 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3389 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
3390 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3391 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3392 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3393 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3394 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3395 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3396 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
3397 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
3398 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3399 i32 addrspace(1)* %out, i32 %in, i32 %old) {
3401 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
3402 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") acq_rel monotonic
3403 %val0 = extractvalue { i32, i1 } %val, 0
3404 store i32 %val0, i32 addrspace(1)* %out, align 4
3408 define amdgpu_kernel void @global_workgroup_seq_cst_monotonic_ret_cmpxchg(
3409 ; GFX6-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
3410 ; GFX6: ; %bb.0: ; %entry
3411 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3412 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
3413 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
3414 ; GFX6-NEXT: s_mov_b32 s2, -1
3415 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3416 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
3417 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
3418 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3419 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
3420 ; GFX6-NEXT: s_waitcnt vmcnt(0)
3421 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
3422 ; GFX6-NEXT: s_endpgm
3424 ; GFX7-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
3425 ; GFX7: ; %bb.0: ; %entry
3426 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3427 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
3428 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3429 ; GFX7-NEXT: s_add_u32 s4, s0, 16
3430 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
3431 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
3432 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
3433 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
3434 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
3435 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3436 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
3437 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
3438 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
3439 ; GFX7-NEXT: s_waitcnt vmcnt(0)
3440 ; GFX7-NEXT: flat_store_dword v[0:1], v2
3441 ; GFX7-NEXT: s_endpgm
3443 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
3444 ; GFX10-WGP: ; %bb.0: ; %entry
3445 ; GFX10-WGP-NEXT: s_clause 0x1
3446 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
3447 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
3448 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
3449 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3450 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
3451 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
3452 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3453 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3454 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3455 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
3456 ; GFX10-WGP-NEXT: buffer_gl0_inv
3457 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
3458 ; GFX10-WGP-NEXT: s_endpgm
3460 ; GFX10-CU-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
3461 ; GFX10-CU: ; %bb.0: ; %entry
3462 ; GFX10-CU-NEXT: s_clause 0x1
3463 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
3464 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
3465 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
3466 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3467 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
3468 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
3469 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3470 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3471 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
3472 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
3473 ; GFX10-CU-NEXT: s_endpgm
3475 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
3476 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3477 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
3478 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
3479 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
3480 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
3481 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3482 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
3483 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
3484 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3485 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
3486 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
3487 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
3488 ; SKIP-CACHE-INV-NEXT: s_endpgm
3490 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
3491 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3492 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3493 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
3494 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3495 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3496 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3497 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3498 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3499 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
3500 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
3501 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3503 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
3504 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3505 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3506 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
3507 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3508 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3509 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3510 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3511 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3512 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3513 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
3514 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
3515 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3516 i32 addrspace(1)* %out, i32 %in, i32 %old) {
3518 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
3519 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") seq_cst monotonic
3520 %val0 = extractvalue { i32, i1 } %val, 0
3521 store i32 %val0, i32 addrspace(1)* %out, align 4
3525 define amdgpu_kernel void @global_workgroup_monotonic_acquire_ret_cmpxchg(
3526 ; GFX6-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
3527 ; GFX6: ; %bb.0: ; %entry
3528 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3529 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
3530 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
3531 ; GFX6-NEXT: s_mov_b32 s2, -1
3532 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3533 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
3534 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
3535 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
3536 ; GFX6-NEXT: s_waitcnt vmcnt(0)
3537 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
3538 ; GFX6-NEXT: s_endpgm
3540 ; GFX7-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
3541 ; GFX7: ; %bb.0: ; %entry
3542 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3543 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
3544 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3545 ; GFX7-NEXT: s_add_u32 s4, s0, 16
3546 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
3547 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
3548 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
3549 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
3550 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
3551 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
3552 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
3553 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
3554 ; GFX7-NEXT: s_waitcnt vmcnt(0)
3555 ; GFX7-NEXT: flat_store_dword v[0:1], v2
3556 ; GFX7-NEXT: s_endpgm
3558 ; GFX10-WGP-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
3559 ; GFX10-WGP: ; %bb.0: ; %entry
3560 ; GFX10-WGP-NEXT: s_clause 0x1
3561 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
3562 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
3563 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
3564 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3565 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
3566 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
3567 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3568 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
3569 ; GFX10-WGP-NEXT: buffer_gl0_inv
3570 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
3571 ; GFX10-WGP-NEXT: s_endpgm
3573 ; GFX10-CU-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
3574 ; GFX10-CU: ; %bb.0: ; %entry
3575 ; GFX10-CU-NEXT: s_clause 0x1
3576 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
3577 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
3578 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
3579 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3580 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
3581 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
3582 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3583 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
3584 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
3585 ; GFX10-CU-NEXT: s_endpgm
3587 ; SKIP-CACHE-INV-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
3588 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3589 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
3590 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
3591 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
3592 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
3593 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3594 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
3595 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
3596 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
3597 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
3598 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
3599 ; SKIP-CACHE-INV-NEXT: s_endpgm
3601 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
3602 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3603 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3604 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
3605 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3606 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3607 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3608 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3609 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
3610 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
3611 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3613 ; GFX90A-TGSPLIT-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
3614 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3615 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3616 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
3617 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3618 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3619 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3620 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3621 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3622 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
3623 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
3624 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3625 i32 addrspace(1)* %out, i32 %in, i32 %old) {
3627 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
3628 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") monotonic acquire
3629 %val0 = extractvalue { i32, i1 } %val, 0
3630 store i32 %val0, i32 addrspace(1)* %out, align 4
3634 define amdgpu_kernel void @global_workgroup_acquire_acquire_ret_cmpxchg(
3635 ; GFX6-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
3636 ; GFX6: ; %bb.0: ; %entry
3637 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3638 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
3639 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
3640 ; GFX6-NEXT: s_mov_b32 s2, -1
3641 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3642 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
3643 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
3644 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
3645 ; GFX6-NEXT: s_waitcnt vmcnt(0)
3646 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
3647 ; GFX6-NEXT: s_endpgm
3649 ; GFX7-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
3650 ; GFX7: ; %bb.0: ; %entry
3651 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3652 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
3653 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3654 ; GFX7-NEXT: s_add_u32 s4, s0, 16
3655 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
3656 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
3657 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
3658 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
3659 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
3660 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
3661 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
3662 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
3663 ; GFX7-NEXT: s_waitcnt vmcnt(0)
3664 ; GFX7-NEXT: flat_store_dword v[0:1], v2
3665 ; GFX7-NEXT: s_endpgm
3667 ; GFX10-WGP-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
3668 ; GFX10-WGP: ; %bb.0: ; %entry
3669 ; GFX10-WGP-NEXT: s_clause 0x1
3670 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
3671 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
3672 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
3673 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3674 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
3675 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
3676 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3677 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
3678 ; GFX10-WGP-NEXT: buffer_gl0_inv
3679 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
3680 ; GFX10-WGP-NEXT: s_endpgm
3682 ; GFX10-CU-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
3683 ; GFX10-CU: ; %bb.0: ; %entry
3684 ; GFX10-CU-NEXT: s_clause 0x1
3685 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
3686 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
3687 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
3688 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3689 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
3690 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
3691 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3692 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
3693 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
3694 ; GFX10-CU-NEXT: s_endpgm
3696 ; SKIP-CACHE-INV-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
3697 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3698 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
3699 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
3700 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
3701 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
3702 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3703 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
3704 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
3705 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
3706 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
3707 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
3708 ; SKIP-CACHE-INV-NEXT: s_endpgm
3710 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
3711 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3712 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3713 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
3714 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3715 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3716 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3717 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3718 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
3719 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
3720 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3722 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
3723 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3724 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3725 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
3726 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3727 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3728 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3729 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3730 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3731 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
3732 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
3733 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3734 i32 addrspace(1)* %out, i32 %in, i32 %old) {
3736 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
3737 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") acquire acquire
3738 %val0 = extractvalue { i32, i1 } %val, 0
3739 store i32 %val0, i32 addrspace(1)* %out, align 4
3743 define amdgpu_kernel void @global_workgroup_release_acquire_ret_cmpxchg(
3744 ; GFX6-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
3745 ; GFX6: ; %bb.0: ; %entry
3746 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3747 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
3748 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
3749 ; GFX6-NEXT: s_mov_b32 s2, -1
3750 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3751 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
3752 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
3753 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3754 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
3755 ; GFX6-NEXT: s_waitcnt vmcnt(0)
3756 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
3757 ; GFX6-NEXT: s_endpgm
3759 ; GFX7-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
3760 ; GFX7: ; %bb.0: ; %entry
3761 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3762 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
3763 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3764 ; GFX7-NEXT: s_add_u32 s4, s0, 16
3765 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
3766 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
3767 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
3768 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
3769 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
3770 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3771 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
3772 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
3773 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
3774 ; GFX7-NEXT: s_waitcnt vmcnt(0)
3775 ; GFX7-NEXT: flat_store_dword v[0:1], v2
3776 ; GFX7-NEXT: s_endpgm
3778 ; GFX10-WGP-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
3779 ; GFX10-WGP: ; %bb.0: ; %entry
3780 ; GFX10-WGP-NEXT: s_clause 0x1
3781 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
3782 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
3783 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
3784 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3785 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
3786 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
3787 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3788 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3789 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3790 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
3791 ; GFX10-WGP-NEXT: buffer_gl0_inv
3792 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
3793 ; GFX10-WGP-NEXT: s_endpgm
3795 ; GFX10-CU-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
3796 ; GFX10-CU: ; %bb.0: ; %entry
3797 ; GFX10-CU-NEXT: s_clause 0x1
3798 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
3799 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
3800 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
3801 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3802 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
3803 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
3804 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3805 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3806 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
3807 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
3808 ; GFX10-CU-NEXT: s_endpgm
3810 ; SKIP-CACHE-INV-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
3811 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3812 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
3813 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
3814 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
3815 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
3816 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3817 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
3818 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
3819 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3820 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
3821 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
3822 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
3823 ; SKIP-CACHE-INV-NEXT: s_endpgm
3825 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
3826 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3827 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3828 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
3829 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3830 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3831 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3832 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3833 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3834 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
3835 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
3836 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3838 ; GFX90A-TGSPLIT-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
3839 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3840 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3841 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
3842 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3843 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3844 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3845 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3846 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3847 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3848 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
3849 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
3850 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3851 i32 addrspace(1)* %out, i32 %in, i32 %old) {
3853 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
3854 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") release acquire
3855 %val0 = extractvalue { i32, i1 } %val, 0
3856 store i32 %val0, i32 addrspace(1)* %out, align 4
3860 define amdgpu_kernel void @global_workgroup_acq_rel_acquire_ret_cmpxchg(
3861 ; GFX6-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
3862 ; GFX6: ; %bb.0: ; %entry
3863 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3864 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
3865 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
3866 ; GFX6-NEXT: s_mov_b32 s2, -1
3867 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3868 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
3869 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
3870 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3871 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
3872 ; GFX6-NEXT: s_waitcnt vmcnt(0)
3873 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
3874 ; GFX6-NEXT: s_endpgm
3876 ; GFX7-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
3877 ; GFX7: ; %bb.0: ; %entry
3878 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3879 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
3880 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3881 ; GFX7-NEXT: s_add_u32 s4, s0, 16
3882 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
3883 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
3884 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
3885 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
3886 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
3887 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3888 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
3889 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
3890 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
3891 ; GFX7-NEXT: s_waitcnt vmcnt(0)
3892 ; GFX7-NEXT: flat_store_dword v[0:1], v2
3893 ; GFX7-NEXT: s_endpgm
3895 ; GFX10-WGP-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
3896 ; GFX10-WGP: ; %bb.0: ; %entry
3897 ; GFX10-WGP-NEXT: s_clause 0x1
3898 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
3899 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
3900 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
3901 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3902 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
3903 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
3904 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3905 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3906 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3907 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
3908 ; GFX10-WGP-NEXT: buffer_gl0_inv
3909 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
3910 ; GFX10-WGP-NEXT: s_endpgm
3912 ; GFX10-CU-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
3913 ; GFX10-CU: ; %bb.0: ; %entry
3914 ; GFX10-CU-NEXT: s_clause 0x1
3915 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
3916 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
3917 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
3918 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3919 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
3920 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
3921 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3922 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3923 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
3924 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
3925 ; GFX10-CU-NEXT: s_endpgm
3927 ; SKIP-CACHE-INV-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
3928 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3929 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
3930 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
3931 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
3932 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
3933 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3934 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
3935 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
3936 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3937 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
3938 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
3939 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
3940 ; SKIP-CACHE-INV-NEXT: s_endpgm
3942 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
3943 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3944 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3945 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
3946 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3947 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3948 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3949 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3950 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3951 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
3952 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
3953 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3955 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
3956 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3957 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3958 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
3959 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
3960 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3961 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3962 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3963 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3964 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3965 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
3966 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
3967 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3968 i32 addrspace(1)* %out, i32 %in, i32 %old) {
3970 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
3971 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") acq_rel acquire
3972 %val0 = extractvalue { i32, i1 } %val, 0
3973 store i32 %val0, i32 addrspace(1)* %out, align 4
3977 define amdgpu_kernel void @global_workgroup_seq_cst_acquire_ret_cmpxchg(
3978 ; GFX6-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
3979 ; GFX6: ; %bb.0: ; %entry
3980 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3981 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
3982 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
3983 ; GFX6-NEXT: s_mov_b32 s2, -1
3984 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3985 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
3986 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
3987 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3988 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
3989 ; GFX6-NEXT: s_waitcnt vmcnt(0)
3990 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
3991 ; GFX6-NEXT: s_endpgm
3993 ; GFX7-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
3994 ; GFX7: ; %bb.0: ; %entry
3995 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3996 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
3997 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3998 ; GFX7-NEXT: s_add_u32 s4, s0, 16
3999 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
4000 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
4001 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
4002 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
4003 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
4004 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4005 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4006 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
4007 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
4008 ; GFX7-NEXT: s_waitcnt vmcnt(0)
4009 ; GFX7-NEXT: flat_store_dword v[0:1], v2
4010 ; GFX7-NEXT: s_endpgm
4012 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
4013 ; GFX10-WGP: ; %bb.0: ; %entry
4014 ; GFX10-WGP-NEXT: s_clause 0x1
4015 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
4016 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
4017 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
4018 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4019 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
4020 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
4021 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4022 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4023 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
4024 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
4025 ; GFX10-WGP-NEXT: buffer_gl0_inv
4026 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
4027 ; GFX10-WGP-NEXT: s_endpgm
4029 ; GFX10-CU-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
4030 ; GFX10-CU: ; %bb.0: ; %entry
4031 ; GFX10-CU-NEXT: s_clause 0x1
4032 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
4033 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
4034 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
4035 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4036 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
4037 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
4038 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4039 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
4040 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
4041 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
4042 ; GFX10-CU-NEXT: s_endpgm
4044 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
4045 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4046 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
4047 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
4048 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
4049 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
4050 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4051 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
4052 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
4053 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4054 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
4055 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
4056 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
4057 ; SKIP-CACHE-INV-NEXT: s_endpgm
4059 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
4060 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4061 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4062 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
4063 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4064 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4065 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4066 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4067 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4068 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
4069 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
4070 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4072 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
4073 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4074 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4075 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
4076 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4077 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4078 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4079 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4080 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4081 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4082 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
4083 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
4084 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4085 i32 addrspace(1)* %out, i32 %in, i32 %old) {
4087 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
4088 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") seq_cst acquire
4089 %val0 = extractvalue { i32, i1 } %val, 0
4090 store i32 %val0, i32 addrspace(1)* %out, align 4
4094 define amdgpu_kernel void @global_workgroup_monotonic_seq_cst_ret_cmpxchg(
4095 ; GFX6-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
4096 ; GFX6: ; %bb.0: ; %entry
4097 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4098 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
4099 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
4100 ; GFX6-NEXT: s_mov_b32 s2, -1
4101 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4102 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
4103 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
4104 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4105 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
4106 ; GFX6-NEXT: s_waitcnt vmcnt(0)
4107 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
4108 ; GFX6-NEXT: s_endpgm
4110 ; GFX7-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
4111 ; GFX7: ; %bb.0: ; %entry
4112 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4113 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
4114 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4115 ; GFX7-NEXT: s_add_u32 s4, s0, 16
4116 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
4117 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
4118 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
4119 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
4120 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
4121 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4122 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4123 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
4124 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
4125 ; GFX7-NEXT: s_waitcnt vmcnt(0)
4126 ; GFX7-NEXT: flat_store_dword v[0:1], v2
4127 ; GFX7-NEXT: s_endpgm
4129 ; GFX10-WGP-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
4130 ; GFX10-WGP: ; %bb.0: ; %entry
4131 ; GFX10-WGP-NEXT: s_clause 0x1
4132 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
4133 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
4134 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
4135 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4136 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
4137 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
4138 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4139 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4140 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
4141 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
4142 ; GFX10-WGP-NEXT: buffer_gl0_inv
4143 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
4144 ; GFX10-WGP-NEXT: s_endpgm
4146 ; GFX10-CU-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
4147 ; GFX10-CU: ; %bb.0: ; %entry
4148 ; GFX10-CU-NEXT: s_clause 0x1
4149 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
4150 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
4151 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
4152 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4153 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
4154 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
4155 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4156 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
4157 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
4158 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
4159 ; GFX10-CU-NEXT: s_endpgm
4161 ; SKIP-CACHE-INV-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
4162 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4163 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
4164 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
4165 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
4166 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
4167 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4168 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
4169 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
4170 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4171 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
4172 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
4173 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
4174 ; SKIP-CACHE-INV-NEXT: s_endpgm
4176 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
4177 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4178 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4179 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
4180 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4181 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4182 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4183 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4184 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4185 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
4186 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
4187 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4189 ; GFX90A-TGSPLIT-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
4190 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4191 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4192 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
4193 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4194 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4195 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4196 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4197 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4198 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4199 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
4200 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
4201 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4202 i32 addrspace(1)* %out, i32 %in, i32 %old) {
4204 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
4205 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") monotonic seq_cst
4206 %val0 = extractvalue { i32, i1 } %val, 0
4207 store i32 %val0, i32 addrspace(1)* %out, align 4
4211 define amdgpu_kernel void @global_workgroup_acquire_seq_cst_ret_cmpxchg(
4212 ; GFX6-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
4213 ; GFX6: ; %bb.0: ; %entry
4214 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4215 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
4216 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
4217 ; GFX6-NEXT: s_mov_b32 s2, -1
4218 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4219 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
4220 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
4221 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4222 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
4223 ; GFX6-NEXT: s_waitcnt vmcnt(0)
4224 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
4225 ; GFX6-NEXT: s_endpgm
4227 ; GFX7-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
4228 ; GFX7: ; %bb.0: ; %entry
4229 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4230 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
4231 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4232 ; GFX7-NEXT: s_add_u32 s4, s0, 16
4233 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
4234 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
4235 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
4236 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
4237 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
4238 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4239 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4240 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
4241 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
4242 ; GFX7-NEXT: s_waitcnt vmcnt(0)
4243 ; GFX7-NEXT: flat_store_dword v[0:1], v2
4244 ; GFX7-NEXT: s_endpgm
4246 ; GFX10-WGP-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
4247 ; GFX10-WGP: ; %bb.0: ; %entry
4248 ; GFX10-WGP-NEXT: s_clause 0x1
4249 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
4250 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
4251 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
4252 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4253 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
4254 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
4255 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4256 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4257 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
4258 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
4259 ; GFX10-WGP-NEXT: buffer_gl0_inv
4260 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
4261 ; GFX10-WGP-NEXT: s_endpgm
4263 ; GFX10-CU-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
4264 ; GFX10-CU: ; %bb.0: ; %entry
4265 ; GFX10-CU-NEXT: s_clause 0x1
4266 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
4267 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
4268 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
4269 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4270 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
4271 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
4272 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4273 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
4274 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
4275 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
4276 ; GFX10-CU-NEXT: s_endpgm
4278 ; SKIP-CACHE-INV-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
4279 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4280 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
4281 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
4282 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
4283 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
4284 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4285 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
4286 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
4287 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4288 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
4289 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
4290 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
4291 ; SKIP-CACHE-INV-NEXT: s_endpgm
4293 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
4294 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4295 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4296 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
4297 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4298 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4299 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4300 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4301 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4302 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
4303 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
4304 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4306 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
4307 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4308 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4309 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
4310 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4311 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4312 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4313 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4314 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4315 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4316 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
4317 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
4318 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4319 i32 addrspace(1)* %out, i32 %in, i32 %old) {
4321 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
4322 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") acquire seq_cst
4323 %val0 = extractvalue { i32, i1 } %val, 0
4324 store i32 %val0, i32 addrspace(1)* %out, align 4
4328 define amdgpu_kernel void @global_workgroup_release_seq_cst_ret_cmpxchg(
4329 ; GFX6-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
4330 ; GFX6: ; %bb.0: ; %entry
4331 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4332 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
4333 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
4334 ; GFX6-NEXT: s_mov_b32 s2, -1
4335 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4336 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
4337 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
4338 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4339 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
4340 ; GFX6-NEXT: s_waitcnt vmcnt(0)
4341 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
4342 ; GFX6-NEXT: s_endpgm
4344 ; GFX7-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
4345 ; GFX7: ; %bb.0: ; %entry
4346 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4347 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
4348 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4349 ; GFX7-NEXT: s_add_u32 s4, s0, 16
4350 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
4351 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
4352 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
4353 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
4354 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
4355 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4356 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4357 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
4358 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
4359 ; GFX7-NEXT: s_waitcnt vmcnt(0)
4360 ; GFX7-NEXT: flat_store_dword v[0:1], v2
4361 ; GFX7-NEXT: s_endpgm
4363 ; GFX10-WGP-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
4364 ; GFX10-WGP: ; %bb.0: ; %entry
4365 ; GFX10-WGP-NEXT: s_clause 0x1
4366 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
4367 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
4368 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
4369 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4370 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
4371 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
4372 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4373 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4374 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
4375 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
4376 ; GFX10-WGP-NEXT: buffer_gl0_inv
4377 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
4378 ; GFX10-WGP-NEXT: s_endpgm
4380 ; GFX10-CU-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
4381 ; GFX10-CU: ; %bb.0: ; %entry
4382 ; GFX10-CU-NEXT: s_clause 0x1
4383 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
4384 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
4385 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
4386 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4387 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
4388 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
4389 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4390 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
4391 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
4392 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
4393 ; GFX10-CU-NEXT: s_endpgm
4395 ; SKIP-CACHE-INV-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
4396 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4397 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
4398 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
4399 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
4400 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
4401 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4402 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
4403 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
4404 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4405 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
4406 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
4407 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
4408 ; SKIP-CACHE-INV-NEXT: s_endpgm
4410 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
4411 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4412 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4413 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
4414 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4415 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4416 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4417 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4418 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4419 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
4420 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
4421 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4423 ; GFX90A-TGSPLIT-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
4424 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4425 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4426 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
4427 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4428 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4429 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4430 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4431 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4432 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4433 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
4434 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
4435 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4436 i32 addrspace(1)* %out, i32 %in, i32 %old) {
4438 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
4439 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") release seq_cst
4440 %val0 = extractvalue { i32, i1 } %val, 0
4441 store i32 %val0, i32 addrspace(1)* %out, align 4
4445 define amdgpu_kernel void @global_workgroup_acq_rel_seq_cst_ret_cmpxchg(
4446 ; GFX6-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
4447 ; GFX6: ; %bb.0: ; %entry
4448 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4449 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
4450 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
4451 ; GFX6-NEXT: s_mov_b32 s2, -1
4452 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4453 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
4454 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
4455 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4456 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
4457 ; GFX6-NEXT: s_waitcnt vmcnt(0)
4458 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
4459 ; GFX6-NEXT: s_endpgm
4461 ; GFX7-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
4462 ; GFX7: ; %bb.0: ; %entry
4463 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4464 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
4465 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4466 ; GFX7-NEXT: s_add_u32 s4, s0, 16
4467 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
4468 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
4469 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
4470 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
4471 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
4472 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4473 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4474 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
4475 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
4476 ; GFX7-NEXT: s_waitcnt vmcnt(0)
4477 ; GFX7-NEXT: flat_store_dword v[0:1], v2
4478 ; GFX7-NEXT: s_endpgm
4480 ; GFX10-WGP-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
4481 ; GFX10-WGP: ; %bb.0: ; %entry
4482 ; GFX10-WGP-NEXT: s_clause 0x1
4483 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
4484 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
4485 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
4486 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4487 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
4488 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
4489 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4490 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4491 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
4492 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
4493 ; GFX10-WGP-NEXT: buffer_gl0_inv
4494 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
4495 ; GFX10-WGP-NEXT: s_endpgm
4497 ; GFX10-CU-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
4498 ; GFX10-CU: ; %bb.0: ; %entry
4499 ; GFX10-CU-NEXT: s_clause 0x1
4500 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
4501 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
4502 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
4503 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4504 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
4505 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
4506 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4507 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
4508 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
4509 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
4510 ; GFX10-CU-NEXT: s_endpgm
4512 ; SKIP-CACHE-INV-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
4513 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4514 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
4515 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
4516 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
4517 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
4518 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4519 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
4520 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
4521 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4522 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
4523 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
4524 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
4525 ; SKIP-CACHE-INV-NEXT: s_endpgm
4527 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
4528 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4529 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4530 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
4531 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4532 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4533 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4534 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4535 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4536 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
4537 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
4538 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4540 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
4541 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4542 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4543 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
4544 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4545 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4546 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4547 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4548 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4549 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4550 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
4551 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
4552 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4553 i32 addrspace(1)* %out, i32 %in, i32 %old) {
4555 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
4556 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") acq_rel seq_cst
4557 %val0 = extractvalue { i32, i1 } %val, 0
4558 store i32 %val0, i32 addrspace(1)* %out, align 4
4562 define amdgpu_kernel void @global_workgroup_seq_cst_seq_cst_ret_cmpxchg(
4563 ; GFX6-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
4564 ; GFX6: ; %bb.0: ; %entry
4565 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4566 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
4567 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
4568 ; GFX6-NEXT: s_mov_b32 s2, -1
4569 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4570 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
4571 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
4572 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4573 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
4574 ; GFX6-NEXT: s_waitcnt vmcnt(0)
4575 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
4576 ; GFX6-NEXT: s_endpgm
4578 ; GFX7-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
4579 ; GFX7: ; %bb.0: ; %entry
4580 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4581 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
4582 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4583 ; GFX7-NEXT: s_add_u32 s4, s0, 16
4584 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
4585 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
4586 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
4587 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
4588 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
4589 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4590 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4591 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
4592 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
4593 ; GFX7-NEXT: s_waitcnt vmcnt(0)
4594 ; GFX7-NEXT: flat_store_dword v[0:1], v2
4595 ; GFX7-NEXT: s_endpgm
4597 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
4598 ; GFX10-WGP: ; %bb.0: ; %entry
4599 ; GFX10-WGP-NEXT: s_clause 0x1
4600 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
4601 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
4602 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
4603 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4604 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
4605 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
4606 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4607 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4608 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
4609 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
4610 ; GFX10-WGP-NEXT: buffer_gl0_inv
4611 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
4612 ; GFX10-WGP-NEXT: s_endpgm
4614 ; GFX10-CU-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
4615 ; GFX10-CU: ; %bb.0: ; %entry
4616 ; GFX10-CU-NEXT: s_clause 0x1
4617 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
4618 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
4619 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
4620 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4621 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
4622 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
4623 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4624 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
4625 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
4626 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
4627 ; GFX10-CU-NEXT: s_endpgm
4629 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
4630 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4631 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
4632 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
4633 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
4634 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
4635 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4636 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
4637 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
4638 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4639 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
4640 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
4641 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
4642 ; SKIP-CACHE-INV-NEXT: s_endpgm
4644 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
4645 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4646 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4647 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
4648 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4649 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4650 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4651 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4652 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4653 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
4654 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
4655 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4657 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
4658 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4659 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4660 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
4661 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
4662 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4663 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4664 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4665 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4666 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4667 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
4668 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
4669 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4670 i32 addrspace(1)* %out, i32 %in, i32 %old) {
4672 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
4673 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup") seq_cst seq_cst
4674 %val0 = extractvalue { i32, i1 } %val, 0
4675 store i32 %val0, i32 addrspace(1)* %out, align 4
4679 define amdgpu_kernel void @global_workgroup_one_as_unordered_load(
4680 ; GFX6-LABEL: global_workgroup_one_as_unordered_load:
4681 ; GFX6: ; %bb.0: ; %entry
4682 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[4:5], 0x0
4683 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
4684 ; GFX6-NEXT: s_mov_b32 s2, -1
4685 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4686 ; GFX6-NEXT: s_mov_b32 s0, s4
4687 ; GFX6-NEXT: s_mov_b32 s1, s5
4688 ; GFX6-NEXT: buffer_load_dword v0, off, s[0:3], 0
4689 ; GFX6-NEXT: s_mov_b32 s4, s6
4690 ; GFX6-NEXT: s_mov_b32 s5, s7
4691 ; GFX6-NEXT: s_mov_b32 s6, s2
4692 ; GFX6-NEXT: s_mov_b32 s7, s3
4693 ; GFX6-NEXT: s_waitcnt vmcnt(0)
4694 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
4695 ; GFX6-NEXT: s_endpgm
4697 ; GFX7-LABEL: global_workgroup_one_as_unordered_load:
4698 ; GFX7: ; %bb.0: ; %entry
4699 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4700 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4701 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
4702 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
4703 ; GFX7-NEXT: flat_load_dword v0, v[0:1]
4704 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
4705 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
4706 ; GFX7-NEXT: s_waitcnt vmcnt(0)
4707 ; GFX7-NEXT: flat_store_dword v[2:3], v0
4708 ; GFX7-NEXT: s_endpgm
4710 ; GFX10-WGP-LABEL: global_workgroup_one_as_unordered_load:
4711 ; GFX10-WGP: ; %bb.0: ; %entry
4712 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4713 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
4714 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4715 ; GFX10-WGP-NEXT: global_load_dword v1, v0, s[0:1]
4716 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
4717 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[2:3]
4718 ; GFX10-WGP-NEXT: s_endpgm
4720 ; GFX10-CU-LABEL: global_workgroup_one_as_unordered_load:
4721 ; GFX10-CU: ; %bb.0: ; %entry
4722 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4723 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
4724 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4725 ; GFX10-CU-NEXT: global_load_dword v1, v0, s[0:1]
4726 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
4727 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[2:3]
4728 ; GFX10-CU-NEXT: s_endpgm
4730 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_unordered_load:
4731 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4732 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
4733 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
4734 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
4735 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4736 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
4737 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
4738 ; SKIP-CACHE-INV-NEXT: buffer_load_dword v0, off, s[0:3], 0
4739 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s6
4740 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s7
4741 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s2
4742 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s3
4743 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
4744 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
4745 ; SKIP-CACHE-INV-NEXT: s_endpgm
4747 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_unordered_load:
4748 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4749 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4750 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
4751 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4752 ; GFX90A-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[0:1]
4753 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
4754 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
4755 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4757 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_unordered_load:
4758 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4759 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4760 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
4761 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4762 ; GFX90A-TGSPLIT-NEXT: global_load_dword v1, v0, s[0:1]
4763 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4764 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
4765 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4766 i32 addrspace(1)* %in, i32 addrspace(1)* %out) {
4768 %val = load atomic i32, i32 addrspace(1)* %in syncscope("workgroup-one-as") unordered, align 4
4769 store i32 %val, i32 addrspace(1)* %out
4773 define amdgpu_kernel void @global_workgroup_one_as_monotonic_load(
4774 ; GFX6-LABEL: global_workgroup_one_as_monotonic_load:
4775 ; GFX6: ; %bb.0: ; %entry
4776 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[4:5], 0x0
4777 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
4778 ; GFX6-NEXT: s_mov_b32 s2, -1
4779 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4780 ; GFX6-NEXT: s_mov_b32 s0, s4
4781 ; GFX6-NEXT: s_mov_b32 s1, s5
4782 ; GFX6-NEXT: buffer_load_dword v0, off, s[0:3], 0
4783 ; GFX6-NEXT: s_mov_b32 s4, s6
4784 ; GFX6-NEXT: s_mov_b32 s5, s7
4785 ; GFX6-NEXT: s_mov_b32 s6, s2
4786 ; GFX6-NEXT: s_mov_b32 s7, s3
4787 ; GFX6-NEXT: s_waitcnt vmcnt(0)
4788 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
4789 ; GFX6-NEXT: s_endpgm
4791 ; GFX7-LABEL: global_workgroup_one_as_monotonic_load:
4792 ; GFX7: ; %bb.0: ; %entry
4793 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4794 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4795 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
4796 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
4797 ; GFX7-NEXT: flat_load_dword v0, v[0:1]
4798 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
4799 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
4800 ; GFX7-NEXT: s_waitcnt vmcnt(0)
4801 ; GFX7-NEXT: flat_store_dword v[2:3], v0
4802 ; GFX7-NEXT: s_endpgm
4804 ; GFX10-WGP-LABEL: global_workgroup_one_as_monotonic_load:
4805 ; GFX10-WGP: ; %bb.0: ; %entry
4806 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4807 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
4808 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4809 ; GFX10-WGP-NEXT: global_load_dword v1, v0, s[0:1] glc
4810 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
4811 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[2:3]
4812 ; GFX10-WGP-NEXT: s_endpgm
4814 ; GFX10-CU-LABEL: global_workgroup_one_as_monotonic_load:
4815 ; GFX10-CU: ; %bb.0: ; %entry
4816 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4817 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
4818 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4819 ; GFX10-CU-NEXT: global_load_dword v1, v0, s[0:1]
4820 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
4821 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[2:3]
4822 ; GFX10-CU-NEXT: s_endpgm
4824 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_monotonic_load:
4825 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4826 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
4827 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
4828 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
4829 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4830 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
4831 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
4832 ; SKIP-CACHE-INV-NEXT: buffer_load_dword v0, off, s[0:3], 0
4833 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s6
4834 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s7
4835 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s2
4836 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s3
4837 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
4838 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
4839 ; SKIP-CACHE-INV-NEXT: s_endpgm
4841 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_load:
4842 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4843 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4844 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
4845 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4846 ; GFX90A-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[0:1]
4847 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
4848 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
4849 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4851 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_load:
4852 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4853 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4854 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
4855 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4856 ; GFX90A-TGSPLIT-NEXT: global_load_dword v1, v0, s[0:1] glc
4857 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4858 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
4859 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4860 i32 addrspace(1)* %in, i32 addrspace(1)* %out) {
4862 %val = load atomic i32, i32 addrspace(1)* %in syncscope("workgroup-one-as") monotonic, align 4
4863 store i32 %val, i32 addrspace(1)* %out
4867 define amdgpu_kernel void @global_workgroup_one_as_acquire_load(
4868 ; GFX6-LABEL: global_workgroup_one_as_acquire_load:
4869 ; GFX6: ; %bb.0: ; %entry
4870 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[4:5], 0x0
4871 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
4872 ; GFX6-NEXT: s_mov_b32 s2, -1
4873 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4874 ; GFX6-NEXT: s_mov_b32 s0, s4
4875 ; GFX6-NEXT: s_mov_b32 s1, s5
4876 ; GFX6-NEXT: buffer_load_dword v0, off, s[0:3], 0
4877 ; GFX6-NEXT: s_mov_b32 s4, s6
4878 ; GFX6-NEXT: s_mov_b32 s5, s7
4879 ; GFX6-NEXT: s_mov_b32 s6, s2
4880 ; GFX6-NEXT: s_mov_b32 s7, s3
4881 ; GFX6-NEXT: s_waitcnt vmcnt(0)
4882 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
4883 ; GFX6-NEXT: s_endpgm
4885 ; GFX7-LABEL: global_workgroup_one_as_acquire_load:
4886 ; GFX7: ; %bb.0: ; %entry
4887 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4888 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4889 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
4890 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
4891 ; GFX7-NEXT: flat_load_dword v0, v[0:1]
4892 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
4893 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
4894 ; GFX7-NEXT: s_waitcnt vmcnt(0)
4895 ; GFX7-NEXT: flat_store_dword v[2:3], v0
4896 ; GFX7-NEXT: s_endpgm
4898 ; GFX10-WGP-LABEL: global_workgroup_one_as_acquire_load:
4899 ; GFX10-WGP: ; %bb.0: ; %entry
4900 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4901 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
4902 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4903 ; GFX10-WGP-NEXT: global_load_dword v1, v0, s[0:1] glc
4904 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
4905 ; GFX10-WGP-NEXT: buffer_gl0_inv
4906 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[2:3]
4907 ; GFX10-WGP-NEXT: s_endpgm
4909 ; GFX10-CU-LABEL: global_workgroup_one_as_acquire_load:
4910 ; GFX10-CU: ; %bb.0: ; %entry
4911 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4912 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
4913 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4914 ; GFX10-CU-NEXT: global_load_dword v1, v0, s[0:1]
4915 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
4916 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[2:3]
4917 ; GFX10-CU-NEXT: s_endpgm
4919 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acquire_load:
4920 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4921 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
4922 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
4923 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
4924 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4925 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
4926 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
4927 ; SKIP-CACHE-INV-NEXT: buffer_load_dword v0, off, s[0:3], 0
4928 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s6
4929 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s7
4930 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s2
4931 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s3
4932 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
4933 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
4934 ; SKIP-CACHE-INV-NEXT: s_endpgm
4936 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_load:
4937 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4938 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4939 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
4940 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4941 ; GFX90A-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[0:1]
4942 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
4943 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
4944 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4946 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acquire_load:
4947 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4948 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4949 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
4950 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4951 ; GFX90A-TGSPLIT-NEXT: global_load_dword v1, v0, s[0:1] glc
4952 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4953 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
4954 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
4955 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4956 i32 addrspace(1)* %in, i32 addrspace(1)* %out) {
4958 %val = load atomic i32, i32 addrspace(1)* %in syncscope("workgroup-one-as") acquire, align 4
4959 store i32 %val, i32 addrspace(1)* %out
4963 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_load(
4964 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_load:
4965 ; GFX6: ; %bb.0: ; %entry
4966 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[4:5], 0x0
4967 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
4968 ; GFX6-NEXT: s_mov_b32 s2, -1
4969 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4970 ; GFX6-NEXT: s_mov_b32 s0, s4
4971 ; GFX6-NEXT: s_mov_b32 s1, s5
4972 ; GFX6-NEXT: buffer_load_dword v0, off, s[0:3], 0
4973 ; GFX6-NEXT: s_mov_b32 s4, s6
4974 ; GFX6-NEXT: s_mov_b32 s5, s7
4975 ; GFX6-NEXT: s_mov_b32 s6, s2
4976 ; GFX6-NEXT: s_mov_b32 s7, s3
4977 ; GFX6-NEXT: s_waitcnt vmcnt(0)
4978 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
4979 ; GFX6-NEXT: s_endpgm
4981 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_load:
4982 ; GFX7: ; %bb.0: ; %entry
4983 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4984 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4985 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
4986 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
4987 ; GFX7-NEXT: flat_load_dword v0, v[0:1]
4988 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
4989 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
4990 ; GFX7-NEXT: s_waitcnt vmcnt(0)
4991 ; GFX7-NEXT: flat_store_dword v[2:3], v0
4992 ; GFX7-NEXT: s_endpgm
4994 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_load:
4995 ; GFX10-WGP: ; %bb.0: ; %entry
4996 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4997 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
4998 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4999 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5000 ; GFX10-WGP-NEXT: global_load_dword v1, v0, s[0:1] glc
5001 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
5002 ; GFX10-WGP-NEXT: buffer_gl0_inv
5003 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[2:3]
5004 ; GFX10-WGP-NEXT: s_endpgm
5006 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_load:
5007 ; GFX10-CU: ; %bb.0: ; %entry
5008 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5009 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
5010 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5011 ; GFX10-CU-NEXT: global_load_dword v1, v0, s[0:1]
5012 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
5013 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[2:3]
5014 ; GFX10-CU-NEXT: s_endpgm
5016 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_load:
5017 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5018 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
5019 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
5020 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
5021 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5022 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
5023 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
5024 ; SKIP-CACHE-INV-NEXT: buffer_load_dword v0, off, s[0:3], 0
5025 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s6
5026 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s7
5027 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s2
5028 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s3
5029 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
5030 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
5031 ; SKIP-CACHE-INV-NEXT: s_endpgm
5033 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_load:
5034 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5035 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5036 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5037 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5038 ; GFX90A-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[0:1]
5039 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
5040 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
5041 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5043 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_load:
5044 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5045 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5046 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5047 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5048 ; GFX90A-TGSPLIT-NEXT: global_load_dword v1, v0, s[0:1] glc
5049 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5050 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
5051 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[2:3]
5052 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5053 i32 addrspace(1)* %in, i32 addrspace(1)* %out) {
5055 %val = load atomic i32, i32 addrspace(1)* %in syncscope("workgroup-one-as") seq_cst, align 4
5056 store i32 %val, i32 addrspace(1)* %out
5060 define amdgpu_kernel void @global_workgroup_one_as_unordered_store(
5061 ; GFX6-LABEL: global_workgroup_one_as_unordered_store:
5062 ; GFX6: ; %bb.0: ; %entry
5063 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x0
5064 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
5065 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
5066 ; GFX6-NEXT: s_mov_b32 s2, -1
5067 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5068 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
5069 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
5070 ; GFX6-NEXT: s_endpgm
5072 ; GFX7-LABEL: global_workgroup_one_as_unordered_store:
5073 ; GFX7: ; %bb.0: ; %entry
5074 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x0
5075 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
5076 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5077 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
5078 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
5079 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
5080 ; GFX7-NEXT: flat_store_dword v[0:1], v2
5081 ; GFX7-NEXT: s_endpgm
5083 ; GFX10-WGP-LABEL: global_workgroup_one_as_unordered_store:
5084 ; GFX10-WGP: ; %bb.0: ; %entry
5085 ; GFX10-WGP-NEXT: s_clause 0x1
5086 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x0
5087 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
5088 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
5089 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5090 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
5091 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
5092 ; GFX10-WGP-NEXT: s_endpgm
5094 ; GFX10-CU-LABEL: global_workgroup_one_as_unordered_store:
5095 ; GFX10-CU: ; %bb.0: ; %entry
5096 ; GFX10-CU-NEXT: s_clause 0x1
5097 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x0
5098 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
5099 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
5100 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5101 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
5102 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
5103 ; GFX10-CU-NEXT: s_endpgm
5105 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_unordered_store:
5106 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5107 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x9
5108 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
5109 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
5110 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
5111 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5112 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
5113 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
5114 ; SKIP-CACHE-INV-NEXT: s_endpgm
5116 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_unordered_store:
5117 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5118 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
5119 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
5120 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5121 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5122 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5123 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
5124 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5126 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_unordered_store:
5127 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5128 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
5129 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
5130 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5131 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5132 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5133 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
5134 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5135 i32 %in, i32 addrspace(1)* %out) {
5137 store atomic i32 %in, i32 addrspace(1)* %out syncscope("workgroup-one-as") unordered, align 4
5141 define amdgpu_kernel void @global_workgroup_one_as_monotonic_store(
5142 ; GFX6-LABEL: global_workgroup_one_as_monotonic_store:
5143 ; GFX6: ; %bb.0: ; %entry
5144 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x0
5145 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
5146 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
5147 ; GFX6-NEXT: s_mov_b32 s2, -1
5148 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5149 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
5150 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
5151 ; GFX6-NEXT: s_endpgm
5153 ; GFX7-LABEL: global_workgroup_one_as_monotonic_store:
5154 ; GFX7: ; %bb.0: ; %entry
5155 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x0
5156 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
5157 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5158 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
5159 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
5160 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
5161 ; GFX7-NEXT: flat_store_dword v[0:1], v2
5162 ; GFX7-NEXT: s_endpgm
5164 ; GFX10-WGP-LABEL: global_workgroup_one_as_monotonic_store:
5165 ; GFX10-WGP: ; %bb.0: ; %entry
5166 ; GFX10-WGP-NEXT: s_clause 0x1
5167 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x0
5168 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
5169 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
5170 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5171 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
5172 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
5173 ; GFX10-WGP-NEXT: s_endpgm
5175 ; GFX10-CU-LABEL: global_workgroup_one_as_monotonic_store:
5176 ; GFX10-CU: ; %bb.0: ; %entry
5177 ; GFX10-CU-NEXT: s_clause 0x1
5178 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x0
5179 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
5180 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
5181 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5182 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
5183 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
5184 ; GFX10-CU-NEXT: s_endpgm
5186 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_monotonic_store:
5187 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5188 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x9
5189 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
5190 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
5191 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
5192 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5193 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
5194 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
5195 ; SKIP-CACHE-INV-NEXT: s_endpgm
5197 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_store:
5198 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5199 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
5200 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
5201 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5202 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5203 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5204 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
5205 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5207 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_store:
5208 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5209 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
5210 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
5211 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5212 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5213 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5214 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
5215 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5216 i32 %in, i32 addrspace(1)* %out) {
5218 store atomic i32 %in, i32 addrspace(1)* %out syncscope("workgroup-one-as") monotonic, align 4
5222 define amdgpu_kernel void @global_workgroup_one_as_release_store(
5223 ; GFX6-LABEL: global_workgroup_one_as_release_store:
5224 ; GFX6: ; %bb.0: ; %entry
5225 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x0
5226 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
5227 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
5228 ; GFX6-NEXT: s_mov_b32 s2, -1
5229 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5230 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
5231 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
5232 ; GFX6-NEXT: s_endpgm
5234 ; GFX7-LABEL: global_workgroup_one_as_release_store:
5235 ; GFX7: ; %bb.0: ; %entry
5236 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x0
5237 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
5238 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5239 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
5240 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
5241 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
5242 ; GFX7-NEXT: flat_store_dword v[0:1], v2
5243 ; GFX7-NEXT: s_endpgm
5245 ; GFX10-WGP-LABEL: global_workgroup_one_as_release_store:
5246 ; GFX10-WGP: ; %bb.0: ; %entry
5247 ; GFX10-WGP-NEXT: s_clause 0x1
5248 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x0
5249 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
5250 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
5251 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5252 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
5253 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
5254 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5255 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
5256 ; GFX10-WGP-NEXT: s_endpgm
5258 ; GFX10-CU-LABEL: global_workgroup_one_as_release_store:
5259 ; GFX10-CU: ; %bb.0: ; %entry
5260 ; GFX10-CU-NEXT: s_clause 0x1
5261 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x0
5262 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
5263 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
5264 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5265 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
5266 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
5267 ; GFX10-CU-NEXT: s_endpgm
5269 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_release_store:
5270 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5271 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x9
5272 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
5273 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
5274 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
5275 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5276 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
5277 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
5278 ; SKIP-CACHE-INV-NEXT: s_endpgm
5280 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_store:
5281 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5282 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
5283 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
5284 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5285 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5286 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5287 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
5288 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5290 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_release_store:
5291 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5292 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
5293 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
5294 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5295 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5296 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5297 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5298 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
5299 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5300 i32 %in, i32 addrspace(1)* %out) {
5302 store atomic i32 %in, i32 addrspace(1)* %out syncscope("workgroup-one-as") release, align 4
5306 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_store(
5307 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_store:
5308 ; GFX6: ; %bb.0: ; %entry
5309 ; GFX6-NEXT: s_load_dword s6, s[4:5], 0x0
5310 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
5311 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
5312 ; GFX6-NEXT: s_mov_b32 s2, -1
5313 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5314 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
5315 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
5316 ; GFX6-NEXT: s_endpgm
5318 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_store:
5319 ; GFX7: ; %bb.0: ; %entry
5320 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x0
5321 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
5322 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5323 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
5324 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
5325 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
5326 ; GFX7-NEXT: flat_store_dword v[0:1], v2
5327 ; GFX7-NEXT: s_endpgm
5329 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_store:
5330 ; GFX10-WGP: ; %bb.0: ; %entry
5331 ; GFX10-WGP-NEXT: s_clause 0x1
5332 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x0
5333 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
5334 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
5335 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5336 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
5337 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
5338 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5339 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
5340 ; GFX10-WGP-NEXT: s_endpgm
5342 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_store:
5343 ; GFX10-CU: ; %bb.0: ; %entry
5344 ; GFX10-CU-NEXT: s_clause 0x1
5345 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x0
5346 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
5347 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
5348 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5349 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
5350 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
5351 ; GFX10-CU-NEXT: s_endpgm
5353 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_store:
5354 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5355 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x9
5356 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
5357 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, 0xf000
5358 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, -1
5359 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5360 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
5361 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
5362 ; SKIP-CACHE-INV-NEXT: s_endpgm
5364 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_store:
5365 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5366 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
5367 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
5368 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5369 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5370 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5371 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
5372 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5374 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_store:
5375 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5376 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
5377 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
5378 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5379 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5380 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5381 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5382 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
5383 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5384 i32 %in, i32 addrspace(1)* %out) {
5386 store atomic i32 %in, i32 addrspace(1)* %out syncscope("workgroup-one-as") seq_cst, align 4
5390 define amdgpu_kernel void @global_workgroup_one_as_monotonic_atomicrmw(
5391 ; GFX6-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
5392 ; GFX6: ; %bb.0: ; %entry
5393 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5394 ; GFX6-NEXT: s_load_dword s4, s[4:5], 0x2
5395 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
5396 ; GFX6-NEXT: s_mov_b32 s2, -1
5397 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5398 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
5399 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
5400 ; GFX6-NEXT: s_endpgm
5402 ; GFX7-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
5403 ; GFX7: ; %bb.0: ; %entry
5404 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5405 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
5406 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5407 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
5408 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
5409 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
5410 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
5411 ; GFX7-NEXT: s_endpgm
5413 ; GFX10-WGP-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
5414 ; GFX10-WGP: ; %bb.0: ; %entry
5415 ; GFX10-WGP-NEXT: s_clause 0x1
5416 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
5417 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5418 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
5419 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5420 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
5421 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[0:1]
5422 ; GFX10-WGP-NEXT: s_endpgm
5424 ; GFX10-CU-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
5425 ; GFX10-CU: ; %bb.0: ; %entry
5426 ; GFX10-CU-NEXT: s_clause 0x1
5427 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
5428 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5429 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
5430 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5431 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
5432 ; GFX10-CU-NEXT: global_atomic_swap v0, v1, s[0:1]
5433 ; GFX10-CU-NEXT: s_endpgm
5435 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
5436 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5437 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
5438 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0xb
5439 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
5440 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
5441 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5442 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
5443 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[4:7], 0
5444 ; SKIP-CACHE-INV-NEXT: s_endpgm
5446 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
5447 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5448 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5449 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
5450 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5451 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5452 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5453 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
5454 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5456 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
5457 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5458 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5459 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
5460 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5461 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5462 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5463 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
5464 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5465 i32 addrspace(1)* %out, i32 %in) {
5467 %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("workgroup-one-as") monotonic
5471 define amdgpu_kernel void @global_workgroup_one_as_acquire_atomicrmw(
5472 ; GFX6-LABEL: global_workgroup_one_as_acquire_atomicrmw:
5473 ; GFX6: ; %bb.0: ; %entry
5474 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5475 ; GFX6-NEXT: s_load_dword s4, s[4:5], 0x2
5476 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
5477 ; GFX6-NEXT: s_mov_b32 s2, -1
5478 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5479 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
5480 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
5481 ; GFX6-NEXT: s_endpgm
5483 ; GFX7-LABEL: global_workgroup_one_as_acquire_atomicrmw:
5484 ; GFX7: ; %bb.0: ; %entry
5485 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5486 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
5487 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5488 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
5489 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
5490 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
5491 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
5492 ; GFX7-NEXT: s_endpgm
5494 ; GFX10-WGP-LABEL: global_workgroup_one_as_acquire_atomicrmw:
5495 ; GFX10-WGP: ; %bb.0: ; %entry
5496 ; GFX10-WGP-NEXT: s_clause 0x1
5497 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
5498 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5499 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
5500 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5501 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
5502 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[0:1]
5503 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5504 ; GFX10-WGP-NEXT: buffer_gl0_inv
5505 ; GFX10-WGP-NEXT: s_endpgm
5507 ; GFX10-CU-LABEL: global_workgroup_one_as_acquire_atomicrmw:
5508 ; GFX10-CU: ; %bb.0: ; %entry
5509 ; GFX10-CU-NEXT: s_clause 0x1
5510 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
5511 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5512 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
5513 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5514 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
5515 ; GFX10-CU-NEXT: global_atomic_swap v0, v1, s[0:1]
5516 ; GFX10-CU-NEXT: s_endpgm
5518 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acquire_atomicrmw:
5519 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5520 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
5521 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0xb
5522 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
5523 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
5524 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5525 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
5526 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[4:7], 0
5527 ; SKIP-CACHE-INV-NEXT: s_endpgm
5529 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_atomicrmw:
5530 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5531 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5532 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
5533 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5534 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5535 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5536 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
5537 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5539 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acquire_atomicrmw:
5540 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5541 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5542 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
5543 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5544 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5545 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5546 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
5547 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5548 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
5549 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5550 i32 addrspace(1)* %out, i32 %in) {
5552 %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("workgroup-one-as") acquire
5556 define amdgpu_kernel void @global_workgroup_one_as_release_atomicrmw(
5557 ; GFX6-LABEL: global_workgroup_one_as_release_atomicrmw:
5558 ; GFX6: ; %bb.0: ; %entry
5559 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5560 ; GFX6-NEXT: s_load_dword s4, s[4:5], 0x2
5561 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
5562 ; GFX6-NEXT: s_mov_b32 s2, -1
5563 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5564 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
5565 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
5566 ; GFX6-NEXT: s_endpgm
5568 ; GFX7-LABEL: global_workgroup_one_as_release_atomicrmw:
5569 ; GFX7: ; %bb.0: ; %entry
5570 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5571 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
5572 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5573 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
5574 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
5575 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
5576 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
5577 ; GFX7-NEXT: s_endpgm
5579 ; GFX10-WGP-LABEL: global_workgroup_one_as_release_atomicrmw:
5580 ; GFX10-WGP: ; %bb.0: ; %entry
5581 ; GFX10-WGP-NEXT: s_clause 0x1
5582 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
5583 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5584 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
5585 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5586 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
5587 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
5588 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5589 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[0:1]
5590 ; GFX10-WGP-NEXT: s_endpgm
5592 ; GFX10-CU-LABEL: global_workgroup_one_as_release_atomicrmw:
5593 ; GFX10-CU: ; %bb.0: ; %entry
5594 ; GFX10-CU-NEXT: s_clause 0x1
5595 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
5596 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5597 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
5598 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5599 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
5600 ; GFX10-CU-NEXT: global_atomic_swap v0, v1, s[0:1]
5601 ; GFX10-CU-NEXT: s_endpgm
5603 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_release_atomicrmw:
5604 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5605 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
5606 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0xb
5607 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
5608 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
5609 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5610 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
5611 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[4:7], 0
5612 ; SKIP-CACHE-INV-NEXT: s_endpgm
5614 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_atomicrmw:
5615 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5616 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5617 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
5618 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5619 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5620 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5621 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
5622 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5624 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_release_atomicrmw:
5625 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5626 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5627 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
5628 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5629 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5630 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5631 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5632 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
5633 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5634 i32 addrspace(1)* %out, i32 %in) {
5636 %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("workgroup-one-as") release
5640 define amdgpu_kernel void @global_workgroup_one_as_acq_rel_atomicrmw(
5641 ; GFX6-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
5642 ; GFX6: ; %bb.0: ; %entry
5643 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5644 ; GFX6-NEXT: s_load_dword s4, s[4:5], 0x2
5645 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
5646 ; GFX6-NEXT: s_mov_b32 s2, -1
5647 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5648 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
5649 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
5650 ; GFX6-NEXT: s_endpgm
5652 ; GFX7-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
5653 ; GFX7: ; %bb.0: ; %entry
5654 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5655 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
5656 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5657 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
5658 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
5659 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
5660 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
5661 ; GFX7-NEXT: s_endpgm
5663 ; GFX10-WGP-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
5664 ; GFX10-WGP: ; %bb.0: ; %entry
5665 ; GFX10-WGP-NEXT: s_clause 0x1
5666 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
5667 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5668 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
5669 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5670 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
5671 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
5672 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5673 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[0:1]
5674 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5675 ; GFX10-WGP-NEXT: buffer_gl0_inv
5676 ; GFX10-WGP-NEXT: s_endpgm
5678 ; GFX10-CU-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
5679 ; GFX10-CU: ; %bb.0: ; %entry
5680 ; GFX10-CU-NEXT: s_clause 0x1
5681 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
5682 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5683 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
5684 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5685 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
5686 ; GFX10-CU-NEXT: global_atomic_swap v0, v1, s[0:1]
5687 ; GFX10-CU-NEXT: s_endpgm
5689 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
5690 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5691 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
5692 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0xb
5693 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
5694 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
5695 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5696 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
5697 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[4:7], 0
5698 ; SKIP-CACHE-INV-NEXT: s_endpgm
5700 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
5701 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5702 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5703 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
5704 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5705 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5706 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5707 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
5708 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5710 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
5711 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5712 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5713 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
5714 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5715 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5716 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5717 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5718 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
5719 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5720 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
5721 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5722 i32 addrspace(1)* %out, i32 %in) {
5724 %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("workgroup-one-as") acq_rel
5728 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_atomicrmw(
5729 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
5730 ; GFX6: ; %bb.0: ; %entry
5731 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5732 ; GFX6-NEXT: s_load_dword s4, s[4:5], 0x2
5733 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
5734 ; GFX6-NEXT: s_mov_b32 s2, -1
5735 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5736 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
5737 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
5738 ; GFX6-NEXT: s_endpgm
5740 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
5741 ; GFX7: ; %bb.0: ; %entry
5742 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5743 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
5744 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5745 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
5746 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
5747 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
5748 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
5749 ; GFX7-NEXT: s_endpgm
5751 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
5752 ; GFX10-WGP: ; %bb.0: ; %entry
5753 ; GFX10-WGP-NEXT: s_clause 0x1
5754 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
5755 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5756 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
5757 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5758 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
5759 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
5760 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5761 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[0:1]
5762 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5763 ; GFX10-WGP-NEXT: buffer_gl0_inv
5764 ; GFX10-WGP-NEXT: s_endpgm
5766 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
5767 ; GFX10-CU: ; %bb.0: ; %entry
5768 ; GFX10-CU-NEXT: s_clause 0x1
5769 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
5770 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5771 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
5772 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5773 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
5774 ; GFX10-CU-NEXT: global_atomic_swap v0, v1, s[0:1]
5775 ; GFX10-CU-NEXT: s_endpgm
5777 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
5778 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5779 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
5780 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0xb
5781 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
5782 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
5783 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5784 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
5785 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[4:7], 0
5786 ; SKIP-CACHE-INV-NEXT: s_endpgm
5788 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
5789 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5790 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5791 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
5792 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5793 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5794 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5795 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
5796 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5798 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
5799 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5800 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5801 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
5802 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5803 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5804 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5805 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5806 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
5807 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5808 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
5809 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5810 i32 addrspace(1)* %out, i32 %in) {
5812 %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("workgroup-one-as") seq_cst
5816 define amdgpu_kernel void @global_workgroup_one_as_acquire_ret_atomicrmw(
5817 ; GFX6-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
5818 ; GFX6: ; %bb.0: ; %entry
5819 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5820 ; GFX6-NEXT: s_load_dword s4, s[4:5], 0x2
5821 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
5822 ; GFX6-NEXT: s_mov_b32 s2, -1
5823 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5824 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
5825 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0 glc
5826 ; GFX6-NEXT: s_waitcnt vmcnt(0)
5827 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
5828 ; GFX6-NEXT: s_endpgm
5830 ; GFX7-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
5831 ; GFX7: ; %bb.0: ; %entry
5832 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5833 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
5834 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5835 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
5836 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
5837 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
5838 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
5839 ; GFX7-NEXT: s_waitcnt vmcnt(0)
5840 ; GFX7-NEXT: flat_store_dword v[0:1], v2
5841 ; GFX7-NEXT: s_endpgm
5843 ; GFX10-WGP-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
5844 ; GFX10-WGP: ; %bb.0: ; %entry
5845 ; GFX10-WGP-NEXT: s_clause 0x1
5846 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
5847 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5848 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
5849 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5850 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
5851 ; GFX10-WGP-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
5852 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
5853 ; GFX10-WGP-NEXT: buffer_gl0_inv
5854 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
5855 ; GFX10-WGP-NEXT: s_endpgm
5857 ; GFX10-CU-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
5858 ; GFX10-CU: ; %bb.0: ; %entry
5859 ; GFX10-CU-NEXT: s_clause 0x1
5860 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
5861 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5862 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
5863 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5864 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
5865 ; GFX10-CU-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
5866 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
5867 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
5868 ; GFX10-CU-NEXT: s_endpgm
5870 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
5871 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5872 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
5873 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0xb
5874 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
5875 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
5876 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5877 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
5878 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[4:7], 0 glc
5879 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
5880 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
5881 ; SKIP-CACHE-INV-NEXT: s_endpgm
5883 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
5884 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5885 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5886 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
5887 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5888 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5889 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5890 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
5891 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
5892 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
5893 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5895 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
5896 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5897 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5898 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
5899 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5900 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5901 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5902 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
5903 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5904 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
5905 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
5906 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5907 i32 addrspace(1)* %out, i32 %in) {
5909 %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("workgroup-one-as") acquire
5910 store i32 %val, i32 addrspace(1)* %out, align 4
5914 define amdgpu_kernel void @global_workgroup_one_as_acq_rel_ret_atomicrmw(
5915 ; GFX6-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
5916 ; GFX6: ; %bb.0: ; %entry
5917 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5918 ; GFX6-NEXT: s_load_dword s4, s[4:5], 0x2
5919 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
5920 ; GFX6-NEXT: s_mov_b32 s2, -1
5921 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5922 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
5923 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0 glc
5924 ; GFX6-NEXT: s_waitcnt vmcnt(0)
5925 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
5926 ; GFX6-NEXT: s_endpgm
5928 ; GFX7-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
5929 ; GFX7: ; %bb.0: ; %entry
5930 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5931 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
5932 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5933 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
5934 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
5935 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
5936 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
5937 ; GFX7-NEXT: s_waitcnt vmcnt(0)
5938 ; GFX7-NEXT: flat_store_dword v[0:1], v2
5939 ; GFX7-NEXT: s_endpgm
5941 ; GFX10-WGP-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
5942 ; GFX10-WGP: ; %bb.0: ; %entry
5943 ; GFX10-WGP-NEXT: s_clause 0x1
5944 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
5945 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5946 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
5947 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5948 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
5949 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
5950 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5951 ; GFX10-WGP-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
5952 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
5953 ; GFX10-WGP-NEXT: buffer_gl0_inv
5954 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
5955 ; GFX10-WGP-NEXT: s_endpgm
5957 ; GFX10-CU-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
5958 ; GFX10-CU: ; %bb.0: ; %entry
5959 ; GFX10-CU-NEXT: s_clause 0x1
5960 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
5961 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5962 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
5963 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5964 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
5965 ; GFX10-CU-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
5966 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
5967 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
5968 ; GFX10-CU-NEXT: s_endpgm
5970 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
5971 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5972 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
5973 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0xb
5974 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
5975 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
5976 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5977 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
5978 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[4:7], 0 glc
5979 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
5980 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
5981 ; SKIP-CACHE-INV-NEXT: s_endpgm
5983 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
5984 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5985 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5986 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
5987 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5988 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5989 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5990 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
5991 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
5992 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
5993 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5995 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
5996 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5997 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5998 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
5999 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
6000 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6001 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
6002 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6003 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
6004 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6005 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
6006 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
6007 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6008 i32 addrspace(1)* %out, i32 %in) {
6010 %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("workgroup-one-as") acq_rel
6011 store i32 %val, i32 addrspace(1)* %out, align 4
6015 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_ret_atomicrmw(
6016 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
6017 ; GFX6: ; %bb.0: ; %entry
6018 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6019 ; GFX6-NEXT: s_load_dword s4, s[4:5], 0x2
6020 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
6021 ; GFX6-NEXT: s_mov_b32 s2, -1
6022 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6023 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
6024 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[0:3], 0 glc
6025 ; GFX6-NEXT: s_waitcnt vmcnt(0)
6026 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
6027 ; GFX6-NEXT: s_endpgm
6029 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
6030 ; GFX7: ; %bb.0: ; %entry
6031 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6032 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
6033 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6034 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
6035 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
6036 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
6037 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
6038 ; GFX7-NEXT: s_waitcnt vmcnt(0)
6039 ; GFX7-NEXT: flat_store_dword v[0:1], v2
6040 ; GFX7-NEXT: s_endpgm
6042 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
6043 ; GFX10-WGP: ; %bb.0: ; %entry
6044 ; GFX10-WGP-NEXT: s_clause 0x1
6045 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
6046 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6047 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
6048 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6049 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s2
6050 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
6051 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6052 ; GFX10-WGP-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
6053 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
6054 ; GFX10-WGP-NEXT: buffer_gl0_inv
6055 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[0:1]
6056 ; GFX10-WGP-NEXT: s_endpgm
6058 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
6059 ; GFX10-CU: ; %bb.0: ; %entry
6060 ; GFX10-CU-NEXT: s_clause 0x1
6061 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
6062 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6063 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
6064 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6065 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s2
6066 ; GFX10-CU-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
6067 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
6068 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[0:1]
6069 ; GFX10-CU-NEXT: s_endpgm
6071 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
6072 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6073 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
6074 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0xb
6075 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
6076 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
6077 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6078 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
6079 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[4:7], 0 glc
6080 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
6081 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
6082 ; SKIP-CACHE-INV-NEXT: s_endpgm
6084 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
6085 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6086 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6087 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
6088 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
6089 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6090 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
6091 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
6092 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
6093 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
6094 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6096 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
6097 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6098 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6099 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
6100 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
6101 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6102 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
6103 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6104 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] glc
6105 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6106 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
6107 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1]
6108 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6109 i32 addrspace(1)* %out, i32 %in) {
6111 %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("workgroup-one-as") seq_cst
6112 store i32 %val, i32 addrspace(1)* %out, align 4
6116 define amdgpu_kernel void @global_workgroup_one_as_monotonic_monotonic_cmpxchg(
6117 ; GFX6-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
6118 ; GFX6: ; %bb.0: ; %entry
6119 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6120 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
6121 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
6122 ; GFX6-NEXT: s_mov_b32 s2, -1
6123 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6124 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
6125 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
6126 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
6127 ; GFX6-NEXT: s_endpgm
6129 ; GFX7-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
6130 ; GFX7: ; %bb.0: ; %entry
6131 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6132 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
6133 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6134 ; GFX7-NEXT: s_add_u32 s0, s0, 16
6135 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
6136 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
6137 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
6138 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
6139 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
6140 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
6141 ; GFX7-NEXT: s_endpgm
6143 ; GFX10-WGP-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
6144 ; GFX10-WGP: ; %bb.0: ; %entry
6145 ; GFX10-WGP-NEXT: s_clause 0x1
6146 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6147 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
6148 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
6149 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6150 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
6151 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
6152 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
6153 ; GFX10-WGP-NEXT: s_endpgm
6155 ; GFX10-CU-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
6156 ; GFX10-CU: ; %bb.0: ; %entry
6157 ; GFX10-CU-NEXT: s_clause 0x1
6158 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6159 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
6160 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
6161 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6162 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
6163 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
6164 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
6165 ; GFX10-CU-NEXT: s_endpgm
6167 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
6168 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6169 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
6170 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
6171 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
6172 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
6173 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6174 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
6175 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
6176 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
6177 ; SKIP-CACHE-INV-NEXT: s_endpgm
6179 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
6180 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6181 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6182 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
6183 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6184 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6185 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6186 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
6187 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6189 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
6190 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6191 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6192 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
6193 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6194 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6195 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6196 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
6197 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6198 i32 addrspace(1)* %out, i32 %in, i32 %old) {
6200 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
6201 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") monotonic monotonic
6205 define amdgpu_kernel void @global_workgroup_one_as_acquire_monotonic_cmpxchg(
6206 ; GFX6-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
6207 ; GFX6: ; %bb.0: ; %entry
6208 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6209 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
6210 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
6211 ; GFX6-NEXT: s_mov_b32 s2, -1
6212 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6213 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
6214 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
6215 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
6216 ; GFX6-NEXT: s_endpgm
6218 ; GFX7-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
6219 ; GFX7: ; %bb.0: ; %entry
6220 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6221 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
6222 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6223 ; GFX7-NEXT: s_add_u32 s0, s0, 16
6224 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
6225 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
6226 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
6227 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
6228 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
6229 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
6230 ; GFX7-NEXT: s_endpgm
6232 ; GFX10-WGP-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
6233 ; GFX10-WGP: ; %bb.0: ; %entry
6234 ; GFX10-WGP-NEXT: s_clause 0x1
6235 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6236 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
6237 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
6238 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6239 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
6240 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
6241 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
6242 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6243 ; GFX10-WGP-NEXT: buffer_gl0_inv
6244 ; GFX10-WGP-NEXT: s_endpgm
6246 ; GFX10-CU-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
6247 ; GFX10-CU: ; %bb.0: ; %entry
6248 ; GFX10-CU-NEXT: s_clause 0x1
6249 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6250 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
6251 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
6252 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6253 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
6254 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
6255 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
6256 ; GFX10-CU-NEXT: s_endpgm
6258 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
6259 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6260 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
6261 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
6262 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
6263 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
6264 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6265 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
6266 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
6267 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
6268 ; SKIP-CACHE-INV-NEXT: s_endpgm
6270 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
6271 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6272 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6273 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
6274 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6275 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6276 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6277 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
6278 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6280 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
6281 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6282 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6283 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
6284 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6285 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6286 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6287 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
6288 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6289 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
6290 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6291 i32 addrspace(1)* %out, i32 %in, i32 %old) {
6293 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
6294 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acquire monotonic
6298 define amdgpu_kernel void @global_workgroup_one_as_release_monotonic_cmpxchg(
6299 ; GFX6-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
6300 ; GFX6: ; %bb.0: ; %entry
6301 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6302 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
6303 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
6304 ; GFX6-NEXT: s_mov_b32 s2, -1
6305 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6306 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
6307 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
6308 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
6309 ; GFX6-NEXT: s_endpgm
6311 ; GFX7-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
6312 ; GFX7: ; %bb.0: ; %entry
6313 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6314 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
6315 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6316 ; GFX7-NEXT: s_add_u32 s0, s0, 16
6317 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
6318 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
6319 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
6320 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
6321 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
6322 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
6323 ; GFX7-NEXT: s_endpgm
6325 ; GFX10-WGP-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
6326 ; GFX10-WGP: ; %bb.0: ; %entry
6327 ; GFX10-WGP-NEXT: s_clause 0x1
6328 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6329 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
6330 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
6331 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6332 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
6333 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
6334 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
6335 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6336 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
6337 ; GFX10-WGP-NEXT: s_endpgm
6339 ; GFX10-CU-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
6340 ; GFX10-CU: ; %bb.0: ; %entry
6341 ; GFX10-CU-NEXT: s_clause 0x1
6342 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6343 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
6344 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
6345 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6346 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
6347 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
6348 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
6349 ; GFX10-CU-NEXT: s_endpgm
6351 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
6352 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6353 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
6354 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
6355 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
6356 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
6357 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6358 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
6359 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
6360 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
6361 ; SKIP-CACHE-INV-NEXT: s_endpgm
6363 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
6364 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6365 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6366 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
6367 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6368 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6369 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6370 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
6371 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6373 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
6374 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6375 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6376 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
6377 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6378 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6379 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6380 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6381 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
6382 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6383 i32 addrspace(1)* %out, i32 %in, i32 %old) {
6385 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
6386 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") release monotonic
6390 define amdgpu_kernel void @global_workgroup_one_as_acq_rel_monotonic_cmpxchg(
6391 ; GFX6-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
6392 ; GFX6: ; %bb.0: ; %entry
6393 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6394 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
6395 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
6396 ; GFX6-NEXT: s_mov_b32 s2, -1
6397 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6398 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
6399 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
6400 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
6401 ; GFX6-NEXT: s_endpgm
6403 ; GFX7-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
6404 ; GFX7: ; %bb.0: ; %entry
6405 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6406 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
6407 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6408 ; GFX7-NEXT: s_add_u32 s0, s0, 16
6409 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
6410 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
6411 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
6412 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
6413 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
6414 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
6415 ; GFX7-NEXT: s_endpgm
6417 ; GFX10-WGP-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
6418 ; GFX10-WGP: ; %bb.0: ; %entry
6419 ; GFX10-WGP-NEXT: s_clause 0x1
6420 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6421 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
6422 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
6423 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6424 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
6425 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
6426 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
6427 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6428 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
6429 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6430 ; GFX10-WGP-NEXT: buffer_gl0_inv
6431 ; GFX10-WGP-NEXT: s_endpgm
6433 ; GFX10-CU-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
6434 ; GFX10-CU: ; %bb.0: ; %entry
6435 ; GFX10-CU-NEXT: s_clause 0x1
6436 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6437 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
6438 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
6439 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6440 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
6441 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
6442 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
6443 ; GFX10-CU-NEXT: s_endpgm
6445 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
6446 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6447 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
6448 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
6449 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
6450 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
6451 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6452 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
6453 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
6454 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
6455 ; SKIP-CACHE-INV-NEXT: s_endpgm
6457 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
6458 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6459 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6460 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
6461 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6462 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6463 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6464 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
6465 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6467 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
6468 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6469 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6470 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
6471 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6472 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6473 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6474 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6475 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
6476 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6477 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
6478 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6479 i32 addrspace(1)* %out, i32 %in, i32 %old) {
6481 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
6482 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acq_rel monotonic
6486 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_monotonic_cmpxchg(
6487 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
6488 ; GFX6: ; %bb.0: ; %entry
6489 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6490 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
6491 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
6492 ; GFX6-NEXT: s_mov_b32 s2, -1
6493 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6494 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
6495 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
6496 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
6497 ; GFX6-NEXT: s_endpgm
6499 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
6500 ; GFX7: ; %bb.0: ; %entry
6501 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6502 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
6503 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6504 ; GFX7-NEXT: s_add_u32 s0, s0, 16
6505 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
6506 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
6507 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
6508 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
6509 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
6510 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
6511 ; GFX7-NEXT: s_endpgm
6513 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
6514 ; GFX10-WGP: ; %bb.0: ; %entry
6515 ; GFX10-WGP-NEXT: s_clause 0x1
6516 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6517 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
6518 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
6519 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6520 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
6521 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
6522 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
6523 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6524 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
6525 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6526 ; GFX10-WGP-NEXT: buffer_gl0_inv
6527 ; GFX10-WGP-NEXT: s_endpgm
6529 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
6530 ; GFX10-CU: ; %bb.0: ; %entry
6531 ; GFX10-CU-NEXT: s_clause 0x1
6532 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6533 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
6534 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
6535 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6536 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
6537 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
6538 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
6539 ; GFX10-CU-NEXT: s_endpgm
6541 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
6542 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6543 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
6544 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
6545 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
6546 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
6547 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6548 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
6549 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
6550 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
6551 ; SKIP-CACHE-INV-NEXT: s_endpgm
6553 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
6554 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6555 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6556 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
6557 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6558 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6559 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6560 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
6561 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6563 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
6564 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6565 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6566 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
6567 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6568 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6569 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6570 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6571 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
6572 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6573 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
6574 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6575 i32 addrspace(1)* %out, i32 %in, i32 %old) {
6577 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
6578 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") seq_cst monotonic
6582 define amdgpu_kernel void @global_workgroup_one_as_monotonic_acquire_cmpxchg(
6583 ; GFX6-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
6584 ; GFX6: ; %bb.0: ; %entry
6585 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6586 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
6587 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
6588 ; GFX6-NEXT: s_mov_b32 s2, -1
6589 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6590 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
6591 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
6592 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
6593 ; GFX6-NEXT: s_endpgm
6595 ; GFX7-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
6596 ; GFX7: ; %bb.0: ; %entry
6597 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6598 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
6599 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6600 ; GFX7-NEXT: s_add_u32 s0, s0, 16
6601 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
6602 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
6603 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
6604 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
6605 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
6606 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
6607 ; GFX7-NEXT: s_endpgm
6609 ; GFX10-WGP-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
6610 ; GFX10-WGP: ; %bb.0: ; %entry
6611 ; GFX10-WGP-NEXT: s_clause 0x1
6612 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6613 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
6614 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
6615 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6616 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
6617 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
6618 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
6619 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6620 ; GFX10-WGP-NEXT: buffer_gl0_inv
6621 ; GFX10-WGP-NEXT: s_endpgm
6623 ; GFX10-CU-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
6624 ; GFX10-CU: ; %bb.0: ; %entry
6625 ; GFX10-CU-NEXT: s_clause 0x1
6626 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6627 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
6628 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
6629 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6630 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
6631 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
6632 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
6633 ; GFX10-CU-NEXT: s_endpgm
6635 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
6636 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6637 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
6638 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
6639 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
6640 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
6641 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6642 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
6643 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
6644 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
6645 ; SKIP-CACHE-INV-NEXT: s_endpgm
6647 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
6648 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6649 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6650 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
6651 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6652 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6653 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6654 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
6655 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6657 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
6658 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6659 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6660 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
6661 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6662 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6663 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6664 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
6665 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6666 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
6667 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6668 i32 addrspace(1)* %out, i32 %in, i32 %old) {
6670 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
6671 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") monotonic acquire
6675 define amdgpu_kernel void @global_workgroup_one_as_acquire_acquire_cmpxchg(
6676 ; GFX6-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
6677 ; GFX6: ; %bb.0: ; %entry
6678 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6679 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
6680 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
6681 ; GFX6-NEXT: s_mov_b32 s2, -1
6682 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6683 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
6684 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
6685 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
6686 ; GFX6-NEXT: s_endpgm
6688 ; GFX7-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
6689 ; GFX7: ; %bb.0: ; %entry
6690 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6691 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
6692 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6693 ; GFX7-NEXT: s_add_u32 s0, s0, 16
6694 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
6695 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
6696 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
6697 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
6698 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
6699 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
6700 ; GFX7-NEXT: s_endpgm
6702 ; GFX10-WGP-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
6703 ; GFX10-WGP: ; %bb.0: ; %entry
6704 ; GFX10-WGP-NEXT: s_clause 0x1
6705 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6706 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
6707 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
6708 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6709 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
6710 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
6711 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
6712 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6713 ; GFX10-WGP-NEXT: buffer_gl0_inv
6714 ; GFX10-WGP-NEXT: s_endpgm
6716 ; GFX10-CU-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
6717 ; GFX10-CU: ; %bb.0: ; %entry
6718 ; GFX10-CU-NEXT: s_clause 0x1
6719 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6720 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
6721 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
6722 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6723 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
6724 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
6725 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
6726 ; GFX10-CU-NEXT: s_endpgm
6728 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
6729 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6730 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
6731 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
6732 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
6733 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
6734 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6735 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
6736 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
6737 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
6738 ; SKIP-CACHE-INV-NEXT: s_endpgm
6740 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
6741 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6742 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6743 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
6744 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6745 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6746 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6747 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
6748 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6750 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
6751 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6752 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6753 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
6754 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6755 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6756 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6757 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
6758 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6759 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
6760 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6761 i32 addrspace(1)* %out, i32 %in, i32 %old) {
6763 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
6764 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acquire acquire
6768 define amdgpu_kernel void @global_workgroup_one_as_release_acquire_cmpxchg(
6769 ; GFX6-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
6770 ; GFX6: ; %bb.0: ; %entry
6771 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6772 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
6773 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
6774 ; GFX6-NEXT: s_mov_b32 s2, -1
6775 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6776 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
6777 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
6778 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
6779 ; GFX6-NEXT: s_endpgm
6781 ; GFX7-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
6782 ; GFX7: ; %bb.0: ; %entry
6783 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6784 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
6785 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6786 ; GFX7-NEXT: s_add_u32 s0, s0, 16
6787 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
6788 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
6789 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
6790 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
6791 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
6792 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
6793 ; GFX7-NEXT: s_endpgm
6795 ; GFX10-WGP-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
6796 ; GFX10-WGP: ; %bb.0: ; %entry
6797 ; GFX10-WGP-NEXT: s_clause 0x1
6798 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6799 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
6800 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
6801 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6802 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
6803 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
6804 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
6805 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6806 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
6807 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6808 ; GFX10-WGP-NEXT: buffer_gl0_inv
6809 ; GFX10-WGP-NEXT: s_endpgm
6811 ; GFX10-CU-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
6812 ; GFX10-CU: ; %bb.0: ; %entry
6813 ; GFX10-CU-NEXT: s_clause 0x1
6814 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6815 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
6816 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
6817 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6818 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
6819 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
6820 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
6821 ; GFX10-CU-NEXT: s_endpgm
6823 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
6824 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6825 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
6826 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
6827 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
6828 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
6829 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6830 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
6831 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
6832 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
6833 ; SKIP-CACHE-INV-NEXT: s_endpgm
6835 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
6836 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6837 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6838 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
6839 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6840 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6841 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6842 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
6843 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6845 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
6846 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6847 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6848 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
6849 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6850 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6851 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6852 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6853 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
6854 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6855 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
6856 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6857 i32 addrspace(1)* %out, i32 %in, i32 %old) {
6859 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
6860 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") release acquire
6864 define amdgpu_kernel void @global_workgroup_one_as_acq_rel_acquire_cmpxchg(
6865 ; GFX6-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
6866 ; GFX6: ; %bb.0: ; %entry
6867 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6868 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
6869 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
6870 ; GFX6-NEXT: s_mov_b32 s2, -1
6871 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6872 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
6873 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
6874 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
6875 ; GFX6-NEXT: s_endpgm
6877 ; GFX7-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
6878 ; GFX7: ; %bb.0: ; %entry
6879 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6880 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
6881 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6882 ; GFX7-NEXT: s_add_u32 s0, s0, 16
6883 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
6884 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
6885 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
6886 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
6887 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
6888 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
6889 ; GFX7-NEXT: s_endpgm
6891 ; GFX10-WGP-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
6892 ; GFX10-WGP: ; %bb.0: ; %entry
6893 ; GFX10-WGP-NEXT: s_clause 0x1
6894 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6895 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
6896 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
6897 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6898 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
6899 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
6900 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
6901 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6902 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
6903 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6904 ; GFX10-WGP-NEXT: buffer_gl0_inv
6905 ; GFX10-WGP-NEXT: s_endpgm
6907 ; GFX10-CU-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
6908 ; GFX10-CU: ; %bb.0: ; %entry
6909 ; GFX10-CU-NEXT: s_clause 0x1
6910 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6911 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
6912 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
6913 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6914 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
6915 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
6916 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
6917 ; GFX10-CU-NEXT: s_endpgm
6919 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
6920 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6921 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
6922 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
6923 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
6924 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
6925 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6926 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
6927 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
6928 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
6929 ; SKIP-CACHE-INV-NEXT: s_endpgm
6931 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
6932 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6933 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6934 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
6935 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6936 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6937 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6938 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
6939 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6941 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
6942 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6943 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6944 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
6945 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
6946 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6947 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6948 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6949 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
6950 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6951 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
6952 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6953 i32 addrspace(1)* %out, i32 %in, i32 %old) {
6955 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
6956 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acq_rel acquire
6960 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_acquire_cmpxchg(
6961 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
6962 ; GFX6: ; %bb.0: ; %entry
6963 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6964 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
6965 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
6966 ; GFX6-NEXT: s_mov_b32 s2, -1
6967 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6968 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
6969 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
6970 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
6971 ; GFX6-NEXT: s_endpgm
6973 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
6974 ; GFX7: ; %bb.0: ; %entry
6975 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6976 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
6977 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6978 ; GFX7-NEXT: s_add_u32 s0, s0, 16
6979 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
6980 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
6981 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
6982 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
6983 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
6984 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
6985 ; GFX7-NEXT: s_endpgm
6987 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
6988 ; GFX10-WGP: ; %bb.0: ; %entry
6989 ; GFX10-WGP-NEXT: s_clause 0x1
6990 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6991 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
6992 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
6993 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6994 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
6995 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
6996 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
6997 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6998 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
6999 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7000 ; GFX10-WGP-NEXT: buffer_gl0_inv
7001 ; GFX10-WGP-NEXT: s_endpgm
7003 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
7004 ; GFX10-CU: ; %bb.0: ; %entry
7005 ; GFX10-CU-NEXT: s_clause 0x1
7006 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7007 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
7008 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
7009 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7010 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
7011 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
7012 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7013 ; GFX10-CU-NEXT: s_endpgm
7015 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
7016 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7017 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
7018 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
7019 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
7020 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
7021 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7022 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
7023 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
7024 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
7025 ; SKIP-CACHE-INV-NEXT: s_endpgm
7027 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
7028 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7029 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7030 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
7031 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
7032 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7033 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7034 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7035 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7037 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
7038 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7039 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7040 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
7041 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
7042 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7043 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7044 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7045 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7046 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7047 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
7048 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7049 i32 addrspace(1)* %out, i32 %in, i32 %old) {
7051 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
7052 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") seq_cst acquire
7056 define amdgpu_kernel void @global_workgroup_one_as_monotonic_seq_cst_cmpxchg(
7057 ; GFX6-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
7058 ; GFX6: ; %bb.0: ; %entry
7059 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7060 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
7061 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
7062 ; GFX6-NEXT: s_mov_b32 s2, -1
7063 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7064 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
7065 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
7066 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
7067 ; GFX6-NEXT: s_endpgm
7069 ; GFX7-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
7070 ; GFX7: ; %bb.0: ; %entry
7071 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7072 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
7073 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7074 ; GFX7-NEXT: s_add_u32 s0, s0, 16
7075 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
7076 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
7077 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
7078 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
7079 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
7080 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
7081 ; GFX7-NEXT: s_endpgm
7083 ; GFX10-WGP-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
7084 ; GFX10-WGP: ; %bb.0: ; %entry
7085 ; GFX10-WGP-NEXT: s_clause 0x1
7086 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7087 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
7088 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
7089 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7090 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
7091 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
7092 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
7093 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7094 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7095 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7096 ; GFX10-WGP-NEXT: buffer_gl0_inv
7097 ; GFX10-WGP-NEXT: s_endpgm
7099 ; GFX10-CU-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
7100 ; GFX10-CU: ; %bb.0: ; %entry
7101 ; GFX10-CU-NEXT: s_clause 0x1
7102 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7103 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
7104 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
7105 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7106 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
7107 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
7108 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7109 ; GFX10-CU-NEXT: s_endpgm
7111 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
7112 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7113 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
7114 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
7115 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
7116 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
7117 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7118 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
7119 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
7120 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
7121 ; SKIP-CACHE-INV-NEXT: s_endpgm
7123 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
7124 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7125 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7126 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
7127 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
7128 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7129 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7130 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7131 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7133 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
7134 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7135 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7136 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
7137 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
7138 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7139 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7140 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7141 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7142 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7143 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
7144 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7145 i32 addrspace(1)* %out, i32 %in, i32 %old) {
7147 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
7148 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") monotonic seq_cst
7152 define amdgpu_kernel void @global_workgroup_one_as_acquire_seq_cst_cmpxchg(
7153 ; GFX6-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
7154 ; GFX6: ; %bb.0: ; %entry
7155 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7156 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
7157 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
7158 ; GFX6-NEXT: s_mov_b32 s2, -1
7159 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7160 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
7161 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
7162 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
7163 ; GFX6-NEXT: s_endpgm
7165 ; GFX7-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
7166 ; GFX7: ; %bb.0: ; %entry
7167 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7168 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
7169 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7170 ; GFX7-NEXT: s_add_u32 s0, s0, 16
7171 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
7172 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
7173 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
7174 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
7175 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
7176 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
7177 ; GFX7-NEXT: s_endpgm
7179 ; GFX10-WGP-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
7180 ; GFX10-WGP: ; %bb.0: ; %entry
7181 ; GFX10-WGP-NEXT: s_clause 0x1
7182 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7183 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
7184 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
7185 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7186 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
7187 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
7188 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
7189 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7190 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7191 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7192 ; GFX10-WGP-NEXT: buffer_gl0_inv
7193 ; GFX10-WGP-NEXT: s_endpgm
7195 ; GFX10-CU-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
7196 ; GFX10-CU: ; %bb.0: ; %entry
7197 ; GFX10-CU-NEXT: s_clause 0x1
7198 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7199 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
7200 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
7201 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7202 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
7203 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
7204 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7205 ; GFX10-CU-NEXT: s_endpgm
7207 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
7208 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7209 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
7210 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
7211 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
7212 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
7213 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7214 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
7215 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
7216 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
7217 ; SKIP-CACHE-INV-NEXT: s_endpgm
7219 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
7220 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7221 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7222 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
7223 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
7224 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7225 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7226 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7227 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7229 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
7230 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7231 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7232 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
7233 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
7234 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7235 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7236 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7237 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7238 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7239 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
7240 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7241 i32 addrspace(1)* %out, i32 %in, i32 %old) {
7243 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
7244 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acquire seq_cst
7248 define amdgpu_kernel void @global_workgroup_one_as_release_seq_cst_cmpxchg(
7249 ; GFX6-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
7250 ; GFX6: ; %bb.0: ; %entry
7251 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7252 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
7253 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
7254 ; GFX6-NEXT: s_mov_b32 s2, -1
7255 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7256 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
7257 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
7258 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
7259 ; GFX6-NEXT: s_endpgm
7261 ; GFX7-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
7262 ; GFX7: ; %bb.0: ; %entry
7263 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7264 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
7265 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7266 ; GFX7-NEXT: s_add_u32 s0, s0, 16
7267 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
7268 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
7269 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
7270 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
7271 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
7272 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
7273 ; GFX7-NEXT: s_endpgm
7275 ; GFX10-WGP-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
7276 ; GFX10-WGP: ; %bb.0: ; %entry
7277 ; GFX10-WGP-NEXT: s_clause 0x1
7278 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7279 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
7280 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
7281 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7282 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
7283 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
7284 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
7285 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7286 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7287 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7288 ; GFX10-WGP-NEXT: buffer_gl0_inv
7289 ; GFX10-WGP-NEXT: s_endpgm
7291 ; GFX10-CU-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
7292 ; GFX10-CU: ; %bb.0: ; %entry
7293 ; GFX10-CU-NEXT: s_clause 0x1
7294 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7295 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
7296 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
7297 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7298 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
7299 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
7300 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7301 ; GFX10-CU-NEXT: s_endpgm
7303 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
7304 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7305 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
7306 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
7307 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
7308 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
7309 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7310 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
7311 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
7312 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
7313 ; SKIP-CACHE-INV-NEXT: s_endpgm
7315 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
7316 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7317 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7318 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
7319 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
7320 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7321 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7322 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7323 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7325 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
7326 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7327 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7328 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
7329 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
7330 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7331 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7332 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7333 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7334 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7335 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
7336 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7337 i32 addrspace(1)* %out, i32 %in, i32 %old) {
7339 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
7340 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") release seq_cst
7344 define amdgpu_kernel void @global_workgroup_one_as_acq_rel_seq_cst_cmpxchg(
7345 ; GFX6-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
7346 ; GFX6: ; %bb.0: ; %entry
7347 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7348 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
7349 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
7350 ; GFX6-NEXT: s_mov_b32 s2, -1
7351 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7352 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
7353 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
7354 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
7355 ; GFX6-NEXT: s_endpgm
7357 ; GFX7-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
7358 ; GFX7: ; %bb.0: ; %entry
7359 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7360 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
7361 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7362 ; GFX7-NEXT: s_add_u32 s0, s0, 16
7363 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
7364 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
7365 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
7366 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
7367 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
7368 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
7369 ; GFX7-NEXT: s_endpgm
7371 ; GFX10-WGP-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
7372 ; GFX10-WGP: ; %bb.0: ; %entry
7373 ; GFX10-WGP-NEXT: s_clause 0x1
7374 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7375 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
7376 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
7377 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7378 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
7379 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
7380 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
7381 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7382 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7383 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7384 ; GFX10-WGP-NEXT: buffer_gl0_inv
7385 ; GFX10-WGP-NEXT: s_endpgm
7387 ; GFX10-CU-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
7388 ; GFX10-CU: ; %bb.0: ; %entry
7389 ; GFX10-CU-NEXT: s_clause 0x1
7390 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7391 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
7392 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
7393 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7394 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
7395 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
7396 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7397 ; GFX10-CU-NEXT: s_endpgm
7399 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
7400 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7401 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
7402 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
7403 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
7404 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
7405 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7406 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
7407 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
7408 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
7409 ; SKIP-CACHE-INV-NEXT: s_endpgm
7411 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
7412 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7413 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7414 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
7415 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
7416 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7417 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7418 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7419 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7421 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
7422 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7423 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7424 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
7425 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
7426 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7427 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7428 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7429 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7430 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7431 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
7432 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7433 i32 addrspace(1)* %out, i32 %in, i32 %old) {
7435 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
7436 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acq_rel seq_cst
7440 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_seq_cst_cmpxchg(
7441 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
7442 ; GFX6: ; %bb.0: ; %entry
7443 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7444 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
7445 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
7446 ; GFX6-NEXT: s_mov_b32 s2, -1
7447 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7448 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
7449 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
7450 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
7451 ; GFX6-NEXT: s_endpgm
7453 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
7454 ; GFX7: ; %bb.0: ; %entry
7455 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7456 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
7457 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7458 ; GFX7-NEXT: s_add_u32 s0, s0, 16
7459 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
7460 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
7461 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
7462 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
7463 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
7464 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
7465 ; GFX7-NEXT: s_endpgm
7467 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
7468 ; GFX10-WGP: ; %bb.0: ; %entry
7469 ; GFX10-WGP-NEXT: s_clause 0x1
7470 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7471 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
7472 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
7473 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7474 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
7475 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
7476 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
7477 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7478 ; GFX10-WGP-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7479 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7480 ; GFX10-WGP-NEXT: buffer_gl0_inv
7481 ; GFX10-WGP-NEXT: s_endpgm
7483 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
7484 ; GFX10-CU: ; %bb.0: ; %entry
7485 ; GFX10-CU-NEXT: s_clause 0x1
7486 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7487 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
7488 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
7489 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7490 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
7491 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
7492 ; GFX10-CU-NEXT: global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7493 ; GFX10-CU-NEXT: s_endpgm
7495 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
7496 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7497 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
7498 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
7499 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
7500 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
7501 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7502 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
7503 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
7504 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
7505 ; SKIP-CACHE-INV-NEXT: s_endpgm
7507 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
7508 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7509 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7510 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
7511 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
7512 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7513 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7514 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7515 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7517 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
7518 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7519 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7520 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
7521 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
7522 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7523 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7524 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7525 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7526 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7527 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
7528 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7529 i32 addrspace(1)* %out, i32 %in, i32 %old) {
7531 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
7532 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") seq_cst seq_cst
7536 define amdgpu_kernel void @global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg(
7537 ; GFX6-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
7538 ; GFX6: ; %bb.0: ; %entry
7539 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7540 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
7541 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
7542 ; GFX6-NEXT: s_mov_b32 s2, -1
7543 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7544 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
7545 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
7546 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
7547 ; GFX6-NEXT: s_waitcnt vmcnt(0)
7548 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
7549 ; GFX6-NEXT: s_endpgm
7551 ; GFX7-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
7552 ; GFX7: ; %bb.0: ; %entry
7553 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7554 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
7555 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7556 ; GFX7-NEXT: s_add_u32 s4, s0, 16
7557 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
7558 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
7559 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
7560 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
7561 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
7562 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
7563 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
7564 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
7565 ; GFX7-NEXT: s_waitcnt vmcnt(0)
7566 ; GFX7-NEXT: flat_store_dword v[0:1], v2
7567 ; GFX7-NEXT: s_endpgm
7569 ; GFX10-WGP-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
7570 ; GFX10-WGP: ; %bb.0: ; %entry
7571 ; GFX10-WGP-NEXT: s_clause 0x1
7572 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7573 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
7574 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
7575 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7576 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
7577 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
7578 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
7579 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
7580 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
7581 ; GFX10-WGP-NEXT: s_endpgm
7583 ; GFX10-CU-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
7584 ; GFX10-CU: ; %bb.0: ; %entry
7585 ; GFX10-CU-NEXT: s_clause 0x1
7586 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7587 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
7588 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
7589 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7590 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
7591 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
7592 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
7593 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
7594 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
7595 ; GFX10-CU-NEXT: s_endpgm
7597 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
7598 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7599 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
7600 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
7601 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
7602 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
7603 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7604 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
7605 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
7606 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
7607 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
7608 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
7609 ; SKIP-CACHE-INV-NEXT: s_endpgm
7611 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
7612 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7613 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7614 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
7615 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
7616 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7617 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7618 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
7619 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
7620 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
7621 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7623 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
7624 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7625 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7626 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
7627 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
7628 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7629 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7630 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
7631 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7632 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
7633 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7634 i32 addrspace(1)* %out, i32 %in, i32 %old) {
7636 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
7637 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") monotonic monotonic
7638 %val0 = extractvalue { i32, i1 } %val, 0
7639 store i32 %val0, i32 addrspace(1)* %out, align 4
7643 define amdgpu_kernel void @global_workgroup_one_as_acquire_monotonic_ret_cmpxchg(
7644 ; GFX6-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
7645 ; GFX6: ; %bb.0: ; %entry
7646 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7647 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
7648 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
7649 ; GFX6-NEXT: s_mov_b32 s2, -1
7650 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7651 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
7652 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
7653 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
7654 ; GFX6-NEXT: s_waitcnt vmcnt(0)
7655 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
7656 ; GFX6-NEXT: s_endpgm
7658 ; GFX7-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
7659 ; GFX7: ; %bb.0: ; %entry
7660 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7661 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
7662 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7663 ; GFX7-NEXT: s_add_u32 s4, s0, 16
7664 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
7665 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
7666 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
7667 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
7668 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
7669 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
7670 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
7671 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
7672 ; GFX7-NEXT: s_waitcnt vmcnt(0)
7673 ; GFX7-NEXT: flat_store_dword v[0:1], v2
7674 ; GFX7-NEXT: s_endpgm
7676 ; GFX10-WGP-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
7677 ; GFX10-WGP: ; %bb.0: ; %entry
7678 ; GFX10-WGP-NEXT: s_clause 0x1
7679 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7680 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
7681 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
7682 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7683 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
7684 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
7685 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
7686 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
7687 ; GFX10-WGP-NEXT: buffer_gl0_inv
7688 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
7689 ; GFX10-WGP-NEXT: s_endpgm
7691 ; GFX10-CU-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
7692 ; GFX10-CU: ; %bb.0: ; %entry
7693 ; GFX10-CU-NEXT: s_clause 0x1
7694 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7695 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
7696 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
7697 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7698 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
7699 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
7700 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
7701 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
7702 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
7703 ; GFX10-CU-NEXT: s_endpgm
7705 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
7706 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7707 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
7708 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
7709 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
7710 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
7711 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7712 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
7713 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
7714 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
7715 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
7716 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
7717 ; SKIP-CACHE-INV-NEXT: s_endpgm
7719 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
7720 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7721 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7722 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
7723 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
7724 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7725 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7726 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
7727 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
7728 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
7729 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7731 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
7732 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7733 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7734 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
7735 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
7736 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7737 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7738 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
7739 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7740 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
7741 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
7742 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7743 i32 addrspace(1)* %out, i32 %in, i32 %old) {
7745 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
7746 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acquire monotonic
7747 %val0 = extractvalue { i32, i1 } %val, 0
7748 store i32 %val0, i32 addrspace(1)* %out, align 4
7752 define amdgpu_kernel void @global_workgroup_one_as_release_monotonic_ret_cmpxchg(
7753 ; GFX6-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
7754 ; GFX6: ; %bb.0: ; %entry
7755 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7756 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
7757 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
7758 ; GFX6-NEXT: s_mov_b32 s2, -1
7759 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7760 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
7761 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
7762 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
7763 ; GFX6-NEXT: s_waitcnt vmcnt(0)
7764 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
7765 ; GFX6-NEXT: s_endpgm
7767 ; GFX7-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
7768 ; GFX7: ; %bb.0: ; %entry
7769 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7770 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
7771 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7772 ; GFX7-NEXT: s_add_u32 s4, s0, 16
7773 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
7774 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
7775 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
7776 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
7777 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
7778 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
7779 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
7780 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
7781 ; GFX7-NEXT: s_waitcnt vmcnt(0)
7782 ; GFX7-NEXT: flat_store_dword v[0:1], v2
7783 ; GFX7-NEXT: s_endpgm
7785 ; GFX10-WGP-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
7786 ; GFX10-WGP: ; %bb.0: ; %entry
7787 ; GFX10-WGP-NEXT: s_clause 0x1
7788 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7789 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
7790 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
7791 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7792 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
7793 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
7794 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
7795 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7796 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
7797 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
7798 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
7799 ; GFX10-WGP-NEXT: s_endpgm
7801 ; GFX10-CU-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
7802 ; GFX10-CU: ; %bb.0: ; %entry
7803 ; GFX10-CU-NEXT: s_clause 0x1
7804 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7805 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
7806 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
7807 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7808 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
7809 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
7810 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
7811 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
7812 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
7813 ; GFX10-CU-NEXT: s_endpgm
7815 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
7816 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7817 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
7818 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
7819 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
7820 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
7821 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7822 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
7823 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
7824 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
7825 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
7826 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
7827 ; SKIP-CACHE-INV-NEXT: s_endpgm
7829 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
7830 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7831 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7832 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
7833 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
7834 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7835 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7836 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
7837 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
7838 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
7839 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7841 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
7842 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7843 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7844 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
7845 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
7846 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7847 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7848 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7849 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
7850 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7851 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
7852 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7853 i32 addrspace(1)* %out, i32 %in, i32 %old) {
7855 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
7856 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") release monotonic
7857 %val0 = extractvalue { i32, i1 } %val, 0
7858 store i32 %val0, i32 addrspace(1)* %out, align 4
7862 define amdgpu_kernel void @global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg(
7863 ; GFX6-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
7864 ; GFX6: ; %bb.0: ; %entry
7865 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7866 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
7867 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
7868 ; GFX6-NEXT: s_mov_b32 s2, -1
7869 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7870 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
7871 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
7872 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
7873 ; GFX6-NEXT: s_waitcnt vmcnt(0)
7874 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
7875 ; GFX6-NEXT: s_endpgm
7877 ; GFX7-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
7878 ; GFX7: ; %bb.0: ; %entry
7879 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7880 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
7881 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7882 ; GFX7-NEXT: s_add_u32 s4, s0, 16
7883 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
7884 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
7885 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
7886 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
7887 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
7888 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
7889 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
7890 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
7891 ; GFX7-NEXT: s_waitcnt vmcnt(0)
7892 ; GFX7-NEXT: flat_store_dword v[0:1], v2
7893 ; GFX7-NEXT: s_endpgm
7895 ; GFX10-WGP-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
7896 ; GFX10-WGP: ; %bb.0: ; %entry
7897 ; GFX10-WGP-NEXT: s_clause 0x1
7898 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7899 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
7900 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
7901 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7902 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
7903 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
7904 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
7905 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7906 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
7907 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
7908 ; GFX10-WGP-NEXT: buffer_gl0_inv
7909 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
7910 ; GFX10-WGP-NEXT: s_endpgm
7912 ; GFX10-CU-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
7913 ; GFX10-CU: ; %bb.0: ; %entry
7914 ; GFX10-CU-NEXT: s_clause 0x1
7915 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
7916 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
7917 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
7918 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7919 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
7920 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
7921 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
7922 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
7923 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
7924 ; GFX10-CU-NEXT: s_endpgm
7926 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
7927 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7928 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
7929 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
7930 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
7931 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
7932 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7933 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
7934 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
7935 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
7936 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
7937 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
7938 ; SKIP-CACHE-INV-NEXT: s_endpgm
7940 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
7941 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7942 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7943 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
7944 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
7945 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7946 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7947 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
7948 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
7949 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
7950 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7952 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
7953 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7954 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7955 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
7956 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
7957 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7958 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7959 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7960 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
7961 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7962 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
7963 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
7964 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7965 i32 addrspace(1)* %out, i32 %in, i32 %old) {
7967 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
7968 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acq_rel monotonic
7969 %val0 = extractvalue { i32, i1 } %val, 0
7970 store i32 %val0, i32 addrspace(1)* %out, align 4
7974 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg(
7975 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
7976 ; GFX6: ; %bb.0: ; %entry
7977 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7978 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
7979 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
7980 ; GFX6-NEXT: s_mov_b32 s2, -1
7981 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7982 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
7983 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
7984 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
7985 ; GFX6-NEXT: s_waitcnt vmcnt(0)
7986 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
7987 ; GFX6-NEXT: s_endpgm
7989 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
7990 ; GFX7: ; %bb.0: ; %entry
7991 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7992 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
7993 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7994 ; GFX7-NEXT: s_add_u32 s4, s0, 16
7995 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
7996 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
7997 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
7998 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
7999 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
8000 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8001 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
8002 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
8003 ; GFX7-NEXT: s_waitcnt vmcnt(0)
8004 ; GFX7-NEXT: flat_store_dword v[0:1], v2
8005 ; GFX7-NEXT: s_endpgm
8007 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
8008 ; GFX10-WGP: ; %bb.0: ; %entry
8009 ; GFX10-WGP-NEXT: s_clause 0x1
8010 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
8011 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
8012 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
8013 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8014 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
8015 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
8016 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8017 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8018 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8019 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8020 ; GFX10-WGP-NEXT: buffer_gl0_inv
8021 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
8022 ; GFX10-WGP-NEXT: s_endpgm
8024 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
8025 ; GFX10-CU: ; %bb.0: ; %entry
8026 ; GFX10-CU-NEXT: s_clause 0x1
8027 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
8028 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
8029 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
8030 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8031 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
8032 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
8033 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8034 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
8035 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
8036 ; GFX10-CU-NEXT: s_endpgm
8038 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
8039 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8040 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
8041 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
8042 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
8043 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
8044 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8045 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
8046 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
8047 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
8048 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
8049 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
8050 ; SKIP-CACHE-INV-NEXT: s_endpgm
8052 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
8053 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8054 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8055 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
8056 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
8057 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8058 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8059 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8060 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
8061 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
8062 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8064 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
8065 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8066 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8067 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
8068 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
8069 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8070 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8071 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8072 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8073 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8074 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
8075 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
8076 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8077 i32 addrspace(1)* %out, i32 %in, i32 %old) {
8079 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
8080 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") seq_cst monotonic
8081 %val0 = extractvalue { i32, i1 } %val, 0
8082 store i32 %val0, i32 addrspace(1)* %out, align 4
8086 define amdgpu_kernel void @global_workgroup_one_as_monotonic_acquire_ret_cmpxchg(
8087 ; GFX6-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
8088 ; GFX6: ; %bb.0: ; %entry
8089 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8090 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
8091 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
8092 ; GFX6-NEXT: s_mov_b32 s2, -1
8093 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8094 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
8095 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
8096 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
8097 ; GFX6-NEXT: s_waitcnt vmcnt(0)
8098 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
8099 ; GFX6-NEXT: s_endpgm
8101 ; GFX7-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
8102 ; GFX7: ; %bb.0: ; %entry
8103 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8104 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
8105 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8106 ; GFX7-NEXT: s_add_u32 s4, s0, 16
8107 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
8108 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
8109 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
8110 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
8111 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
8112 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8113 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
8114 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
8115 ; GFX7-NEXT: s_waitcnt vmcnt(0)
8116 ; GFX7-NEXT: flat_store_dword v[0:1], v2
8117 ; GFX7-NEXT: s_endpgm
8119 ; GFX10-WGP-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
8120 ; GFX10-WGP: ; %bb.0: ; %entry
8121 ; GFX10-WGP-NEXT: s_clause 0x1
8122 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
8123 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
8124 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
8125 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8126 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
8127 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
8128 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8129 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8130 ; GFX10-WGP-NEXT: buffer_gl0_inv
8131 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
8132 ; GFX10-WGP-NEXT: s_endpgm
8134 ; GFX10-CU-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
8135 ; GFX10-CU: ; %bb.0: ; %entry
8136 ; GFX10-CU-NEXT: s_clause 0x1
8137 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
8138 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
8139 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
8140 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8141 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
8142 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
8143 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8144 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
8145 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
8146 ; GFX10-CU-NEXT: s_endpgm
8148 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
8149 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8150 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
8151 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
8152 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
8153 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
8154 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8155 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
8156 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
8157 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
8158 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
8159 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
8160 ; SKIP-CACHE-INV-NEXT: s_endpgm
8162 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
8163 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8164 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8165 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
8166 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
8167 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8168 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8169 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8170 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
8171 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
8172 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8174 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
8175 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8176 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8177 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
8178 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
8179 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8180 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8181 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8182 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8183 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
8184 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
8185 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8186 i32 addrspace(1)* %out, i32 %in, i32 %old) {
8188 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
8189 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") monotonic acquire
8190 %val0 = extractvalue { i32, i1 } %val, 0
8191 store i32 %val0, i32 addrspace(1)* %out, align 4
8195 define amdgpu_kernel void @global_workgroup_one_as_acquire_acquire_ret_cmpxchg(
8196 ; GFX6-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
8197 ; GFX6: ; %bb.0: ; %entry
8198 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8199 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
8200 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
8201 ; GFX6-NEXT: s_mov_b32 s2, -1
8202 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8203 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
8204 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
8205 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
8206 ; GFX6-NEXT: s_waitcnt vmcnt(0)
8207 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
8208 ; GFX6-NEXT: s_endpgm
8210 ; GFX7-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
8211 ; GFX7: ; %bb.0: ; %entry
8212 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8213 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
8214 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8215 ; GFX7-NEXT: s_add_u32 s4, s0, 16
8216 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
8217 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
8218 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
8219 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
8220 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
8221 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8222 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
8223 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
8224 ; GFX7-NEXT: s_waitcnt vmcnt(0)
8225 ; GFX7-NEXT: flat_store_dword v[0:1], v2
8226 ; GFX7-NEXT: s_endpgm
8228 ; GFX10-WGP-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
8229 ; GFX10-WGP: ; %bb.0: ; %entry
8230 ; GFX10-WGP-NEXT: s_clause 0x1
8231 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
8232 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
8233 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
8234 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8235 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
8236 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
8237 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8238 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8239 ; GFX10-WGP-NEXT: buffer_gl0_inv
8240 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
8241 ; GFX10-WGP-NEXT: s_endpgm
8243 ; GFX10-CU-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
8244 ; GFX10-CU: ; %bb.0: ; %entry
8245 ; GFX10-CU-NEXT: s_clause 0x1
8246 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
8247 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
8248 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
8249 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8250 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
8251 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
8252 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8253 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
8254 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
8255 ; GFX10-CU-NEXT: s_endpgm
8257 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
8258 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8259 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
8260 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
8261 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
8262 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
8263 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8264 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
8265 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
8266 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
8267 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
8268 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
8269 ; SKIP-CACHE-INV-NEXT: s_endpgm
8271 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
8272 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8273 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8274 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
8275 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
8276 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8277 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8278 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8279 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
8280 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
8281 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8283 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
8284 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8285 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8286 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
8287 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
8288 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8289 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8290 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8291 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8292 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
8293 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
8294 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8295 i32 addrspace(1)* %out, i32 %in, i32 %old) {
8297 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
8298 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acquire acquire
8299 %val0 = extractvalue { i32, i1 } %val, 0
8300 store i32 %val0, i32 addrspace(1)* %out, align 4
8304 define amdgpu_kernel void @global_workgroup_one_as_release_acquire_ret_cmpxchg(
8305 ; GFX6-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
8306 ; GFX6: ; %bb.0: ; %entry
8307 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8308 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
8309 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
8310 ; GFX6-NEXT: s_mov_b32 s2, -1
8311 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8312 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
8313 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
8314 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
8315 ; GFX6-NEXT: s_waitcnt vmcnt(0)
8316 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
8317 ; GFX6-NEXT: s_endpgm
8319 ; GFX7-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
8320 ; GFX7: ; %bb.0: ; %entry
8321 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8322 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
8323 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8324 ; GFX7-NEXT: s_add_u32 s4, s0, 16
8325 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
8326 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
8327 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
8328 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
8329 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
8330 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8331 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
8332 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
8333 ; GFX7-NEXT: s_waitcnt vmcnt(0)
8334 ; GFX7-NEXT: flat_store_dword v[0:1], v2
8335 ; GFX7-NEXT: s_endpgm
8337 ; GFX10-WGP-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
8338 ; GFX10-WGP: ; %bb.0: ; %entry
8339 ; GFX10-WGP-NEXT: s_clause 0x1
8340 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
8341 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
8342 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
8343 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8344 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
8345 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
8346 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8347 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8348 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8349 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8350 ; GFX10-WGP-NEXT: buffer_gl0_inv
8351 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
8352 ; GFX10-WGP-NEXT: s_endpgm
8354 ; GFX10-CU-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
8355 ; GFX10-CU: ; %bb.0: ; %entry
8356 ; GFX10-CU-NEXT: s_clause 0x1
8357 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
8358 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
8359 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
8360 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8361 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
8362 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
8363 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8364 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
8365 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
8366 ; GFX10-CU-NEXT: s_endpgm
8368 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
8369 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8370 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
8371 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
8372 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
8373 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
8374 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8375 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
8376 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
8377 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
8378 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
8379 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
8380 ; SKIP-CACHE-INV-NEXT: s_endpgm
8382 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
8383 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8384 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8385 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
8386 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
8387 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8388 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8389 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8390 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
8391 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
8392 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8394 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
8395 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8396 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8397 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
8398 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
8399 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8400 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8401 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8402 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8403 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8404 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
8405 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
8406 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8407 i32 addrspace(1)* %out, i32 %in, i32 %old) {
8409 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
8410 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") release acquire
8411 %val0 = extractvalue { i32, i1 } %val, 0
8412 store i32 %val0, i32 addrspace(1)* %out, align 4
8416 define amdgpu_kernel void @global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg(
8417 ; GFX6-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
8418 ; GFX6: ; %bb.0: ; %entry
8419 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8420 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
8421 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
8422 ; GFX6-NEXT: s_mov_b32 s2, -1
8423 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8424 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
8425 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
8426 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
8427 ; GFX6-NEXT: s_waitcnt vmcnt(0)
8428 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
8429 ; GFX6-NEXT: s_endpgm
8431 ; GFX7-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
8432 ; GFX7: ; %bb.0: ; %entry
8433 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8434 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
8435 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8436 ; GFX7-NEXT: s_add_u32 s4, s0, 16
8437 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
8438 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
8439 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
8440 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
8441 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
8442 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8443 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
8444 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
8445 ; GFX7-NEXT: s_waitcnt vmcnt(0)
8446 ; GFX7-NEXT: flat_store_dword v[0:1], v2
8447 ; GFX7-NEXT: s_endpgm
8449 ; GFX10-WGP-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
8450 ; GFX10-WGP: ; %bb.0: ; %entry
8451 ; GFX10-WGP-NEXT: s_clause 0x1
8452 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
8453 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
8454 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
8455 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8456 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
8457 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
8458 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8459 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8460 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8461 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8462 ; GFX10-WGP-NEXT: buffer_gl0_inv
8463 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
8464 ; GFX10-WGP-NEXT: s_endpgm
8466 ; GFX10-CU-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
8467 ; GFX10-CU: ; %bb.0: ; %entry
8468 ; GFX10-CU-NEXT: s_clause 0x1
8469 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
8470 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
8471 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
8472 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8473 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
8474 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
8475 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8476 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
8477 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
8478 ; GFX10-CU-NEXT: s_endpgm
8480 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
8481 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8482 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
8483 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
8484 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
8485 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
8486 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8487 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
8488 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
8489 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
8490 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
8491 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
8492 ; SKIP-CACHE-INV-NEXT: s_endpgm
8494 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
8495 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8496 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8497 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
8498 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
8499 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8500 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8501 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8502 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
8503 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
8504 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8506 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
8507 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8508 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8509 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
8510 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
8511 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8512 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8513 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8514 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8515 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8516 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
8517 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
8518 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8519 i32 addrspace(1)* %out, i32 %in, i32 %old) {
8521 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
8522 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acq_rel acquire
8523 %val0 = extractvalue { i32, i1 } %val, 0
8524 store i32 %val0, i32 addrspace(1)* %out, align 4
8528 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg(
8529 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
8530 ; GFX6: ; %bb.0: ; %entry
8531 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8532 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
8533 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
8534 ; GFX6-NEXT: s_mov_b32 s2, -1
8535 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8536 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
8537 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
8538 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
8539 ; GFX6-NEXT: s_waitcnt vmcnt(0)
8540 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
8541 ; GFX6-NEXT: s_endpgm
8543 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
8544 ; GFX7: ; %bb.0: ; %entry
8545 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8546 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
8547 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8548 ; GFX7-NEXT: s_add_u32 s4, s0, 16
8549 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
8550 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
8551 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
8552 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
8553 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
8554 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8555 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
8556 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
8557 ; GFX7-NEXT: s_waitcnt vmcnt(0)
8558 ; GFX7-NEXT: flat_store_dword v[0:1], v2
8559 ; GFX7-NEXT: s_endpgm
8561 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
8562 ; GFX10-WGP: ; %bb.0: ; %entry
8563 ; GFX10-WGP-NEXT: s_clause 0x1
8564 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
8565 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
8566 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
8567 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8568 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
8569 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
8570 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8571 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8572 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8573 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8574 ; GFX10-WGP-NEXT: buffer_gl0_inv
8575 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
8576 ; GFX10-WGP-NEXT: s_endpgm
8578 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
8579 ; GFX10-CU: ; %bb.0: ; %entry
8580 ; GFX10-CU-NEXT: s_clause 0x1
8581 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
8582 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
8583 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
8584 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8585 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
8586 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
8587 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8588 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
8589 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
8590 ; GFX10-CU-NEXT: s_endpgm
8592 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
8593 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8594 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
8595 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
8596 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
8597 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
8598 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8599 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
8600 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
8601 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
8602 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
8603 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
8604 ; SKIP-CACHE-INV-NEXT: s_endpgm
8606 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
8607 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8608 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8609 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
8610 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
8611 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8612 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8613 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8614 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
8615 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
8616 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8618 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
8619 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8620 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8621 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
8622 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
8623 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8624 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8625 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8626 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8627 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8628 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
8629 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
8630 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8631 i32 addrspace(1)* %out, i32 %in, i32 %old) {
8633 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
8634 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") seq_cst acquire
8635 %val0 = extractvalue { i32, i1 } %val, 0
8636 store i32 %val0, i32 addrspace(1)* %out, align 4
8640 define amdgpu_kernel void @global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg(
8641 ; GFX6-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
8642 ; GFX6: ; %bb.0: ; %entry
8643 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8644 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
8645 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
8646 ; GFX6-NEXT: s_mov_b32 s2, -1
8647 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8648 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
8649 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
8650 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
8651 ; GFX6-NEXT: s_waitcnt vmcnt(0)
8652 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
8653 ; GFX6-NEXT: s_endpgm
8655 ; GFX7-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
8656 ; GFX7: ; %bb.0: ; %entry
8657 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8658 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
8659 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8660 ; GFX7-NEXT: s_add_u32 s4, s0, 16
8661 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
8662 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
8663 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
8664 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
8665 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
8666 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8667 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
8668 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
8669 ; GFX7-NEXT: s_waitcnt vmcnt(0)
8670 ; GFX7-NEXT: flat_store_dword v[0:1], v2
8671 ; GFX7-NEXT: s_endpgm
8673 ; GFX10-WGP-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
8674 ; GFX10-WGP: ; %bb.0: ; %entry
8675 ; GFX10-WGP-NEXT: s_clause 0x1
8676 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
8677 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
8678 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
8679 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8680 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
8681 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
8682 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8683 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8684 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8685 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8686 ; GFX10-WGP-NEXT: buffer_gl0_inv
8687 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
8688 ; GFX10-WGP-NEXT: s_endpgm
8690 ; GFX10-CU-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
8691 ; GFX10-CU: ; %bb.0: ; %entry
8692 ; GFX10-CU-NEXT: s_clause 0x1
8693 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
8694 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
8695 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
8696 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8697 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
8698 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
8699 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8700 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
8701 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
8702 ; GFX10-CU-NEXT: s_endpgm
8704 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
8705 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8706 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
8707 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
8708 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
8709 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
8710 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8711 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
8712 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
8713 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
8714 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
8715 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
8716 ; SKIP-CACHE-INV-NEXT: s_endpgm
8718 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
8719 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8720 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8721 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
8722 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
8723 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8724 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8725 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8726 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
8727 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
8728 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8730 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
8731 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8732 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8733 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
8734 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
8735 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8736 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8737 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8738 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8739 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8740 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
8741 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
8742 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8743 i32 addrspace(1)* %out, i32 %in, i32 %old) {
8745 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
8746 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") monotonic seq_cst
8747 %val0 = extractvalue { i32, i1 } %val, 0
8748 store i32 %val0, i32 addrspace(1)* %out, align 4
8752 define amdgpu_kernel void @global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg(
8753 ; GFX6-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
8754 ; GFX6: ; %bb.0: ; %entry
8755 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8756 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
8757 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
8758 ; GFX6-NEXT: s_mov_b32 s2, -1
8759 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8760 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
8761 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
8762 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
8763 ; GFX6-NEXT: s_waitcnt vmcnt(0)
8764 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
8765 ; GFX6-NEXT: s_endpgm
8767 ; GFX7-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
8768 ; GFX7: ; %bb.0: ; %entry
8769 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8770 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
8771 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8772 ; GFX7-NEXT: s_add_u32 s4, s0, 16
8773 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
8774 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
8775 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
8776 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
8777 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
8778 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8779 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
8780 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
8781 ; GFX7-NEXT: s_waitcnt vmcnt(0)
8782 ; GFX7-NEXT: flat_store_dword v[0:1], v2
8783 ; GFX7-NEXT: s_endpgm
8785 ; GFX10-WGP-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
8786 ; GFX10-WGP: ; %bb.0: ; %entry
8787 ; GFX10-WGP-NEXT: s_clause 0x1
8788 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
8789 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
8790 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
8791 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8792 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
8793 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
8794 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8795 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8796 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8797 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8798 ; GFX10-WGP-NEXT: buffer_gl0_inv
8799 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
8800 ; GFX10-WGP-NEXT: s_endpgm
8802 ; GFX10-CU-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
8803 ; GFX10-CU: ; %bb.0: ; %entry
8804 ; GFX10-CU-NEXT: s_clause 0x1
8805 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
8806 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
8807 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
8808 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8809 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
8810 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
8811 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8812 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
8813 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
8814 ; GFX10-CU-NEXT: s_endpgm
8816 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
8817 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8818 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
8819 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
8820 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
8821 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
8822 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8823 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
8824 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
8825 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
8826 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
8827 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
8828 ; SKIP-CACHE-INV-NEXT: s_endpgm
8830 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
8831 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8832 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8833 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
8834 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
8835 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8836 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8837 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8838 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
8839 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
8840 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8842 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
8843 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8844 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8845 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
8846 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
8847 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8848 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8849 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8850 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8851 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8852 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
8853 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
8854 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8855 i32 addrspace(1)* %out, i32 %in, i32 %old) {
8857 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
8858 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acquire seq_cst
8859 %val0 = extractvalue { i32, i1 } %val, 0
8860 store i32 %val0, i32 addrspace(1)* %out, align 4
8864 define amdgpu_kernel void @global_workgroup_one_as_release_seq_cst_ret_cmpxchg(
8865 ; GFX6-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
8866 ; GFX6: ; %bb.0: ; %entry
8867 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8868 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
8869 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
8870 ; GFX6-NEXT: s_mov_b32 s2, -1
8871 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8872 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
8873 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
8874 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
8875 ; GFX6-NEXT: s_waitcnt vmcnt(0)
8876 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
8877 ; GFX6-NEXT: s_endpgm
8879 ; GFX7-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
8880 ; GFX7: ; %bb.0: ; %entry
8881 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8882 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
8883 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8884 ; GFX7-NEXT: s_add_u32 s4, s0, 16
8885 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
8886 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
8887 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
8888 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
8889 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
8890 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8891 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
8892 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
8893 ; GFX7-NEXT: s_waitcnt vmcnt(0)
8894 ; GFX7-NEXT: flat_store_dword v[0:1], v2
8895 ; GFX7-NEXT: s_endpgm
8897 ; GFX10-WGP-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
8898 ; GFX10-WGP: ; %bb.0: ; %entry
8899 ; GFX10-WGP-NEXT: s_clause 0x1
8900 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
8901 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
8902 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
8903 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8904 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
8905 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
8906 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8907 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8908 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8909 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8910 ; GFX10-WGP-NEXT: buffer_gl0_inv
8911 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
8912 ; GFX10-WGP-NEXT: s_endpgm
8914 ; GFX10-CU-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
8915 ; GFX10-CU: ; %bb.0: ; %entry
8916 ; GFX10-CU-NEXT: s_clause 0x1
8917 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
8918 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
8919 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
8920 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8921 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
8922 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
8923 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8924 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
8925 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
8926 ; GFX10-CU-NEXT: s_endpgm
8928 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
8929 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8930 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
8931 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
8932 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
8933 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
8934 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8935 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
8936 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
8937 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
8938 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
8939 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
8940 ; SKIP-CACHE-INV-NEXT: s_endpgm
8942 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
8943 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8944 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8945 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
8946 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
8947 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8948 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8949 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8950 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
8951 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
8952 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8954 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
8955 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8956 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8957 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
8958 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
8959 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8960 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8961 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8962 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8963 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8964 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
8965 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
8966 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8967 i32 addrspace(1)* %out, i32 %in, i32 %old) {
8969 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
8970 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") release seq_cst
8971 %val0 = extractvalue { i32, i1 } %val, 0
8972 store i32 %val0, i32 addrspace(1)* %out, align 4
8976 define amdgpu_kernel void @global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg(
8977 ; GFX6-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
8978 ; GFX6: ; %bb.0: ; %entry
8979 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8980 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
8981 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
8982 ; GFX6-NEXT: s_mov_b32 s2, -1
8983 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8984 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
8985 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
8986 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
8987 ; GFX6-NEXT: s_waitcnt vmcnt(0)
8988 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
8989 ; GFX6-NEXT: s_endpgm
8991 ; GFX7-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
8992 ; GFX7: ; %bb.0: ; %entry
8993 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8994 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
8995 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8996 ; GFX7-NEXT: s_add_u32 s4, s0, 16
8997 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
8998 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
8999 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
9000 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
9001 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
9002 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9003 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
9004 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
9005 ; GFX7-NEXT: s_waitcnt vmcnt(0)
9006 ; GFX7-NEXT: flat_store_dword v[0:1], v2
9007 ; GFX7-NEXT: s_endpgm
9009 ; GFX10-WGP-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
9010 ; GFX10-WGP: ; %bb.0: ; %entry
9011 ; GFX10-WGP-NEXT: s_clause 0x1
9012 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
9013 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
9014 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
9015 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
9016 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
9017 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
9018 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
9019 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9020 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
9021 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
9022 ; GFX10-WGP-NEXT: buffer_gl0_inv
9023 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
9024 ; GFX10-WGP-NEXT: s_endpgm
9026 ; GFX10-CU-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
9027 ; GFX10-CU: ; %bb.0: ; %entry
9028 ; GFX10-CU-NEXT: s_clause 0x1
9029 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
9030 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
9031 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
9032 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9033 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
9034 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
9035 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
9036 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
9037 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
9038 ; GFX10-CU-NEXT: s_endpgm
9040 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
9041 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
9042 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
9043 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
9044 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
9045 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
9046 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9047 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
9048 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
9049 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
9050 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
9051 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
9052 ; SKIP-CACHE-INV-NEXT: s_endpgm
9054 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
9055 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
9056 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
9057 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
9058 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9059 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9060 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9061 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
9062 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
9063 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
9064 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
9066 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
9067 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
9068 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
9069 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
9070 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9071 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9072 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9073 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9074 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
9075 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9076 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
9077 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
9078 ; GFX90A-TGSPLIT-NEXT: s_endpgm
9079 i32 addrspace(1)* %out, i32 %in, i32 %old) {
9081 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
9082 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acq_rel seq_cst
9083 %val0 = extractvalue { i32, i1 } %val, 0
9084 store i32 %val0, i32 addrspace(1)* %out, align 4
9088 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg(
9089 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
9090 ; GFX6: ; %bb.0: ; %entry
9091 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
9092 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
9093 ; GFX6-NEXT: s_mov_b32 s3, 0x100f000
9094 ; GFX6-NEXT: s_mov_b32 s2, -1
9095 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
9096 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
9097 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
9098 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
9099 ; GFX6-NEXT: s_waitcnt vmcnt(0)
9100 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
9101 ; GFX6-NEXT: s_endpgm
9103 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
9104 ; GFX7: ; %bb.0: ; %entry
9105 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
9106 ; GFX7-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x2
9107 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
9108 ; GFX7-NEXT: s_add_u32 s4, s0, 16
9109 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
9110 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
9111 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
9112 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
9113 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
9114 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9115 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
9116 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
9117 ; GFX7-NEXT: s_waitcnt vmcnt(0)
9118 ; GFX7-NEXT: flat_store_dword v[0:1], v2
9119 ; GFX7-NEXT: s_endpgm
9121 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
9122 ; GFX10-WGP: ; %bb.0: ; %entry
9123 ; GFX10-WGP-NEXT: s_clause 0x1
9124 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
9125 ; GFX10-WGP-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
9126 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, 0
9127 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
9128 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
9129 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
9130 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
9131 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9132 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
9133 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
9134 ; GFX10-WGP-NEXT: buffer_gl0_inv
9135 ; GFX10-WGP-NEXT: global_store_dword v2, v0, s[2:3]
9136 ; GFX10-WGP-NEXT: s_endpgm
9138 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
9139 ; GFX10-CU: ; %bb.0: ; %entry
9140 ; GFX10-CU-NEXT: s_clause 0x1
9141 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
9142 ; GFX10-CU-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
9143 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, 0
9144 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9145 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
9146 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
9147 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
9148 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
9149 ; GFX10-CU-NEXT: global_store_dword v2, v0, s[2:3]
9150 ; GFX10-CU-NEXT: s_endpgm
9152 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
9153 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
9154 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
9155 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
9156 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, 0xf000
9157 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
9158 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9159 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
9160 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
9161 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
9162 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
9163 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[4:7], 0
9164 ; SKIP-CACHE-INV-NEXT: s_endpgm
9166 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
9167 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
9168 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
9169 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
9170 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9171 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9172 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9173 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
9174 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
9175 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
9176 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
9178 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
9179 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
9180 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
9181 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x8
9182 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, 0
9183 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9184 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9185 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9186 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
9187 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9188 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
9189 ; GFX90A-TGSPLIT-NEXT: global_store_dword v2, v0, s[0:1]
9190 ; GFX90A-TGSPLIT-NEXT: s_endpgm
9191 i32 addrspace(1)* %out, i32 %in, i32 %old) {
9193 %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
9194 %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("workgroup-one-as") seq_cst seq_cst
9195 %val0 = extractvalue { i32, i1 } %val, 0
9196 store i32 %val0, i32 addrspace(1)* %out, align 4