[ORC] Add std::tuple support to SimplePackedSerialization.
[llvm-project.git] / llvm / test / CodeGen / AMDGPU / memory-legalizer-global-agent.ll
blobfb078ddb13f727d8dddb2e33899e72a1b0b1ab79
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_agent_unordered_load(
11 ; GFX6-LABEL: global_agent_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
26 ; GFX6-NEXT:    s_endpgm
28 ; GFX7-LABEL: global_agent_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
39 ; GFX7-NEXT:    s_endpgm
41 ; GFX10-WGP-LABEL: global_agent_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_agent_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_agent_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_agent_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_agent_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) {
98 entry:
99   %val = load atomic i32, i32 addrspace(1)* %in syncscope("agent") unordered, align 4
100   store i32 %val, i32 addrspace(1)* %out
101   ret void
104 define amdgpu_kernel void @global_agent_monotonic_load(
105 ; GFX6-LABEL: global_agent_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 glc
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_agent_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] glc
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_agent_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 dlc
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_agent_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] glc dlc
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_agent_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 glc
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_agent_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] glc
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_agent_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) {
192 entry:
193   %val = load atomic i32, i32 addrspace(1)* %in syncscope("agent") monotonic, align 4
194   store i32 %val, i32 addrspace(1)* %out
195   ret void
198 define amdgpu_kernel void @global_agent_acquire_load(
199 ; GFX6-LABEL: global_agent_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 glc
208 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
209 ; GFX6-NEXT:    buffer_wbinvl1
210 ; GFX6-NEXT:    s_mov_b32 s4, s6
211 ; GFX6-NEXT:    s_mov_b32 s5, s7
212 ; GFX6-NEXT:    s_mov_b32 s6, s2
213 ; GFX6-NEXT:    s_mov_b32 s7, s3
214 ; GFX6-NEXT:    buffer_store_dword v0, off, s[4:7], 0
215 ; GFX6-NEXT:    s_endpgm
217 ; GFX7-LABEL: global_agent_acquire_load:
218 ; GFX7:       ; %bb.0: ; %entry
219 ; GFX7-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
220 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
221 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
222 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
223 ; GFX7-NEXT:    flat_load_dword v0, v[0:1] glc
224 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
225 ; GFX7-NEXT:    buffer_wbinvl1_vol
226 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
227 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
228 ; GFX7-NEXT:    flat_store_dword v[2:3], v0
229 ; GFX7-NEXT:    s_endpgm
231 ; GFX10-WGP-LABEL: global_agent_acquire_load:
232 ; GFX10-WGP:       ; %bb.0: ; %entry
233 ; GFX10-WGP-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
234 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, 0
235 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
236 ; GFX10-WGP-NEXT:    global_load_dword v1, v0, s[0:1] glc dlc
237 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
238 ; GFX10-WGP-NEXT:    buffer_gl0_inv
239 ; GFX10-WGP-NEXT:    buffer_gl1_inv
240 ; GFX10-WGP-NEXT:    global_store_dword v0, v1, s[2:3]
241 ; GFX10-WGP-NEXT:    s_endpgm
243 ; GFX10-CU-LABEL: global_agent_acquire_load:
244 ; GFX10-CU:       ; %bb.0: ; %entry
245 ; GFX10-CU-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
246 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, 0
247 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
248 ; GFX10-CU-NEXT:    global_load_dword v1, v0, s[0:1] glc dlc
249 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
250 ; GFX10-CU-NEXT:    buffer_gl0_inv
251 ; GFX10-CU-NEXT:    buffer_gl1_inv
252 ; GFX10-CU-NEXT:    global_store_dword v0, v1, s[2:3]
253 ; GFX10-CU-NEXT:    s_endpgm
255 ; SKIP-CACHE-INV-LABEL: global_agent_acquire_load:
256 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
257 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx4 s[4:7], s[0:1], 0x9
258 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s3, 0xf000
259 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s2, -1
260 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
261 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s0, s4
262 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s1, s5
263 ; SKIP-CACHE-INV-NEXT:    buffer_load_dword v0, off, s[0:3], 0 glc
264 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
265 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s4, s6
266 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s5, s7
267 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, s2
268 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, s3
269 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
270 ; SKIP-CACHE-INV-NEXT:    s_endpgm
272 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_acquire_load:
273 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
274 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
275 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
276 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
277 ; GFX90A-NOTTGSPLIT-NEXT:    global_load_dword v1, v0, s[0:1] glc
278 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
279 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
280 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v0, v1, s[2:3]
281 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
283 ; GFX90A-TGSPLIT-LABEL: global_agent_acquire_load:
284 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
285 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
286 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
287 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
288 ; GFX90A-TGSPLIT-NEXT:    global_load_dword v1, v0, s[0:1] glc
289 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
290 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
291 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v0, v1, s[2:3]
292 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
293     i32 addrspace(1)* %in, i32 addrspace(1)* %out) {
294 entry:
295   %val = load atomic i32, i32 addrspace(1)* %in syncscope("agent") acquire, align 4
296   store i32 %val, i32 addrspace(1)* %out
297   ret void
300 define amdgpu_kernel void @global_agent_seq_cst_load(
301 ; GFX6-LABEL: global_agent_seq_cst_load:
302 ; GFX6:       ; %bb.0: ; %entry
303 ; GFX6-NEXT:    s_load_dwordx4 s[4:7], s[4:5], 0x0
304 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
305 ; GFX6-NEXT:    s_mov_b32 s2, -1
306 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
307 ; GFX6-NEXT:    s_mov_b32 s0, s4
308 ; GFX6-NEXT:    s_mov_b32 s1, s5
309 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
310 ; GFX6-NEXT:    buffer_load_dword v0, off, s[0:3], 0 glc
311 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
312 ; GFX6-NEXT:    buffer_wbinvl1
313 ; GFX6-NEXT:    s_mov_b32 s4, s6
314 ; GFX6-NEXT:    s_mov_b32 s5, s7
315 ; GFX6-NEXT:    s_mov_b32 s6, s2
316 ; GFX6-NEXT:    s_mov_b32 s7, s3
317 ; GFX6-NEXT:    buffer_store_dword v0, off, s[4:7], 0
318 ; GFX6-NEXT:    s_endpgm
320 ; GFX7-LABEL: global_agent_seq_cst_load:
321 ; GFX7:       ; %bb.0: ; %entry
322 ; GFX7-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
323 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
324 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
325 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
326 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
327 ; GFX7-NEXT:    flat_load_dword v0, v[0:1] glc
328 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
329 ; GFX7-NEXT:    buffer_wbinvl1_vol
330 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
331 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
332 ; GFX7-NEXT:    flat_store_dword v[2:3], v0
333 ; GFX7-NEXT:    s_endpgm
335 ; GFX10-WGP-LABEL: global_agent_seq_cst_load:
336 ; GFX10-WGP:       ; %bb.0: ; %entry
337 ; GFX10-WGP-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
338 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, 0
339 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
340 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
341 ; GFX10-WGP-NEXT:    global_load_dword v1, v0, s[0:1] glc dlc
342 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
343 ; GFX10-WGP-NEXT:    buffer_gl0_inv
344 ; GFX10-WGP-NEXT:    buffer_gl1_inv
345 ; GFX10-WGP-NEXT:    global_store_dword v0, v1, s[2:3]
346 ; GFX10-WGP-NEXT:    s_endpgm
348 ; GFX10-CU-LABEL: global_agent_seq_cst_load:
349 ; GFX10-CU:       ; %bb.0: ; %entry
350 ; GFX10-CU-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
351 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, 0
352 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
353 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
354 ; GFX10-CU-NEXT:    global_load_dword v1, v0, s[0:1] glc dlc
355 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
356 ; GFX10-CU-NEXT:    buffer_gl0_inv
357 ; GFX10-CU-NEXT:    buffer_gl1_inv
358 ; GFX10-CU-NEXT:    global_store_dword v0, v1, s[2:3]
359 ; GFX10-CU-NEXT:    s_endpgm
361 ; SKIP-CACHE-INV-LABEL: global_agent_seq_cst_load:
362 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
363 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx4 s[4:7], s[0:1], 0x9
364 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s3, 0xf000
365 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s2, -1
366 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
367 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s0, s4
368 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s1, s5
369 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
370 ; SKIP-CACHE-INV-NEXT:    buffer_load_dword v0, off, s[0:3], 0 glc
371 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
372 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s4, s6
373 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s5, s7
374 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, s2
375 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, s3
376 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
377 ; SKIP-CACHE-INV-NEXT:    s_endpgm
379 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_seq_cst_load:
380 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
381 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
382 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
383 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
384 ; GFX90A-NOTTGSPLIT-NEXT:    global_load_dword v1, v0, s[0:1] glc
385 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
386 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
387 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v0, v1, s[2:3]
388 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
390 ; GFX90A-TGSPLIT-LABEL: global_agent_seq_cst_load:
391 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
392 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
393 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
394 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
395 ; GFX90A-TGSPLIT-NEXT:    global_load_dword v1, v0, s[0:1] glc
396 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
397 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
398 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v0, v1, s[2:3]
399 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
400     i32 addrspace(1)* %in, i32 addrspace(1)* %out) {
401 entry:
402   %val = load atomic i32, i32 addrspace(1)* %in syncscope("agent") seq_cst, align 4
403   store i32 %val, i32 addrspace(1)* %out
404   ret void
407 define amdgpu_kernel void @global_agent_unordered_store(
408 ; GFX6-LABEL: global_agent_unordered_store:
409 ; GFX6:       ; %bb.0: ; %entry
410 ; GFX6-NEXT:    s_load_dword s6, s[4:5], 0x0
411 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x2
412 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
413 ; GFX6-NEXT:    s_mov_b32 s2, -1
414 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
415 ; GFX6-NEXT:    v_mov_b32_e32 v0, s6
416 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
417 ; GFX6-NEXT:    s_endpgm
419 ; GFX7-LABEL: global_agent_unordered_store:
420 ; GFX7:       ; %bb.0: ; %entry
421 ; GFX7-NEXT:    s_load_dword s2, s[4:5], 0x0
422 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x2
423 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
424 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
425 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
426 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
427 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
428 ; GFX7-NEXT:    s_endpgm
430 ; GFX10-WGP-LABEL: global_agent_unordered_store:
431 ; GFX10-WGP:       ; %bb.0: ; %entry
432 ; GFX10-WGP-NEXT:    s_clause 0x1
433 ; GFX10-WGP-NEXT:    s_load_dword s2, s[4:5], 0x0
434 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
435 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, 0
436 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
437 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s2
438 ; GFX10-WGP-NEXT:    global_store_dword v0, v1, s[0:1]
439 ; GFX10-WGP-NEXT:    s_endpgm
441 ; GFX10-CU-LABEL: global_agent_unordered_store:
442 ; GFX10-CU:       ; %bb.0: ; %entry
443 ; GFX10-CU-NEXT:    s_clause 0x1
444 ; GFX10-CU-NEXT:    s_load_dword s2, s[4:5], 0x0
445 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
446 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, 0
447 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
448 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s2
449 ; GFX10-CU-NEXT:    global_store_dword v0, v1, s[0:1]
450 ; GFX10-CU-NEXT:    s_endpgm
452 ; SKIP-CACHE-INV-LABEL: global_agent_unordered_store:
453 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
454 ; SKIP-CACHE-INV-NEXT:    s_load_dword s4, s[0:1], 0x9
455 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
456 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s3, 0xf000
457 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s2, -1
458 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
459 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s4
460 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[0:3], 0
461 ; SKIP-CACHE-INV-NEXT:    s_endpgm
463 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_unordered_store:
464 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
465 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x0
466 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
467 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
468 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
469 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
470 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v0, v1, s[0:1]
471 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
473 ; GFX90A-TGSPLIT-LABEL: global_agent_unordered_store:
474 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
475 ; GFX90A-TGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x0
476 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
477 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
478 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
479 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
480 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v0, v1, s[0:1]
481 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
482     i32 %in, i32 addrspace(1)* %out) {
483 entry:
484   store atomic i32 %in, i32 addrspace(1)* %out syncscope("agent") unordered, align 4
485   ret void
488 define amdgpu_kernel void @global_agent_monotonic_store(
489 ; GFX6-LABEL: global_agent_monotonic_store:
490 ; GFX6:       ; %bb.0: ; %entry
491 ; GFX6-NEXT:    s_load_dword s6, s[4:5], 0x0
492 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x2
493 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
494 ; GFX6-NEXT:    s_mov_b32 s2, -1
495 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
496 ; GFX6-NEXT:    v_mov_b32_e32 v0, s6
497 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
498 ; GFX6-NEXT:    s_endpgm
500 ; GFX7-LABEL: global_agent_monotonic_store:
501 ; GFX7:       ; %bb.0: ; %entry
502 ; GFX7-NEXT:    s_load_dword s2, s[4:5], 0x0
503 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x2
504 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
505 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
506 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
507 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
508 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
509 ; GFX7-NEXT:    s_endpgm
511 ; GFX10-WGP-LABEL: global_agent_monotonic_store:
512 ; GFX10-WGP:       ; %bb.0: ; %entry
513 ; GFX10-WGP-NEXT:    s_clause 0x1
514 ; GFX10-WGP-NEXT:    s_load_dword s2, s[4:5], 0x0
515 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
516 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, 0
517 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
518 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s2
519 ; GFX10-WGP-NEXT:    global_store_dword v0, v1, s[0:1]
520 ; GFX10-WGP-NEXT:    s_endpgm
522 ; GFX10-CU-LABEL: global_agent_monotonic_store:
523 ; GFX10-CU:       ; %bb.0: ; %entry
524 ; GFX10-CU-NEXT:    s_clause 0x1
525 ; GFX10-CU-NEXT:    s_load_dword s2, s[4:5], 0x0
526 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
527 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, 0
528 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
529 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s2
530 ; GFX10-CU-NEXT:    global_store_dword v0, v1, s[0:1]
531 ; GFX10-CU-NEXT:    s_endpgm
533 ; SKIP-CACHE-INV-LABEL: global_agent_monotonic_store:
534 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
535 ; SKIP-CACHE-INV-NEXT:    s_load_dword s4, s[0:1], 0x9
536 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
537 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s3, 0xf000
538 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s2, -1
539 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
540 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s4
541 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[0:3], 0
542 ; SKIP-CACHE-INV-NEXT:    s_endpgm
544 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_monotonic_store:
545 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
546 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x0
547 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
548 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
549 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
550 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
551 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v0, v1, s[0:1]
552 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
554 ; GFX90A-TGSPLIT-LABEL: global_agent_monotonic_store:
555 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
556 ; GFX90A-TGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x0
557 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
558 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
559 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
560 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
561 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v0, v1, s[0:1]
562 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
563     i32 %in, i32 addrspace(1)* %out) {
564 entry:
565   store atomic i32 %in, i32 addrspace(1)* %out syncscope("agent") monotonic, align 4
566   ret void
569 define amdgpu_kernel void @global_agent_release_store(
570 ; GFX6-LABEL: global_agent_release_store:
571 ; GFX6:       ; %bb.0: ; %entry
572 ; GFX6-NEXT:    s_load_dword s6, s[4:5], 0x0
573 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x2
574 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
575 ; GFX6-NEXT:    s_mov_b32 s2, -1
576 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
577 ; GFX6-NEXT:    v_mov_b32_e32 v0, s6
578 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
579 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
580 ; GFX6-NEXT:    s_endpgm
582 ; GFX7-LABEL: global_agent_release_store:
583 ; GFX7:       ; %bb.0: ; %entry
584 ; GFX7-NEXT:    s_load_dword s2, s[4:5], 0x0
585 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x2
586 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
587 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
588 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
589 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
590 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
591 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
592 ; GFX7-NEXT:    s_endpgm
594 ; GFX10-WGP-LABEL: global_agent_release_store:
595 ; GFX10-WGP:       ; %bb.0: ; %entry
596 ; GFX10-WGP-NEXT:    s_clause 0x1
597 ; GFX10-WGP-NEXT:    s_load_dword s2, s[4:5], 0x0
598 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
599 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, 0
600 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
601 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s2
602 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
603 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
604 ; GFX10-WGP-NEXT:    global_store_dword v0, v1, s[0:1]
605 ; GFX10-WGP-NEXT:    s_endpgm
607 ; GFX10-CU-LABEL: global_agent_release_store:
608 ; GFX10-CU:       ; %bb.0: ; %entry
609 ; GFX10-CU-NEXT:    s_clause 0x1
610 ; GFX10-CU-NEXT:    s_load_dword s2, s[4:5], 0x0
611 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
612 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, 0
613 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
614 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s2
615 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
616 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
617 ; GFX10-CU-NEXT:    global_store_dword v0, v1, s[0:1]
618 ; GFX10-CU-NEXT:    s_endpgm
620 ; SKIP-CACHE-INV-LABEL: global_agent_release_store:
621 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
622 ; SKIP-CACHE-INV-NEXT:    s_load_dword s4, s[0:1], 0x9
623 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
624 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s3, 0xf000
625 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s2, -1
626 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
627 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s4
628 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
629 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[0:3], 0
630 ; SKIP-CACHE-INV-NEXT:    s_endpgm
632 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_release_store:
633 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
634 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x0
635 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
636 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
637 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
638 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
639 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
640 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v0, v1, s[0:1]
641 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
643 ; GFX90A-TGSPLIT-LABEL: global_agent_release_store:
644 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
645 ; GFX90A-TGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x0
646 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
647 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
648 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
649 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
650 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
651 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v0, v1, s[0:1]
652 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
653     i32 %in, i32 addrspace(1)* %out) {
654 entry:
655   store atomic i32 %in, i32 addrspace(1)* %out syncscope("agent") release, align 4
656   ret void
659 define amdgpu_kernel void @global_agent_seq_cst_store(
660 ; GFX6-LABEL: global_agent_seq_cst_store:
661 ; GFX6:       ; %bb.0: ; %entry
662 ; GFX6-NEXT:    s_load_dword s6, s[4:5], 0x0
663 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x2
664 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
665 ; GFX6-NEXT:    s_mov_b32 s2, -1
666 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
667 ; GFX6-NEXT:    v_mov_b32_e32 v0, s6
668 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
669 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
670 ; GFX6-NEXT:    s_endpgm
672 ; GFX7-LABEL: global_agent_seq_cst_store:
673 ; GFX7:       ; %bb.0: ; %entry
674 ; GFX7-NEXT:    s_load_dword s2, s[4:5], 0x0
675 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x2
676 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
677 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
678 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
679 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
680 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
681 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
682 ; GFX7-NEXT:    s_endpgm
684 ; GFX10-WGP-LABEL: global_agent_seq_cst_store:
685 ; GFX10-WGP:       ; %bb.0: ; %entry
686 ; GFX10-WGP-NEXT:    s_clause 0x1
687 ; GFX10-WGP-NEXT:    s_load_dword s2, s[4:5], 0x0
688 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
689 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, 0
690 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
691 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s2
692 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
693 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
694 ; GFX10-WGP-NEXT:    global_store_dword v0, v1, s[0:1]
695 ; GFX10-WGP-NEXT:    s_endpgm
697 ; GFX10-CU-LABEL: global_agent_seq_cst_store:
698 ; GFX10-CU:       ; %bb.0: ; %entry
699 ; GFX10-CU-NEXT:    s_clause 0x1
700 ; GFX10-CU-NEXT:    s_load_dword s2, s[4:5], 0x0
701 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
702 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, 0
703 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
704 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s2
705 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
706 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
707 ; GFX10-CU-NEXT:    global_store_dword v0, v1, s[0:1]
708 ; GFX10-CU-NEXT:    s_endpgm
710 ; SKIP-CACHE-INV-LABEL: global_agent_seq_cst_store:
711 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
712 ; SKIP-CACHE-INV-NEXT:    s_load_dword s4, s[0:1], 0x9
713 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
714 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s3, 0xf000
715 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s2, -1
716 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
717 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s4
718 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
719 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[0:3], 0
720 ; SKIP-CACHE-INV-NEXT:    s_endpgm
722 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_seq_cst_store:
723 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
724 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x0
725 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
726 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
727 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
728 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
729 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
730 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v0, v1, s[0:1]
731 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
733 ; GFX90A-TGSPLIT-LABEL: global_agent_seq_cst_store:
734 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
735 ; GFX90A-TGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x0
736 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
737 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
738 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
739 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
740 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
741 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v0, v1, s[0:1]
742 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
743     i32 %in, i32 addrspace(1)* %out) {
744 entry:
745   store atomic i32 %in, i32 addrspace(1)* %out syncscope("agent") seq_cst, align 4
746   ret void
749 define amdgpu_kernel void @global_agent_monotonic_atomicrmw(
750 ; GFX6-LABEL: global_agent_monotonic_atomicrmw:
751 ; GFX6:       ; %bb.0: ; %entry
752 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
753 ; GFX6-NEXT:    s_load_dword s4, s[4:5], 0x2
754 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
755 ; GFX6-NEXT:    s_mov_b32 s2, -1
756 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
757 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
758 ; GFX6-NEXT:    buffer_atomic_swap v0, off, s[0:3], 0
759 ; GFX6-NEXT:    s_endpgm
761 ; GFX7-LABEL: global_agent_monotonic_atomicrmw:
762 ; GFX7:       ; %bb.0: ; %entry
763 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
764 ; GFX7-NEXT:    s_load_dword s2, s[4:5], 0x2
765 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
766 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
767 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
768 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
769 ; GFX7-NEXT:    flat_atomic_swap v[0:1], v2
770 ; GFX7-NEXT:    s_endpgm
772 ; GFX10-WGP-LABEL: global_agent_monotonic_atomicrmw:
773 ; GFX10-WGP:       ; %bb.0: ; %entry
774 ; GFX10-WGP-NEXT:    s_clause 0x1
775 ; GFX10-WGP-NEXT:    s_load_dword s2, s[4:5], 0x8
776 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
777 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, 0
778 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
779 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s2
780 ; GFX10-WGP-NEXT:    global_atomic_swap v0, v1, s[0:1]
781 ; GFX10-WGP-NEXT:    s_endpgm
783 ; GFX10-CU-LABEL: global_agent_monotonic_atomicrmw:
784 ; GFX10-CU:       ; %bb.0: ; %entry
785 ; GFX10-CU-NEXT:    s_clause 0x1
786 ; GFX10-CU-NEXT:    s_load_dword s2, s[4:5], 0x8
787 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
788 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, 0
789 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
790 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s2
791 ; GFX10-CU-NEXT:    global_atomic_swap v0, v1, s[0:1]
792 ; GFX10-CU-NEXT:    s_endpgm
794 ; SKIP-CACHE-INV-LABEL: global_agent_monotonic_atomicrmw:
795 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
796 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
797 ; SKIP-CACHE-INV-NEXT:    s_load_dword s0, s[0:1], 0xb
798 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
799 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
800 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
801 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
802 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_swap v0, off, s[4:7], 0
803 ; SKIP-CACHE-INV-NEXT:    s_endpgm
805 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_monotonic_atomicrmw:
806 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
807 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
808 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
809 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
810 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
811 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
812 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_swap v0, v1, s[0:1]
813 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
815 ; GFX90A-TGSPLIT-LABEL: global_agent_monotonic_atomicrmw:
816 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
817 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
818 ; GFX90A-TGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
819 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
820 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
821 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
822 ; GFX90A-TGSPLIT-NEXT:    global_atomic_swap v0, v1, s[0:1]
823 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
824     i32 addrspace(1)* %out, i32 %in) {
825 entry:
826   %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("agent") monotonic
827   ret void
830 define amdgpu_kernel void @global_agent_acquire_atomicrmw(
831 ; GFX6-LABEL: global_agent_acquire_atomicrmw:
832 ; GFX6:       ; %bb.0: ; %entry
833 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
834 ; GFX6-NEXT:    s_load_dword s4, s[4:5], 0x2
835 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
836 ; GFX6-NEXT:    s_mov_b32 s2, -1
837 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
838 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
839 ; GFX6-NEXT:    buffer_atomic_swap v0, off, s[0:3], 0
840 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
841 ; GFX6-NEXT:    buffer_wbinvl1
842 ; GFX6-NEXT:    s_endpgm
844 ; GFX7-LABEL: global_agent_acquire_atomicrmw:
845 ; GFX7:       ; %bb.0: ; %entry
846 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
847 ; GFX7-NEXT:    s_load_dword s2, s[4:5], 0x2
848 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
849 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
850 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
851 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
852 ; GFX7-NEXT:    flat_atomic_swap v[0:1], v2
853 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
854 ; GFX7-NEXT:    buffer_wbinvl1_vol
855 ; GFX7-NEXT:    s_endpgm
857 ; GFX10-WGP-LABEL: global_agent_acquire_atomicrmw:
858 ; GFX10-WGP:       ; %bb.0: ; %entry
859 ; GFX10-WGP-NEXT:    s_clause 0x1
860 ; GFX10-WGP-NEXT:    s_load_dword s2, s[4:5], 0x8
861 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
862 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, 0
863 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
864 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s2
865 ; GFX10-WGP-NEXT:    global_atomic_swap v0, v1, s[0:1]
866 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
867 ; GFX10-WGP-NEXT:    buffer_gl0_inv
868 ; GFX10-WGP-NEXT:    buffer_gl1_inv
869 ; GFX10-WGP-NEXT:    s_endpgm
871 ; GFX10-CU-LABEL: global_agent_acquire_atomicrmw:
872 ; GFX10-CU:       ; %bb.0: ; %entry
873 ; GFX10-CU-NEXT:    s_clause 0x1
874 ; GFX10-CU-NEXT:    s_load_dword s2, s[4:5], 0x8
875 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
876 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, 0
877 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
878 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s2
879 ; GFX10-CU-NEXT:    global_atomic_swap v0, v1, s[0:1]
880 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
881 ; GFX10-CU-NEXT:    buffer_gl0_inv
882 ; GFX10-CU-NEXT:    buffer_gl1_inv
883 ; GFX10-CU-NEXT:    s_endpgm
885 ; SKIP-CACHE-INV-LABEL: global_agent_acquire_atomicrmw:
886 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
887 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
888 ; SKIP-CACHE-INV-NEXT:    s_load_dword s0, s[0:1], 0xb
889 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
890 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
891 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
892 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
893 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_swap v0, off, s[4:7], 0
894 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
895 ; SKIP-CACHE-INV-NEXT:    s_endpgm
897 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_acquire_atomicrmw:
898 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
899 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
900 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
901 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
902 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
903 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
904 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_swap v0, v1, s[0:1]
905 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
906 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
907 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
909 ; GFX90A-TGSPLIT-LABEL: global_agent_acquire_atomicrmw:
910 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
911 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
912 ; GFX90A-TGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
913 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
914 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
915 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
916 ; GFX90A-TGSPLIT-NEXT:    global_atomic_swap v0, v1, s[0:1]
917 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
918 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
919 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
920     i32 addrspace(1)* %out, i32 %in) {
921 entry:
922   %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("agent") acquire
923   ret void
926 define amdgpu_kernel void @global_agent_release_atomicrmw(
927 ; GFX6-LABEL: global_agent_release_atomicrmw:
928 ; GFX6:       ; %bb.0: ; %entry
929 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
930 ; GFX6-NEXT:    s_load_dword s4, s[4:5], 0x2
931 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
932 ; GFX6-NEXT:    s_mov_b32 s2, -1
933 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
934 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
935 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
936 ; GFX6-NEXT:    buffer_atomic_swap v0, off, s[0:3], 0
937 ; GFX6-NEXT:    s_endpgm
939 ; GFX7-LABEL: global_agent_release_atomicrmw:
940 ; GFX7:       ; %bb.0: ; %entry
941 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
942 ; GFX7-NEXT:    s_load_dword s2, s[4:5], 0x2
943 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
944 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
945 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
946 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
947 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
948 ; GFX7-NEXT:    flat_atomic_swap v[0:1], v2
949 ; GFX7-NEXT:    s_endpgm
951 ; GFX10-WGP-LABEL: global_agent_release_atomicrmw:
952 ; GFX10-WGP:       ; %bb.0: ; %entry
953 ; GFX10-WGP-NEXT:    s_clause 0x1
954 ; GFX10-WGP-NEXT:    s_load_dword s2, s[4:5], 0x8
955 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
956 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, 0
957 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
958 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s2
959 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
960 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
961 ; GFX10-WGP-NEXT:    global_atomic_swap v0, v1, s[0:1]
962 ; GFX10-WGP-NEXT:    s_endpgm
964 ; GFX10-CU-LABEL: global_agent_release_atomicrmw:
965 ; GFX10-CU:       ; %bb.0: ; %entry
966 ; GFX10-CU-NEXT:    s_clause 0x1
967 ; GFX10-CU-NEXT:    s_load_dword s2, s[4:5], 0x8
968 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
969 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, 0
970 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
971 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s2
972 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
973 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
974 ; GFX10-CU-NEXT:    global_atomic_swap v0, v1, s[0:1]
975 ; GFX10-CU-NEXT:    s_endpgm
977 ; SKIP-CACHE-INV-LABEL: global_agent_release_atomicrmw:
978 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
979 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
980 ; SKIP-CACHE-INV-NEXT:    s_load_dword s0, s[0:1], 0xb
981 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
982 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
983 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
984 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
985 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
986 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_swap v0, off, s[4:7], 0
987 ; SKIP-CACHE-INV-NEXT:    s_endpgm
989 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_release_atomicrmw:
990 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
991 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
992 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
993 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
994 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
995 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
996 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
997 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_swap v0, v1, s[0:1]
998 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
1000 ; GFX90A-TGSPLIT-LABEL: global_agent_release_atomicrmw:
1001 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
1002 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1003 ; GFX90A-TGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
1004 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
1005 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
1006 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
1007 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1008 ; GFX90A-TGSPLIT-NEXT:    global_atomic_swap v0, v1, s[0:1]
1009 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
1010     i32 addrspace(1)* %out, i32 %in) {
1011 entry:
1012   %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("agent") release
1013   ret void
1016 define amdgpu_kernel void @global_agent_acq_rel_atomicrmw(
1017 ; GFX6-LABEL: global_agent_acq_rel_atomicrmw:
1018 ; GFX6:       ; %bb.0: ; %entry
1019 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1020 ; GFX6-NEXT:    s_load_dword s4, s[4:5], 0x2
1021 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
1022 ; GFX6-NEXT:    s_mov_b32 s2, -1
1023 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
1024 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
1025 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1026 ; GFX6-NEXT:    buffer_atomic_swap v0, off, s[0:3], 0
1027 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
1028 ; GFX6-NEXT:    buffer_wbinvl1
1029 ; GFX6-NEXT:    s_endpgm
1031 ; GFX7-LABEL: global_agent_acq_rel_atomicrmw:
1032 ; GFX7:       ; %bb.0: ; %entry
1033 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1034 ; GFX7-NEXT:    s_load_dword s2, s[4:5], 0x2
1035 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
1036 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
1037 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
1038 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
1039 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1040 ; GFX7-NEXT:    flat_atomic_swap v[0:1], v2
1041 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
1042 ; GFX7-NEXT:    buffer_wbinvl1_vol
1043 ; GFX7-NEXT:    s_endpgm
1045 ; GFX10-WGP-LABEL: global_agent_acq_rel_atomicrmw:
1046 ; GFX10-WGP:       ; %bb.0: ; %entry
1047 ; GFX10-WGP-NEXT:    s_clause 0x1
1048 ; GFX10-WGP-NEXT:    s_load_dword s2, s[4:5], 0x8
1049 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1050 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, 0
1051 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
1052 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s2
1053 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1054 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
1055 ; GFX10-WGP-NEXT:    global_atomic_swap v0, v1, s[0:1]
1056 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
1057 ; GFX10-WGP-NEXT:    buffer_gl0_inv
1058 ; GFX10-WGP-NEXT:    buffer_gl1_inv
1059 ; GFX10-WGP-NEXT:    s_endpgm
1061 ; GFX10-CU-LABEL: global_agent_acq_rel_atomicrmw:
1062 ; GFX10-CU:       ; %bb.0: ; %entry
1063 ; GFX10-CU-NEXT:    s_clause 0x1
1064 ; GFX10-CU-NEXT:    s_load_dword s2, s[4:5], 0x8
1065 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1066 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, 0
1067 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
1068 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s2
1069 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1070 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
1071 ; GFX10-CU-NEXT:    global_atomic_swap v0, v1, s[0:1]
1072 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
1073 ; GFX10-CU-NEXT:    buffer_gl0_inv
1074 ; GFX10-CU-NEXT:    buffer_gl1_inv
1075 ; GFX10-CU-NEXT:    s_endpgm
1077 ; SKIP-CACHE-INV-LABEL: global_agent_acq_rel_atomicrmw:
1078 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
1079 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
1080 ; SKIP-CACHE-INV-NEXT:    s_load_dword s0, s[0:1], 0xb
1081 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
1082 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
1083 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
1084 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
1085 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1086 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_swap v0, off, s[4:7], 0
1087 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
1088 ; SKIP-CACHE-INV-NEXT:    s_endpgm
1090 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_acq_rel_atomicrmw:
1091 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
1092 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1093 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
1094 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
1095 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
1096 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
1097 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1098 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_swap v0, v1, s[0:1]
1099 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
1100 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
1101 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
1103 ; GFX90A-TGSPLIT-LABEL: global_agent_acq_rel_atomicrmw:
1104 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
1105 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1106 ; GFX90A-TGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
1107 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
1108 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
1109 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
1110 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1111 ; GFX90A-TGSPLIT-NEXT:    global_atomic_swap v0, v1, s[0:1]
1112 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
1113 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
1114 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
1115     i32 addrspace(1)* %out, i32 %in) {
1116 entry:
1117   %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("agent") acq_rel
1118   ret void
1121 define amdgpu_kernel void @global_agent_seq_cst_atomicrmw(
1122 ; GFX6-LABEL: global_agent_seq_cst_atomicrmw:
1123 ; GFX6:       ; %bb.0: ; %entry
1124 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1125 ; GFX6-NEXT:    s_load_dword s4, s[4:5], 0x2
1126 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
1127 ; GFX6-NEXT:    s_mov_b32 s2, -1
1128 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
1129 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
1130 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1131 ; GFX6-NEXT:    buffer_atomic_swap v0, off, s[0:3], 0
1132 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
1133 ; GFX6-NEXT:    buffer_wbinvl1
1134 ; GFX6-NEXT:    s_endpgm
1136 ; GFX7-LABEL: global_agent_seq_cst_atomicrmw:
1137 ; GFX7:       ; %bb.0: ; %entry
1138 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1139 ; GFX7-NEXT:    s_load_dword s2, s[4:5], 0x2
1140 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
1141 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
1142 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
1143 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
1144 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1145 ; GFX7-NEXT:    flat_atomic_swap v[0:1], v2
1146 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
1147 ; GFX7-NEXT:    buffer_wbinvl1_vol
1148 ; GFX7-NEXT:    s_endpgm
1150 ; GFX10-WGP-LABEL: global_agent_seq_cst_atomicrmw:
1151 ; GFX10-WGP:       ; %bb.0: ; %entry
1152 ; GFX10-WGP-NEXT:    s_clause 0x1
1153 ; GFX10-WGP-NEXT:    s_load_dword s2, s[4:5], 0x8
1154 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1155 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, 0
1156 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
1157 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s2
1158 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1159 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
1160 ; GFX10-WGP-NEXT:    global_atomic_swap v0, v1, s[0:1]
1161 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
1162 ; GFX10-WGP-NEXT:    buffer_gl0_inv
1163 ; GFX10-WGP-NEXT:    buffer_gl1_inv
1164 ; GFX10-WGP-NEXT:    s_endpgm
1166 ; GFX10-CU-LABEL: global_agent_seq_cst_atomicrmw:
1167 ; GFX10-CU:       ; %bb.0: ; %entry
1168 ; GFX10-CU-NEXT:    s_clause 0x1
1169 ; GFX10-CU-NEXT:    s_load_dword s2, s[4:5], 0x8
1170 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1171 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, 0
1172 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
1173 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s2
1174 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1175 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
1176 ; GFX10-CU-NEXT:    global_atomic_swap v0, v1, s[0:1]
1177 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
1178 ; GFX10-CU-NEXT:    buffer_gl0_inv
1179 ; GFX10-CU-NEXT:    buffer_gl1_inv
1180 ; GFX10-CU-NEXT:    s_endpgm
1182 ; SKIP-CACHE-INV-LABEL: global_agent_seq_cst_atomicrmw:
1183 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
1184 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
1185 ; SKIP-CACHE-INV-NEXT:    s_load_dword s0, s[0:1], 0xb
1186 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
1187 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
1188 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
1189 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
1190 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1191 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_swap v0, off, s[4:7], 0
1192 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
1193 ; SKIP-CACHE-INV-NEXT:    s_endpgm
1195 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_seq_cst_atomicrmw:
1196 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
1197 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1198 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
1199 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
1200 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
1201 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
1202 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1203 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_swap v0, v1, s[0:1]
1204 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
1205 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
1206 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
1208 ; GFX90A-TGSPLIT-LABEL: global_agent_seq_cst_atomicrmw:
1209 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
1210 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1211 ; GFX90A-TGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
1212 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
1213 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
1214 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
1215 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1216 ; GFX90A-TGSPLIT-NEXT:    global_atomic_swap v0, v1, s[0:1]
1217 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
1218 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
1219 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
1220     i32 addrspace(1)* %out, i32 %in) {
1221 entry:
1222   %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("agent") seq_cst
1223   ret void
1226 define amdgpu_kernel void @global_agent_acquire_ret_atomicrmw(
1227 ; GFX6-LABEL: global_agent_acquire_ret_atomicrmw:
1228 ; GFX6:       ; %bb.0: ; %entry
1229 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1230 ; GFX6-NEXT:    s_load_dword s4, s[4:5], 0x2
1231 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
1232 ; GFX6-NEXT:    s_mov_b32 s2, -1
1233 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
1234 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
1235 ; GFX6-NEXT:    buffer_atomic_swap v0, off, s[0:3], 0 glc
1236 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
1237 ; GFX6-NEXT:    buffer_wbinvl1
1238 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
1239 ; GFX6-NEXT:    s_endpgm
1241 ; GFX7-LABEL: global_agent_acquire_ret_atomicrmw:
1242 ; GFX7:       ; %bb.0: ; %entry
1243 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1244 ; GFX7-NEXT:    s_load_dword s2, s[4:5], 0x2
1245 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
1246 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
1247 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
1248 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
1249 ; GFX7-NEXT:    flat_atomic_swap v2, v[0:1], v2 glc
1250 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
1251 ; GFX7-NEXT:    buffer_wbinvl1_vol
1252 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
1253 ; GFX7-NEXT:    s_endpgm
1255 ; GFX10-WGP-LABEL: global_agent_acquire_ret_atomicrmw:
1256 ; GFX10-WGP:       ; %bb.0: ; %entry
1257 ; GFX10-WGP-NEXT:    s_clause 0x1
1258 ; GFX10-WGP-NEXT:    s_load_dword s2, s[4:5], 0x8
1259 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1260 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, 0
1261 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
1262 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s2
1263 ; GFX10-WGP-NEXT:    global_atomic_swap v1, v0, v1, s[0:1] glc
1264 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
1265 ; GFX10-WGP-NEXT:    buffer_gl0_inv
1266 ; GFX10-WGP-NEXT:    buffer_gl1_inv
1267 ; GFX10-WGP-NEXT:    global_store_dword v0, v1, s[0:1]
1268 ; GFX10-WGP-NEXT:    s_endpgm
1270 ; GFX10-CU-LABEL: global_agent_acquire_ret_atomicrmw:
1271 ; GFX10-CU:       ; %bb.0: ; %entry
1272 ; GFX10-CU-NEXT:    s_clause 0x1
1273 ; GFX10-CU-NEXT:    s_load_dword s2, s[4:5], 0x8
1274 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1275 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, 0
1276 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
1277 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s2
1278 ; GFX10-CU-NEXT:    global_atomic_swap v1, v0, v1, s[0:1] glc
1279 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
1280 ; GFX10-CU-NEXT:    buffer_gl0_inv
1281 ; GFX10-CU-NEXT:    buffer_gl1_inv
1282 ; GFX10-CU-NEXT:    global_store_dword v0, v1, s[0:1]
1283 ; GFX10-CU-NEXT:    s_endpgm
1285 ; SKIP-CACHE-INV-LABEL: global_agent_acquire_ret_atomicrmw:
1286 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
1287 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
1288 ; SKIP-CACHE-INV-NEXT:    s_load_dword s0, s[0:1], 0xb
1289 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
1290 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
1291 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
1292 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
1293 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_swap v0, off, s[4:7], 0 glc
1294 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
1295 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
1296 ; SKIP-CACHE-INV-NEXT:    s_endpgm
1298 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_acquire_ret_atomicrmw:
1299 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
1300 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1301 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
1302 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
1303 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
1304 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
1305 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_swap v1, v0, v1, s[0:1] glc
1306 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
1307 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
1308 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v0, v1, s[0:1]
1309 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
1311 ; GFX90A-TGSPLIT-LABEL: global_agent_acquire_ret_atomicrmw:
1312 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
1313 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1314 ; GFX90A-TGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
1315 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
1316 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
1317 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
1318 ; GFX90A-TGSPLIT-NEXT:    global_atomic_swap v1, v0, v1, s[0:1] glc
1319 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
1320 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
1321 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v0, v1, s[0:1]
1322 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
1323     i32 addrspace(1)* %out, i32 %in) {
1324 entry:
1325   %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("agent") acquire
1326   store i32 %val, i32 addrspace(1)* %out, align 4
1327   ret void
1330 define amdgpu_kernel void @global_agent_acq_rel_ret_atomicrmw(
1331 ; GFX6-LABEL: global_agent_acq_rel_ret_atomicrmw:
1332 ; GFX6:       ; %bb.0: ; %entry
1333 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1334 ; GFX6-NEXT:    s_load_dword s4, s[4:5], 0x2
1335 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
1336 ; GFX6-NEXT:    s_mov_b32 s2, -1
1337 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
1338 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
1339 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1340 ; GFX6-NEXT:    buffer_atomic_swap v0, off, s[0:3], 0 glc
1341 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
1342 ; GFX6-NEXT:    buffer_wbinvl1
1343 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
1344 ; GFX6-NEXT:    s_endpgm
1346 ; GFX7-LABEL: global_agent_acq_rel_ret_atomicrmw:
1347 ; GFX7:       ; %bb.0: ; %entry
1348 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1349 ; GFX7-NEXT:    s_load_dword s2, s[4:5], 0x2
1350 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
1351 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
1352 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
1353 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
1354 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1355 ; GFX7-NEXT:    flat_atomic_swap v2, v[0:1], v2 glc
1356 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
1357 ; GFX7-NEXT:    buffer_wbinvl1_vol
1358 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
1359 ; GFX7-NEXT:    s_endpgm
1361 ; GFX10-WGP-LABEL: global_agent_acq_rel_ret_atomicrmw:
1362 ; GFX10-WGP:       ; %bb.0: ; %entry
1363 ; GFX10-WGP-NEXT:    s_clause 0x1
1364 ; GFX10-WGP-NEXT:    s_load_dword s2, s[4:5], 0x8
1365 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1366 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, 0
1367 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
1368 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s2
1369 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1370 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
1371 ; GFX10-WGP-NEXT:    global_atomic_swap v1, v0, v1, s[0:1] glc
1372 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
1373 ; GFX10-WGP-NEXT:    buffer_gl0_inv
1374 ; GFX10-WGP-NEXT:    buffer_gl1_inv
1375 ; GFX10-WGP-NEXT:    global_store_dword v0, v1, s[0:1]
1376 ; GFX10-WGP-NEXT:    s_endpgm
1378 ; GFX10-CU-LABEL: global_agent_acq_rel_ret_atomicrmw:
1379 ; GFX10-CU:       ; %bb.0: ; %entry
1380 ; GFX10-CU-NEXT:    s_clause 0x1
1381 ; GFX10-CU-NEXT:    s_load_dword s2, s[4:5], 0x8
1382 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1383 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, 0
1384 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
1385 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s2
1386 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1387 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
1388 ; GFX10-CU-NEXT:    global_atomic_swap v1, v0, v1, s[0:1] glc
1389 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
1390 ; GFX10-CU-NEXT:    buffer_gl0_inv
1391 ; GFX10-CU-NEXT:    buffer_gl1_inv
1392 ; GFX10-CU-NEXT:    global_store_dword v0, v1, s[0:1]
1393 ; GFX10-CU-NEXT:    s_endpgm
1395 ; SKIP-CACHE-INV-LABEL: global_agent_acq_rel_ret_atomicrmw:
1396 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
1397 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
1398 ; SKIP-CACHE-INV-NEXT:    s_load_dword s0, s[0:1], 0xb
1399 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
1400 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
1401 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
1402 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
1403 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1404 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_swap v0, off, s[4:7], 0 glc
1405 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
1406 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
1407 ; SKIP-CACHE-INV-NEXT:    s_endpgm
1409 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_acq_rel_ret_atomicrmw:
1410 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
1411 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1412 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
1413 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
1414 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
1415 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
1416 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1417 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_swap v1, v0, v1, s[0:1] glc
1418 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
1419 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
1420 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v0, v1, s[0:1]
1421 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
1423 ; GFX90A-TGSPLIT-LABEL: global_agent_acq_rel_ret_atomicrmw:
1424 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
1425 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1426 ; GFX90A-TGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
1427 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
1428 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
1429 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
1430 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1431 ; GFX90A-TGSPLIT-NEXT:    global_atomic_swap v1, v0, v1, s[0:1] glc
1432 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
1433 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
1434 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v0, v1, s[0:1]
1435 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
1436     i32 addrspace(1)* %out, i32 %in) {
1437 entry:
1438   %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("agent") acq_rel
1439   store i32 %val, i32 addrspace(1)* %out, align 4
1440   ret void
1443 define amdgpu_kernel void @global_agent_seq_cst_ret_atomicrmw(
1444 ; GFX6-LABEL: global_agent_seq_cst_ret_atomicrmw:
1445 ; GFX6:       ; %bb.0: ; %entry
1446 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1447 ; GFX6-NEXT:    s_load_dword s4, s[4:5], 0x2
1448 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
1449 ; GFX6-NEXT:    s_mov_b32 s2, -1
1450 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
1451 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
1452 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1453 ; GFX6-NEXT:    buffer_atomic_swap v0, off, s[0:3], 0 glc
1454 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
1455 ; GFX6-NEXT:    buffer_wbinvl1
1456 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
1457 ; GFX6-NEXT:    s_endpgm
1459 ; GFX7-LABEL: global_agent_seq_cst_ret_atomicrmw:
1460 ; GFX7:       ; %bb.0: ; %entry
1461 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1462 ; GFX7-NEXT:    s_load_dword s2, s[4:5], 0x2
1463 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
1464 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
1465 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
1466 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
1467 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1468 ; GFX7-NEXT:    flat_atomic_swap v2, v[0:1], v2 glc
1469 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
1470 ; GFX7-NEXT:    buffer_wbinvl1_vol
1471 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
1472 ; GFX7-NEXT:    s_endpgm
1474 ; GFX10-WGP-LABEL: global_agent_seq_cst_ret_atomicrmw:
1475 ; GFX10-WGP:       ; %bb.0: ; %entry
1476 ; GFX10-WGP-NEXT:    s_clause 0x1
1477 ; GFX10-WGP-NEXT:    s_load_dword s2, s[4:5], 0x8
1478 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1479 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, 0
1480 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
1481 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s2
1482 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1483 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
1484 ; GFX10-WGP-NEXT:    global_atomic_swap v1, v0, v1, s[0:1] glc
1485 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
1486 ; GFX10-WGP-NEXT:    buffer_gl0_inv
1487 ; GFX10-WGP-NEXT:    buffer_gl1_inv
1488 ; GFX10-WGP-NEXT:    global_store_dword v0, v1, s[0:1]
1489 ; GFX10-WGP-NEXT:    s_endpgm
1491 ; GFX10-CU-LABEL: global_agent_seq_cst_ret_atomicrmw:
1492 ; GFX10-CU:       ; %bb.0: ; %entry
1493 ; GFX10-CU-NEXT:    s_clause 0x1
1494 ; GFX10-CU-NEXT:    s_load_dword s2, s[4:5], 0x8
1495 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1496 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, 0
1497 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
1498 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s2
1499 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1500 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
1501 ; GFX10-CU-NEXT:    global_atomic_swap v1, v0, v1, s[0:1] glc
1502 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
1503 ; GFX10-CU-NEXT:    buffer_gl0_inv
1504 ; GFX10-CU-NEXT:    buffer_gl1_inv
1505 ; GFX10-CU-NEXT:    global_store_dword v0, v1, s[0:1]
1506 ; GFX10-CU-NEXT:    s_endpgm
1508 ; SKIP-CACHE-INV-LABEL: global_agent_seq_cst_ret_atomicrmw:
1509 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
1510 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
1511 ; SKIP-CACHE-INV-NEXT:    s_load_dword s0, s[0:1], 0xb
1512 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
1513 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
1514 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
1515 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
1516 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1517 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_swap v0, off, s[4:7], 0 glc
1518 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
1519 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
1520 ; SKIP-CACHE-INV-NEXT:    s_endpgm
1522 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_seq_cst_ret_atomicrmw:
1523 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
1524 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1525 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
1526 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
1527 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
1528 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
1529 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1530 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_swap v1, v0, v1, s[0:1] glc
1531 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
1532 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
1533 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v0, v1, s[0:1]
1534 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
1536 ; GFX90A-TGSPLIT-LABEL: global_agent_seq_cst_ret_atomicrmw:
1537 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
1538 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1539 ; GFX90A-TGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
1540 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
1541 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
1542 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
1543 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1544 ; GFX90A-TGSPLIT-NEXT:    global_atomic_swap v1, v0, v1, s[0:1] glc
1545 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
1546 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
1547 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v0, v1, s[0:1]
1548 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
1549     i32 addrspace(1)* %out, i32 %in) {
1550 entry:
1551   %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("agent") seq_cst
1552   store i32 %val, i32 addrspace(1)* %out, align 4
1553   ret void
1556 define amdgpu_kernel void @global_agent_monotonic_monotonic_cmpxchg(
1557 ; GFX6-LABEL: global_agent_monotonic_monotonic_cmpxchg:
1558 ; GFX6:       ; %bb.0: ; %entry
1559 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1560 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
1561 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
1562 ; GFX6-NEXT:    s_mov_b32 s2, -1
1563 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
1564 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
1565 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
1566 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
1567 ; GFX6-NEXT:    s_endpgm
1569 ; GFX7-LABEL: global_agent_monotonic_monotonic_cmpxchg:
1570 ; GFX7:       ; %bb.0: ; %entry
1571 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1572 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
1573 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
1574 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
1575 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
1576 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
1577 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
1578 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
1579 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
1580 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
1581 ; GFX7-NEXT:    s_endpgm
1583 ; GFX10-WGP-LABEL: global_agent_monotonic_monotonic_cmpxchg:
1584 ; GFX10-WGP:       ; %bb.0: ; %entry
1585 ; GFX10-WGP-NEXT:    s_clause 0x1
1586 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
1587 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
1588 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
1589 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
1590 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
1591 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
1592 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
1593 ; GFX10-WGP-NEXT:    s_endpgm
1595 ; GFX10-CU-LABEL: global_agent_monotonic_monotonic_cmpxchg:
1596 ; GFX10-CU:       ; %bb.0: ; %entry
1597 ; GFX10-CU-NEXT:    s_clause 0x1
1598 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
1599 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
1600 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
1601 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
1602 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
1603 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
1604 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
1605 ; GFX10-CU-NEXT:    s_endpgm
1607 ; SKIP-CACHE-INV-LABEL: global_agent_monotonic_monotonic_cmpxchg:
1608 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
1609 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
1610 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
1611 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
1612 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
1613 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
1614 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
1615 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
1616 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
1617 ; SKIP-CACHE-INV-NEXT:    s_endpgm
1619 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_monotonic_monotonic_cmpxchg:
1620 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
1621 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1622 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
1623 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
1624 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
1625 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
1626 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
1627 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
1629 ; GFX90A-TGSPLIT-LABEL: global_agent_monotonic_monotonic_cmpxchg:
1630 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
1631 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1632 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
1633 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
1634 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
1635 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
1636 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
1637 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
1638     i32 addrspace(1)* %out, i32 %in, i32 %old) {
1639 entry:
1640   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
1641   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") monotonic monotonic
1642   ret void
1645 define amdgpu_kernel void @global_agent_acquire_monotonic_cmpxchg(
1646 ; GFX6-LABEL: global_agent_acquire_monotonic_cmpxchg:
1647 ; GFX6:       ; %bb.0: ; %entry
1648 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1649 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
1650 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
1651 ; GFX6-NEXT:    s_mov_b32 s2, -1
1652 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
1653 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
1654 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
1655 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
1656 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
1657 ; GFX6-NEXT:    buffer_wbinvl1
1658 ; GFX6-NEXT:    s_endpgm
1660 ; GFX7-LABEL: global_agent_acquire_monotonic_cmpxchg:
1661 ; GFX7:       ; %bb.0: ; %entry
1662 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1663 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
1664 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
1665 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
1666 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
1667 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
1668 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
1669 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
1670 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
1671 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
1672 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
1673 ; GFX7-NEXT:    buffer_wbinvl1_vol
1674 ; GFX7-NEXT:    s_endpgm
1676 ; GFX10-WGP-LABEL: global_agent_acquire_monotonic_cmpxchg:
1677 ; GFX10-WGP:       ; %bb.0: ; %entry
1678 ; GFX10-WGP-NEXT:    s_clause 0x1
1679 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
1680 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
1681 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
1682 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
1683 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
1684 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
1685 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
1686 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
1687 ; GFX10-WGP-NEXT:    buffer_gl0_inv
1688 ; GFX10-WGP-NEXT:    buffer_gl1_inv
1689 ; GFX10-WGP-NEXT:    s_endpgm
1691 ; GFX10-CU-LABEL: global_agent_acquire_monotonic_cmpxchg:
1692 ; GFX10-CU:       ; %bb.0: ; %entry
1693 ; GFX10-CU-NEXT:    s_clause 0x1
1694 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
1695 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
1696 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
1697 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
1698 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
1699 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
1700 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
1701 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
1702 ; GFX10-CU-NEXT:    buffer_gl0_inv
1703 ; GFX10-CU-NEXT:    buffer_gl1_inv
1704 ; GFX10-CU-NEXT:    s_endpgm
1706 ; SKIP-CACHE-INV-LABEL: global_agent_acquire_monotonic_cmpxchg:
1707 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
1708 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
1709 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
1710 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
1711 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
1712 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
1713 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
1714 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
1715 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
1716 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
1717 ; SKIP-CACHE-INV-NEXT:    s_endpgm
1719 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_acquire_monotonic_cmpxchg:
1720 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
1721 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1722 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
1723 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
1724 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
1725 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
1726 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
1727 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
1728 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
1729 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
1731 ; GFX90A-TGSPLIT-LABEL: global_agent_acquire_monotonic_cmpxchg:
1732 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
1733 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1734 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
1735 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
1736 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
1737 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
1738 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
1739 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
1740 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
1741 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
1742     i32 addrspace(1)* %out, i32 %in, i32 %old) {
1743 entry:
1744   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
1745   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") acquire monotonic
1746   ret void
1749 define amdgpu_kernel void @global_agent_release_monotonic_cmpxchg(
1750 ; GFX6-LABEL: global_agent_release_monotonic_cmpxchg:
1751 ; GFX6:       ; %bb.0: ; %entry
1752 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1753 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
1754 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
1755 ; GFX6-NEXT:    s_mov_b32 s2, -1
1756 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
1757 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
1758 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
1759 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1760 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
1761 ; GFX6-NEXT:    s_endpgm
1763 ; GFX7-LABEL: global_agent_release_monotonic_cmpxchg:
1764 ; GFX7:       ; %bb.0: ; %entry
1765 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1766 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
1767 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
1768 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
1769 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
1770 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
1771 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
1772 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
1773 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
1774 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1775 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
1776 ; GFX7-NEXT:    s_endpgm
1778 ; GFX10-WGP-LABEL: global_agent_release_monotonic_cmpxchg:
1779 ; GFX10-WGP:       ; %bb.0: ; %entry
1780 ; GFX10-WGP-NEXT:    s_clause 0x1
1781 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
1782 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
1783 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
1784 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
1785 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
1786 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
1787 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1788 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
1789 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
1790 ; GFX10-WGP-NEXT:    s_endpgm
1792 ; GFX10-CU-LABEL: global_agent_release_monotonic_cmpxchg:
1793 ; GFX10-CU:       ; %bb.0: ; %entry
1794 ; GFX10-CU-NEXT:    s_clause 0x1
1795 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
1796 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
1797 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
1798 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
1799 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
1800 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
1801 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1802 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
1803 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
1804 ; GFX10-CU-NEXT:    s_endpgm
1806 ; SKIP-CACHE-INV-LABEL: global_agent_release_monotonic_cmpxchg:
1807 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
1808 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
1809 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
1810 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
1811 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
1812 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
1813 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
1814 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
1815 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1816 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
1817 ; SKIP-CACHE-INV-NEXT:    s_endpgm
1819 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_release_monotonic_cmpxchg:
1820 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
1821 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1822 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
1823 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
1824 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
1825 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
1826 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1827 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
1828 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
1830 ; GFX90A-TGSPLIT-LABEL: global_agent_release_monotonic_cmpxchg:
1831 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
1832 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1833 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
1834 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
1835 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
1836 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
1837 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1838 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
1839 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
1840     i32 addrspace(1)* %out, i32 %in, i32 %old) {
1841 entry:
1842   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
1843   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") release monotonic
1844   ret void
1847 define amdgpu_kernel void @global_agent_acq_rel_monotonic_cmpxchg(
1848 ; GFX6-LABEL: global_agent_acq_rel_monotonic_cmpxchg:
1849 ; GFX6:       ; %bb.0: ; %entry
1850 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1851 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
1852 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
1853 ; GFX6-NEXT:    s_mov_b32 s2, -1
1854 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
1855 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
1856 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
1857 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1858 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
1859 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
1860 ; GFX6-NEXT:    buffer_wbinvl1
1861 ; GFX6-NEXT:    s_endpgm
1863 ; GFX7-LABEL: global_agent_acq_rel_monotonic_cmpxchg:
1864 ; GFX7:       ; %bb.0: ; %entry
1865 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1866 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
1867 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
1868 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
1869 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
1870 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
1871 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
1872 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
1873 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
1874 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1875 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
1876 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
1877 ; GFX7-NEXT:    buffer_wbinvl1_vol
1878 ; GFX7-NEXT:    s_endpgm
1880 ; GFX10-WGP-LABEL: global_agent_acq_rel_monotonic_cmpxchg:
1881 ; GFX10-WGP:       ; %bb.0: ; %entry
1882 ; GFX10-WGP-NEXT:    s_clause 0x1
1883 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
1884 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
1885 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
1886 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
1887 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
1888 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
1889 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1890 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
1891 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
1892 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
1893 ; GFX10-WGP-NEXT:    buffer_gl0_inv
1894 ; GFX10-WGP-NEXT:    buffer_gl1_inv
1895 ; GFX10-WGP-NEXT:    s_endpgm
1897 ; GFX10-CU-LABEL: global_agent_acq_rel_monotonic_cmpxchg:
1898 ; GFX10-CU:       ; %bb.0: ; %entry
1899 ; GFX10-CU-NEXT:    s_clause 0x1
1900 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
1901 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
1902 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
1903 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
1904 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
1905 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
1906 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1907 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
1908 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
1909 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
1910 ; GFX10-CU-NEXT:    buffer_gl0_inv
1911 ; GFX10-CU-NEXT:    buffer_gl1_inv
1912 ; GFX10-CU-NEXT:    s_endpgm
1914 ; SKIP-CACHE-INV-LABEL: global_agent_acq_rel_monotonic_cmpxchg:
1915 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
1916 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
1917 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
1918 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
1919 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
1920 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
1921 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
1922 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
1923 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1924 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
1925 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
1926 ; SKIP-CACHE-INV-NEXT:    s_endpgm
1928 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_acq_rel_monotonic_cmpxchg:
1929 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
1930 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1931 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
1932 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
1933 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
1934 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
1935 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1936 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
1937 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
1938 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
1939 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
1941 ; GFX90A-TGSPLIT-LABEL: global_agent_acq_rel_monotonic_cmpxchg:
1942 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
1943 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1944 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
1945 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
1946 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
1947 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
1948 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1949 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
1950 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
1951 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
1952 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
1953     i32 addrspace(1)* %out, i32 %in, i32 %old) {
1954 entry:
1955   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
1956   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") acq_rel monotonic
1957   ret void
1960 define amdgpu_kernel void @global_agent_seq_cst_monotonic_cmpxchg(
1961 ; GFX6-LABEL: global_agent_seq_cst_monotonic_cmpxchg:
1962 ; GFX6:       ; %bb.0: ; %entry
1963 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1964 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
1965 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
1966 ; GFX6-NEXT:    s_mov_b32 s2, -1
1967 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
1968 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
1969 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
1970 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1971 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
1972 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
1973 ; GFX6-NEXT:    buffer_wbinvl1
1974 ; GFX6-NEXT:    s_endpgm
1976 ; GFX7-LABEL: global_agent_seq_cst_monotonic_cmpxchg:
1977 ; GFX7:       ; %bb.0: ; %entry
1978 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
1979 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
1980 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
1981 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
1982 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
1983 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
1984 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
1985 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
1986 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
1987 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
1988 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
1989 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
1990 ; GFX7-NEXT:    buffer_wbinvl1_vol
1991 ; GFX7-NEXT:    s_endpgm
1993 ; GFX10-WGP-LABEL: global_agent_seq_cst_monotonic_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:    s_waitcnt vmcnt(0) lgkmcnt(0)
2003 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
2004 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2005 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
2006 ; GFX10-WGP-NEXT:    buffer_gl0_inv
2007 ; GFX10-WGP-NEXT:    buffer_gl1_inv
2008 ; GFX10-WGP-NEXT:    s_endpgm
2010 ; GFX10-CU-LABEL: global_agent_seq_cst_monotonic_cmpxchg:
2011 ; GFX10-CU:       ; %bb.0: ; %entry
2012 ; GFX10-CU-NEXT:    s_clause 0x1
2013 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
2014 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
2015 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
2016 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
2017 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
2018 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
2019 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2020 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
2021 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2022 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
2023 ; GFX10-CU-NEXT:    buffer_gl0_inv
2024 ; GFX10-CU-NEXT:    buffer_gl1_inv
2025 ; GFX10-CU-NEXT:    s_endpgm
2027 ; SKIP-CACHE-INV-LABEL: global_agent_seq_cst_monotonic_cmpxchg:
2028 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
2029 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
2030 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
2031 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
2032 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
2033 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
2034 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
2035 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
2036 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2037 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2038 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
2039 ; SKIP-CACHE-INV-NEXT:    s_endpgm
2041 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_seq_cst_monotonic_cmpxchg:
2042 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
2043 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2044 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
2045 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
2046 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
2047 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2048 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2049 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2050 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
2051 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
2052 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
2054 ; GFX90A-TGSPLIT-LABEL: global_agent_seq_cst_monotonic_cmpxchg:
2055 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
2056 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2057 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
2058 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
2059 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
2060 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2061 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2062 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2063 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
2064 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
2065 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
2066     i32 addrspace(1)* %out, i32 %in, i32 %old) {
2067 entry:
2068   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
2069   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") seq_cst monotonic
2070   ret void
2073 define amdgpu_kernel void @global_agent_monotonic_acquire_cmpxchg(
2074 ; GFX6-LABEL: global_agent_monotonic_acquire_cmpxchg:
2075 ; GFX6:       ; %bb.0: ; %entry
2076 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2077 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
2078 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
2079 ; GFX6-NEXT:    s_mov_b32 s2, -1
2080 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
2081 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
2082 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
2083 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
2084 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
2085 ; GFX6-NEXT:    buffer_wbinvl1
2086 ; GFX6-NEXT:    s_endpgm
2088 ; GFX7-LABEL: global_agent_monotonic_acquire_cmpxchg:
2089 ; GFX7:       ; %bb.0: ; %entry
2090 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2091 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
2092 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
2093 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
2094 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
2095 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
2096 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
2097 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
2098 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
2099 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
2100 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
2101 ; GFX7-NEXT:    buffer_wbinvl1_vol
2102 ; GFX7-NEXT:    s_endpgm
2104 ; GFX10-WGP-LABEL: global_agent_monotonic_acquire_cmpxchg:
2105 ; GFX10-WGP:       ; %bb.0: ; %entry
2106 ; GFX10-WGP-NEXT:    s_clause 0x1
2107 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
2108 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
2109 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
2110 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
2111 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
2112 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
2113 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2114 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
2115 ; GFX10-WGP-NEXT:    buffer_gl0_inv
2116 ; GFX10-WGP-NEXT:    buffer_gl1_inv
2117 ; GFX10-WGP-NEXT:    s_endpgm
2119 ; GFX10-CU-LABEL: global_agent_monotonic_acquire_cmpxchg:
2120 ; GFX10-CU:       ; %bb.0: ; %entry
2121 ; GFX10-CU-NEXT:    s_clause 0x1
2122 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
2123 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
2124 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
2125 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
2126 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
2127 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
2128 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2129 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
2130 ; GFX10-CU-NEXT:    buffer_gl0_inv
2131 ; GFX10-CU-NEXT:    buffer_gl1_inv
2132 ; GFX10-CU-NEXT:    s_endpgm
2134 ; SKIP-CACHE-INV-LABEL: global_agent_monotonic_acquire_cmpxchg:
2135 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
2136 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
2137 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
2138 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
2139 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
2140 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
2141 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
2142 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
2143 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2144 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
2145 ; SKIP-CACHE-INV-NEXT:    s_endpgm
2147 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_monotonic_acquire_cmpxchg:
2148 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
2149 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2150 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
2151 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
2152 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
2153 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2154 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2155 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
2156 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
2157 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
2159 ; GFX90A-TGSPLIT-LABEL: global_agent_monotonic_acquire_cmpxchg:
2160 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
2161 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2162 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
2163 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
2164 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
2165 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2166 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2167 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
2168 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
2169 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
2170     i32 addrspace(1)* %out, i32 %in, i32 %old) {
2171 entry:
2172   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
2173   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") monotonic acquire
2174   ret void
2177 define amdgpu_kernel void @global_agent_acquire_acquire_cmpxchg(
2178 ; GFX6-LABEL: global_agent_acquire_acquire_cmpxchg:
2179 ; GFX6:       ; %bb.0: ; %entry
2180 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2181 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
2182 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
2183 ; GFX6-NEXT:    s_mov_b32 s2, -1
2184 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
2185 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
2186 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
2187 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
2188 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
2189 ; GFX6-NEXT:    buffer_wbinvl1
2190 ; GFX6-NEXT:    s_endpgm
2192 ; GFX7-LABEL: global_agent_acquire_acquire_cmpxchg:
2193 ; GFX7:       ; %bb.0: ; %entry
2194 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2195 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
2196 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
2197 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
2198 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
2199 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
2200 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
2201 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
2202 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
2203 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
2204 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
2205 ; GFX7-NEXT:    buffer_wbinvl1_vol
2206 ; GFX7-NEXT:    s_endpgm
2208 ; GFX10-WGP-LABEL: global_agent_acquire_acquire_cmpxchg:
2209 ; GFX10-WGP:       ; %bb.0: ; %entry
2210 ; GFX10-WGP-NEXT:    s_clause 0x1
2211 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
2212 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
2213 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
2214 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
2215 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
2216 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
2217 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2218 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
2219 ; GFX10-WGP-NEXT:    buffer_gl0_inv
2220 ; GFX10-WGP-NEXT:    buffer_gl1_inv
2221 ; GFX10-WGP-NEXT:    s_endpgm
2223 ; GFX10-CU-LABEL: global_agent_acquire_acquire_cmpxchg:
2224 ; GFX10-CU:       ; %bb.0: ; %entry
2225 ; GFX10-CU-NEXT:    s_clause 0x1
2226 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
2227 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
2228 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
2229 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
2230 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
2231 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
2232 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2233 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
2234 ; GFX10-CU-NEXT:    buffer_gl0_inv
2235 ; GFX10-CU-NEXT:    buffer_gl1_inv
2236 ; GFX10-CU-NEXT:    s_endpgm
2238 ; SKIP-CACHE-INV-LABEL: global_agent_acquire_acquire_cmpxchg:
2239 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
2240 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
2241 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
2242 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
2243 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
2244 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
2245 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
2246 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
2247 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2248 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
2249 ; SKIP-CACHE-INV-NEXT:    s_endpgm
2251 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_acquire_acquire_cmpxchg:
2252 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
2253 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2254 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
2255 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
2256 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
2257 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2258 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2259 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
2260 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
2261 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
2263 ; GFX90A-TGSPLIT-LABEL: global_agent_acquire_acquire_cmpxchg:
2264 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
2265 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2266 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
2267 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
2268 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
2269 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2270 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2271 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
2272 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
2273 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
2274     i32 addrspace(1)* %out, i32 %in, i32 %old) {
2275 entry:
2276   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
2277   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") acquire acquire
2278   ret void
2281 define amdgpu_kernel void @global_agent_release_acquire_cmpxchg(
2282 ; GFX6-LABEL: global_agent_release_acquire_cmpxchg:
2283 ; GFX6:       ; %bb.0: ; %entry
2284 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2285 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
2286 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
2287 ; GFX6-NEXT:    s_mov_b32 s2, -1
2288 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
2289 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
2290 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
2291 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2292 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
2293 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
2294 ; GFX6-NEXT:    buffer_wbinvl1
2295 ; GFX6-NEXT:    s_endpgm
2297 ; GFX7-LABEL: global_agent_release_acquire_cmpxchg:
2298 ; GFX7:       ; %bb.0: ; %entry
2299 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2300 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
2301 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
2302 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
2303 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
2304 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
2305 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
2306 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
2307 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
2308 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2309 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
2310 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
2311 ; GFX7-NEXT:    buffer_wbinvl1_vol
2312 ; GFX7-NEXT:    s_endpgm
2314 ; GFX10-WGP-LABEL: global_agent_release_acquire_cmpxchg:
2315 ; GFX10-WGP:       ; %bb.0: ; %entry
2316 ; GFX10-WGP-NEXT:    s_clause 0x1
2317 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
2318 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
2319 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
2320 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
2321 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
2322 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
2323 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2324 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
2325 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2326 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
2327 ; GFX10-WGP-NEXT:    buffer_gl0_inv
2328 ; GFX10-WGP-NEXT:    buffer_gl1_inv
2329 ; GFX10-WGP-NEXT:    s_endpgm
2331 ; GFX10-CU-LABEL: global_agent_release_acquire_cmpxchg:
2332 ; GFX10-CU:       ; %bb.0: ; %entry
2333 ; GFX10-CU-NEXT:    s_clause 0x1
2334 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
2335 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
2336 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
2337 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
2338 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
2339 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
2340 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2341 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
2342 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2343 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
2344 ; GFX10-CU-NEXT:    buffer_gl0_inv
2345 ; GFX10-CU-NEXT:    buffer_gl1_inv
2346 ; GFX10-CU-NEXT:    s_endpgm
2348 ; SKIP-CACHE-INV-LABEL: global_agent_release_acquire_cmpxchg:
2349 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
2350 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
2351 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
2352 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
2353 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
2354 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
2355 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
2356 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
2357 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2358 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2359 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
2360 ; SKIP-CACHE-INV-NEXT:    s_endpgm
2362 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_release_acquire_cmpxchg:
2363 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
2364 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2365 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
2366 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
2367 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
2368 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2369 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2370 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2371 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
2372 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
2373 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
2375 ; GFX90A-TGSPLIT-LABEL: global_agent_release_acquire_cmpxchg:
2376 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
2377 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2378 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
2379 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
2380 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
2381 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2382 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2383 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2384 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
2385 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
2386 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
2387     i32 addrspace(1)* %out, i32 %in, i32 %old) {
2388 entry:
2389   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
2390   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") release acquire
2391   ret void
2394 define amdgpu_kernel void @global_agent_acq_rel_acquire_cmpxchg(
2395 ; GFX6-LABEL: global_agent_acq_rel_acquire_cmpxchg:
2396 ; GFX6:       ; %bb.0: ; %entry
2397 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2398 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
2399 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
2400 ; GFX6-NEXT:    s_mov_b32 s2, -1
2401 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
2402 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
2403 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
2404 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2405 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
2406 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
2407 ; GFX6-NEXT:    buffer_wbinvl1
2408 ; GFX6-NEXT:    s_endpgm
2410 ; GFX7-LABEL: global_agent_acq_rel_acquire_cmpxchg:
2411 ; GFX7:       ; %bb.0: ; %entry
2412 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2413 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
2414 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
2415 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
2416 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
2417 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
2418 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
2419 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
2420 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
2421 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2422 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
2423 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
2424 ; GFX7-NEXT:    buffer_wbinvl1_vol
2425 ; GFX7-NEXT:    s_endpgm
2427 ; GFX10-WGP-LABEL: global_agent_acq_rel_acquire_cmpxchg:
2428 ; GFX10-WGP:       ; %bb.0: ; %entry
2429 ; GFX10-WGP-NEXT:    s_clause 0x1
2430 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
2431 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
2432 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
2433 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
2434 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
2435 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
2436 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2437 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
2438 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2439 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
2440 ; GFX10-WGP-NEXT:    buffer_gl0_inv
2441 ; GFX10-WGP-NEXT:    buffer_gl1_inv
2442 ; GFX10-WGP-NEXT:    s_endpgm
2444 ; GFX10-CU-LABEL: global_agent_acq_rel_acquire_cmpxchg:
2445 ; GFX10-CU:       ; %bb.0: ; %entry
2446 ; GFX10-CU-NEXT:    s_clause 0x1
2447 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
2448 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
2449 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
2450 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
2451 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
2452 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
2453 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2454 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
2455 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2456 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
2457 ; GFX10-CU-NEXT:    buffer_gl0_inv
2458 ; GFX10-CU-NEXT:    buffer_gl1_inv
2459 ; GFX10-CU-NEXT:    s_endpgm
2461 ; SKIP-CACHE-INV-LABEL: global_agent_acq_rel_acquire_cmpxchg:
2462 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
2463 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
2464 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
2465 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
2466 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
2467 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
2468 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
2469 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
2470 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2471 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2472 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
2473 ; SKIP-CACHE-INV-NEXT:    s_endpgm
2475 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_acq_rel_acquire_cmpxchg:
2476 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
2477 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2478 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
2479 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
2480 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
2481 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2482 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2483 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2484 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
2485 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
2486 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
2488 ; GFX90A-TGSPLIT-LABEL: global_agent_acq_rel_acquire_cmpxchg:
2489 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
2490 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2491 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
2492 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
2493 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
2494 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2495 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2496 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2497 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
2498 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
2499 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
2500     i32 addrspace(1)* %out, i32 %in, i32 %old) {
2501 entry:
2502   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
2503   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") acq_rel acquire
2504   ret void
2507 define amdgpu_kernel void @global_agent_seq_cst_acquire_cmpxchg(
2508 ; GFX6-LABEL: global_agent_seq_cst_acquire_cmpxchg:
2509 ; GFX6:       ; %bb.0: ; %entry
2510 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2511 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
2512 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
2513 ; GFX6-NEXT:    s_mov_b32 s2, -1
2514 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
2515 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
2516 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
2517 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2518 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
2519 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
2520 ; GFX6-NEXT:    buffer_wbinvl1
2521 ; GFX6-NEXT:    s_endpgm
2523 ; GFX7-LABEL: global_agent_seq_cst_acquire_cmpxchg:
2524 ; GFX7:       ; %bb.0: ; %entry
2525 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2526 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
2527 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
2528 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
2529 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
2530 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
2531 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
2532 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
2533 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
2534 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2535 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
2536 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
2537 ; GFX7-NEXT:    buffer_wbinvl1_vol
2538 ; GFX7-NEXT:    s_endpgm
2540 ; GFX10-WGP-LABEL: global_agent_seq_cst_acquire_cmpxchg:
2541 ; GFX10-WGP:       ; %bb.0: ; %entry
2542 ; GFX10-WGP-NEXT:    s_clause 0x1
2543 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
2544 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
2545 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
2546 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
2547 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
2548 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
2549 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2550 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
2551 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2552 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
2553 ; GFX10-WGP-NEXT:    buffer_gl0_inv
2554 ; GFX10-WGP-NEXT:    buffer_gl1_inv
2555 ; GFX10-WGP-NEXT:    s_endpgm
2557 ; GFX10-CU-LABEL: global_agent_seq_cst_acquire_cmpxchg:
2558 ; GFX10-CU:       ; %bb.0: ; %entry
2559 ; GFX10-CU-NEXT:    s_clause 0x1
2560 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
2561 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
2562 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
2563 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
2564 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
2565 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
2566 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2567 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
2568 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2569 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
2570 ; GFX10-CU-NEXT:    buffer_gl0_inv
2571 ; GFX10-CU-NEXT:    buffer_gl1_inv
2572 ; GFX10-CU-NEXT:    s_endpgm
2574 ; SKIP-CACHE-INV-LABEL: global_agent_seq_cst_acquire_cmpxchg:
2575 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
2576 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
2577 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
2578 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
2579 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
2580 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
2581 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
2582 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
2583 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2584 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2585 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
2586 ; SKIP-CACHE-INV-NEXT:    s_endpgm
2588 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_seq_cst_acquire_cmpxchg:
2589 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
2590 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2591 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
2592 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
2593 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
2594 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2595 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2596 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2597 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
2598 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
2599 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
2601 ; GFX90A-TGSPLIT-LABEL: global_agent_seq_cst_acquire_cmpxchg:
2602 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
2603 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2604 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
2605 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
2606 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
2607 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2608 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2609 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2610 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
2611 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
2612 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
2613     i32 addrspace(1)* %out, i32 %in, i32 %old) {
2614 entry:
2615   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
2616   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") seq_cst acquire
2617   ret void
2620 define amdgpu_kernel void @global_agent_monotonic_seq_cst_cmpxchg(
2621 ; GFX6-LABEL: global_agent_monotonic_seq_cst_cmpxchg:
2622 ; GFX6:       ; %bb.0: ; %entry
2623 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2624 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
2625 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
2626 ; GFX6-NEXT:    s_mov_b32 s2, -1
2627 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
2628 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
2629 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
2630 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2631 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
2632 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
2633 ; GFX6-NEXT:    buffer_wbinvl1
2634 ; GFX6-NEXT:    s_endpgm
2636 ; GFX7-LABEL: global_agent_monotonic_seq_cst_cmpxchg:
2637 ; GFX7:       ; %bb.0: ; %entry
2638 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2639 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
2640 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
2641 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
2642 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
2643 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
2644 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
2645 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
2646 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
2647 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2648 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
2649 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
2650 ; GFX7-NEXT:    buffer_wbinvl1_vol
2651 ; GFX7-NEXT:    s_endpgm
2653 ; GFX10-WGP-LABEL: global_agent_monotonic_seq_cst_cmpxchg:
2654 ; GFX10-WGP:       ; %bb.0: ; %entry
2655 ; GFX10-WGP-NEXT:    s_clause 0x1
2656 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
2657 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
2658 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
2659 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
2660 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
2661 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
2662 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2663 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
2664 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2665 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
2666 ; GFX10-WGP-NEXT:    buffer_gl0_inv
2667 ; GFX10-WGP-NEXT:    buffer_gl1_inv
2668 ; GFX10-WGP-NEXT:    s_endpgm
2670 ; GFX10-CU-LABEL: global_agent_monotonic_seq_cst_cmpxchg:
2671 ; GFX10-CU:       ; %bb.0: ; %entry
2672 ; GFX10-CU-NEXT:    s_clause 0x1
2673 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
2674 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
2675 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
2676 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
2677 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
2678 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
2679 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2680 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
2681 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2682 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
2683 ; GFX10-CU-NEXT:    buffer_gl0_inv
2684 ; GFX10-CU-NEXT:    buffer_gl1_inv
2685 ; GFX10-CU-NEXT:    s_endpgm
2687 ; SKIP-CACHE-INV-LABEL: global_agent_monotonic_seq_cst_cmpxchg:
2688 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
2689 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
2690 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
2691 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
2692 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
2693 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
2694 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
2695 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
2696 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2697 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2698 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
2699 ; SKIP-CACHE-INV-NEXT:    s_endpgm
2701 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_monotonic_seq_cst_cmpxchg:
2702 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
2703 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2704 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
2705 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
2706 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
2707 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2708 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2709 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2710 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
2711 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
2712 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
2714 ; GFX90A-TGSPLIT-LABEL: global_agent_monotonic_seq_cst_cmpxchg:
2715 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
2716 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2717 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
2718 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
2719 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
2720 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2721 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2722 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2723 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
2724 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
2725 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
2726     i32 addrspace(1)* %out, i32 %in, i32 %old) {
2727 entry:
2728   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
2729   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") monotonic seq_cst
2730   ret void
2733 define amdgpu_kernel void @global_agent_acquire_seq_cst_cmpxchg(
2734 ; GFX6-LABEL: global_agent_acquire_seq_cst_cmpxchg:
2735 ; GFX6:       ; %bb.0: ; %entry
2736 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2737 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
2738 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
2739 ; GFX6-NEXT:    s_mov_b32 s2, -1
2740 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
2741 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
2742 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
2743 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2744 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
2745 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
2746 ; GFX6-NEXT:    buffer_wbinvl1
2747 ; GFX6-NEXT:    s_endpgm
2749 ; GFX7-LABEL: global_agent_acquire_seq_cst_cmpxchg:
2750 ; GFX7:       ; %bb.0: ; %entry
2751 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2752 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
2753 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
2754 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
2755 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
2756 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
2757 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
2758 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
2759 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
2760 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2761 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
2762 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
2763 ; GFX7-NEXT:    buffer_wbinvl1_vol
2764 ; GFX7-NEXT:    s_endpgm
2766 ; GFX10-WGP-LABEL: global_agent_acquire_seq_cst_cmpxchg:
2767 ; GFX10-WGP:       ; %bb.0: ; %entry
2768 ; GFX10-WGP-NEXT:    s_clause 0x1
2769 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
2770 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
2771 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
2772 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
2773 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
2774 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
2775 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2776 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
2777 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2778 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
2779 ; GFX10-WGP-NEXT:    buffer_gl0_inv
2780 ; GFX10-WGP-NEXT:    buffer_gl1_inv
2781 ; GFX10-WGP-NEXT:    s_endpgm
2783 ; GFX10-CU-LABEL: global_agent_acquire_seq_cst_cmpxchg:
2784 ; GFX10-CU:       ; %bb.0: ; %entry
2785 ; GFX10-CU-NEXT:    s_clause 0x1
2786 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
2787 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
2788 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
2789 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
2790 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
2791 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
2792 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2793 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
2794 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2795 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
2796 ; GFX10-CU-NEXT:    buffer_gl0_inv
2797 ; GFX10-CU-NEXT:    buffer_gl1_inv
2798 ; GFX10-CU-NEXT:    s_endpgm
2800 ; SKIP-CACHE-INV-LABEL: global_agent_acquire_seq_cst_cmpxchg:
2801 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
2802 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
2803 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
2804 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
2805 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
2806 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
2807 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
2808 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
2809 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2810 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2811 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
2812 ; SKIP-CACHE-INV-NEXT:    s_endpgm
2814 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_acquire_seq_cst_cmpxchg:
2815 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
2816 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2817 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
2818 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
2819 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
2820 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2821 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2822 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2823 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
2824 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
2825 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
2827 ; GFX90A-TGSPLIT-LABEL: global_agent_acquire_seq_cst_cmpxchg:
2828 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
2829 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2830 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
2831 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
2832 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
2833 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2834 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2835 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2836 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
2837 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
2838 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
2839     i32 addrspace(1)* %out, i32 %in, i32 %old) {
2840 entry:
2841   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
2842   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") acquire seq_cst
2843   ret void
2846 define amdgpu_kernel void @global_agent_release_seq_cst_cmpxchg(
2847 ; GFX6-LABEL: global_agent_release_seq_cst_cmpxchg:
2848 ; GFX6:       ; %bb.0: ; %entry
2849 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2850 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
2851 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
2852 ; GFX6-NEXT:    s_mov_b32 s2, -1
2853 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
2854 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
2855 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
2856 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2857 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
2858 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
2859 ; GFX6-NEXT:    buffer_wbinvl1
2860 ; GFX6-NEXT:    s_endpgm
2862 ; GFX7-LABEL: global_agent_release_seq_cst_cmpxchg:
2863 ; GFX7:       ; %bb.0: ; %entry
2864 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2865 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
2866 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
2867 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
2868 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
2869 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
2870 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
2871 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
2872 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
2873 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2874 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
2875 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
2876 ; GFX7-NEXT:    buffer_wbinvl1_vol
2877 ; GFX7-NEXT:    s_endpgm
2879 ; GFX10-WGP-LABEL: global_agent_release_seq_cst_cmpxchg:
2880 ; GFX10-WGP:       ; %bb.0: ; %entry
2881 ; GFX10-WGP-NEXT:    s_clause 0x1
2882 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
2883 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
2884 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
2885 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
2886 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
2887 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
2888 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2889 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
2890 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2891 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
2892 ; GFX10-WGP-NEXT:    buffer_gl0_inv
2893 ; GFX10-WGP-NEXT:    buffer_gl1_inv
2894 ; GFX10-WGP-NEXT:    s_endpgm
2896 ; GFX10-CU-LABEL: global_agent_release_seq_cst_cmpxchg:
2897 ; GFX10-CU:       ; %bb.0: ; %entry
2898 ; GFX10-CU-NEXT:    s_clause 0x1
2899 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
2900 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
2901 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
2902 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
2903 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
2904 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
2905 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2906 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
2907 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
2908 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
2909 ; GFX10-CU-NEXT:    buffer_gl0_inv
2910 ; GFX10-CU-NEXT:    buffer_gl1_inv
2911 ; GFX10-CU-NEXT:    s_endpgm
2913 ; SKIP-CACHE-INV-LABEL: global_agent_release_seq_cst_cmpxchg:
2914 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
2915 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
2916 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
2917 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
2918 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
2919 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
2920 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
2921 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
2922 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2923 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2924 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
2925 ; SKIP-CACHE-INV-NEXT:    s_endpgm
2927 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_release_seq_cst_cmpxchg:
2928 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
2929 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2930 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
2931 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
2932 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
2933 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2934 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2935 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2936 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
2937 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
2938 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
2940 ; GFX90A-TGSPLIT-LABEL: global_agent_release_seq_cst_cmpxchg:
2941 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
2942 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2943 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
2944 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
2945 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
2946 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
2947 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2948 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
2949 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
2950 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
2951 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
2952     i32 addrspace(1)* %out, i32 %in, i32 %old) {
2953 entry:
2954   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
2955   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") release seq_cst
2956   ret void
2959 define amdgpu_kernel void @global_agent_acq_rel_seq_cst_cmpxchg(
2960 ; GFX6-LABEL: global_agent_acq_rel_seq_cst_cmpxchg:
2961 ; GFX6:       ; %bb.0: ; %entry
2962 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
2963 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
2964 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
2965 ; GFX6-NEXT:    s_mov_b32 s2, -1
2966 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
2967 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
2968 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
2969 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2970 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
2971 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
2972 ; GFX6-NEXT:    buffer_wbinvl1
2973 ; GFX6-NEXT:    s_endpgm
2975 ; GFX7-LABEL: global_agent_acq_rel_seq_cst_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 s0, s0, 16
2981 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
2982 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
2983 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
2984 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
2985 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
2986 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
2987 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
2988 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
2989 ; GFX7-NEXT:    buffer_wbinvl1_vol
2990 ; GFX7-NEXT:    s_endpgm
2992 ; GFX10-WGP-LABEL: global_agent_acq_rel_seq_cst_cmpxchg:
2993 ; GFX10-WGP:       ; %bb.0: ; %entry
2994 ; GFX10-WGP-NEXT:    s_clause 0x1
2995 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
2996 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
2997 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
2998 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
2999 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
3000 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
3001 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3002 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
3003 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
3004 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
3005 ; GFX10-WGP-NEXT:    buffer_gl0_inv
3006 ; GFX10-WGP-NEXT:    buffer_gl1_inv
3007 ; GFX10-WGP-NEXT:    s_endpgm
3009 ; GFX10-CU-LABEL: global_agent_acq_rel_seq_cst_cmpxchg:
3010 ; GFX10-CU:       ; %bb.0: ; %entry
3011 ; GFX10-CU-NEXT:    s_clause 0x1
3012 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
3013 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
3014 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
3015 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
3016 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
3017 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
3018 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3019 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
3020 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
3021 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
3022 ; GFX10-CU-NEXT:    buffer_gl0_inv
3023 ; GFX10-CU-NEXT:    buffer_gl1_inv
3024 ; GFX10-CU-NEXT:    s_endpgm
3026 ; SKIP-CACHE-INV-LABEL: global_agent_acq_rel_seq_cst_cmpxchg:
3027 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
3028 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
3029 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
3030 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
3031 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
3032 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
3033 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
3034 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
3035 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3036 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
3037 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
3038 ; SKIP-CACHE-INV-NEXT:    s_endpgm
3040 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_acq_rel_seq_cst_cmpxchg:
3041 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
3042 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3043 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
3044 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
3045 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
3046 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3047 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3048 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3049 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
3050 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
3051 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
3053 ; GFX90A-TGSPLIT-LABEL: global_agent_acq_rel_seq_cst_cmpxchg:
3054 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
3055 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3056 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
3057 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
3058 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
3059 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3060 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3061 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3062 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
3063 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
3064 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
3065     i32 addrspace(1)* %out, i32 %in, i32 %old) {
3066 entry:
3067   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
3068   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") acq_rel seq_cst
3069   ret void
3072 define amdgpu_kernel void @global_agent_seq_cst_seq_cst_cmpxchg(
3073 ; GFX6-LABEL: global_agent_seq_cst_seq_cst_cmpxchg:
3074 ; GFX6:       ; %bb.0: ; %entry
3075 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3076 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
3077 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
3078 ; GFX6-NEXT:    s_mov_b32 s2, -1
3079 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
3080 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
3081 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
3082 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3083 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
3084 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
3085 ; GFX6-NEXT:    buffer_wbinvl1
3086 ; GFX6-NEXT:    s_endpgm
3088 ; GFX7-LABEL: global_agent_seq_cst_seq_cst_cmpxchg:
3089 ; GFX7:       ; %bb.0: ; %entry
3090 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3091 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
3092 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
3093 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
3094 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
3095 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
3096 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
3097 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
3098 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
3099 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3100 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
3101 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
3102 ; GFX7-NEXT:    buffer_wbinvl1_vol
3103 ; GFX7-NEXT:    s_endpgm
3105 ; GFX10-WGP-LABEL: global_agent_seq_cst_seq_cst_cmpxchg:
3106 ; GFX10-WGP:       ; %bb.0: ; %entry
3107 ; GFX10-WGP-NEXT:    s_clause 0x1
3108 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
3109 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
3110 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
3111 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
3112 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
3113 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
3114 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3115 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
3116 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
3117 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
3118 ; GFX10-WGP-NEXT:    buffer_gl0_inv
3119 ; GFX10-WGP-NEXT:    buffer_gl1_inv
3120 ; GFX10-WGP-NEXT:    s_endpgm
3122 ; GFX10-CU-LABEL: global_agent_seq_cst_seq_cst_cmpxchg:
3123 ; GFX10-CU:       ; %bb.0: ; %entry
3124 ; GFX10-CU-NEXT:    s_clause 0x1
3125 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
3126 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
3127 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
3128 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
3129 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
3130 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
3131 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3132 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
3133 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
3134 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
3135 ; GFX10-CU-NEXT:    buffer_gl0_inv
3136 ; GFX10-CU-NEXT:    buffer_gl1_inv
3137 ; GFX10-CU-NEXT:    s_endpgm
3139 ; SKIP-CACHE-INV-LABEL: global_agent_seq_cst_seq_cst_cmpxchg:
3140 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
3141 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
3142 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
3143 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
3144 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
3145 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
3146 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
3147 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
3148 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3149 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
3150 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
3151 ; SKIP-CACHE-INV-NEXT:    s_endpgm
3153 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_seq_cst_seq_cst_cmpxchg:
3154 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
3155 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3156 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
3157 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
3158 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
3159 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3160 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3161 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3162 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
3163 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
3164 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
3166 ; GFX90A-TGSPLIT-LABEL: global_agent_seq_cst_seq_cst_cmpxchg:
3167 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
3168 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3169 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
3170 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
3171 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
3172 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3173 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3174 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
3175 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
3176 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
3177 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
3178     i32 addrspace(1)* %out, i32 %in, i32 %old) {
3179 entry:
3180   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
3181   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") seq_cst seq_cst
3182   ret void
3185 define amdgpu_kernel void @global_agent_monotonic_monotonic_ret_cmpxchg(
3186 ; GFX6-LABEL: global_agent_monotonic_monotonic_ret_cmpxchg:
3187 ; GFX6:       ; %bb.0: ; %entry
3188 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3189 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
3190 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
3191 ; GFX6-NEXT:    s_mov_b32 s2, -1
3192 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
3193 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
3194 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
3195 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
3196 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
3197 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
3198 ; GFX6-NEXT:    s_endpgm
3200 ; GFX7-LABEL: global_agent_monotonic_monotonic_ret_cmpxchg:
3201 ; GFX7:       ; %bb.0: ; %entry
3202 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3203 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
3204 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
3205 ; GFX7-NEXT:    s_add_u32 s4, s0, 16
3206 ; GFX7-NEXT:    s_addc_u32 s5, s1, 0
3207 ; GFX7-NEXT:    v_mov_b32_e32 v0, s4
3208 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
3209 ; GFX7-NEXT:    v_mov_b32_e32 v1, s5
3210 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
3211 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
3212 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
3213 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
3214 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
3215 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
3216 ; GFX7-NEXT:    s_endpgm
3218 ; GFX10-WGP-LABEL: global_agent_monotonic_monotonic_ret_cmpxchg:
3219 ; GFX10-WGP:       ; %bb.0: ; %entry
3220 ; GFX10-WGP-NEXT:    s_clause 0x1
3221 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
3222 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
3223 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
3224 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
3225 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
3226 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
3227 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3228 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
3229 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
3230 ; GFX10-WGP-NEXT:    s_endpgm
3232 ; GFX10-CU-LABEL: global_agent_monotonic_monotonic_ret_cmpxchg:
3233 ; GFX10-CU:       ; %bb.0: ; %entry
3234 ; GFX10-CU-NEXT:    s_clause 0x1
3235 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
3236 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
3237 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
3238 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
3239 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
3240 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
3241 ; GFX10-CU-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3242 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
3243 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
3244 ; GFX10-CU-NEXT:    s_endpgm
3246 ; SKIP-CACHE-INV-LABEL: global_agent_monotonic_monotonic_ret_cmpxchg:
3247 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
3248 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
3249 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
3250 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
3251 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
3252 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
3253 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
3254 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
3255 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
3256 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
3257 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
3258 ; SKIP-CACHE-INV-NEXT:    s_endpgm
3260 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_monotonic_monotonic_ret_cmpxchg:
3261 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
3262 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3263 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
3264 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
3265 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
3266 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3267 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3268 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
3269 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
3270 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
3272 ; GFX90A-TGSPLIT-LABEL: global_agent_monotonic_monotonic_ret_cmpxchg:
3273 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
3274 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3275 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
3276 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
3277 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
3278 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3279 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3280 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
3281 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
3282 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
3283     i32 addrspace(1)* %out, i32 %in, i32 %old) {
3284 entry:
3285   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
3286   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") monotonic monotonic
3287   %val0 = extractvalue { i32, i1 } %val, 0
3288   store i32 %val0, i32 addrspace(1)* %out, align 4
3289   ret void
3292 define amdgpu_kernel void @global_agent_acquire_monotonic_ret_cmpxchg(
3293 ; GFX6-LABEL: global_agent_acquire_monotonic_ret_cmpxchg:
3294 ; GFX6:       ; %bb.0: ; %entry
3295 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3296 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
3297 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
3298 ; GFX6-NEXT:    s_mov_b32 s2, -1
3299 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
3300 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
3301 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
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_wbinvl1
3305 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
3306 ; GFX6-NEXT:    s_endpgm
3308 ; GFX7-LABEL: global_agent_acquire_monotonic_ret_cmpxchg:
3309 ; GFX7:       ; %bb.0: ; %entry
3310 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3311 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
3312 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
3313 ; GFX7-NEXT:    s_add_u32 s4, s0, 16
3314 ; GFX7-NEXT:    s_addc_u32 s5, s1, 0
3315 ; GFX7-NEXT:    v_mov_b32_e32 v0, s4
3316 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
3317 ; GFX7-NEXT:    v_mov_b32_e32 v1, s5
3318 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
3319 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
3320 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
3321 ; GFX7-NEXT:    buffer_wbinvl1_vol
3322 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
3323 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
3324 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
3325 ; GFX7-NEXT:    s_endpgm
3327 ; GFX10-WGP-LABEL: global_agent_acquire_monotonic_ret_cmpxchg:
3328 ; GFX10-WGP:       ; %bb.0: ; %entry
3329 ; GFX10-WGP-NEXT:    s_clause 0x1
3330 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
3331 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
3332 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
3333 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
3334 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
3335 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
3336 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3337 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
3338 ; GFX10-WGP-NEXT:    buffer_gl0_inv
3339 ; GFX10-WGP-NEXT:    buffer_gl1_inv
3340 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
3341 ; GFX10-WGP-NEXT:    s_endpgm
3343 ; GFX10-CU-LABEL: global_agent_acquire_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:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3353 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
3354 ; GFX10-CU-NEXT:    buffer_gl0_inv
3355 ; GFX10-CU-NEXT:    buffer_gl1_inv
3356 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
3357 ; GFX10-CU-NEXT:    s_endpgm
3359 ; SKIP-CACHE-INV-LABEL: global_agent_acquire_monotonic_ret_cmpxchg:
3360 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
3361 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
3362 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
3363 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
3364 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
3365 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
3366 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
3367 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
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_agent_acquire_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:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3381 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
3382 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
3383 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
3384 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
3386 ; GFX90A-TGSPLIT-LABEL: global_agent_acquire_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:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3394 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
3395 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
3396 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
3397 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
3398     i32 addrspace(1)* %out, i32 %in, i32 %old) {
3399 entry:
3400   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
3401   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") acquire monotonic
3402   %val0 = extractvalue { i32, i1 } %val, 0
3403   store i32 %val0, i32 addrspace(1)* %out, align 4
3404   ret void
3407 define amdgpu_kernel void @global_agent_release_monotonic_ret_cmpxchg(
3408 ; GFX6-LABEL: global_agent_release_monotonic_ret_cmpxchg:
3409 ; GFX6:       ; %bb.0: ; %entry
3410 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3411 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
3412 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
3413 ; GFX6-NEXT:    s_mov_b32 s2, -1
3414 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
3415 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
3416 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
3417 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3418 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
3419 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
3420 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
3421 ; GFX6-NEXT:    s_endpgm
3423 ; GFX7-LABEL: global_agent_release_monotonic_ret_cmpxchg:
3424 ; GFX7:       ; %bb.0: ; %entry
3425 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3426 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
3427 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
3428 ; GFX7-NEXT:    s_add_u32 s4, s0, 16
3429 ; GFX7-NEXT:    s_addc_u32 s5, s1, 0
3430 ; GFX7-NEXT:    v_mov_b32_e32 v0, s4
3431 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
3432 ; GFX7-NEXT:    v_mov_b32_e32 v1, s5
3433 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
3434 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3435 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
3436 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
3437 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
3438 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
3439 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
3440 ; GFX7-NEXT:    s_endpgm
3442 ; GFX10-WGP-LABEL: global_agent_release_monotonic_ret_cmpxchg:
3443 ; GFX10-WGP:       ; %bb.0: ; %entry
3444 ; GFX10-WGP-NEXT:    s_clause 0x1
3445 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
3446 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
3447 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
3448 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
3449 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
3450 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
3451 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3452 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
3453 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3454 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
3455 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
3456 ; GFX10-WGP-NEXT:    s_endpgm
3458 ; GFX10-CU-LABEL: global_agent_release_monotonic_ret_cmpxchg:
3459 ; GFX10-CU:       ; %bb.0: ; %entry
3460 ; GFX10-CU-NEXT:    s_clause 0x1
3461 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
3462 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
3463 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
3464 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
3465 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
3466 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
3467 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3468 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
3469 ; GFX10-CU-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3470 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
3471 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
3472 ; GFX10-CU-NEXT:    s_endpgm
3474 ; SKIP-CACHE-INV-LABEL: global_agent_release_monotonic_ret_cmpxchg:
3475 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
3476 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
3477 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
3478 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
3479 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
3480 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
3481 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
3482 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
3483 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3484 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
3485 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
3486 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
3487 ; SKIP-CACHE-INV-NEXT:    s_endpgm
3489 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_release_monotonic_ret_cmpxchg:
3490 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
3491 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3492 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
3493 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
3494 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
3495 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3496 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3497 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3498 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
3499 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
3500 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
3502 ; GFX90A-TGSPLIT-LABEL: global_agent_release_monotonic_ret_cmpxchg:
3503 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
3504 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3505 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
3506 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
3507 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
3508 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3509 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3510 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3511 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
3512 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
3513 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
3514     i32 addrspace(1)* %out, i32 %in, i32 %old) {
3515 entry:
3516   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
3517   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") release monotonic
3518   %val0 = extractvalue { i32, i1 } %val, 0
3519   store i32 %val0, i32 addrspace(1)* %out, align 4
3520   ret void
3523 define amdgpu_kernel void @global_agent_acq_rel_monotonic_ret_cmpxchg(
3524 ; GFX6-LABEL: global_agent_acq_rel_monotonic_ret_cmpxchg:
3525 ; GFX6:       ; %bb.0: ; %entry
3526 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3527 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
3528 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
3529 ; GFX6-NEXT:    s_mov_b32 s2, -1
3530 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
3531 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
3532 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
3533 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3534 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
3535 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
3536 ; GFX6-NEXT:    buffer_wbinvl1
3537 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
3538 ; GFX6-NEXT:    s_endpgm
3540 ; GFX7-LABEL: global_agent_acq_rel_monotonic_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:    s_waitcnt vmcnt(0) lgkmcnt(0)
3552 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
3553 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
3554 ; GFX7-NEXT:    buffer_wbinvl1_vol
3555 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
3556 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
3557 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
3558 ; GFX7-NEXT:    s_endpgm
3560 ; GFX10-WGP-LABEL: global_agent_acq_rel_monotonic_ret_cmpxchg:
3561 ; GFX10-WGP:       ; %bb.0: ; %entry
3562 ; GFX10-WGP-NEXT:    s_clause 0x1
3563 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
3564 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
3565 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
3566 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
3567 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
3568 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
3569 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3570 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
3571 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3572 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
3573 ; GFX10-WGP-NEXT:    buffer_gl0_inv
3574 ; GFX10-WGP-NEXT:    buffer_gl1_inv
3575 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
3576 ; GFX10-WGP-NEXT:    s_endpgm
3578 ; GFX10-CU-LABEL: global_agent_acq_rel_monotonic_ret_cmpxchg:
3579 ; GFX10-CU:       ; %bb.0: ; %entry
3580 ; GFX10-CU-NEXT:    s_clause 0x1
3581 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
3582 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
3583 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
3584 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
3585 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
3586 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
3587 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3588 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
3589 ; GFX10-CU-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3590 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
3591 ; GFX10-CU-NEXT:    buffer_gl0_inv
3592 ; GFX10-CU-NEXT:    buffer_gl1_inv
3593 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
3594 ; GFX10-CU-NEXT:    s_endpgm
3596 ; SKIP-CACHE-INV-LABEL: global_agent_acq_rel_monotonic_ret_cmpxchg:
3597 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
3598 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
3599 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
3600 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
3601 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
3602 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
3603 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
3604 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
3605 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3606 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
3607 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
3608 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
3609 ; SKIP-CACHE-INV-NEXT:    s_endpgm
3611 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_acq_rel_monotonic_ret_cmpxchg:
3612 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
3613 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3614 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
3615 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
3616 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
3617 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3618 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3619 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3620 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
3621 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
3622 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
3623 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
3625 ; GFX90A-TGSPLIT-LABEL: global_agent_acq_rel_monotonic_ret_cmpxchg:
3626 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
3627 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3628 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
3629 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
3630 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
3631 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3632 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3633 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3634 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
3635 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
3636 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
3637 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
3638     i32 addrspace(1)* %out, i32 %in, i32 %old) {
3639 entry:
3640   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
3641   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") acq_rel monotonic
3642   %val0 = extractvalue { i32, i1 } %val, 0
3643   store i32 %val0, i32 addrspace(1)* %out, align 4
3644   ret void
3647 define amdgpu_kernel void @global_agent_seq_cst_monotonic_ret_cmpxchg(
3648 ; GFX6-LABEL: global_agent_seq_cst_monotonic_ret_cmpxchg:
3649 ; GFX6:       ; %bb.0: ; %entry
3650 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3651 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
3652 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
3653 ; GFX6-NEXT:    s_mov_b32 s2, -1
3654 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
3655 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
3656 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
3657 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3658 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
3659 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
3660 ; GFX6-NEXT:    buffer_wbinvl1
3661 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
3662 ; GFX6-NEXT:    s_endpgm
3664 ; GFX7-LABEL: global_agent_seq_cst_monotonic_ret_cmpxchg:
3665 ; GFX7:       ; %bb.0: ; %entry
3666 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3667 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
3668 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
3669 ; GFX7-NEXT:    s_add_u32 s4, s0, 16
3670 ; GFX7-NEXT:    s_addc_u32 s5, s1, 0
3671 ; GFX7-NEXT:    v_mov_b32_e32 v0, s4
3672 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
3673 ; GFX7-NEXT:    v_mov_b32_e32 v1, s5
3674 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
3675 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3676 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
3677 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
3678 ; GFX7-NEXT:    buffer_wbinvl1_vol
3679 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
3680 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
3681 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
3682 ; GFX7-NEXT:    s_endpgm
3684 ; GFX10-WGP-LABEL: global_agent_seq_cst_monotonic_ret_cmpxchg:
3685 ; GFX10-WGP:       ; %bb.0: ; %entry
3686 ; GFX10-WGP-NEXT:    s_clause 0x1
3687 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
3688 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
3689 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
3690 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
3691 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
3692 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
3693 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3694 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
3695 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3696 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
3697 ; GFX10-WGP-NEXT:    buffer_gl0_inv
3698 ; GFX10-WGP-NEXT:    buffer_gl1_inv
3699 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
3700 ; GFX10-WGP-NEXT:    s_endpgm
3702 ; GFX10-CU-LABEL: global_agent_seq_cst_monotonic_ret_cmpxchg:
3703 ; GFX10-CU:       ; %bb.0: ; %entry
3704 ; GFX10-CU-NEXT:    s_clause 0x1
3705 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
3706 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
3707 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
3708 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
3709 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
3710 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
3711 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3712 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
3713 ; GFX10-CU-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3714 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
3715 ; GFX10-CU-NEXT:    buffer_gl0_inv
3716 ; GFX10-CU-NEXT:    buffer_gl1_inv
3717 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
3718 ; GFX10-CU-NEXT:    s_endpgm
3720 ; SKIP-CACHE-INV-LABEL: global_agent_seq_cst_monotonic_ret_cmpxchg:
3721 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
3722 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
3723 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
3724 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
3725 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
3726 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
3727 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
3728 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
3729 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3730 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
3731 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
3732 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
3733 ; SKIP-CACHE-INV-NEXT:    s_endpgm
3735 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_seq_cst_monotonic_ret_cmpxchg:
3736 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
3737 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3738 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
3739 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
3740 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
3741 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3742 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3743 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3744 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
3745 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
3746 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
3747 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
3749 ; GFX90A-TGSPLIT-LABEL: global_agent_seq_cst_monotonic_ret_cmpxchg:
3750 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
3751 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3752 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
3753 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
3754 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
3755 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3756 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
3757 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3758 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
3759 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
3760 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
3761 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
3762     i32 addrspace(1)* %out, i32 %in, i32 %old) {
3763 entry:
3764   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
3765   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") seq_cst monotonic
3766   %val0 = extractvalue { i32, i1 } %val, 0
3767   store i32 %val0, i32 addrspace(1)* %out, align 4
3768   ret void
3771 define amdgpu_kernel void @global_agent_monotonic_acquire_ret_cmpxchg(
3772 ; GFX6-LABEL: global_agent_monotonic_acquire_ret_cmpxchg:
3773 ; GFX6:       ; %bb.0: ; %entry
3774 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3775 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
3776 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
3777 ; GFX6-NEXT:    s_mov_b32 s2, -1
3778 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
3779 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
3780 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
3781 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
3782 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
3783 ; GFX6-NEXT:    buffer_wbinvl1
3784 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
3785 ; GFX6-NEXT:    s_endpgm
3787 ; GFX7-LABEL: global_agent_monotonic_acquire_ret_cmpxchg:
3788 ; GFX7:       ; %bb.0: ; %entry
3789 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3790 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
3791 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
3792 ; GFX7-NEXT:    s_add_u32 s4, s0, 16
3793 ; GFX7-NEXT:    s_addc_u32 s5, s1, 0
3794 ; GFX7-NEXT:    v_mov_b32_e32 v0, s4
3795 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
3796 ; GFX7-NEXT:    v_mov_b32_e32 v1, s5
3797 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
3798 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
3799 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
3800 ; GFX7-NEXT:    buffer_wbinvl1_vol
3801 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
3802 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
3803 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
3804 ; GFX7-NEXT:    s_endpgm
3806 ; GFX10-WGP-LABEL: global_agent_monotonic_acquire_ret_cmpxchg:
3807 ; GFX10-WGP:       ; %bb.0: ; %entry
3808 ; GFX10-WGP-NEXT:    s_clause 0x1
3809 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
3810 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
3811 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
3812 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
3813 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
3814 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
3815 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3816 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
3817 ; GFX10-WGP-NEXT:    buffer_gl0_inv
3818 ; GFX10-WGP-NEXT:    buffer_gl1_inv
3819 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
3820 ; GFX10-WGP-NEXT:    s_endpgm
3822 ; GFX10-CU-LABEL: global_agent_monotonic_acquire_ret_cmpxchg:
3823 ; GFX10-CU:       ; %bb.0: ; %entry
3824 ; GFX10-CU-NEXT:    s_clause 0x1
3825 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
3826 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
3827 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
3828 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
3829 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
3830 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
3831 ; GFX10-CU-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3832 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
3833 ; GFX10-CU-NEXT:    buffer_gl0_inv
3834 ; GFX10-CU-NEXT:    buffer_gl1_inv
3835 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
3836 ; GFX10-CU-NEXT:    s_endpgm
3838 ; SKIP-CACHE-INV-LABEL: global_agent_monotonic_acquire_ret_cmpxchg:
3839 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
3840 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
3841 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
3842 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
3843 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
3844 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
3845 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
3846 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
3847 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
3848 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
3849 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
3850 ; SKIP-CACHE-INV-NEXT:    s_endpgm
3852 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_monotonic_acquire_ret_cmpxchg:
3853 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
3854 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3855 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
3856 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
3857 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
3858 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3859 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3860 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
3861 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
3862 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
3863 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
3865 ; GFX90A-TGSPLIT-LABEL: global_agent_monotonic_acquire_ret_cmpxchg:
3866 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
3867 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3868 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
3869 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
3870 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
3871 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3872 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3873 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
3874 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
3875 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
3876 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
3877     i32 addrspace(1)* %out, i32 %in, i32 %old) {
3878 entry:
3879   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
3880   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") monotonic acquire
3881   %val0 = extractvalue { i32, i1 } %val, 0
3882   store i32 %val0, i32 addrspace(1)* %out, align 4
3883   ret void
3886 define amdgpu_kernel void @global_agent_acquire_acquire_ret_cmpxchg(
3887 ; GFX6-LABEL: global_agent_acquire_acquire_ret_cmpxchg:
3888 ; GFX6:       ; %bb.0: ; %entry
3889 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3890 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
3891 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
3892 ; GFX6-NEXT:    s_mov_b32 s2, -1
3893 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
3894 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
3895 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
3896 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
3897 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
3898 ; GFX6-NEXT:    buffer_wbinvl1
3899 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
3900 ; GFX6-NEXT:    s_endpgm
3902 ; GFX7-LABEL: global_agent_acquire_acquire_ret_cmpxchg:
3903 ; GFX7:       ; %bb.0: ; %entry
3904 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3905 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
3906 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
3907 ; GFX7-NEXT:    s_add_u32 s4, s0, 16
3908 ; GFX7-NEXT:    s_addc_u32 s5, s1, 0
3909 ; GFX7-NEXT:    v_mov_b32_e32 v0, s4
3910 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
3911 ; GFX7-NEXT:    v_mov_b32_e32 v1, s5
3912 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
3913 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
3914 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
3915 ; GFX7-NEXT:    buffer_wbinvl1_vol
3916 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
3917 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
3918 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
3919 ; GFX7-NEXT:    s_endpgm
3921 ; GFX10-WGP-LABEL: global_agent_acquire_acquire_ret_cmpxchg:
3922 ; GFX10-WGP:       ; %bb.0: ; %entry
3923 ; GFX10-WGP-NEXT:    s_clause 0x1
3924 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
3925 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
3926 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
3927 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
3928 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
3929 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
3930 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3931 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
3932 ; GFX10-WGP-NEXT:    buffer_gl0_inv
3933 ; GFX10-WGP-NEXT:    buffer_gl1_inv
3934 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
3935 ; GFX10-WGP-NEXT:    s_endpgm
3937 ; GFX10-CU-LABEL: global_agent_acquire_acquire_ret_cmpxchg:
3938 ; GFX10-CU:       ; %bb.0: ; %entry
3939 ; GFX10-CU-NEXT:    s_clause 0x1
3940 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
3941 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
3942 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
3943 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
3944 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
3945 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
3946 ; GFX10-CU-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
3947 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
3948 ; GFX10-CU-NEXT:    buffer_gl0_inv
3949 ; GFX10-CU-NEXT:    buffer_gl1_inv
3950 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
3951 ; GFX10-CU-NEXT:    s_endpgm
3953 ; SKIP-CACHE-INV-LABEL: global_agent_acquire_acquire_ret_cmpxchg:
3954 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
3955 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
3956 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
3957 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
3958 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
3959 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
3960 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
3961 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
3962 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
3963 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
3964 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
3965 ; SKIP-CACHE-INV-NEXT:    s_endpgm
3967 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_acquire_acquire_ret_cmpxchg:
3968 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
3969 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3970 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
3971 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
3972 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
3973 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3974 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3975 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
3976 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
3977 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
3978 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
3980 ; GFX90A-TGSPLIT-LABEL: global_agent_acquire_acquire_ret_cmpxchg:
3981 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
3982 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
3983 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
3984 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
3985 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
3986 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
3987 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
3988 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
3989 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
3990 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
3991 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
3992     i32 addrspace(1)* %out, i32 %in, i32 %old) {
3993 entry:
3994   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
3995   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") acquire acquire
3996   %val0 = extractvalue { i32, i1 } %val, 0
3997   store i32 %val0, i32 addrspace(1)* %out, align 4
3998   ret void
4001 define amdgpu_kernel void @global_agent_release_acquire_ret_cmpxchg(
4002 ; GFX6-LABEL: global_agent_release_acquire_ret_cmpxchg:
4003 ; GFX6:       ; %bb.0: ; %entry
4004 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4005 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
4006 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
4007 ; GFX6-NEXT:    s_mov_b32 s2, -1
4008 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
4009 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
4010 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
4011 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4012 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
4013 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
4014 ; GFX6-NEXT:    buffer_wbinvl1
4015 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
4016 ; GFX6-NEXT:    s_endpgm
4018 ; GFX7-LABEL: global_agent_release_acquire_ret_cmpxchg:
4019 ; GFX7:       ; %bb.0: ; %entry
4020 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4021 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
4022 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
4023 ; GFX7-NEXT:    s_add_u32 s4, s0, 16
4024 ; GFX7-NEXT:    s_addc_u32 s5, s1, 0
4025 ; GFX7-NEXT:    v_mov_b32_e32 v0, s4
4026 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
4027 ; GFX7-NEXT:    v_mov_b32_e32 v1, s5
4028 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
4029 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4030 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4031 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
4032 ; GFX7-NEXT:    buffer_wbinvl1_vol
4033 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
4034 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
4035 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
4036 ; GFX7-NEXT:    s_endpgm
4038 ; GFX10-WGP-LABEL: global_agent_release_acquire_ret_cmpxchg:
4039 ; GFX10-WGP:       ; %bb.0: ; %entry
4040 ; GFX10-WGP-NEXT:    s_clause 0x1
4041 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
4042 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
4043 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
4044 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
4045 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
4046 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
4047 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4048 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
4049 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
4050 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
4051 ; GFX10-WGP-NEXT:    buffer_gl0_inv
4052 ; GFX10-WGP-NEXT:    buffer_gl1_inv
4053 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
4054 ; GFX10-WGP-NEXT:    s_endpgm
4056 ; GFX10-CU-LABEL: global_agent_release_acquire_ret_cmpxchg:
4057 ; GFX10-CU:       ; %bb.0: ; %entry
4058 ; GFX10-CU-NEXT:    s_clause 0x1
4059 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
4060 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
4061 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
4062 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
4063 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
4064 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
4065 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4066 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
4067 ; GFX10-CU-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
4068 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
4069 ; GFX10-CU-NEXT:    buffer_gl0_inv
4070 ; GFX10-CU-NEXT:    buffer_gl1_inv
4071 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
4072 ; GFX10-CU-NEXT:    s_endpgm
4074 ; SKIP-CACHE-INV-LABEL: global_agent_release_acquire_ret_cmpxchg:
4075 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
4076 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
4077 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
4078 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
4079 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
4080 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
4081 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
4082 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
4083 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4084 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
4085 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
4086 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
4087 ; SKIP-CACHE-INV-NEXT:    s_endpgm
4089 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_release_acquire_ret_cmpxchg:
4090 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
4091 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4092 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
4093 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
4094 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
4095 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4096 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4097 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4098 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
4099 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
4100 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
4101 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
4103 ; GFX90A-TGSPLIT-LABEL: global_agent_release_acquire_ret_cmpxchg:
4104 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
4105 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4106 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
4107 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
4108 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
4109 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4110 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4111 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4112 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
4113 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
4114 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
4115 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
4116     i32 addrspace(1)* %out, i32 %in, i32 %old) {
4117 entry:
4118   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
4119   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") release acquire
4120   %val0 = extractvalue { i32, i1 } %val, 0
4121   store i32 %val0, i32 addrspace(1)* %out, align 4
4122   ret void
4125 define amdgpu_kernel void @global_agent_acq_rel_acquire_ret_cmpxchg(
4126 ; GFX6-LABEL: global_agent_acq_rel_acquire_ret_cmpxchg:
4127 ; GFX6:       ; %bb.0: ; %entry
4128 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4129 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
4130 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
4131 ; GFX6-NEXT:    s_mov_b32 s2, -1
4132 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
4133 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
4134 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
4135 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4136 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
4137 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
4138 ; GFX6-NEXT:    buffer_wbinvl1
4139 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
4140 ; GFX6-NEXT:    s_endpgm
4142 ; GFX7-LABEL: global_agent_acq_rel_acquire_ret_cmpxchg:
4143 ; GFX7:       ; %bb.0: ; %entry
4144 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4145 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
4146 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
4147 ; GFX7-NEXT:    s_add_u32 s4, s0, 16
4148 ; GFX7-NEXT:    s_addc_u32 s5, s1, 0
4149 ; GFX7-NEXT:    v_mov_b32_e32 v0, s4
4150 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
4151 ; GFX7-NEXT:    v_mov_b32_e32 v1, s5
4152 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
4153 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4154 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4155 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
4156 ; GFX7-NEXT:    buffer_wbinvl1_vol
4157 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
4158 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
4159 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
4160 ; GFX7-NEXT:    s_endpgm
4162 ; GFX10-WGP-LABEL: global_agent_acq_rel_acquire_ret_cmpxchg:
4163 ; GFX10-WGP:       ; %bb.0: ; %entry
4164 ; GFX10-WGP-NEXT:    s_clause 0x1
4165 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
4166 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
4167 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
4168 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
4169 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
4170 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
4171 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4172 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
4173 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
4174 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
4175 ; GFX10-WGP-NEXT:    buffer_gl0_inv
4176 ; GFX10-WGP-NEXT:    buffer_gl1_inv
4177 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
4178 ; GFX10-WGP-NEXT:    s_endpgm
4180 ; GFX10-CU-LABEL: global_agent_acq_rel_acquire_ret_cmpxchg:
4181 ; GFX10-CU:       ; %bb.0: ; %entry
4182 ; GFX10-CU-NEXT:    s_clause 0x1
4183 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
4184 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
4185 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
4186 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
4187 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
4188 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
4189 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4190 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
4191 ; GFX10-CU-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
4192 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
4193 ; GFX10-CU-NEXT:    buffer_gl0_inv
4194 ; GFX10-CU-NEXT:    buffer_gl1_inv
4195 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
4196 ; GFX10-CU-NEXT:    s_endpgm
4198 ; SKIP-CACHE-INV-LABEL: global_agent_acq_rel_acquire_ret_cmpxchg:
4199 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
4200 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
4201 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
4202 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
4203 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
4204 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
4205 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
4206 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
4207 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4208 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
4209 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
4210 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
4211 ; SKIP-CACHE-INV-NEXT:    s_endpgm
4213 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_acq_rel_acquire_ret_cmpxchg:
4214 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
4215 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4216 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
4217 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
4218 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
4219 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4220 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4221 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4222 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
4223 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
4224 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
4225 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
4227 ; GFX90A-TGSPLIT-LABEL: global_agent_acq_rel_acquire_ret_cmpxchg:
4228 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
4229 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4230 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
4231 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
4232 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
4233 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4234 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4235 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4236 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
4237 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
4238 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
4239 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
4240     i32 addrspace(1)* %out, i32 %in, i32 %old) {
4241 entry:
4242   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
4243   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") acq_rel acquire
4244   %val0 = extractvalue { i32, i1 } %val, 0
4245   store i32 %val0, i32 addrspace(1)* %out, align 4
4246   ret void
4249 define amdgpu_kernel void @global_agent_seq_cst_acquire_ret_cmpxchg(
4250 ; GFX6-LABEL: global_agent_seq_cst_acquire_ret_cmpxchg:
4251 ; GFX6:       ; %bb.0: ; %entry
4252 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4253 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
4254 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
4255 ; GFX6-NEXT:    s_mov_b32 s2, -1
4256 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
4257 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
4258 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
4259 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4260 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
4261 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
4262 ; GFX6-NEXT:    buffer_wbinvl1
4263 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
4264 ; GFX6-NEXT:    s_endpgm
4266 ; GFX7-LABEL: global_agent_seq_cst_acquire_ret_cmpxchg:
4267 ; GFX7:       ; %bb.0: ; %entry
4268 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4269 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
4270 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
4271 ; GFX7-NEXT:    s_add_u32 s4, s0, 16
4272 ; GFX7-NEXT:    s_addc_u32 s5, s1, 0
4273 ; GFX7-NEXT:    v_mov_b32_e32 v0, s4
4274 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
4275 ; GFX7-NEXT:    v_mov_b32_e32 v1, s5
4276 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
4277 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4278 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4279 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
4280 ; GFX7-NEXT:    buffer_wbinvl1_vol
4281 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
4282 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
4283 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
4284 ; GFX7-NEXT:    s_endpgm
4286 ; GFX10-WGP-LABEL: global_agent_seq_cst_acquire_ret_cmpxchg:
4287 ; GFX10-WGP:       ; %bb.0: ; %entry
4288 ; GFX10-WGP-NEXT:    s_clause 0x1
4289 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
4290 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
4291 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
4292 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
4293 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
4294 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
4295 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4296 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
4297 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
4298 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
4299 ; GFX10-WGP-NEXT:    buffer_gl0_inv
4300 ; GFX10-WGP-NEXT:    buffer_gl1_inv
4301 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
4302 ; GFX10-WGP-NEXT:    s_endpgm
4304 ; GFX10-CU-LABEL: global_agent_seq_cst_acquire_ret_cmpxchg:
4305 ; GFX10-CU:       ; %bb.0: ; %entry
4306 ; GFX10-CU-NEXT:    s_clause 0x1
4307 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
4308 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
4309 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
4310 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
4311 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
4312 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
4313 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4314 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
4315 ; GFX10-CU-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
4316 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
4317 ; GFX10-CU-NEXT:    buffer_gl0_inv
4318 ; GFX10-CU-NEXT:    buffer_gl1_inv
4319 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
4320 ; GFX10-CU-NEXT:    s_endpgm
4322 ; SKIP-CACHE-INV-LABEL: global_agent_seq_cst_acquire_ret_cmpxchg:
4323 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
4324 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
4325 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
4326 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
4327 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
4328 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
4329 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
4330 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
4331 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4332 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
4333 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
4334 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
4335 ; SKIP-CACHE-INV-NEXT:    s_endpgm
4337 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_seq_cst_acquire_ret_cmpxchg:
4338 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
4339 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4340 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
4341 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
4342 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
4343 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4344 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4345 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4346 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
4347 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
4348 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
4349 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
4351 ; GFX90A-TGSPLIT-LABEL: global_agent_seq_cst_acquire_ret_cmpxchg:
4352 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
4353 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4354 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
4355 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
4356 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
4357 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4358 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4359 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4360 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
4361 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
4362 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
4363 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
4364     i32 addrspace(1)* %out, i32 %in, i32 %old) {
4365 entry:
4366   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
4367   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") seq_cst acquire
4368   %val0 = extractvalue { i32, i1 } %val, 0
4369   store i32 %val0, i32 addrspace(1)* %out, align 4
4370   ret void
4373 define amdgpu_kernel void @global_agent_monotonic_seq_cst_ret_cmpxchg(
4374 ; GFX6-LABEL: global_agent_monotonic_seq_cst_ret_cmpxchg:
4375 ; GFX6:       ; %bb.0: ; %entry
4376 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4377 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
4378 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
4379 ; GFX6-NEXT:    s_mov_b32 s2, -1
4380 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
4381 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
4382 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
4383 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4384 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
4385 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
4386 ; GFX6-NEXT:    buffer_wbinvl1
4387 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
4388 ; GFX6-NEXT:    s_endpgm
4390 ; GFX7-LABEL: global_agent_monotonic_seq_cst_ret_cmpxchg:
4391 ; GFX7:       ; %bb.0: ; %entry
4392 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4393 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
4394 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
4395 ; GFX7-NEXT:    s_add_u32 s4, s0, 16
4396 ; GFX7-NEXT:    s_addc_u32 s5, s1, 0
4397 ; GFX7-NEXT:    v_mov_b32_e32 v0, s4
4398 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
4399 ; GFX7-NEXT:    v_mov_b32_e32 v1, s5
4400 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
4401 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4402 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4403 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
4404 ; GFX7-NEXT:    buffer_wbinvl1_vol
4405 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
4406 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
4407 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
4408 ; GFX7-NEXT:    s_endpgm
4410 ; GFX10-WGP-LABEL: global_agent_monotonic_seq_cst_ret_cmpxchg:
4411 ; GFX10-WGP:       ; %bb.0: ; %entry
4412 ; GFX10-WGP-NEXT:    s_clause 0x1
4413 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
4414 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
4415 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
4416 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
4417 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
4418 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
4419 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4420 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
4421 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
4422 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
4423 ; GFX10-WGP-NEXT:    buffer_gl0_inv
4424 ; GFX10-WGP-NEXT:    buffer_gl1_inv
4425 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
4426 ; GFX10-WGP-NEXT:    s_endpgm
4428 ; GFX10-CU-LABEL: global_agent_monotonic_seq_cst_ret_cmpxchg:
4429 ; GFX10-CU:       ; %bb.0: ; %entry
4430 ; GFX10-CU-NEXT:    s_clause 0x1
4431 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
4432 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
4433 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
4434 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
4435 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
4436 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
4437 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4438 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
4439 ; GFX10-CU-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
4440 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
4441 ; GFX10-CU-NEXT:    buffer_gl0_inv
4442 ; GFX10-CU-NEXT:    buffer_gl1_inv
4443 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
4444 ; GFX10-CU-NEXT:    s_endpgm
4446 ; SKIP-CACHE-INV-LABEL: global_agent_monotonic_seq_cst_ret_cmpxchg:
4447 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
4448 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
4449 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
4450 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
4451 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
4452 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
4453 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
4454 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
4455 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4456 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
4457 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
4458 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
4459 ; SKIP-CACHE-INV-NEXT:    s_endpgm
4461 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_monotonic_seq_cst_ret_cmpxchg:
4462 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
4463 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4464 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
4465 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
4466 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
4467 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4468 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4469 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4470 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
4471 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
4472 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
4473 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
4475 ; GFX90A-TGSPLIT-LABEL: global_agent_monotonic_seq_cst_ret_cmpxchg:
4476 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
4477 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4478 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
4479 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
4480 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
4481 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4482 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4483 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4484 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
4485 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
4486 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
4487 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
4488     i32 addrspace(1)* %out, i32 %in, i32 %old) {
4489 entry:
4490   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
4491   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") monotonic seq_cst
4492   %val0 = extractvalue { i32, i1 } %val, 0
4493   store i32 %val0, i32 addrspace(1)* %out, align 4
4494   ret void
4497 define amdgpu_kernel void @global_agent_acquire_seq_cst_ret_cmpxchg(
4498 ; GFX6-LABEL: global_agent_acquire_seq_cst_ret_cmpxchg:
4499 ; GFX6:       ; %bb.0: ; %entry
4500 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4501 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
4502 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
4503 ; GFX6-NEXT:    s_mov_b32 s2, -1
4504 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
4505 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
4506 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
4507 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4508 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
4509 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
4510 ; GFX6-NEXT:    buffer_wbinvl1
4511 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
4512 ; GFX6-NEXT:    s_endpgm
4514 ; GFX7-LABEL: global_agent_acquire_seq_cst_ret_cmpxchg:
4515 ; GFX7:       ; %bb.0: ; %entry
4516 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4517 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
4518 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
4519 ; GFX7-NEXT:    s_add_u32 s4, s0, 16
4520 ; GFX7-NEXT:    s_addc_u32 s5, s1, 0
4521 ; GFX7-NEXT:    v_mov_b32_e32 v0, s4
4522 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
4523 ; GFX7-NEXT:    v_mov_b32_e32 v1, s5
4524 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
4525 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4526 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4527 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
4528 ; GFX7-NEXT:    buffer_wbinvl1_vol
4529 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
4530 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
4531 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
4532 ; GFX7-NEXT:    s_endpgm
4534 ; GFX10-WGP-LABEL: global_agent_acquire_seq_cst_ret_cmpxchg:
4535 ; GFX10-WGP:       ; %bb.0: ; %entry
4536 ; GFX10-WGP-NEXT:    s_clause 0x1
4537 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
4538 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
4539 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
4540 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
4541 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
4542 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
4543 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4544 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
4545 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
4546 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
4547 ; GFX10-WGP-NEXT:    buffer_gl0_inv
4548 ; GFX10-WGP-NEXT:    buffer_gl1_inv
4549 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
4550 ; GFX10-WGP-NEXT:    s_endpgm
4552 ; GFX10-CU-LABEL: global_agent_acquire_seq_cst_ret_cmpxchg:
4553 ; GFX10-CU:       ; %bb.0: ; %entry
4554 ; GFX10-CU-NEXT:    s_clause 0x1
4555 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
4556 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
4557 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
4558 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
4559 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
4560 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
4561 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4562 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
4563 ; GFX10-CU-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
4564 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
4565 ; GFX10-CU-NEXT:    buffer_gl0_inv
4566 ; GFX10-CU-NEXT:    buffer_gl1_inv
4567 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
4568 ; GFX10-CU-NEXT:    s_endpgm
4570 ; SKIP-CACHE-INV-LABEL: global_agent_acquire_seq_cst_ret_cmpxchg:
4571 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
4572 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
4573 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
4574 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
4575 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
4576 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
4577 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
4578 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
4579 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4580 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
4581 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
4582 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
4583 ; SKIP-CACHE-INV-NEXT:    s_endpgm
4585 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_acquire_seq_cst_ret_cmpxchg:
4586 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
4587 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4588 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
4589 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
4590 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
4591 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4592 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4593 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4594 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
4595 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
4596 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
4597 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
4599 ; GFX90A-TGSPLIT-LABEL: global_agent_acquire_seq_cst_ret_cmpxchg:
4600 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
4601 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4602 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
4603 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
4604 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
4605 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4606 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4607 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4608 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
4609 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
4610 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
4611 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
4612     i32 addrspace(1)* %out, i32 %in, i32 %old) {
4613 entry:
4614   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
4615   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") acquire seq_cst
4616   %val0 = extractvalue { i32, i1 } %val, 0
4617   store i32 %val0, i32 addrspace(1)* %out, align 4
4618   ret void
4621 define amdgpu_kernel void @global_agent_release_seq_cst_ret_cmpxchg(
4622 ; GFX6-LABEL: global_agent_release_seq_cst_ret_cmpxchg:
4623 ; GFX6:       ; %bb.0: ; %entry
4624 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4625 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
4626 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
4627 ; GFX6-NEXT:    s_mov_b32 s2, -1
4628 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
4629 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
4630 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
4631 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4632 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
4633 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
4634 ; GFX6-NEXT:    buffer_wbinvl1
4635 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
4636 ; GFX6-NEXT:    s_endpgm
4638 ; GFX7-LABEL: global_agent_release_seq_cst_ret_cmpxchg:
4639 ; GFX7:       ; %bb.0: ; %entry
4640 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4641 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
4642 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
4643 ; GFX7-NEXT:    s_add_u32 s4, s0, 16
4644 ; GFX7-NEXT:    s_addc_u32 s5, s1, 0
4645 ; GFX7-NEXT:    v_mov_b32_e32 v0, s4
4646 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
4647 ; GFX7-NEXT:    v_mov_b32_e32 v1, s5
4648 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
4649 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4650 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4651 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
4652 ; GFX7-NEXT:    buffer_wbinvl1_vol
4653 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
4654 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
4655 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
4656 ; GFX7-NEXT:    s_endpgm
4658 ; GFX10-WGP-LABEL: global_agent_release_seq_cst_ret_cmpxchg:
4659 ; GFX10-WGP:       ; %bb.0: ; %entry
4660 ; GFX10-WGP-NEXT:    s_clause 0x1
4661 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
4662 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
4663 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
4664 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
4665 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
4666 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
4667 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4668 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
4669 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
4670 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
4671 ; GFX10-WGP-NEXT:    buffer_gl0_inv
4672 ; GFX10-WGP-NEXT:    buffer_gl1_inv
4673 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
4674 ; GFX10-WGP-NEXT:    s_endpgm
4676 ; GFX10-CU-LABEL: global_agent_release_seq_cst_ret_cmpxchg:
4677 ; GFX10-CU:       ; %bb.0: ; %entry
4678 ; GFX10-CU-NEXT:    s_clause 0x1
4679 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
4680 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
4681 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
4682 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
4683 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
4684 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
4685 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4686 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
4687 ; GFX10-CU-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
4688 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
4689 ; GFX10-CU-NEXT:    buffer_gl0_inv
4690 ; GFX10-CU-NEXT:    buffer_gl1_inv
4691 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
4692 ; GFX10-CU-NEXT:    s_endpgm
4694 ; SKIP-CACHE-INV-LABEL: global_agent_release_seq_cst_ret_cmpxchg:
4695 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
4696 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
4697 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
4698 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
4699 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
4700 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
4701 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
4702 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
4703 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4704 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
4705 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
4706 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
4707 ; SKIP-CACHE-INV-NEXT:    s_endpgm
4709 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_release_seq_cst_ret_cmpxchg:
4710 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
4711 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4712 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
4713 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
4714 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
4715 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4716 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4717 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4718 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
4719 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
4720 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
4721 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
4723 ; GFX90A-TGSPLIT-LABEL: global_agent_release_seq_cst_ret_cmpxchg:
4724 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
4725 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4726 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
4727 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
4728 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
4729 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4730 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4731 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4732 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
4733 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
4734 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
4735 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
4736     i32 addrspace(1)* %out, i32 %in, i32 %old) {
4737 entry:
4738   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
4739   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") release seq_cst
4740   %val0 = extractvalue { i32, i1 } %val, 0
4741   store i32 %val0, i32 addrspace(1)* %out, align 4
4742   ret void
4745 define amdgpu_kernel void @global_agent_acq_rel_seq_cst_ret_cmpxchg(
4746 ; GFX6-LABEL: global_agent_acq_rel_seq_cst_ret_cmpxchg:
4747 ; GFX6:       ; %bb.0: ; %entry
4748 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4749 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
4750 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
4751 ; GFX6-NEXT:    s_mov_b32 s2, -1
4752 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
4753 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
4754 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
4755 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4756 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
4757 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
4758 ; GFX6-NEXT:    buffer_wbinvl1
4759 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
4760 ; GFX6-NEXT:    s_endpgm
4762 ; GFX7-LABEL: global_agent_acq_rel_seq_cst_ret_cmpxchg:
4763 ; GFX7:       ; %bb.0: ; %entry
4764 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4765 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
4766 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
4767 ; GFX7-NEXT:    s_add_u32 s4, s0, 16
4768 ; GFX7-NEXT:    s_addc_u32 s5, s1, 0
4769 ; GFX7-NEXT:    v_mov_b32_e32 v0, s4
4770 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
4771 ; GFX7-NEXT:    v_mov_b32_e32 v1, s5
4772 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
4773 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4774 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4775 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
4776 ; GFX7-NEXT:    buffer_wbinvl1_vol
4777 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
4778 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
4779 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
4780 ; GFX7-NEXT:    s_endpgm
4782 ; GFX10-WGP-LABEL: global_agent_acq_rel_seq_cst_ret_cmpxchg:
4783 ; GFX10-WGP:       ; %bb.0: ; %entry
4784 ; GFX10-WGP-NEXT:    s_clause 0x1
4785 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
4786 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
4787 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
4788 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
4789 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
4790 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
4791 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4792 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
4793 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
4794 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
4795 ; GFX10-WGP-NEXT:    buffer_gl0_inv
4796 ; GFX10-WGP-NEXT:    buffer_gl1_inv
4797 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
4798 ; GFX10-WGP-NEXT:    s_endpgm
4800 ; GFX10-CU-LABEL: global_agent_acq_rel_seq_cst_ret_cmpxchg:
4801 ; GFX10-CU:       ; %bb.0: ; %entry
4802 ; GFX10-CU-NEXT:    s_clause 0x1
4803 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
4804 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
4805 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
4806 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
4807 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
4808 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
4809 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4810 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
4811 ; GFX10-CU-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
4812 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
4813 ; GFX10-CU-NEXT:    buffer_gl0_inv
4814 ; GFX10-CU-NEXT:    buffer_gl1_inv
4815 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
4816 ; GFX10-CU-NEXT:    s_endpgm
4818 ; SKIP-CACHE-INV-LABEL: global_agent_acq_rel_seq_cst_ret_cmpxchg:
4819 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
4820 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
4821 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
4822 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
4823 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
4824 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
4825 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
4826 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
4827 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4828 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
4829 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
4830 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
4831 ; SKIP-CACHE-INV-NEXT:    s_endpgm
4833 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_acq_rel_seq_cst_ret_cmpxchg:
4834 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
4835 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4836 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
4837 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
4838 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
4839 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4840 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4841 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4842 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
4843 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
4844 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
4845 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
4847 ; GFX90A-TGSPLIT-LABEL: global_agent_acq_rel_seq_cst_ret_cmpxchg:
4848 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
4849 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4850 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
4851 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
4852 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
4853 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4854 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4855 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4856 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
4857 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
4858 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
4859 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
4860     i32 addrspace(1)* %out, i32 %in, i32 %old) {
4861 entry:
4862   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
4863   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") acq_rel seq_cst
4864   %val0 = extractvalue { i32, i1 } %val, 0
4865   store i32 %val0, i32 addrspace(1)* %out, align 4
4866   ret void
4869 define amdgpu_kernel void @global_agent_seq_cst_seq_cst_ret_cmpxchg(
4870 ; GFX6-LABEL: global_agent_seq_cst_seq_cst_ret_cmpxchg:
4871 ; GFX6:       ; %bb.0: ; %entry
4872 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4873 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
4874 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
4875 ; GFX6-NEXT:    s_mov_b32 s2, -1
4876 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
4877 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
4878 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
4879 ; GFX6-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4880 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
4881 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
4882 ; GFX6-NEXT:    buffer_wbinvl1
4883 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
4884 ; GFX6-NEXT:    s_endpgm
4886 ; GFX7-LABEL: global_agent_seq_cst_seq_cst_ret_cmpxchg:
4887 ; GFX7:       ; %bb.0: ; %entry
4888 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4889 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
4890 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
4891 ; GFX7-NEXT:    s_add_u32 s4, s0, 16
4892 ; GFX7-NEXT:    s_addc_u32 s5, s1, 0
4893 ; GFX7-NEXT:    v_mov_b32_e32 v0, s4
4894 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
4895 ; GFX7-NEXT:    v_mov_b32_e32 v1, s5
4896 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
4897 ; GFX7-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4898 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4899 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
4900 ; GFX7-NEXT:    buffer_wbinvl1_vol
4901 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
4902 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
4903 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
4904 ; GFX7-NEXT:    s_endpgm
4906 ; GFX10-WGP-LABEL: global_agent_seq_cst_seq_cst_ret_cmpxchg:
4907 ; GFX10-WGP:       ; %bb.0: ; %entry
4908 ; GFX10-WGP-NEXT:    s_clause 0x1
4909 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
4910 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
4911 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
4912 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
4913 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
4914 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
4915 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4916 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
4917 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
4918 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
4919 ; GFX10-WGP-NEXT:    buffer_gl0_inv
4920 ; GFX10-WGP-NEXT:    buffer_gl1_inv
4921 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
4922 ; GFX10-WGP-NEXT:    s_endpgm
4924 ; GFX10-CU-LABEL: global_agent_seq_cst_seq_cst_ret_cmpxchg:
4925 ; GFX10-CU:       ; %bb.0: ; %entry
4926 ; GFX10-CU-NEXT:    s_clause 0x1
4927 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
4928 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
4929 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
4930 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
4931 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
4932 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
4933 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4934 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
4935 ; GFX10-CU-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
4936 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
4937 ; GFX10-CU-NEXT:    buffer_gl0_inv
4938 ; GFX10-CU-NEXT:    buffer_gl1_inv
4939 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
4940 ; GFX10-CU-NEXT:    s_endpgm
4942 ; SKIP-CACHE-INV-LABEL: global_agent_seq_cst_seq_cst_ret_cmpxchg:
4943 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
4944 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
4945 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
4946 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
4947 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
4948 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
4949 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
4950 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
4951 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4952 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
4953 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
4954 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
4955 ; SKIP-CACHE-INV-NEXT:    s_endpgm
4957 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_seq_cst_seq_cst_ret_cmpxchg:
4958 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
4959 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4960 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
4961 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
4962 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
4963 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4964 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4965 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4966 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
4967 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
4968 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
4969 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
4971 ; GFX90A-TGSPLIT-LABEL: global_agent_seq_cst_seq_cst_ret_cmpxchg:
4972 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
4973 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
4974 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
4975 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
4976 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
4977 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
4978 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
4979 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
4980 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
4981 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
4982 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
4983 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
4984     i32 addrspace(1)* %out, i32 %in, i32 %old) {
4985 entry:
4986   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
4987   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent") seq_cst seq_cst
4988   %val0 = extractvalue { i32, i1 } %val, 0
4989   store i32 %val0, i32 addrspace(1)* %out, align 4
4990   ret void
4993 define amdgpu_kernel void @global_agent_one_as_unordered_load(
4994 ; GFX6-LABEL: global_agent_one_as_unordered_load:
4995 ; GFX6:       ; %bb.0: ; %entry
4996 ; GFX6-NEXT:    s_load_dwordx4 s[4:7], s[4:5], 0x0
4997 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
4998 ; GFX6-NEXT:    s_mov_b32 s2, -1
4999 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
5000 ; GFX6-NEXT:    s_mov_b32 s0, s4
5001 ; GFX6-NEXT:    s_mov_b32 s1, s5
5002 ; GFX6-NEXT:    buffer_load_dword v0, off, s[0:3], 0
5003 ; GFX6-NEXT:    s_mov_b32 s4, s6
5004 ; GFX6-NEXT:    s_mov_b32 s5, s7
5005 ; GFX6-NEXT:    s_mov_b32 s6, s2
5006 ; GFX6-NEXT:    s_mov_b32 s7, s3
5007 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
5008 ; GFX6-NEXT:    buffer_store_dword v0, off, s[4:7], 0
5009 ; GFX6-NEXT:    s_endpgm
5011 ; GFX7-LABEL: global_agent_one_as_unordered_load:
5012 ; GFX7:       ; %bb.0: ; %entry
5013 ; GFX7-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
5014 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
5015 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
5016 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
5017 ; GFX7-NEXT:    flat_load_dword v0, v[0:1]
5018 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
5019 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
5020 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
5021 ; GFX7-NEXT:    flat_store_dword v[2:3], v0
5022 ; GFX7-NEXT:    s_endpgm
5024 ; GFX10-WGP-LABEL: global_agent_one_as_unordered_load:
5025 ; GFX10-WGP:       ; %bb.0: ; %entry
5026 ; GFX10-WGP-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
5027 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, 0
5028 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
5029 ; GFX10-WGP-NEXT:    global_load_dword v1, v0, s[0:1]
5030 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
5031 ; GFX10-WGP-NEXT:    global_store_dword v0, v1, s[2:3]
5032 ; GFX10-WGP-NEXT:    s_endpgm
5034 ; GFX10-CU-LABEL: global_agent_one_as_unordered_load:
5035 ; GFX10-CU:       ; %bb.0: ; %entry
5036 ; GFX10-CU-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
5037 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, 0
5038 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
5039 ; GFX10-CU-NEXT:    global_load_dword v1, v0, s[0:1]
5040 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
5041 ; GFX10-CU-NEXT:    global_store_dword v0, v1, s[2:3]
5042 ; GFX10-CU-NEXT:    s_endpgm
5044 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_unordered_load:
5045 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
5046 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx4 s[4:7], s[0:1], 0x9
5047 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s3, 0xf000
5048 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s2, -1
5049 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
5050 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s0, s4
5051 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s1, s5
5052 ; SKIP-CACHE-INV-NEXT:    buffer_load_dword v0, off, s[0:3], 0
5053 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s4, s6
5054 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s5, s7
5055 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, s2
5056 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, s3
5057 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
5058 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
5059 ; SKIP-CACHE-INV-NEXT:    s_endpgm
5061 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_unordered_load:
5062 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
5063 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
5064 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
5065 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
5066 ; GFX90A-NOTTGSPLIT-NEXT:    global_load_dword v1, v0, s[0:1]
5067 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
5068 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v0, v1, s[2:3]
5069 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
5071 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_unordered_load:
5072 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
5073 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
5074 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
5075 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
5076 ; GFX90A-TGSPLIT-NEXT:    global_load_dword v1, v0, s[0:1]
5077 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
5078 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v0, v1, s[2:3]
5079 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
5080     i32 addrspace(1)* %in, i32 addrspace(1)* %out) {
5081 entry:
5082   %val = load atomic i32, i32 addrspace(1)* %in syncscope("agent-one-as") unordered, align 4
5083   store i32 %val, i32 addrspace(1)* %out
5084   ret void
5087 define amdgpu_kernel void @global_agent_one_as_monotonic_load(
5088 ; GFX6-LABEL: global_agent_one_as_monotonic_load:
5089 ; GFX6:       ; %bb.0: ; %entry
5090 ; GFX6-NEXT:    s_load_dwordx4 s[4:7], s[4:5], 0x0
5091 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
5092 ; GFX6-NEXT:    s_mov_b32 s2, -1
5093 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
5094 ; GFX6-NEXT:    s_mov_b32 s0, s4
5095 ; GFX6-NEXT:    s_mov_b32 s1, s5
5096 ; GFX6-NEXT:    buffer_load_dword v0, off, s[0:3], 0 glc
5097 ; GFX6-NEXT:    s_mov_b32 s4, s6
5098 ; GFX6-NEXT:    s_mov_b32 s5, s7
5099 ; GFX6-NEXT:    s_mov_b32 s6, s2
5100 ; GFX6-NEXT:    s_mov_b32 s7, s3
5101 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
5102 ; GFX6-NEXT:    buffer_store_dword v0, off, s[4:7], 0
5103 ; GFX6-NEXT:    s_endpgm
5105 ; GFX7-LABEL: global_agent_one_as_monotonic_load:
5106 ; GFX7:       ; %bb.0: ; %entry
5107 ; GFX7-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
5108 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
5109 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
5110 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
5111 ; GFX7-NEXT:    flat_load_dword v0, v[0:1] glc
5112 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
5113 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
5114 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
5115 ; GFX7-NEXT:    flat_store_dword v[2:3], v0
5116 ; GFX7-NEXT:    s_endpgm
5118 ; GFX10-WGP-LABEL: global_agent_one_as_monotonic_load:
5119 ; GFX10-WGP:       ; %bb.0: ; %entry
5120 ; GFX10-WGP-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
5121 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, 0
5122 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
5123 ; GFX10-WGP-NEXT:    global_load_dword v1, v0, s[0:1] glc dlc
5124 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
5125 ; GFX10-WGP-NEXT:    global_store_dword v0, v1, s[2:3]
5126 ; GFX10-WGP-NEXT:    s_endpgm
5128 ; GFX10-CU-LABEL: global_agent_one_as_monotonic_load:
5129 ; GFX10-CU:       ; %bb.0: ; %entry
5130 ; GFX10-CU-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
5131 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, 0
5132 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
5133 ; GFX10-CU-NEXT:    global_load_dword v1, v0, s[0:1] glc dlc
5134 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
5135 ; GFX10-CU-NEXT:    global_store_dword v0, v1, s[2:3]
5136 ; GFX10-CU-NEXT:    s_endpgm
5138 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_monotonic_load:
5139 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
5140 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx4 s[4:7], s[0:1], 0x9
5141 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s3, 0xf000
5142 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s2, -1
5143 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
5144 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s0, s4
5145 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s1, s5
5146 ; SKIP-CACHE-INV-NEXT:    buffer_load_dword v0, off, s[0:3], 0 glc
5147 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s4, s6
5148 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s5, s7
5149 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, s2
5150 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, s3
5151 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
5152 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
5153 ; SKIP-CACHE-INV-NEXT:    s_endpgm
5155 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_monotonic_load:
5156 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
5157 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
5158 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
5159 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
5160 ; GFX90A-NOTTGSPLIT-NEXT:    global_load_dword v1, v0, s[0:1] glc
5161 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
5162 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v0, v1, s[2:3]
5163 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
5165 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_monotonic_load:
5166 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
5167 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
5168 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
5169 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
5170 ; GFX90A-TGSPLIT-NEXT:    global_load_dword v1, v0, s[0:1] glc
5171 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
5172 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v0, v1, s[2:3]
5173 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
5174     i32 addrspace(1)* %in, i32 addrspace(1)* %out) {
5175 entry:
5176   %val = load atomic i32, i32 addrspace(1)* %in syncscope("agent-one-as") monotonic, align 4
5177   store i32 %val, i32 addrspace(1)* %out
5178   ret void
5181 define amdgpu_kernel void @global_agent_one_as_acquire_load(
5182 ; GFX6-LABEL: global_agent_one_as_acquire_load:
5183 ; GFX6:       ; %bb.0: ; %entry
5184 ; GFX6-NEXT:    s_load_dwordx4 s[4:7], s[4:5], 0x0
5185 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
5186 ; GFX6-NEXT:    s_mov_b32 s2, -1
5187 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
5188 ; GFX6-NEXT:    s_mov_b32 s0, s4
5189 ; GFX6-NEXT:    s_mov_b32 s1, s5
5190 ; GFX6-NEXT:    buffer_load_dword v0, off, s[0:3], 0 glc
5191 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
5192 ; GFX6-NEXT:    buffer_wbinvl1
5193 ; GFX6-NEXT:    s_mov_b32 s4, s6
5194 ; GFX6-NEXT:    s_mov_b32 s5, s7
5195 ; GFX6-NEXT:    s_mov_b32 s6, s2
5196 ; GFX6-NEXT:    s_mov_b32 s7, s3
5197 ; GFX6-NEXT:    buffer_store_dword v0, off, s[4:7], 0
5198 ; GFX6-NEXT:    s_endpgm
5200 ; GFX7-LABEL: global_agent_one_as_acquire_load:
5201 ; GFX7:       ; %bb.0: ; %entry
5202 ; GFX7-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
5203 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
5204 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
5205 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
5206 ; GFX7-NEXT:    flat_load_dword v0, v[0:1] glc
5207 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
5208 ; GFX7-NEXT:    buffer_wbinvl1_vol
5209 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
5210 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
5211 ; GFX7-NEXT:    flat_store_dword v[2:3], v0
5212 ; GFX7-NEXT:    s_endpgm
5214 ; GFX10-WGP-LABEL: global_agent_one_as_acquire_load:
5215 ; GFX10-WGP:       ; %bb.0: ; %entry
5216 ; GFX10-WGP-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
5217 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, 0
5218 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
5219 ; GFX10-WGP-NEXT:    global_load_dword v1, v0, s[0:1] glc dlc
5220 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
5221 ; GFX10-WGP-NEXT:    buffer_gl0_inv
5222 ; GFX10-WGP-NEXT:    buffer_gl1_inv
5223 ; GFX10-WGP-NEXT:    global_store_dword v0, v1, s[2:3]
5224 ; GFX10-WGP-NEXT:    s_endpgm
5226 ; GFX10-CU-LABEL: global_agent_one_as_acquire_load:
5227 ; GFX10-CU:       ; %bb.0: ; %entry
5228 ; GFX10-CU-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
5229 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, 0
5230 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
5231 ; GFX10-CU-NEXT:    global_load_dword v1, v0, s[0:1] glc dlc
5232 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
5233 ; GFX10-CU-NEXT:    buffer_gl0_inv
5234 ; GFX10-CU-NEXT:    buffer_gl1_inv
5235 ; GFX10-CU-NEXT:    global_store_dword v0, v1, s[2:3]
5236 ; GFX10-CU-NEXT:    s_endpgm
5238 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_acquire_load:
5239 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
5240 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx4 s[4:7], s[0:1], 0x9
5241 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s3, 0xf000
5242 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s2, -1
5243 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
5244 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s0, s4
5245 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s1, s5
5246 ; SKIP-CACHE-INV-NEXT:    buffer_load_dword v0, off, s[0:3], 0 glc
5247 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
5248 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s4, s6
5249 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s5, s7
5250 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, s2
5251 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, s3
5252 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
5253 ; SKIP-CACHE-INV-NEXT:    s_endpgm
5255 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_acquire_load:
5256 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
5257 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
5258 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
5259 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
5260 ; GFX90A-NOTTGSPLIT-NEXT:    global_load_dword v1, v0, s[0:1] glc
5261 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
5262 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
5263 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v0, v1, s[2:3]
5264 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
5266 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_acquire_load:
5267 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
5268 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
5269 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
5270 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
5271 ; GFX90A-TGSPLIT-NEXT:    global_load_dword v1, v0, s[0:1] glc
5272 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
5273 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
5274 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v0, v1, s[2:3]
5275 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
5276     i32 addrspace(1)* %in, i32 addrspace(1)* %out) {
5277 entry:
5278   %val = load atomic i32, i32 addrspace(1)* %in syncscope("agent-one-as") acquire, align 4
5279   store i32 %val, i32 addrspace(1)* %out
5280   ret void
5283 define amdgpu_kernel void @global_agent_one_as_seq_cst_load(
5284 ; GFX6-LABEL: global_agent_one_as_seq_cst_load:
5285 ; GFX6:       ; %bb.0: ; %entry
5286 ; GFX6-NEXT:    s_load_dwordx4 s[4:7], s[4:5], 0x0
5287 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
5288 ; GFX6-NEXT:    s_mov_b32 s2, -1
5289 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
5290 ; GFX6-NEXT:    s_mov_b32 s0, s4
5291 ; GFX6-NEXT:    s_mov_b32 s1, s5
5292 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
5293 ; GFX6-NEXT:    buffer_load_dword v0, off, s[0:3], 0 glc
5294 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
5295 ; GFX6-NEXT:    buffer_wbinvl1
5296 ; GFX6-NEXT:    s_mov_b32 s4, s6
5297 ; GFX6-NEXT:    s_mov_b32 s5, s7
5298 ; GFX6-NEXT:    s_mov_b32 s6, s2
5299 ; GFX6-NEXT:    s_mov_b32 s7, s3
5300 ; GFX6-NEXT:    buffer_store_dword v0, off, s[4:7], 0
5301 ; GFX6-NEXT:    s_endpgm
5303 ; GFX7-LABEL: global_agent_one_as_seq_cst_load:
5304 ; GFX7:       ; %bb.0: ; %entry
5305 ; GFX7-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
5306 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
5307 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
5308 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
5309 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
5310 ; GFX7-NEXT:    flat_load_dword v0, v[0:1] glc
5311 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
5312 ; GFX7-NEXT:    buffer_wbinvl1_vol
5313 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
5314 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
5315 ; GFX7-NEXT:    flat_store_dword v[2:3], v0
5316 ; GFX7-NEXT:    s_endpgm
5318 ; GFX10-WGP-LABEL: global_agent_one_as_seq_cst_load:
5319 ; GFX10-WGP:       ; %bb.0: ; %entry
5320 ; GFX10-WGP-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
5321 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, 0
5322 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
5323 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
5324 ; GFX10-WGP-NEXT:    global_load_dword v1, v0, s[0:1] glc dlc
5325 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
5326 ; GFX10-WGP-NEXT:    buffer_gl0_inv
5327 ; GFX10-WGP-NEXT:    buffer_gl1_inv
5328 ; GFX10-WGP-NEXT:    global_store_dword v0, v1, s[2:3]
5329 ; GFX10-WGP-NEXT:    s_endpgm
5331 ; GFX10-CU-LABEL: global_agent_one_as_seq_cst_load:
5332 ; GFX10-CU:       ; %bb.0: ; %entry
5333 ; GFX10-CU-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
5334 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, 0
5335 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
5336 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
5337 ; GFX10-CU-NEXT:    global_load_dword v1, v0, s[0:1] glc dlc
5338 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
5339 ; GFX10-CU-NEXT:    buffer_gl0_inv
5340 ; GFX10-CU-NEXT:    buffer_gl1_inv
5341 ; GFX10-CU-NEXT:    global_store_dword v0, v1, s[2:3]
5342 ; GFX10-CU-NEXT:    s_endpgm
5344 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_seq_cst_load:
5345 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
5346 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx4 s[4:7], s[0:1], 0x9
5347 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s3, 0xf000
5348 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s2, -1
5349 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
5350 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s0, s4
5351 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s1, s5
5352 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
5353 ; SKIP-CACHE-INV-NEXT:    buffer_load_dword v0, off, s[0:3], 0 glc
5354 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
5355 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s4, s6
5356 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s5, s7
5357 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, s2
5358 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, s3
5359 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
5360 ; SKIP-CACHE-INV-NEXT:    s_endpgm
5362 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_seq_cst_load:
5363 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
5364 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
5365 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
5366 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
5367 ; GFX90A-NOTTGSPLIT-NEXT:    global_load_dword v1, v0, s[0:1] glc
5368 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
5369 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
5370 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v0, v1, s[2:3]
5371 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
5373 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_seq_cst_load:
5374 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
5375 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x0
5376 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
5377 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
5378 ; GFX90A-TGSPLIT-NEXT:    global_load_dword v1, v0, s[0:1] glc
5379 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
5380 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
5381 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v0, v1, s[2:3]
5382 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
5383     i32 addrspace(1)* %in, i32 addrspace(1)* %out) {
5384 entry:
5385   %val = load atomic i32, i32 addrspace(1)* %in syncscope("agent-one-as") seq_cst, align 4
5386   store i32 %val, i32 addrspace(1)* %out
5387   ret void
5390 define amdgpu_kernel void @global_agent_one_as_unordered_store(
5391 ; GFX6-LABEL: global_agent_one_as_unordered_store:
5392 ; GFX6:       ; %bb.0: ; %entry
5393 ; GFX6-NEXT:    s_load_dword s6, s[4:5], 0x0
5394 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], 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, s6
5399 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
5400 ; GFX6-NEXT:    s_endpgm
5402 ; GFX7-LABEL: global_agent_one_as_unordered_store:
5403 ; GFX7:       ; %bb.0: ; %entry
5404 ; GFX7-NEXT:    s_load_dword s2, s[4:5], 0x0
5405 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x2
5406 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
5407 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
5408 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
5409 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
5410 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
5411 ; GFX7-NEXT:    s_endpgm
5413 ; GFX10-WGP-LABEL: global_agent_one_as_unordered_store:
5414 ; GFX10-WGP:       ; %bb.0: ; %entry
5415 ; GFX10-WGP-NEXT:    s_clause 0x1
5416 ; GFX10-WGP-NEXT:    s_load_dword s2, s[4:5], 0x0
5417 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
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_store_dword v0, v1, s[0:1]
5422 ; GFX10-WGP-NEXT:    s_endpgm
5424 ; GFX10-CU-LABEL: global_agent_one_as_unordered_store:
5425 ; GFX10-CU:       ; %bb.0: ; %entry
5426 ; GFX10-CU-NEXT:    s_clause 0x1
5427 ; GFX10-CU-NEXT:    s_load_dword s2, s[4:5], 0x0
5428 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
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_store_dword v0, v1, s[0:1]
5433 ; GFX10-CU-NEXT:    s_endpgm
5435 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_unordered_store:
5436 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
5437 ; SKIP-CACHE-INV-NEXT:    s_load_dword s4, s[0:1], 0x9
5438 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
5439 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s3, 0xf000
5440 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s2, -1
5441 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
5442 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s4
5443 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[0:3], 0
5444 ; SKIP-CACHE-INV-NEXT:    s_endpgm
5446 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_unordered_store:
5447 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
5448 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x0
5449 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], 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_store_dword v0, v1, s[0:1]
5454 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
5456 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_unordered_store:
5457 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
5458 ; GFX90A-TGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x0
5459 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], 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_store_dword v0, v1, s[0:1]
5464 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
5465     i32 %in, i32 addrspace(1)* %out) {
5466 entry:
5467   store atomic i32 %in, i32 addrspace(1)* %out syncscope("agent-one-as") unordered, align 4
5468   ret void
5471 define amdgpu_kernel void @global_agent_one_as_monotonic_store(
5472 ; GFX6-LABEL: global_agent_one_as_monotonic_store:
5473 ; GFX6:       ; %bb.0: ; %entry
5474 ; GFX6-NEXT:    s_load_dword s6, s[4:5], 0x0
5475 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], 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, s6
5480 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
5481 ; GFX6-NEXT:    s_endpgm
5483 ; GFX7-LABEL: global_agent_one_as_monotonic_store:
5484 ; GFX7:       ; %bb.0: ; %entry
5485 ; GFX7-NEXT:    s_load_dword s2, s[4:5], 0x0
5486 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x2
5487 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
5488 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
5489 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
5490 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
5491 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
5492 ; GFX7-NEXT:    s_endpgm
5494 ; GFX10-WGP-LABEL: global_agent_one_as_monotonic_store:
5495 ; GFX10-WGP:       ; %bb.0: ; %entry
5496 ; GFX10-WGP-NEXT:    s_clause 0x1
5497 ; GFX10-WGP-NEXT:    s_load_dword s2, s[4:5], 0x0
5498 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
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_store_dword v0, v1, s[0:1]
5503 ; GFX10-WGP-NEXT:    s_endpgm
5505 ; GFX10-CU-LABEL: global_agent_one_as_monotonic_store:
5506 ; GFX10-CU:       ; %bb.0: ; %entry
5507 ; GFX10-CU-NEXT:    s_clause 0x1
5508 ; GFX10-CU-NEXT:    s_load_dword s2, s[4:5], 0x0
5509 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
5510 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, 0
5511 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
5512 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s2
5513 ; GFX10-CU-NEXT:    global_store_dword v0, v1, s[0:1]
5514 ; GFX10-CU-NEXT:    s_endpgm
5516 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_monotonic_store:
5517 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
5518 ; SKIP-CACHE-INV-NEXT:    s_load_dword s4, s[0:1], 0x9
5519 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
5520 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s3, 0xf000
5521 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s2, -1
5522 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
5523 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s4
5524 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[0:3], 0
5525 ; SKIP-CACHE-INV-NEXT:    s_endpgm
5527 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_monotonic_store:
5528 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
5529 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x0
5530 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
5531 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
5532 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
5533 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
5534 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v0, v1, s[0:1]
5535 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
5537 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_monotonic_store:
5538 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
5539 ; GFX90A-TGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x0
5540 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
5541 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
5542 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
5543 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
5544 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v0, v1, s[0:1]
5545 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
5546     i32 %in, i32 addrspace(1)* %out) {
5547 entry:
5548   store atomic i32 %in, i32 addrspace(1)* %out syncscope("agent-one-as") monotonic, align 4
5549   ret void
5552 define amdgpu_kernel void @global_agent_one_as_release_store(
5553 ; GFX6-LABEL: global_agent_one_as_release_store:
5554 ; GFX6:       ; %bb.0: ; %entry
5555 ; GFX6-NEXT:    s_load_dword s6, s[4:5], 0x0
5556 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x2
5557 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
5558 ; GFX6-NEXT:    s_mov_b32 s2, -1
5559 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
5560 ; GFX6-NEXT:    v_mov_b32_e32 v0, s6
5561 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
5562 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
5563 ; GFX6-NEXT:    s_endpgm
5565 ; GFX7-LABEL: global_agent_one_as_release_store:
5566 ; GFX7:       ; %bb.0: ; %entry
5567 ; GFX7-NEXT:    s_load_dword s2, s[4:5], 0x0
5568 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x2
5569 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
5570 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
5571 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
5572 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
5573 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
5574 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
5575 ; GFX7-NEXT:    s_endpgm
5577 ; GFX10-WGP-LABEL: global_agent_one_as_release_store:
5578 ; GFX10-WGP:       ; %bb.0: ; %entry
5579 ; GFX10-WGP-NEXT:    s_clause 0x1
5580 ; GFX10-WGP-NEXT:    s_load_dword s2, s[4:5], 0x0
5581 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
5582 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, 0
5583 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
5584 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s2
5585 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
5586 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
5587 ; GFX10-WGP-NEXT:    global_store_dword v0, v1, s[0:1]
5588 ; GFX10-WGP-NEXT:    s_endpgm
5590 ; GFX10-CU-LABEL: global_agent_one_as_release_store:
5591 ; GFX10-CU:       ; %bb.0: ; %entry
5592 ; GFX10-CU-NEXT:    s_clause 0x1
5593 ; GFX10-CU-NEXT:    s_load_dword s2, s[4:5], 0x0
5594 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
5595 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, 0
5596 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
5597 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s2
5598 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
5599 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
5600 ; GFX10-CU-NEXT:    global_store_dword v0, v1, s[0:1]
5601 ; GFX10-CU-NEXT:    s_endpgm
5603 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_release_store:
5604 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
5605 ; SKIP-CACHE-INV-NEXT:    s_load_dword s4, s[0:1], 0x9
5606 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
5607 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s3, 0xf000
5608 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s2, -1
5609 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
5610 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s4
5611 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
5612 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[0:3], 0
5613 ; SKIP-CACHE-INV-NEXT:    s_endpgm
5615 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_release_store:
5616 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
5617 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x0
5618 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
5619 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
5620 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
5621 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
5622 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
5623 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v0, v1, s[0:1]
5624 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
5626 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_release_store:
5627 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
5628 ; GFX90A-TGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x0
5629 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
5630 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
5631 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
5632 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
5633 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
5634 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v0, v1, s[0:1]
5635 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
5636     i32 %in, i32 addrspace(1)* %out) {
5637 entry:
5638   store atomic i32 %in, i32 addrspace(1)* %out syncscope("agent-one-as") release, align 4
5639   ret void
5642 define amdgpu_kernel void @global_agent_one_as_seq_cst_store(
5643 ; GFX6-LABEL: global_agent_one_as_seq_cst_store:
5644 ; GFX6:       ; %bb.0: ; %entry
5645 ; GFX6-NEXT:    s_load_dword s6, s[4:5], 0x0
5646 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x2
5647 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
5648 ; GFX6-NEXT:    s_mov_b32 s2, -1
5649 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
5650 ; GFX6-NEXT:    v_mov_b32_e32 v0, s6
5651 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
5652 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
5653 ; GFX6-NEXT:    s_endpgm
5655 ; GFX7-LABEL: global_agent_one_as_seq_cst_store:
5656 ; GFX7:       ; %bb.0: ; %entry
5657 ; GFX7-NEXT:    s_load_dword s2, s[4:5], 0x0
5658 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x2
5659 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
5660 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
5661 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
5662 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
5663 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
5664 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
5665 ; GFX7-NEXT:    s_endpgm
5667 ; GFX10-WGP-LABEL: global_agent_one_as_seq_cst_store:
5668 ; GFX10-WGP:       ; %bb.0: ; %entry
5669 ; GFX10-WGP-NEXT:    s_clause 0x1
5670 ; GFX10-WGP-NEXT:    s_load_dword s2, s[4:5], 0x0
5671 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
5672 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, 0
5673 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
5674 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s2
5675 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
5676 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
5677 ; GFX10-WGP-NEXT:    global_store_dword v0, v1, s[0:1]
5678 ; GFX10-WGP-NEXT:    s_endpgm
5680 ; GFX10-CU-LABEL: global_agent_one_as_seq_cst_store:
5681 ; GFX10-CU:       ; %bb.0: ; %entry
5682 ; GFX10-CU-NEXT:    s_clause 0x1
5683 ; GFX10-CU-NEXT:    s_load_dword s2, s[4:5], 0x0
5684 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
5685 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, 0
5686 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
5687 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s2
5688 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
5689 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
5690 ; GFX10-CU-NEXT:    global_store_dword v0, v1, s[0:1]
5691 ; GFX10-CU-NEXT:    s_endpgm
5693 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_seq_cst_store:
5694 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
5695 ; SKIP-CACHE-INV-NEXT:    s_load_dword s4, s[0:1], 0x9
5696 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
5697 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s3, 0xf000
5698 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s2, -1
5699 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
5700 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s4
5701 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
5702 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[0:3], 0
5703 ; SKIP-CACHE-INV-NEXT:    s_endpgm
5705 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_seq_cst_store:
5706 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
5707 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x0
5708 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
5709 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
5710 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
5711 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
5712 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
5713 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v0, v1, s[0:1]
5714 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
5716 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_seq_cst_store:
5717 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
5718 ; GFX90A-TGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x0
5719 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
5720 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
5721 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
5722 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
5723 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
5724 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v0, v1, s[0:1]
5725 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
5726     i32 %in, i32 addrspace(1)* %out) {
5727 entry:
5728   store atomic i32 %in, i32 addrspace(1)* %out syncscope("agent-one-as") seq_cst, align 4
5729   ret void
5732 define amdgpu_kernel void @global_agent_one_as_monotonic_atomicrmw(
5733 ; GFX6-LABEL: global_agent_one_as_monotonic_atomicrmw:
5734 ; GFX6:       ; %bb.0: ; %entry
5735 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
5736 ; GFX6-NEXT:    s_load_dword s4, s[4:5], 0x2
5737 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
5738 ; GFX6-NEXT:    s_mov_b32 s2, -1
5739 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
5740 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
5741 ; GFX6-NEXT:    buffer_atomic_swap v0, off, s[0:3], 0
5742 ; GFX6-NEXT:    s_endpgm
5744 ; GFX7-LABEL: global_agent_one_as_monotonic_atomicrmw:
5745 ; GFX7:       ; %bb.0: ; %entry
5746 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
5747 ; GFX7-NEXT:    s_load_dword s2, s[4:5], 0x2
5748 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
5749 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
5750 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
5751 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
5752 ; GFX7-NEXT:    flat_atomic_swap v[0:1], v2
5753 ; GFX7-NEXT:    s_endpgm
5755 ; GFX10-WGP-LABEL: global_agent_one_as_monotonic_atomicrmw:
5756 ; GFX10-WGP:       ; %bb.0: ; %entry
5757 ; GFX10-WGP-NEXT:    s_clause 0x1
5758 ; GFX10-WGP-NEXT:    s_load_dword s2, s[4:5], 0x8
5759 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
5760 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, 0
5761 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
5762 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s2
5763 ; GFX10-WGP-NEXT:    global_atomic_swap v0, v1, s[0:1]
5764 ; GFX10-WGP-NEXT:    s_endpgm
5766 ; GFX10-CU-LABEL: global_agent_one_as_monotonic_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_agent_one_as_monotonic_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_agent_one_as_monotonic_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_agent_one_as_monotonic_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:    global_atomic_swap v0, v1, s[0:1]
5806 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
5807     i32 addrspace(1)* %out, i32 %in) {
5808 entry:
5809   %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("agent-one-as") monotonic
5810   ret void
5813 define amdgpu_kernel void @global_agent_one_as_acquire_atomicrmw(
5814 ; GFX6-LABEL: global_agent_one_as_acquire_atomicrmw:
5815 ; GFX6:       ; %bb.0: ; %entry
5816 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
5817 ; GFX6-NEXT:    s_load_dword s4, s[4:5], 0x2
5818 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
5819 ; GFX6-NEXT:    s_mov_b32 s2, -1
5820 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
5821 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
5822 ; GFX6-NEXT:    buffer_atomic_swap v0, off, s[0:3], 0
5823 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
5824 ; GFX6-NEXT:    buffer_wbinvl1
5825 ; GFX6-NEXT:    s_endpgm
5827 ; GFX7-LABEL: global_agent_one_as_acquire_atomicrmw:
5828 ; GFX7:       ; %bb.0: ; %entry
5829 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
5830 ; GFX7-NEXT:    s_load_dword s2, s[4:5], 0x2
5831 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
5832 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
5833 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
5834 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
5835 ; GFX7-NEXT:    flat_atomic_swap v[0:1], v2
5836 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
5837 ; GFX7-NEXT:    buffer_wbinvl1_vol
5838 ; GFX7-NEXT:    s_endpgm
5840 ; GFX10-WGP-LABEL: global_agent_one_as_acquire_atomicrmw:
5841 ; GFX10-WGP:       ; %bb.0: ; %entry
5842 ; GFX10-WGP-NEXT:    s_clause 0x1
5843 ; GFX10-WGP-NEXT:    s_load_dword s2, s[4:5], 0x8
5844 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
5845 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, 0
5846 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
5847 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s2
5848 ; GFX10-WGP-NEXT:    global_atomic_swap v0, v1, s[0:1]
5849 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
5850 ; GFX10-WGP-NEXT:    buffer_gl0_inv
5851 ; GFX10-WGP-NEXT:    buffer_gl1_inv
5852 ; GFX10-WGP-NEXT:    s_endpgm
5854 ; GFX10-CU-LABEL: global_agent_one_as_acquire_atomicrmw:
5855 ; GFX10-CU:       ; %bb.0: ; %entry
5856 ; GFX10-CU-NEXT:    s_clause 0x1
5857 ; GFX10-CU-NEXT:    s_load_dword s2, s[4:5], 0x8
5858 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
5859 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, 0
5860 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
5861 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s2
5862 ; GFX10-CU-NEXT:    global_atomic_swap v0, v1, s[0:1]
5863 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
5864 ; GFX10-CU-NEXT:    buffer_gl0_inv
5865 ; GFX10-CU-NEXT:    buffer_gl1_inv
5866 ; GFX10-CU-NEXT:    s_endpgm
5868 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_acquire_atomicrmw:
5869 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
5870 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
5871 ; SKIP-CACHE-INV-NEXT:    s_load_dword s0, s[0:1], 0xb
5872 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
5873 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
5874 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
5875 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
5876 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_swap v0, off, s[4:7], 0
5877 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
5878 ; SKIP-CACHE-INV-NEXT:    s_endpgm
5880 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_acquire_atomicrmw:
5881 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
5882 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
5883 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
5884 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
5885 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
5886 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
5887 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_swap v0, v1, s[0:1]
5888 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
5889 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
5890 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
5892 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_acquire_atomicrmw:
5893 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
5894 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
5895 ; GFX90A-TGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
5896 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
5897 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
5898 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
5899 ; GFX90A-TGSPLIT-NEXT:    global_atomic_swap v0, v1, s[0:1]
5900 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
5901 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
5902 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
5903     i32 addrspace(1)* %out, i32 %in) {
5904 entry:
5905   %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("agent-one-as") acquire
5906   ret void
5909 define amdgpu_kernel void @global_agent_one_as_release_atomicrmw(
5910 ; GFX6-LABEL: global_agent_one_as_release_atomicrmw:
5911 ; GFX6:       ; %bb.0: ; %entry
5912 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
5913 ; GFX6-NEXT:    s_load_dword s4, s[4:5], 0x2
5914 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
5915 ; GFX6-NEXT:    s_mov_b32 s2, -1
5916 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
5917 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
5918 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
5919 ; GFX6-NEXT:    buffer_atomic_swap v0, off, s[0:3], 0
5920 ; GFX6-NEXT:    s_endpgm
5922 ; GFX7-LABEL: global_agent_one_as_release_atomicrmw:
5923 ; GFX7:       ; %bb.0: ; %entry
5924 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
5925 ; GFX7-NEXT:    s_load_dword s2, s[4:5], 0x2
5926 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
5927 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
5928 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
5929 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
5930 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
5931 ; GFX7-NEXT:    flat_atomic_swap v[0:1], v2
5932 ; GFX7-NEXT:    s_endpgm
5934 ; GFX10-WGP-LABEL: global_agent_one_as_release_atomicrmw:
5935 ; GFX10-WGP:       ; %bb.0: ; %entry
5936 ; GFX10-WGP-NEXT:    s_clause 0x1
5937 ; GFX10-WGP-NEXT:    s_load_dword s2, s[4:5], 0x8
5938 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
5939 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, 0
5940 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
5941 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s2
5942 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
5943 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
5944 ; GFX10-WGP-NEXT:    global_atomic_swap v0, v1, s[0:1]
5945 ; GFX10-WGP-NEXT:    s_endpgm
5947 ; GFX10-CU-LABEL: global_agent_one_as_release_atomicrmw:
5948 ; GFX10-CU:       ; %bb.0: ; %entry
5949 ; GFX10-CU-NEXT:    s_clause 0x1
5950 ; GFX10-CU-NEXT:    s_load_dword s2, s[4:5], 0x8
5951 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
5952 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, 0
5953 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
5954 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s2
5955 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
5956 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
5957 ; GFX10-CU-NEXT:    global_atomic_swap v0, v1, s[0:1]
5958 ; GFX10-CU-NEXT:    s_endpgm
5960 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_release_atomicrmw:
5961 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
5962 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
5963 ; SKIP-CACHE-INV-NEXT:    s_load_dword s0, s[0:1], 0xb
5964 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
5965 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
5966 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
5967 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
5968 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
5969 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_swap v0, off, s[4:7], 0
5970 ; SKIP-CACHE-INV-NEXT:    s_endpgm
5972 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_release_atomicrmw:
5973 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
5974 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
5975 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
5976 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
5977 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
5978 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
5979 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
5980 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_swap v0, v1, s[0:1]
5981 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
5983 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_release_atomicrmw:
5984 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
5985 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
5986 ; GFX90A-TGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
5987 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
5988 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
5989 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
5990 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
5991 ; GFX90A-TGSPLIT-NEXT:    global_atomic_swap v0, v1, s[0:1]
5992 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
5993     i32 addrspace(1)* %out, i32 %in) {
5994 entry:
5995   %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("agent-one-as") release
5996   ret void
5999 define amdgpu_kernel void @global_agent_one_as_acq_rel_atomicrmw(
6000 ; GFX6-LABEL: global_agent_one_as_acq_rel_atomicrmw:
6001 ; GFX6:       ; %bb.0: ; %entry
6002 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6003 ; GFX6-NEXT:    s_load_dword s4, s[4:5], 0x2
6004 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
6005 ; GFX6-NEXT:    s_mov_b32 s2, -1
6006 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
6007 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
6008 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
6009 ; GFX6-NEXT:    buffer_atomic_swap v0, off, s[0:3], 0
6010 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
6011 ; GFX6-NEXT:    buffer_wbinvl1
6012 ; GFX6-NEXT:    s_endpgm
6014 ; GFX7-LABEL: global_agent_one_as_acq_rel_atomicrmw:
6015 ; GFX7:       ; %bb.0: ; %entry
6016 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6017 ; GFX7-NEXT:    s_load_dword s2, s[4:5], 0x2
6018 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
6019 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
6020 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
6021 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
6022 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
6023 ; GFX7-NEXT:    flat_atomic_swap v[0:1], v2
6024 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
6025 ; GFX7-NEXT:    buffer_wbinvl1_vol
6026 ; GFX7-NEXT:    s_endpgm
6028 ; GFX10-WGP-LABEL: global_agent_one_as_acq_rel_atomicrmw:
6029 ; GFX10-WGP:       ; %bb.0: ; %entry
6030 ; GFX10-WGP-NEXT:    s_clause 0x1
6031 ; GFX10-WGP-NEXT:    s_load_dword s2, s[4:5], 0x8
6032 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6033 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, 0
6034 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
6035 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s2
6036 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
6037 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
6038 ; GFX10-WGP-NEXT:    global_atomic_swap v0, v1, s[0:1]
6039 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
6040 ; GFX10-WGP-NEXT:    buffer_gl0_inv
6041 ; GFX10-WGP-NEXT:    buffer_gl1_inv
6042 ; GFX10-WGP-NEXT:    s_endpgm
6044 ; GFX10-CU-LABEL: global_agent_one_as_acq_rel_atomicrmw:
6045 ; GFX10-CU:       ; %bb.0: ; %entry
6046 ; GFX10-CU-NEXT:    s_clause 0x1
6047 ; GFX10-CU-NEXT:    s_load_dword s2, s[4:5], 0x8
6048 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6049 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, 0
6050 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
6051 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s2
6052 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
6053 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
6054 ; GFX10-CU-NEXT:    global_atomic_swap v0, v1, s[0:1]
6055 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
6056 ; GFX10-CU-NEXT:    buffer_gl0_inv
6057 ; GFX10-CU-NEXT:    buffer_gl1_inv
6058 ; GFX10-CU-NEXT:    s_endpgm
6060 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_acq_rel_atomicrmw:
6061 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
6062 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
6063 ; SKIP-CACHE-INV-NEXT:    s_load_dword s0, s[0:1], 0xb
6064 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
6065 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
6066 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
6067 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
6068 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
6069 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_swap v0, off, s[4:7], 0
6070 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
6071 ; SKIP-CACHE-INV-NEXT:    s_endpgm
6073 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_acq_rel_atomicrmw:
6074 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
6075 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6076 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
6077 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
6078 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
6079 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
6080 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
6081 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_swap v0, v1, s[0:1]
6082 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
6083 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
6084 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
6086 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_acq_rel_atomicrmw:
6087 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
6088 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6089 ; GFX90A-TGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
6090 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
6091 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
6092 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
6093 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
6094 ; GFX90A-TGSPLIT-NEXT:    global_atomic_swap v0, v1, s[0:1]
6095 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
6096 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
6097 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
6098     i32 addrspace(1)* %out, i32 %in) {
6099 entry:
6100   %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("agent-one-as") acq_rel
6101   ret void
6104 define amdgpu_kernel void @global_agent_one_as_seq_cst_atomicrmw(
6105 ; GFX6-LABEL: global_agent_one_as_seq_cst_atomicrmw:
6106 ; GFX6:       ; %bb.0: ; %entry
6107 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6108 ; GFX6-NEXT:    s_load_dword s4, s[4:5], 0x2
6109 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
6110 ; GFX6-NEXT:    s_mov_b32 s2, -1
6111 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
6112 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
6113 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
6114 ; GFX6-NEXT:    buffer_atomic_swap v0, off, s[0:3], 0
6115 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
6116 ; GFX6-NEXT:    buffer_wbinvl1
6117 ; GFX6-NEXT:    s_endpgm
6119 ; GFX7-LABEL: global_agent_one_as_seq_cst_atomicrmw:
6120 ; GFX7:       ; %bb.0: ; %entry
6121 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6122 ; GFX7-NEXT:    s_load_dword s2, s[4:5], 0x2
6123 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
6124 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
6125 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
6126 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
6127 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
6128 ; GFX7-NEXT:    flat_atomic_swap v[0:1], v2
6129 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
6130 ; GFX7-NEXT:    buffer_wbinvl1_vol
6131 ; GFX7-NEXT:    s_endpgm
6133 ; GFX10-WGP-LABEL: global_agent_one_as_seq_cst_atomicrmw:
6134 ; GFX10-WGP:       ; %bb.0: ; %entry
6135 ; GFX10-WGP-NEXT:    s_clause 0x1
6136 ; GFX10-WGP-NEXT:    s_load_dword s2, s[4:5], 0x8
6137 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6138 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, 0
6139 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
6140 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s2
6141 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
6142 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
6143 ; GFX10-WGP-NEXT:    global_atomic_swap v0, v1, s[0:1]
6144 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
6145 ; GFX10-WGP-NEXT:    buffer_gl0_inv
6146 ; GFX10-WGP-NEXT:    buffer_gl1_inv
6147 ; GFX10-WGP-NEXT:    s_endpgm
6149 ; GFX10-CU-LABEL: global_agent_one_as_seq_cst_atomicrmw:
6150 ; GFX10-CU:       ; %bb.0: ; %entry
6151 ; GFX10-CU-NEXT:    s_clause 0x1
6152 ; GFX10-CU-NEXT:    s_load_dword s2, s[4:5], 0x8
6153 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6154 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, 0
6155 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
6156 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s2
6157 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
6158 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
6159 ; GFX10-CU-NEXT:    global_atomic_swap v0, v1, s[0:1]
6160 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
6161 ; GFX10-CU-NEXT:    buffer_gl0_inv
6162 ; GFX10-CU-NEXT:    buffer_gl1_inv
6163 ; GFX10-CU-NEXT:    s_endpgm
6165 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_seq_cst_atomicrmw:
6166 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
6167 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
6168 ; SKIP-CACHE-INV-NEXT:    s_load_dword s0, s[0:1], 0xb
6169 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
6170 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
6171 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
6172 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
6173 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
6174 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_swap v0, off, s[4:7], 0
6175 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
6176 ; SKIP-CACHE-INV-NEXT:    s_endpgm
6178 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_seq_cst_atomicrmw:
6179 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
6180 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6181 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
6182 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
6183 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
6184 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
6185 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
6186 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_swap v0, v1, s[0:1]
6187 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
6188 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
6189 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
6191 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_seq_cst_atomicrmw:
6192 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
6193 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6194 ; GFX90A-TGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
6195 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
6196 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
6197 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
6198 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
6199 ; GFX90A-TGSPLIT-NEXT:    global_atomic_swap v0, v1, s[0:1]
6200 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
6201 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
6202 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
6203     i32 addrspace(1)* %out, i32 %in) {
6204 entry:
6205   %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("agent-one-as") seq_cst
6206   ret void
6209 define amdgpu_kernel void @global_agent_one_as_acquire_ret_atomicrmw(
6210 ; GFX6-LABEL: global_agent_one_as_acquire_ret_atomicrmw:
6211 ; GFX6:       ; %bb.0: ; %entry
6212 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6213 ; GFX6-NEXT:    s_load_dword s4, s[4:5], 0x2
6214 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
6215 ; GFX6-NEXT:    s_mov_b32 s2, -1
6216 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
6217 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
6218 ; GFX6-NEXT:    buffer_atomic_swap v0, off, s[0:3], 0 glc
6219 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
6220 ; GFX6-NEXT:    buffer_wbinvl1
6221 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
6222 ; GFX6-NEXT:    s_endpgm
6224 ; GFX7-LABEL: global_agent_one_as_acquire_ret_atomicrmw:
6225 ; GFX7:       ; %bb.0: ; %entry
6226 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6227 ; GFX7-NEXT:    s_load_dword s2, s[4:5], 0x2
6228 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
6229 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
6230 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
6231 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
6232 ; GFX7-NEXT:    flat_atomic_swap v2, v[0:1], v2 glc
6233 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
6234 ; GFX7-NEXT:    buffer_wbinvl1_vol
6235 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
6236 ; GFX7-NEXT:    s_endpgm
6238 ; GFX10-WGP-LABEL: global_agent_one_as_acquire_ret_atomicrmw:
6239 ; GFX10-WGP:       ; %bb.0: ; %entry
6240 ; GFX10-WGP-NEXT:    s_clause 0x1
6241 ; GFX10-WGP-NEXT:    s_load_dword s2, s[4:5], 0x8
6242 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6243 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, 0
6244 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
6245 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s2
6246 ; GFX10-WGP-NEXT:    global_atomic_swap v1, v0, v1, s[0:1] glc
6247 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
6248 ; GFX10-WGP-NEXT:    buffer_gl0_inv
6249 ; GFX10-WGP-NEXT:    buffer_gl1_inv
6250 ; GFX10-WGP-NEXT:    global_store_dword v0, v1, s[0:1]
6251 ; GFX10-WGP-NEXT:    s_endpgm
6253 ; GFX10-CU-LABEL: global_agent_one_as_acquire_ret_atomicrmw:
6254 ; GFX10-CU:       ; %bb.0: ; %entry
6255 ; GFX10-CU-NEXT:    s_clause 0x1
6256 ; GFX10-CU-NEXT:    s_load_dword s2, s[4:5], 0x8
6257 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6258 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, 0
6259 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
6260 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s2
6261 ; GFX10-CU-NEXT:    global_atomic_swap v1, v0, v1, s[0:1] glc
6262 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
6263 ; GFX10-CU-NEXT:    buffer_gl0_inv
6264 ; GFX10-CU-NEXT:    buffer_gl1_inv
6265 ; GFX10-CU-NEXT:    global_store_dword v0, v1, s[0:1]
6266 ; GFX10-CU-NEXT:    s_endpgm
6268 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_acquire_ret_atomicrmw:
6269 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
6270 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
6271 ; SKIP-CACHE-INV-NEXT:    s_load_dword s0, s[0:1], 0xb
6272 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
6273 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
6274 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
6275 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
6276 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_swap v0, off, s[4:7], 0 glc
6277 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
6278 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
6279 ; SKIP-CACHE-INV-NEXT:    s_endpgm
6281 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_acquire_ret_atomicrmw:
6282 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
6283 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6284 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
6285 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
6286 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
6287 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
6288 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_swap v1, v0, v1, s[0:1] glc
6289 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
6290 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
6291 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v0, v1, s[0:1]
6292 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
6294 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_acquire_ret_atomicrmw:
6295 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
6296 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6297 ; GFX90A-TGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
6298 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
6299 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
6300 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
6301 ; GFX90A-TGSPLIT-NEXT:    global_atomic_swap v1, v0, v1, s[0:1] glc
6302 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
6303 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
6304 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v0, v1, s[0:1]
6305 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
6306     i32 addrspace(1)* %out, i32 %in) {
6307 entry:
6308   %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("agent-one-as") acquire
6309   store i32 %val, i32 addrspace(1)* %out, align 4
6310   ret void
6313 define amdgpu_kernel void @global_agent_one_as_acq_rel_ret_atomicrmw(
6314 ; GFX6-LABEL: global_agent_one_as_acq_rel_ret_atomicrmw:
6315 ; GFX6:       ; %bb.0: ; %entry
6316 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6317 ; GFX6-NEXT:    s_load_dword s4, s[4:5], 0x2
6318 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
6319 ; GFX6-NEXT:    s_mov_b32 s2, -1
6320 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
6321 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
6322 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
6323 ; GFX6-NEXT:    buffer_atomic_swap v0, off, s[0:3], 0 glc
6324 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
6325 ; GFX6-NEXT:    buffer_wbinvl1
6326 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
6327 ; GFX6-NEXT:    s_endpgm
6329 ; GFX7-LABEL: global_agent_one_as_acq_rel_ret_atomicrmw:
6330 ; GFX7:       ; %bb.0: ; %entry
6331 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6332 ; GFX7-NEXT:    s_load_dword s2, s[4:5], 0x2
6333 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
6334 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
6335 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
6336 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
6337 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
6338 ; GFX7-NEXT:    flat_atomic_swap v2, v[0:1], v2 glc
6339 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
6340 ; GFX7-NEXT:    buffer_wbinvl1_vol
6341 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
6342 ; GFX7-NEXT:    s_endpgm
6344 ; GFX10-WGP-LABEL: global_agent_one_as_acq_rel_ret_atomicrmw:
6345 ; GFX10-WGP:       ; %bb.0: ; %entry
6346 ; GFX10-WGP-NEXT:    s_clause 0x1
6347 ; GFX10-WGP-NEXT:    s_load_dword s2, s[4:5], 0x8
6348 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6349 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, 0
6350 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
6351 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s2
6352 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
6353 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
6354 ; GFX10-WGP-NEXT:    global_atomic_swap v1, v0, v1, s[0:1] glc
6355 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
6356 ; GFX10-WGP-NEXT:    buffer_gl0_inv
6357 ; GFX10-WGP-NEXT:    buffer_gl1_inv
6358 ; GFX10-WGP-NEXT:    global_store_dword v0, v1, s[0:1]
6359 ; GFX10-WGP-NEXT:    s_endpgm
6361 ; GFX10-CU-LABEL: global_agent_one_as_acq_rel_ret_atomicrmw:
6362 ; GFX10-CU:       ; %bb.0: ; %entry
6363 ; GFX10-CU-NEXT:    s_clause 0x1
6364 ; GFX10-CU-NEXT:    s_load_dword s2, s[4:5], 0x8
6365 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6366 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, 0
6367 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
6368 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s2
6369 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
6370 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
6371 ; GFX10-CU-NEXT:    global_atomic_swap v1, v0, v1, s[0:1] glc
6372 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
6373 ; GFX10-CU-NEXT:    buffer_gl0_inv
6374 ; GFX10-CU-NEXT:    buffer_gl1_inv
6375 ; GFX10-CU-NEXT:    global_store_dword v0, v1, s[0:1]
6376 ; GFX10-CU-NEXT:    s_endpgm
6378 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_acq_rel_ret_atomicrmw:
6379 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
6380 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
6381 ; SKIP-CACHE-INV-NEXT:    s_load_dword s0, s[0:1], 0xb
6382 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
6383 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
6384 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
6385 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
6386 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
6387 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_swap v0, off, s[4:7], 0 glc
6388 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
6389 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
6390 ; SKIP-CACHE-INV-NEXT:    s_endpgm
6392 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_acq_rel_ret_atomicrmw:
6393 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
6394 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6395 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
6396 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
6397 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
6398 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
6399 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
6400 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_swap v1, v0, v1, s[0:1] glc
6401 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
6402 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
6403 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v0, v1, s[0:1]
6404 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
6406 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_acq_rel_ret_atomicrmw:
6407 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
6408 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6409 ; GFX90A-TGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
6410 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
6411 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
6412 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
6413 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
6414 ; GFX90A-TGSPLIT-NEXT:    global_atomic_swap v1, v0, v1, s[0:1] glc
6415 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
6416 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
6417 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v0, v1, s[0:1]
6418 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
6419     i32 addrspace(1)* %out, i32 %in) {
6420 entry:
6421   %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("agent-one-as") acq_rel
6422   store i32 %val, i32 addrspace(1)* %out, align 4
6423   ret void
6426 define amdgpu_kernel void @global_agent_one_as_seq_cst_ret_atomicrmw(
6427 ; GFX6-LABEL: global_agent_one_as_seq_cst_ret_atomicrmw:
6428 ; GFX6:       ; %bb.0: ; %entry
6429 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6430 ; GFX6-NEXT:    s_load_dword s4, s[4:5], 0x2
6431 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
6432 ; GFX6-NEXT:    s_mov_b32 s2, -1
6433 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
6434 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
6435 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
6436 ; GFX6-NEXT:    buffer_atomic_swap v0, off, s[0:3], 0 glc
6437 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
6438 ; GFX6-NEXT:    buffer_wbinvl1
6439 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
6440 ; GFX6-NEXT:    s_endpgm
6442 ; GFX7-LABEL: global_agent_one_as_seq_cst_ret_atomicrmw:
6443 ; GFX7:       ; %bb.0: ; %entry
6444 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6445 ; GFX7-NEXT:    s_load_dword s2, s[4:5], 0x2
6446 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
6447 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
6448 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
6449 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
6450 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
6451 ; GFX7-NEXT:    flat_atomic_swap v2, v[0:1], v2 glc
6452 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
6453 ; GFX7-NEXT:    buffer_wbinvl1_vol
6454 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
6455 ; GFX7-NEXT:    s_endpgm
6457 ; GFX10-WGP-LABEL: global_agent_one_as_seq_cst_ret_atomicrmw:
6458 ; GFX10-WGP:       ; %bb.0: ; %entry
6459 ; GFX10-WGP-NEXT:    s_clause 0x1
6460 ; GFX10-WGP-NEXT:    s_load_dword s2, s[4:5], 0x8
6461 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6462 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, 0
6463 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
6464 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s2
6465 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
6466 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
6467 ; GFX10-WGP-NEXT:    global_atomic_swap v1, v0, v1, s[0:1] glc
6468 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
6469 ; GFX10-WGP-NEXT:    buffer_gl0_inv
6470 ; GFX10-WGP-NEXT:    buffer_gl1_inv
6471 ; GFX10-WGP-NEXT:    global_store_dword v0, v1, s[0:1]
6472 ; GFX10-WGP-NEXT:    s_endpgm
6474 ; GFX10-CU-LABEL: global_agent_one_as_seq_cst_ret_atomicrmw:
6475 ; GFX10-CU:       ; %bb.0: ; %entry
6476 ; GFX10-CU-NEXT:    s_clause 0x1
6477 ; GFX10-CU-NEXT:    s_load_dword s2, s[4:5], 0x8
6478 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6479 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, 0
6480 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
6481 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s2
6482 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
6483 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
6484 ; GFX10-CU-NEXT:    global_atomic_swap v1, v0, v1, s[0:1] glc
6485 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
6486 ; GFX10-CU-NEXT:    buffer_gl0_inv
6487 ; GFX10-CU-NEXT:    buffer_gl1_inv
6488 ; GFX10-CU-NEXT:    global_store_dword v0, v1, s[0:1]
6489 ; GFX10-CU-NEXT:    s_endpgm
6491 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_seq_cst_ret_atomicrmw:
6492 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
6493 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
6494 ; SKIP-CACHE-INV-NEXT:    s_load_dword s0, s[0:1], 0xb
6495 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
6496 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
6497 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
6498 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
6499 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
6500 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_swap v0, off, s[4:7], 0 glc
6501 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
6502 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
6503 ; SKIP-CACHE-INV-NEXT:    s_endpgm
6505 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_seq_cst_ret_atomicrmw:
6506 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
6507 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6508 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
6509 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
6510 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
6511 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
6512 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
6513 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_swap v1, v0, v1, s[0:1] glc
6514 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
6515 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
6516 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v0, v1, s[0:1]
6517 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
6519 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_seq_cst_ret_atomicrmw:
6520 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
6521 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6522 ; GFX90A-TGSPLIT-NEXT:    s_load_dword s2, s[4:5], 0x8
6523 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v0, 0
6524 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
6525 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v1, s2
6526 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
6527 ; GFX90A-TGSPLIT-NEXT:    global_atomic_swap v1, v0, v1, s[0:1] glc
6528 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
6529 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
6530 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v0, v1, s[0:1]
6531 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
6532     i32 addrspace(1)* %out, i32 %in) {
6533 entry:
6534   %val = atomicrmw volatile xchg i32 addrspace(1)* %out, i32 %in syncscope("agent-one-as") seq_cst
6535   store i32 %val, i32 addrspace(1)* %out, align 4
6536   ret void
6539 define amdgpu_kernel void @global_agent_one_as_monotonic_monotonic_cmpxchg(
6540 ; GFX6-LABEL: global_agent_one_as_monotonic_monotonic_cmpxchg:
6541 ; GFX6:       ; %bb.0: ; %entry
6542 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6543 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
6544 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
6545 ; GFX6-NEXT:    s_mov_b32 s2, -1
6546 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
6547 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
6548 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
6549 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
6550 ; GFX6-NEXT:    s_endpgm
6552 ; GFX7-LABEL: global_agent_one_as_monotonic_monotonic_cmpxchg:
6553 ; GFX7:       ; %bb.0: ; %entry
6554 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6555 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
6556 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
6557 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
6558 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
6559 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
6560 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
6561 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
6562 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
6563 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
6564 ; GFX7-NEXT:    s_endpgm
6566 ; GFX10-WGP-LABEL: global_agent_one_as_monotonic_monotonic_cmpxchg:
6567 ; GFX10-WGP:       ; %bb.0: ; %entry
6568 ; GFX10-WGP-NEXT:    s_clause 0x1
6569 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
6570 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
6571 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
6572 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
6573 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
6574 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
6575 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
6576 ; GFX10-WGP-NEXT:    s_endpgm
6578 ; GFX10-CU-LABEL: global_agent_one_as_monotonic_monotonic_cmpxchg:
6579 ; GFX10-CU:       ; %bb.0: ; %entry
6580 ; GFX10-CU-NEXT:    s_clause 0x1
6581 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
6582 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
6583 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
6584 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
6585 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
6586 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
6587 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
6588 ; GFX10-CU-NEXT:    s_endpgm
6590 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_monotonic_monotonic_cmpxchg:
6591 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
6592 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
6593 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
6594 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
6595 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
6596 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
6597 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
6598 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
6599 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
6600 ; SKIP-CACHE-INV-NEXT:    s_endpgm
6602 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_monotonic_monotonic_cmpxchg:
6603 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
6604 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6605 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
6606 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
6607 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
6608 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6609 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
6610 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
6612 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_monotonic_monotonic_cmpxchg:
6613 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
6614 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6615 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
6616 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
6617 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
6618 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6619 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
6620 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
6621     i32 addrspace(1)* %out, i32 %in, i32 %old) {
6622 entry:
6623   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
6624   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") monotonic monotonic
6625   ret void
6628 define amdgpu_kernel void @global_agent_one_as_acquire_monotonic_cmpxchg(
6629 ; GFX6-LABEL: global_agent_one_as_acquire_monotonic_cmpxchg:
6630 ; GFX6:       ; %bb.0: ; %entry
6631 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6632 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
6633 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
6634 ; GFX6-NEXT:    s_mov_b32 s2, -1
6635 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
6636 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
6637 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
6638 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
6639 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
6640 ; GFX6-NEXT:    buffer_wbinvl1
6641 ; GFX6-NEXT:    s_endpgm
6643 ; GFX7-LABEL: global_agent_one_as_acquire_monotonic_cmpxchg:
6644 ; GFX7:       ; %bb.0: ; %entry
6645 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6646 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
6647 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
6648 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
6649 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
6650 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
6651 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
6652 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
6653 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
6654 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
6655 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
6656 ; GFX7-NEXT:    buffer_wbinvl1_vol
6657 ; GFX7-NEXT:    s_endpgm
6659 ; GFX10-WGP-LABEL: global_agent_one_as_acquire_monotonic_cmpxchg:
6660 ; GFX10-WGP:       ; %bb.0: ; %entry
6661 ; GFX10-WGP-NEXT:    s_clause 0x1
6662 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
6663 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
6664 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
6665 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
6666 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
6667 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
6668 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
6669 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
6670 ; GFX10-WGP-NEXT:    buffer_gl0_inv
6671 ; GFX10-WGP-NEXT:    buffer_gl1_inv
6672 ; GFX10-WGP-NEXT:    s_endpgm
6674 ; GFX10-CU-LABEL: global_agent_one_as_acquire_monotonic_cmpxchg:
6675 ; GFX10-CU:       ; %bb.0: ; %entry
6676 ; GFX10-CU-NEXT:    s_clause 0x1
6677 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
6678 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
6679 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
6680 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
6681 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
6682 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
6683 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
6684 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
6685 ; GFX10-CU-NEXT:    buffer_gl0_inv
6686 ; GFX10-CU-NEXT:    buffer_gl1_inv
6687 ; GFX10-CU-NEXT:    s_endpgm
6689 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_acquire_monotonic_cmpxchg:
6690 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
6691 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
6692 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
6693 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
6694 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
6695 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
6696 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
6697 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
6698 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
6699 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
6700 ; SKIP-CACHE-INV-NEXT:    s_endpgm
6702 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_acquire_monotonic_cmpxchg:
6703 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
6704 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6705 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
6706 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
6707 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
6708 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6709 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
6710 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
6711 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
6712 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
6714 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_acquire_monotonic_cmpxchg:
6715 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
6716 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6717 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
6718 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
6719 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
6720 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6721 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
6722 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
6723 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
6724 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
6725     i32 addrspace(1)* %out, i32 %in, i32 %old) {
6726 entry:
6727   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
6728   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") acquire monotonic
6729   ret void
6732 define amdgpu_kernel void @global_agent_one_as_release_monotonic_cmpxchg(
6733 ; GFX6-LABEL: global_agent_one_as_release_monotonic_cmpxchg:
6734 ; GFX6:       ; %bb.0: ; %entry
6735 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6736 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
6737 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
6738 ; GFX6-NEXT:    s_mov_b32 s2, -1
6739 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
6740 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
6741 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
6742 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
6743 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
6744 ; GFX6-NEXT:    s_endpgm
6746 ; GFX7-LABEL: global_agent_one_as_release_monotonic_cmpxchg:
6747 ; GFX7:       ; %bb.0: ; %entry
6748 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6749 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
6750 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
6751 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
6752 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
6753 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
6754 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
6755 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
6756 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
6757 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
6758 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
6759 ; GFX7-NEXT:    s_endpgm
6761 ; GFX10-WGP-LABEL: global_agent_one_as_release_monotonic_cmpxchg:
6762 ; GFX10-WGP:       ; %bb.0: ; %entry
6763 ; GFX10-WGP-NEXT:    s_clause 0x1
6764 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
6765 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
6766 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
6767 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
6768 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
6769 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
6770 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
6771 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
6772 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
6773 ; GFX10-WGP-NEXT:    s_endpgm
6775 ; GFX10-CU-LABEL: global_agent_one_as_release_monotonic_cmpxchg:
6776 ; GFX10-CU:       ; %bb.0: ; %entry
6777 ; GFX10-CU-NEXT:    s_clause 0x1
6778 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
6779 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
6780 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
6781 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
6782 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
6783 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
6784 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
6785 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
6786 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
6787 ; GFX10-CU-NEXT:    s_endpgm
6789 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_release_monotonic_cmpxchg:
6790 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
6791 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
6792 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
6793 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
6794 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
6795 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
6796 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
6797 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
6798 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
6799 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
6800 ; SKIP-CACHE-INV-NEXT:    s_endpgm
6802 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_release_monotonic_cmpxchg:
6803 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
6804 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6805 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
6806 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
6807 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
6808 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6809 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
6810 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
6811 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
6813 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_release_monotonic_cmpxchg:
6814 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
6815 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6816 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
6817 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
6818 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
6819 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6820 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
6821 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
6822 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
6823     i32 addrspace(1)* %out, i32 %in, i32 %old) {
6824 entry:
6825   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
6826   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") release monotonic
6827   ret void
6830 define amdgpu_kernel void @global_agent_one_as_acq_rel_monotonic_cmpxchg(
6831 ; GFX6-LABEL: global_agent_one_as_acq_rel_monotonic_cmpxchg:
6832 ; GFX6:       ; %bb.0: ; %entry
6833 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6834 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
6835 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
6836 ; GFX6-NEXT:    s_mov_b32 s2, -1
6837 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
6838 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
6839 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
6840 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
6841 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
6842 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
6843 ; GFX6-NEXT:    buffer_wbinvl1
6844 ; GFX6-NEXT:    s_endpgm
6846 ; GFX7-LABEL: global_agent_one_as_acq_rel_monotonic_cmpxchg:
6847 ; GFX7:       ; %bb.0: ; %entry
6848 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6849 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
6850 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
6851 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
6852 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
6853 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
6854 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
6855 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
6856 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
6857 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
6858 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
6859 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
6860 ; GFX7-NEXT:    buffer_wbinvl1_vol
6861 ; GFX7-NEXT:    s_endpgm
6863 ; GFX10-WGP-LABEL: global_agent_one_as_acq_rel_monotonic_cmpxchg:
6864 ; GFX10-WGP:       ; %bb.0: ; %entry
6865 ; GFX10-WGP-NEXT:    s_clause 0x1
6866 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
6867 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
6868 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
6869 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
6870 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
6871 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
6872 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
6873 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
6874 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
6875 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
6876 ; GFX10-WGP-NEXT:    buffer_gl0_inv
6877 ; GFX10-WGP-NEXT:    buffer_gl1_inv
6878 ; GFX10-WGP-NEXT:    s_endpgm
6880 ; GFX10-CU-LABEL: global_agent_one_as_acq_rel_monotonic_cmpxchg:
6881 ; GFX10-CU:       ; %bb.0: ; %entry
6882 ; GFX10-CU-NEXT:    s_clause 0x1
6883 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
6884 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
6885 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
6886 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
6887 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
6888 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
6889 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
6890 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
6891 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
6892 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
6893 ; GFX10-CU-NEXT:    buffer_gl0_inv
6894 ; GFX10-CU-NEXT:    buffer_gl1_inv
6895 ; GFX10-CU-NEXT:    s_endpgm
6897 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_acq_rel_monotonic_cmpxchg:
6898 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
6899 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
6900 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
6901 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
6902 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
6903 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
6904 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
6905 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
6906 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
6907 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
6908 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
6909 ; SKIP-CACHE-INV-NEXT:    s_endpgm
6911 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_acq_rel_monotonic_cmpxchg:
6912 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
6913 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6914 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
6915 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
6916 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
6917 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6918 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
6919 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
6920 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
6921 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
6922 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
6924 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_acq_rel_monotonic_cmpxchg:
6925 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
6926 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6927 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
6928 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
6929 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
6930 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
6931 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
6932 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
6933 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
6934 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
6935 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
6936     i32 addrspace(1)* %out, i32 %in, i32 %old) {
6937 entry:
6938   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
6939   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") acq_rel monotonic
6940   ret void
6943 define amdgpu_kernel void @global_agent_one_as_seq_cst_monotonic_cmpxchg(
6944 ; GFX6-LABEL: global_agent_one_as_seq_cst_monotonic_cmpxchg:
6945 ; GFX6:       ; %bb.0: ; %entry
6946 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6947 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
6948 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
6949 ; GFX6-NEXT:    s_mov_b32 s2, -1
6950 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
6951 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
6952 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
6953 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
6954 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
6955 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
6956 ; GFX6-NEXT:    buffer_wbinvl1
6957 ; GFX6-NEXT:    s_endpgm
6959 ; GFX7-LABEL: global_agent_one_as_seq_cst_monotonic_cmpxchg:
6960 ; GFX7:       ; %bb.0: ; %entry
6961 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
6962 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
6963 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
6964 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
6965 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
6966 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
6967 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
6968 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
6969 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
6970 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
6971 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
6972 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
6973 ; GFX7-NEXT:    buffer_wbinvl1_vol
6974 ; GFX7-NEXT:    s_endpgm
6976 ; GFX10-WGP-LABEL: global_agent_one_as_seq_cst_monotonic_cmpxchg:
6977 ; GFX10-WGP:       ; %bb.0: ; %entry
6978 ; GFX10-WGP-NEXT:    s_clause 0x1
6979 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
6980 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
6981 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
6982 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
6983 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
6984 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
6985 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
6986 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
6987 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
6988 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
6989 ; GFX10-WGP-NEXT:    buffer_gl0_inv
6990 ; GFX10-WGP-NEXT:    buffer_gl1_inv
6991 ; GFX10-WGP-NEXT:    s_endpgm
6993 ; GFX10-CU-LABEL: global_agent_one_as_seq_cst_monotonic_cmpxchg:
6994 ; GFX10-CU:       ; %bb.0: ; %entry
6995 ; GFX10-CU-NEXT:    s_clause 0x1
6996 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
6997 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
6998 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
6999 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
7000 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
7001 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
7002 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
7003 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
7004 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7005 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
7006 ; GFX10-CU-NEXT:    buffer_gl0_inv
7007 ; GFX10-CU-NEXT:    buffer_gl1_inv
7008 ; GFX10-CU-NEXT:    s_endpgm
7010 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_seq_cst_monotonic_cmpxchg:
7011 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
7012 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
7013 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
7014 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
7015 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
7016 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
7017 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
7018 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
7019 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
7020 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
7021 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
7022 ; SKIP-CACHE-INV-NEXT:    s_endpgm
7024 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_seq_cst_monotonic_cmpxchg:
7025 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
7026 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7027 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
7028 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
7029 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
7030 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7031 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7032 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7033 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7034 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
7035 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
7037 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_seq_cst_monotonic_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) {
7050 entry:
7051   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
7052   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") seq_cst monotonic
7053   ret void
7056 define amdgpu_kernel void @global_agent_one_as_monotonic_acquire_cmpxchg(
7057 ; GFX6-LABEL: global_agent_one_as_monotonic_acquire_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_waitcnt vmcnt(0)
7068 ; GFX6-NEXT:    buffer_wbinvl1
7069 ; GFX6-NEXT:    s_endpgm
7071 ; GFX7-LABEL: global_agent_one_as_monotonic_acquire_cmpxchg:
7072 ; GFX7:       ; %bb.0: ; %entry
7073 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7074 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
7075 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
7076 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
7077 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
7078 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
7079 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
7080 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
7081 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
7082 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
7083 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
7084 ; GFX7-NEXT:    buffer_wbinvl1_vol
7085 ; GFX7-NEXT:    s_endpgm
7087 ; GFX10-WGP-LABEL: global_agent_one_as_monotonic_acquire_cmpxchg:
7088 ; GFX10-WGP:       ; %bb.0: ; %entry
7089 ; GFX10-WGP-NEXT:    s_clause 0x1
7090 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
7091 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
7092 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
7093 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
7094 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
7095 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
7096 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7097 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
7098 ; GFX10-WGP-NEXT:    buffer_gl0_inv
7099 ; GFX10-WGP-NEXT:    buffer_gl1_inv
7100 ; GFX10-WGP-NEXT:    s_endpgm
7102 ; GFX10-CU-LABEL: global_agent_one_as_monotonic_acquire_cmpxchg:
7103 ; GFX10-CU:       ; %bb.0: ; %entry
7104 ; GFX10-CU-NEXT:    s_clause 0x1
7105 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
7106 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
7107 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
7108 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
7109 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
7110 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
7111 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7112 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
7113 ; GFX10-CU-NEXT:    buffer_gl0_inv
7114 ; GFX10-CU-NEXT:    buffer_gl1_inv
7115 ; GFX10-CU-NEXT:    s_endpgm
7117 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_monotonic_acquire_cmpxchg:
7118 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
7119 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
7120 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
7121 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
7122 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
7123 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
7124 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
7125 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
7126 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
7127 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
7128 ; SKIP-CACHE-INV-NEXT:    s_endpgm
7130 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_monotonic_acquire_cmpxchg:
7131 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
7132 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7133 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
7134 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
7135 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
7136 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7137 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7138 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7139 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
7140 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
7142 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_monotonic_acquire_cmpxchg:
7143 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
7144 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7145 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
7146 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
7147 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
7148 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7149 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7150 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7151 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
7152 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
7153     i32 addrspace(1)* %out, i32 %in, i32 %old) {
7154 entry:
7155   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
7156   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") monotonic acquire
7157   ret void
7160 define amdgpu_kernel void @global_agent_one_as_acquire_acquire_cmpxchg(
7161 ; GFX6-LABEL: global_agent_one_as_acquire_acquire_cmpxchg:
7162 ; GFX6:       ; %bb.0: ; %entry
7163 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7164 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
7165 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
7166 ; GFX6-NEXT:    s_mov_b32 s2, -1
7167 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
7168 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
7169 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
7170 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
7171 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
7172 ; GFX6-NEXT:    buffer_wbinvl1
7173 ; GFX6-NEXT:    s_endpgm
7175 ; GFX7-LABEL: global_agent_one_as_acquire_acquire_cmpxchg:
7176 ; GFX7:       ; %bb.0: ; %entry
7177 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7178 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
7179 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
7180 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
7181 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
7182 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
7183 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
7184 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
7185 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
7186 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
7187 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
7188 ; GFX7-NEXT:    buffer_wbinvl1_vol
7189 ; GFX7-NEXT:    s_endpgm
7191 ; GFX10-WGP-LABEL: global_agent_one_as_acquire_acquire_cmpxchg:
7192 ; GFX10-WGP:       ; %bb.0: ; %entry
7193 ; GFX10-WGP-NEXT:    s_clause 0x1
7194 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
7195 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
7196 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
7197 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
7198 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
7199 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
7200 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7201 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
7202 ; GFX10-WGP-NEXT:    buffer_gl0_inv
7203 ; GFX10-WGP-NEXT:    buffer_gl1_inv
7204 ; GFX10-WGP-NEXT:    s_endpgm
7206 ; GFX10-CU-LABEL: global_agent_one_as_acquire_acquire_cmpxchg:
7207 ; GFX10-CU:       ; %bb.0: ; %entry
7208 ; GFX10-CU-NEXT:    s_clause 0x1
7209 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
7210 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
7211 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
7212 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
7213 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
7214 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
7215 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7216 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
7217 ; GFX10-CU-NEXT:    buffer_gl0_inv
7218 ; GFX10-CU-NEXT:    buffer_gl1_inv
7219 ; GFX10-CU-NEXT:    s_endpgm
7221 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_acquire_acquire_cmpxchg:
7222 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
7223 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
7224 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
7225 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
7226 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
7227 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
7228 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
7229 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
7230 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
7231 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
7232 ; SKIP-CACHE-INV-NEXT:    s_endpgm
7234 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_acquire_acquire_cmpxchg:
7235 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
7236 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7237 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
7238 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
7239 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
7240 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7241 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7242 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7243 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
7244 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
7246 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_acquire_acquire_cmpxchg:
7247 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
7248 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7249 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
7250 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
7251 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
7252 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7253 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7254 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7255 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
7256 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
7257     i32 addrspace(1)* %out, i32 %in, i32 %old) {
7258 entry:
7259   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
7260   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") acquire acquire
7261   ret void
7264 define amdgpu_kernel void @global_agent_one_as_release_acquire_cmpxchg(
7265 ; GFX6-LABEL: global_agent_one_as_release_acquire_cmpxchg:
7266 ; GFX6:       ; %bb.0: ; %entry
7267 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7268 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
7269 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
7270 ; GFX6-NEXT:    s_mov_b32 s2, -1
7271 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
7272 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
7273 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
7274 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
7275 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
7276 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
7277 ; GFX6-NEXT:    buffer_wbinvl1
7278 ; GFX6-NEXT:    s_endpgm
7280 ; GFX7-LABEL: global_agent_one_as_release_acquire_cmpxchg:
7281 ; GFX7:       ; %bb.0: ; %entry
7282 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7283 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
7284 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
7285 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
7286 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
7287 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
7288 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
7289 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
7290 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
7291 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
7292 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
7293 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
7294 ; GFX7-NEXT:    buffer_wbinvl1_vol
7295 ; GFX7-NEXT:    s_endpgm
7297 ; GFX10-WGP-LABEL: global_agent_one_as_release_acquire_cmpxchg:
7298 ; GFX10-WGP:       ; %bb.0: ; %entry
7299 ; GFX10-WGP-NEXT:    s_clause 0x1
7300 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
7301 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
7302 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
7303 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
7304 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
7305 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
7306 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
7307 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
7308 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7309 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
7310 ; GFX10-WGP-NEXT:    buffer_gl0_inv
7311 ; GFX10-WGP-NEXT:    buffer_gl1_inv
7312 ; GFX10-WGP-NEXT:    s_endpgm
7314 ; GFX10-CU-LABEL: global_agent_one_as_release_acquire_cmpxchg:
7315 ; GFX10-CU:       ; %bb.0: ; %entry
7316 ; GFX10-CU-NEXT:    s_clause 0x1
7317 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
7318 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
7319 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
7320 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
7321 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
7322 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
7323 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
7324 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
7325 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7326 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
7327 ; GFX10-CU-NEXT:    buffer_gl0_inv
7328 ; GFX10-CU-NEXT:    buffer_gl1_inv
7329 ; GFX10-CU-NEXT:    s_endpgm
7331 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_release_acquire_cmpxchg:
7332 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
7333 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
7334 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
7335 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
7336 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
7337 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
7338 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
7339 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
7340 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
7341 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
7342 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
7343 ; SKIP-CACHE-INV-NEXT:    s_endpgm
7345 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_release_acquire_cmpxchg:
7346 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
7347 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7348 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
7349 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
7350 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
7351 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7352 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7353 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7354 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7355 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
7356 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
7358 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_release_acquire_cmpxchg:
7359 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
7360 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7361 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
7362 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
7363 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
7364 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7365 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7366 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7367 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7368 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
7369 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
7370     i32 addrspace(1)* %out, i32 %in, i32 %old) {
7371 entry:
7372   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
7373   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") release acquire
7374   ret void
7377 define amdgpu_kernel void @global_agent_one_as_acq_rel_acquire_cmpxchg(
7378 ; GFX6-LABEL: global_agent_one_as_acq_rel_acquire_cmpxchg:
7379 ; GFX6:       ; %bb.0: ; %entry
7380 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7381 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
7382 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
7383 ; GFX6-NEXT:    s_mov_b32 s2, -1
7384 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
7385 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
7386 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
7387 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
7388 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
7389 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
7390 ; GFX6-NEXT:    buffer_wbinvl1
7391 ; GFX6-NEXT:    s_endpgm
7393 ; GFX7-LABEL: global_agent_one_as_acq_rel_acquire_cmpxchg:
7394 ; GFX7:       ; %bb.0: ; %entry
7395 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7396 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
7397 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
7398 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
7399 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
7400 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
7401 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
7402 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
7403 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
7404 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
7405 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
7406 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
7407 ; GFX7-NEXT:    buffer_wbinvl1_vol
7408 ; GFX7-NEXT:    s_endpgm
7410 ; GFX10-WGP-LABEL: global_agent_one_as_acq_rel_acquire_cmpxchg:
7411 ; GFX10-WGP:       ; %bb.0: ; %entry
7412 ; GFX10-WGP-NEXT:    s_clause 0x1
7413 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
7414 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
7415 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
7416 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
7417 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
7418 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
7419 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
7420 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
7421 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7422 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
7423 ; GFX10-WGP-NEXT:    buffer_gl0_inv
7424 ; GFX10-WGP-NEXT:    buffer_gl1_inv
7425 ; GFX10-WGP-NEXT:    s_endpgm
7427 ; GFX10-CU-LABEL: global_agent_one_as_acq_rel_acquire_cmpxchg:
7428 ; GFX10-CU:       ; %bb.0: ; %entry
7429 ; GFX10-CU-NEXT:    s_clause 0x1
7430 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
7431 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
7432 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
7433 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
7434 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
7435 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
7436 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
7437 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
7438 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7439 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
7440 ; GFX10-CU-NEXT:    buffer_gl0_inv
7441 ; GFX10-CU-NEXT:    buffer_gl1_inv
7442 ; GFX10-CU-NEXT:    s_endpgm
7444 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_acq_rel_acquire_cmpxchg:
7445 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
7446 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
7447 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
7448 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
7449 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
7450 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
7451 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
7452 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
7453 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
7454 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
7455 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
7456 ; SKIP-CACHE-INV-NEXT:    s_endpgm
7458 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_acq_rel_acquire_cmpxchg:
7459 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
7460 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7461 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
7462 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
7463 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
7464 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7465 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7466 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7467 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7468 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
7469 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
7471 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_acq_rel_acquire_cmpxchg:
7472 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
7473 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7474 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
7475 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
7476 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
7477 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7478 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7479 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7480 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7481 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
7482 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
7483     i32 addrspace(1)* %out, i32 %in, i32 %old) {
7484 entry:
7485   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
7486   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") acq_rel acquire
7487   ret void
7490 define amdgpu_kernel void @global_agent_one_as_seq_cst_acquire_cmpxchg(
7491 ; GFX6-LABEL: global_agent_one_as_seq_cst_acquire_cmpxchg:
7492 ; GFX6:       ; %bb.0: ; %entry
7493 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7494 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
7495 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
7496 ; GFX6-NEXT:    s_mov_b32 s2, -1
7497 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
7498 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
7499 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
7500 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
7501 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
7502 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
7503 ; GFX6-NEXT:    buffer_wbinvl1
7504 ; GFX6-NEXT:    s_endpgm
7506 ; GFX7-LABEL: global_agent_one_as_seq_cst_acquire_cmpxchg:
7507 ; GFX7:       ; %bb.0: ; %entry
7508 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7509 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
7510 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
7511 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
7512 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
7513 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
7514 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
7515 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
7516 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
7517 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
7518 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
7519 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
7520 ; GFX7-NEXT:    buffer_wbinvl1_vol
7521 ; GFX7-NEXT:    s_endpgm
7523 ; GFX10-WGP-LABEL: global_agent_one_as_seq_cst_acquire_cmpxchg:
7524 ; GFX10-WGP:       ; %bb.0: ; %entry
7525 ; GFX10-WGP-NEXT:    s_clause 0x1
7526 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
7527 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
7528 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
7529 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
7530 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
7531 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
7532 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
7533 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
7534 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7535 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
7536 ; GFX10-WGP-NEXT:    buffer_gl0_inv
7537 ; GFX10-WGP-NEXT:    buffer_gl1_inv
7538 ; GFX10-WGP-NEXT:    s_endpgm
7540 ; GFX10-CU-LABEL: global_agent_one_as_seq_cst_acquire_cmpxchg:
7541 ; GFX10-CU:       ; %bb.0: ; %entry
7542 ; GFX10-CU-NEXT:    s_clause 0x1
7543 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
7544 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
7545 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
7546 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
7547 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
7548 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
7549 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
7550 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
7551 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7552 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
7553 ; GFX10-CU-NEXT:    buffer_gl0_inv
7554 ; GFX10-CU-NEXT:    buffer_gl1_inv
7555 ; GFX10-CU-NEXT:    s_endpgm
7557 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_seq_cst_acquire_cmpxchg:
7558 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
7559 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
7560 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
7561 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
7562 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
7563 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
7564 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
7565 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
7566 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
7567 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
7568 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
7569 ; SKIP-CACHE-INV-NEXT:    s_endpgm
7571 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_seq_cst_acquire_cmpxchg:
7572 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
7573 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7574 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
7575 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
7576 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
7577 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7578 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7579 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7580 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7581 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
7582 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
7584 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_seq_cst_acquire_cmpxchg:
7585 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
7586 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7587 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
7588 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
7589 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
7590 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7591 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7592 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7593 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7594 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
7595 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
7596     i32 addrspace(1)* %out, i32 %in, i32 %old) {
7597 entry:
7598   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
7599   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") seq_cst acquire
7600   ret void
7603 define amdgpu_kernel void @global_agent_one_as_monotonic_seq_cst_cmpxchg(
7604 ; GFX6-LABEL: global_agent_one_as_monotonic_seq_cst_cmpxchg:
7605 ; GFX6:       ; %bb.0: ; %entry
7606 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7607 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
7608 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
7609 ; GFX6-NEXT:    s_mov_b32 s2, -1
7610 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
7611 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
7612 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
7613 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
7614 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
7615 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
7616 ; GFX6-NEXT:    buffer_wbinvl1
7617 ; GFX6-NEXT:    s_endpgm
7619 ; GFX7-LABEL: global_agent_one_as_monotonic_seq_cst_cmpxchg:
7620 ; GFX7:       ; %bb.0: ; %entry
7621 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7622 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
7623 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
7624 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
7625 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
7626 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
7627 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
7628 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
7629 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
7630 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
7631 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
7632 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
7633 ; GFX7-NEXT:    buffer_wbinvl1_vol
7634 ; GFX7-NEXT:    s_endpgm
7636 ; GFX10-WGP-LABEL: global_agent_one_as_monotonic_seq_cst_cmpxchg:
7637 ; GFX10-WGP:       ; %bb.0: ; %entry
7638 ; GFX10-WGP-NEXT:    s_clause 0x1
7639 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
7640 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
7641 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
7642 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
7643 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
7644 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
7645 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
7646 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
7647 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7648 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
7649 ; GFX10-WGP-NEXT:    buffer_gl0_inv
7650 ; GFX10-WGP-NEXT:    buffer_gl1_inv
7651 ; GFX10-WGP-NEXT:    s_endpgm
7653 ; GFX10-CU-LABEL: global_agent_one_as_monotonic_seq_cst_cmpxchg:
7654 ; GFX10-CU:       ; %bb.0: ; %entry
7655 ; GFX10-CU-NEXT:    s_clause 0x1
7656 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
7657 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
7658 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
7659 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
7660 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
7661 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
7662 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
7663 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
7664 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7665 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
7666 ; GFX10-CU-NEXT:    buffer_gl0_inv
7667 ; GFX10-CU-NEXT:    buffer_gl1_inv
7668 ; GFX10-CU-NEXT:    s_endpgm
7670 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_monotonic_seq_cst_cmpxchg:
7671 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
7672 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
7673 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
7674 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
7675 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
7676 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
7677 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
7678 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
7679 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
7680 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
7681 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
7682 ; SKIP-CACHE-INV-NEXT:    s_endpgm
7684 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_monotonic_seq_cst_cmpxchg:
7685 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
7686 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7687 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
7688 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
7689 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
7690 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7691 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7692 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7693 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7694 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
7695 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
7697 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_monotonic_seq_cst_cmpxchg:
7698 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
7699 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7700 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
7701 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
7702 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
7703 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7704 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7705 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7706 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7707 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
7708 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
7709     i32 addrspace(1)* %out, i32 %in, i32 %old) {
7710 entry:
7711   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
7712   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") monotonic seq_cst
7713   ret void
7716 define amdgpu_kernel void @global_agent_one_as_acquire_seq_cst_cmpxchg(
7717 ; GFX6-LABEL: global_agent_one_as_acquire_seq_cst_cmpxchg:
7718 ; GFX6:       ; %bb.0: ; %entry
7719 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7720 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
7721 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
7722 ; GFX6-NEXT:    s_mov_b32 s2, -1
7723 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
7724 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
7725 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
7726 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
7727 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
7728 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
7729 ; GFX6-NEXT:    buffer_wbinvl1
7730 ; GFX6-NEXT:    s_endpgm
7732 ; GFX7-LABEL: global_agent_one_as_acquire_seq_cst_cmpxchg:
7733 ; GFX7:       ; %bb.0: ; %entry
7734 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7735 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
7736 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
7737 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
7738 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
7739 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
7740 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
7741 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
7742 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
7743 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
7744 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
7745 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
7746 ; GFX7-NEXT:    buffer_wbinvl1_vol
7747 ; GFX7-NEXT:    s_endpgm
7749 ; GFX10-WGP-LABEL: global_agent_one_as_acquire_seq_cst_cmpxchg:
7750 ; GFX10-WGP:       ; %bb.0: ; %entry
7751 ; GFX10-WGP-NEXT:    s_clause 0x1
7752 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
7753 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
7754 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
7755 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
7756 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
7757 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
7758 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
7759 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
7760 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7761 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
7762 ; GFX10-WGP-NEXT:    buffer_gl0_inv
7763 ; GFX10-WGP-NEXT:    buffer_gl1_inv
7764 ; GFX10-WGP-NEXT:    s_endpgm
7766 ; GFX10-CU-LABEL: global_agent_one_as_acquire_seq_cst_cmpxchg:
7767 ; GFX10-CU:       ; %bb.0: ; %entry
7768 ; GFX10-CU-NEXT:    s_clause 0x1
7769 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
7770 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
7771 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
7772 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
7773 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
7774 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
7775 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
7776 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
7777 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7778 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
7779 ; GFX10-CU-NEXT:    buffer_gl0_inv
7780 ; GFX10-CU-NEXT:    buffer_gl1_inv
7781 ; GFX10-CU-NEXT:    s_endpgm
7783 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_acquire_seq_cst_cmpxchg:
7784 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
7785 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
7786 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
7787 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
7788 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
7789 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
7790 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
7791 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
7792 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
7793 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
7794 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
7795 ; SKIP-CACHE-INV-NEXT:    s_endpgm
7797 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_acquire_seq_cst_cmpxchg:
7798 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
7799 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7800 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
7801 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
7802 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
7803 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7804 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7805 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7806 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7807 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
7808 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
7810 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_acquire_seq_cst_cmpxchg:
7811 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
7812 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7813 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
7814 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
7815 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
7816 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7817 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7818 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7819 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7820 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
7821 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
7822     i32 addrspace(1)* %out, i32 %in, i32 %old) {
7823 entry:
7824   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
7825   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") acquire seq_cst
7826   ret void
7829 define amdgpu_kernel void @global_agent_one_as_release_seq_cst_cmpxchg(
7830 ; GFX6-LABEL: global_agent_one_as_release_seq_cst_cmpxchg:
7831 ; GFX6:       ; %bb.0: ; %entry
7832 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7833 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
7834 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
7835 ; GFX6-NEXT:    s_mov_b32 s2, -1
7836 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
7837 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
7838 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
7839 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
7840 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
7841 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
7842 ; GFX6-NEXT:    buffer_wbinvl1
7843 ; GFX6-NEXT:    s_endpgm
7845 ; GFX7-LABEL: global_agent_one_as_release_seq_cst_cmpxchg:
7846 ; GFX7:       ; %bb.0: ; %entry
7847 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7848 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
7849 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
7850 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
7851 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
7852 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
7853 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
7854 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
7855 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
7856 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
7857 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
7858 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
7859 ; GFX7-NEXT:    buffer_wbinvl1_vol
7860 ; GFX7-NEXT:    s_endpgm
7862 ; GFX10-WGP-LABEL: global_agent_one_as_release_seq_cst_cmpxchg:
7863 ; GFX10-WGP:       ; %bb.0: ; %entry
7864 ; GFX10-WGP-NEXT:    s_clause 0x1
7865 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
7866 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
7867 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
7868 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
7869 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
7870 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
7871 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
7872 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
7873 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7874 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
7875 ; GFX10-WGP-NEXT:    buffer_gl0_inv
7876 ; GFX10-WGP-NEXT:    buffer_gl1_inv
7877 ; GFX10-WGP-NEXT:    s_endpgm
7879 ; GFX10-CU-LABEL: global_agent_one_as_release_seq_cst_cmpxchg:
7880 ; GFX10-CU:       ; %bb.0: ; %entry
7881 ; GFX10-CU-NEXT:    s_clause 0x1
7882 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
7883 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
7884 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
7885 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
7886 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
7887 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
7888 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
7889 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
7890 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7891 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
7892 ; GFX10-CU-NEXT:    buffer_gl0_inv
7893 ; GFX10-CU-NEXT:    buffer_gl1_inv
7894 ; GFX10-CU-NEXT:    s_endpgm
7896 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_release_seq_cst_cmpxchg:
7897 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
7898 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
7899 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
7900 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
7901 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
7902 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
7903 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
7904 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
7905 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
7906 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
7907 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
7908 ; SKIP-CACHE-INV-NEXT:    s_endpgm
7910 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_release_seq_cst_cmpxchg:
7911 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
7912 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7913 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
7914 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
7915 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
7916 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7917 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7918 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7919 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7920 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
7921 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
7923 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_release_seq_cst_cmpxchg:
7924 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
7925 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7926 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
7927 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
7928 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
7929 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
7930 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7931 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
7932 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
7933 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
7934 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
7935     i32 addrspace(1)* %out, i32 %in, i32 %old) {
7936 entry:
7937   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
7938   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") release seq_cst
7939   ret void
7942 define amdgpu_kernel void @global_agent_one_as_acq_rel_seq_cst_cmpxchg(
7943 ; GFX6-LABEL: global_agent_one_as_acq_rel_seq_cst_cmpxchg:
7944 ; GFX6:       ; %bb.0: ; %entry
7945 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7946 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
7947 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
7948 ; GFX6-NEXT:    s_mov_b32 s2, -1
7949 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
7950 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
7951 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
7952 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
7953 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
7954 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
7955 ; GFX6-NEXT:    buffer_wbinvl1
7956 ; GFX6-NEXT:    s_endpgm
7958 ; GFX7-LABEL: global_agent_one_as_acq_rel_seq_cst_cmpxchg:
7959 ; GFX7:       ; %bb.0: ; %entry
7960 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
7961 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
7962 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
7963 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
7964 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
7965 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
7966 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
7967 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
7968 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
7969 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
7970 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
7971 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
7972 ; GFX7-NEXT:    buffer_wbinvl1_vol
7973 ; GFX7-NEXT:    s_endpgm
7975 ; GFX10-WGP-LABEL: global_agent_one_as_acq_rel_seq_cst_cmpxchg:
7976 ; GFX10-WGP:       ; %bb.0: ; %entry
7977 ; GFX10-WGP-NEXT:    s_clause 0x1
7978 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
7979 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
7980 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
7981 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
7982 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
7983 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
7984 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
7985 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
7986 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
7987 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
7988 ; GFX10-WGP-NEXT:    buffer_gl0_inv
7989 ; GFX10-WGP-NEXT:    buffer_gl1_inv
7990 ; GFX10-WGP-NEXT:    s_endpgm
7992 ; GFX10-CU-LABEL: global_agent_one_as_acq_rel_seq_cst_cmpxchg:
7993 ; GFX10-CU:       ; %bb.0: ; %entry
7994 ; GFX10-CU-NEXT:    s_clause 0x1
7995 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
7996 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
7997 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
7998 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
7999 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
8000 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
8001 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
8002 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
8003 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
8004 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
8005 ; GFX10-CU-NEXT:    buffer_gl0_inv
8006 ; GFX10-CU-NEXT:    buffer_gl1_inv
8007 ; GFX10-CU-NEXT:    s_endpgm
8009 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_acq_rel_seq_cst_cmpxchg:
8010 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
8011 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
8012 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
8013 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
8014 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
8015 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
8016 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
8017 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
8018 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
8019 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
8020 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
8021 ; SKIP-CACHE-INV-NEXT:    s_endpgm
8023 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_acq_rel_seq_cst_cmpxchg:
8024 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
8025 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8026 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
8027 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
8028 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
8029 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8030 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
8031 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
8032 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
8033 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
8034 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
8036 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_acq_rel_seq_cst_cmpxchg:
8037 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
8038 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8039 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
8040 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
8041 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
8042 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8043 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
8044 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
8045 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
8046 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
8047 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
8048     i32 addrspace(1)* %out, i32 %in, i32 %old) {
8049 entry:
8050   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
8051   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") acq_rel seq_cst
8052   ret void
8055 define amdgpu_kernel void @global_agent_one_as_seq_cst_seq_cst_cmpxchg(
8056 ; GFX6-LABEL: global_agent_one_as_seq_cst_seq_cst_cmpxchg:
8057 ; GFX6:       ; %bb.0: ; %entry
8058 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8059 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
8060 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
8061 ; GFX6-NEXT:    s_mov_b32 s2, -1
8062 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
8063 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
8064 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
8065 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
8066 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
8067 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
8068 ; GFX6-NEXT:    buffer_wbinvl1
8069 ; GFX6-NEXT:    s_endpgm
8071 ; GFX7-LABEL: global_agent_one_as_seq_cst_seq_cst_cmpxchg:
8072 ; GFX7:       ; %bb.0: ; %entry
8073 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8074 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
8075 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
8076 ; GFX7-NEXT:    s_add_u32 s0, s0, 16
8077 ; GFX7-NEXT:    s_addc_u32 s1, s1, 0
8078 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
8079 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
8080 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
8081 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
8082 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
8083 ; GFX7-NEXT:    flat_atomic_cmpswap v[0:1], v[2:3]
8084 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
8085 ; GFX7-NEXT:    buffer_wbinvl1_vol
8086 ; GFX7-NEXT:    s_endpgm
8088 ; GFX10-WGP-LABEL: global_agent_one_as_seq_cst_seq_cst_cmpxchg:
8089 ; GFX10-WGP:       ; %bb.0: ; %entry
8090 ; GFX10-WGP-NEXT:    s_clause 0x1
8091 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
8092 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
8093 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
8094 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
8095 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
8096 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
8097 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
8098 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
8099 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
8100 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
8101 ; GFX10-WGP-NEXT:    buffer_gl0_inv
8102 ; GFX10-WGP-NEXT:    buffer_gl1_inv
8103 ; GFX10-WGP-NEXT:    s_endpgm
8105 ; GFX10-CU-LABEL: global_agent_one_as_seq_cst_seq_cst_cmpxchg:
8106 ; GFX10-CU:       ; %bb.0: ; %entry
8107 ; GFX10-CU-NEXT:    s_clause 0x1
8108 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
8109 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
8110 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
8111 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
8112 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
8113 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
8114 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
8115 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
8116 ; GFX10-CU-NEXT:    global_atomic_cmpswap v2, v[0:1], s[2:3] offset:16
8117 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
8118 ; GFX10-CU-NEXT:    buffer_gl0_inv
8119 ; GFX10-CU-NEXT:    buffer_gl1_inv
8120 ; GFX10-CU-NEXT:    s_endpgm
8122 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_seq_cst_seq_cst_cmpxchg:
8123 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
8124 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
8125 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
8126 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
8127 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
8128 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
8129 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
8130 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
8131 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
8132 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
8133 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
8134 ; SKIP-CACHE-INV-NEXT:    s_endpgm
8136 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_seq_cst_seq_cst_cmpxchg:
8137 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
8138 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8139 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
8140 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
8141 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
8142 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8143 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
8144 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
8145 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
8146 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
8147 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
8149 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_seq_cst_seq_cst_cmpxchg:
8150 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
8151 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8152 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
8153 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
8154 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
8155 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8156 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
8157 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v2, v[0:1], s[0:1] offset:16
8158 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
8159 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
8160 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
8161     i32 addrspace(1)* %out, i32 %in, i32 %old) {
8162 entry:
8163   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
8164   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") seq_cst seq_cst
8165   ret void
8168 define amdgpu_kernel void @global_agent_one_as_monotonic_monotonic_ret_cmpxchg(
8169 ; GFX6-LABEL: global_agent_one_as_monotonic_monotonic_ret_cmpxchg:
8170 ; GFX6:       ; %bb.0: ; %entry
8171 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8172 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
8173 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
8174 ; GFX6-NEXT:    s_mov_b32 s2, -1
8175 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
8176 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
8177 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
8178 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
8179 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
8180 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
8181 ; GFX6-NEXT:    s_endpgm
8183 ; GFX7-LABEL: global_agent_one_as_monotonic_monotonic_ret_cmpxchg:
8184 ; GFX7:       ; %bb.0: ; %entry
8185 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8186 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
8187 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
8188 ; GFX7-NEXT:    s_add_u32 s4, s0, 16
8189 ; GFX7-NEXT:    s_addc_u32 s5, s1, 0
8190 ; GFX7-NEXT:    v_mov_b32_e32 v0, s4
8191 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
8192 ; GFX7-NEXT:    v_mov_b32_e32 v1, s5
8193 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
8194 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8195 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
8196 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
8197 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
8198 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
8199 ; GFX7-NEXT:    s_endpgm
8201 ; GFX10-WGP-LABEL: global_agent_one_as_monotonic_monotonic_ret_cmpxchg:
8202 ; GFX10-WGP:       ; %bb.0: ; %entry
8203 ; GFX10-WGP-NEXT:    s_clause 0x1
8204 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
8205 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
8206 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
8207 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
8208 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
8209 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
8210 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8211 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
8212 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
8213 ; GFX10-WGP-NEXT:    s_endpgm
8215 ; GFX10-CU-LABEL: global_agent_one_as_monotonic_monotonic_ret_cmpxchg:
8216 ; GFX10-CU:       ; %bb.0: ; %entry
8217 ; GFX10-CU-NEXT:    s_clause 0x1
8218 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
8219 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
8220 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
8221 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
8222 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
8223 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
8224 ; GFX10-CU-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8225 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
8226 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
8227 ; GFX10-CU-NEXT:    s_endpgm
8229 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_monotonic_monotonic_ret_cmpxchg:
8230 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
8231 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
8232 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
8233 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
8234 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
8235 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
8236 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
8237 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
8238 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
8239 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
8240 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
8241 ; SKIP-CACHE-INV-NEXT:    s_endpgm
8243 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_monotonic_monotonic_ret_cmpxchg:
8244 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
8245 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8246 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
8247 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
8248 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
8249 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8250 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8251 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
8252 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
8253 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
8255 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_monotonic_monotonic_ret_cmpxchg:
8256 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
8257 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8258 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
8259 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
8260 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
8261 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8262 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8263 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
8264 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
8265 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
8266     i32 addrspace(1)* %out, i32 %in, i32 %old) {
8267 entry:
8268   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
8269   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") monotonic monotonic
8270   %val0 = extractvalue { i32, i1 } %val, 0
8271   store i32 %val0, i32 addrspace(1)* %out, align 4
8272   ret void
8275 define amdgpu_kernel void @global_agent_one_as_acquire_monotonic_ret_cmpxchg(
8276 ; GFX6-LABEL: global_agent_one_as_acquire_monotonic_ret_cmpxchg:
8277 ; GFX6:       ; %bb.0: ; %entry
8278 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8279 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
8280 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
8281 ; GFX6-NEXT:    s_mov_b32 s2, -1
8282 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
8283 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
8284 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
8285 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
8286 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
8287 ; GFX6-NEXT:    buffer_wbinvl1
8288 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
8289 ; GFX6-NEXT:    s_endpgm
8291 ; GFX7-LABEL: global_agent_one_as_acquire_monotonic_ret_cmpxchg:
8292 ; GFX7:       ; %bb.0: ; %entry
8293 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8294 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
8295 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
8296 ; GFX7-NEXT:    s_add_u32 s4, s0, 16
8297 ; GFX7-NEXT:    s_addc_u32 s5, s1, 0
8298 ; GFX7-NEXT:    v_mov_b32_e32 v0, s4
8299 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
8300 ; GFX7-NEXT:    v_mov_b32_e32 v1, s5
8301 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
8302 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8303 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
8304 ; GFX7-NEXT:    buffer_wbinvl1_vol
8305 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
8306 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
8307 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
8308 ; GFX7-NEXT:    s_endpgm
8310 ; GFX10-WGP-LABEL: global_agent_one_as_acquire_monotonic_ret_cmpxchg:
8311 ; GFX10-WGP:       ; %bb.0: ; %entry
8312 ; GFX10-WGP-NEXT:    s_clause 0x1
8313 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
8314 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
8315 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
8316 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
8317 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
8318 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
8319 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8320 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
8321 ; GFX10-WGP-NEXT:    buffer_gl0_inv
8322 ; GFX10-WGP-NEXT:    buffer_gl1_inv
8323 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
8324 ; GFX10-WGP-NEXT:    s_endpgm
8326 ; GFX10-CU-LABEL: global_agent_one_as_acquire_monotonic_ret_cmpxchg:
8327 ; GFX10-CU:       ; %bb.0: ; %entry
8328 ; GFX10-CU-NEXT:    s_clause 0x1
8329 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
8330 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
8331 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
8332 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
8333 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
8334 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
8335 ; GFX10-CU-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8336 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
8337 ; GFX10-CU-NEXT:    buffer_gl0_inv
8338 ; GFX10-CU-NEXT:    buffer_gl1_inv
8339 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
8340 ; GFX10-CU-NEXT:    s_endpgm
8342 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_acquire_monotonic_ret_cmpxchg:
8343 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
8344 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
8345 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
8346 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
8347 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
8348 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
8349 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
8350 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
8351 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
8352 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
8353 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
8354 ; SKIP-CACHE-INV-NEXT:    s_endpgm
8356 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_acquire_monotonic_ret_cmpxchg:
8357 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
8358 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8359 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
8360 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
8361 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
8362 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8363 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8364 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
8365 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
8366 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
8367 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
8369 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_acquire_monotonic_ret_cmpxchg:
8370 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
8371 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8372 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
8373 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
8374 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
8375 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8376 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8377 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
8378 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
8379 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
8380 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
8381     i32 addrspace(1)* %out, i32 %in, i32 %old) {
8382 entry:
8383   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
8384   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") acquire monotonic
8385   %val0 = extractvalue { i32, i1 } %val, 0
8386   store i32 %val0, i32 addrspace(1)* %out, align 4
8387   ret void
8390 define amdgpu_kernel void @global_agent_one_as_acq_rel_monotonic_ret_cmpxchg(
8391 ; GFX6-LABEL: global_agent_one_as_acq_rel_monotonic_ret_cmpxchg:
8392 ; GFX6:       ; %bb.0: ; %entry
8393 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8394 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
8395 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
8396 ; GFX6-NEXT:    s_mov_b32 s2, -1
8397 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
8398 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
8399 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
8400 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
8401 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
8402 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
8403 ; GFX6-NEXT:    buffer_wbinvl1
8404 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
8405 ; GFX6-NEXT:    s_endpgm
8407 ; GFX7-LABEL: global_agent_one_as_acq_rel_monotonic_ret_cmpxchg:
8408 ; GFX7:       ; %bb.0: ; %entry
8409 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8410 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
8411 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
8412 ; GFX7-NEXT:    s_add_u32 s4, s0, 16
8413 ; GFX7-NEXT:    s_addc_u32 s5, s1, 0
8414 ; GFX7-NEXT:    v_mov_b32_e32 v0, s4
8415 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
8416 ; GFX7-NEXT:    v_mov_b32_e32 v1, s5
8417 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
8418 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
8419 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8420 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
8421 ; GFX7-NEXT:    buffer_wbinvl1_vol
8422 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
8423 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
8424 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
8425 ; GFX7-NEXT:    s_endpgm
8427 ; GFX10-WGP-LABEL: global_agent_one_as_acq_rel_monotonic_ret_cmpxchg:
8428 ; GFX10-WGP:       ; %bb.0: ; %entry
8429 ; GFX10-WGP-NEXT:    s_clause 0x1
8430 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
8431 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
8432 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
8433 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
8434 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
8435 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
8436 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
8437 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
8438 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8439 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
8440 ; GFX10-WGP-NEXT:    buffer_gl0_inv
8441 ; GFX10-WGP-NEXT:    buffer_gl1_inv
8442 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
8443 ; GFX10-WGP-NEXT:    s_endpgm
8445 ; GFX10-CU-LABEL: global_agent_one_as_acq_rel_monotonic_ret_cmpxchg:
8446 ; GFX10-CU:       ; %bb.0: ; %entry
8447 ; GFX10-CU-NEXT:    s_clause 0x1
8448 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
8449 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
8450 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
8451 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
8452 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
8453 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
8454 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
8455 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
8456 ; GFX10-CU-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8457 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
8458 ; GFX10-CU-NEXT:    buffer_gl0_inv
8459 ; GFX10-CU-NEXT:    buffer_gl1_inv
8460 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
8461 ; GFX10-CU-NEXT:    s_endpgm
8463 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_acq_rel_monotonic_ret_cmpxchg:
8464 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
8465 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
8466 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
8467 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
8468 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
8469 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
8470 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
8471 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
8472 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
8473 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
8474 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
8475 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
8476 ; SKIP-CACHE-INV-NEXT:    s_endpgm
8478 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_acq_rel_monotonic_ret_cmpxchg:
8479 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
8480 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8481 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
8482 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
8483 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
8484 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8485 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
8486 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8487 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
8488 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
8489 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
8490 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
8492 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_acq_rel_monotonic_ret_cmpxchg:
8493 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
8494 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8495 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
8496 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
8497 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
8498 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8499 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
8500 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8501 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
8502 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
8503 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
8504 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
8505     i32 addrspace(1)* %out, i32 %in, i32 %old) {
8506 entry:
8507   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
8508   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") acq_rel monotonic
8509   %val0 = extractvalue { i32, i1 } %val, 0
8510   store i32 %val0, i32 addrspace(1)* %out, align 4
8511   ret void
8514 define amdgpu_kernel void @global_agent_one_as_seq_cst_monotonic_ret_cmpxchg(
8515 ; GFX6-LABEL: global_agent_one_as_seq_cst_monotonic_ret_cmpxchg:
8516 ; GFX6:       ; %bb.0: ; %entry
8517 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8518 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
8519 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
8520 ; GFX6-NEXT:    s_mov_b32 s2, -1
8521 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
8522 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
8523 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
8524 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
8525 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
8526 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
8527 ; GFX6-NEXT:    buffer_wbinvl1
8528 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
8529 ; GFX6-NEXT:    s_endpgm
8531 ; GFX7-LABEL: global_agent_one_as_seq_cst_monotonic_ret_cmpxchg:
8532 ; GFX7:       ; %bb.0: ; %entry
8533 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8534 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
8535 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
8536 ; GFX7-NEXT:    s_add_u32 s4, s0, 16
8537 ; GFX7-NEXT:    s_addc_u32 s5, s1, 0
8538 ; GFX7-NEXT:    v_mov_b32_e32 v0, s4
8539 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
8540 ; GFX7-NEXT:    v_mov_b32_e32 v1, s5
8541 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
8542 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
8543 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8544 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
8545 ; GFX7-NEXT:    buffer_wbinvl1_vol
8546 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
8547 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
8548 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
8549 ; GFX7-NEXT:    s_endpgm
8551 ; GFX10-WGP-LABEL: global_agent_one_as_seq_cst_monotonic_ret_cmpxchg:
8552 ; GFX10-WGP:       ; %bb.0: ; %entry
8553 ; GFX10-WGP-NEXT:    s_clause 0x1
8554 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
8555 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
8556 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
8557 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
8558 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
8559 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
8560 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
8561 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
8562 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8563 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
8564 ; GFX10-WGP-NEXT:    buffer_gl0_inv
8565 ; GFX10-WGP-NEXT:    buffer_gl1_inv
8566 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
8567 ; GFX10-WGP-NEXT:    s_endpgm
8569 ; GFX10-CU-LABEL: global_agent_one_as_seq_cst_monotonic_ret_cmpxchg:
8570 ; GFX10-CU:       ; %bb.0: ; %entry
8571 ; GFX10-CU-NEXT:    s_clause 0x1
8572 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
8573 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
8574 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
8575 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
8576 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
8577 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
8578 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
8579 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
8580 ; GFX10-CU-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8581 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
8582 ; GFX10-CU-NEXT:    buffer_gl0_inv
8583 ; GFX10-CU-NEXT:    buffer_gl1_inv
8584 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
8585 ; GFX10-CU-NEXT:    s_endpgm
8587 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_seq_cst_monotonic_ret_cmpxchg:
8588 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
8589 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
8590 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
8591 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
8592 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
8593 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
8594 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
8595 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
8596 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
8597 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
8598 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
8599 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
8600 ; SKIP-CACHE-INV-NEXT:    s_endpgm
8602 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_seq_cst_monotonic_ret_cmpxchg:
8603 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
8604 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8605 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
8606 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
8607 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
8608 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8609 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
8610 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8611 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
8612 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
8613 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
8614 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
8616 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_seq_cst_monotonic_ret_cmpxchg:
8617 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
8618 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8619 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
8620 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
8621 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
8622 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8623 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
8624 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8625 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
8626 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
8627 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
8628 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
8629     i32 addrspace(1)* %out, i32 %in, i32 %old) {
8630 entry:
8631   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
8632   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") seq_cst monotonic
8633   %val0 = extractvalue { i32, i1 } %val, 0
8634   store i32 %val0, i32 addrspace(1)* %out, align 4
8635   ret void
8638 define amdgpu_kernel void @global_agent_one_as_monotonic_acquire_ret_cmpxchg(
8639 ; GFX6-LABEL: global_agent_one_as_monotonic_acquire_ret_cmpxchg:
8640 ; GFX6:       ; %bb.0: ; %entry
8641 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8642 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
8643 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
8644 ; GFX6-NEXT:    s_mov_b32 s2, -1
8645 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
8646 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
8647 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
8648 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
8649 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
8650 ; GFX6-NEXT:    buffer_wbinvl1
8651 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
8652 ; GFX6-NEXT:    s_endpgm
8654 ; GFX7-LABEL: global_agent_one_as_monotonic_acquire_ret_cmpxchg:
8655 ; GFX7:       ; %bb.0: ; %entry
8656 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8657 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
8658 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
8659 ; GFX7-NEXT:    s_add_u32 s4, s0, 16
8660 ; GFX7-NEXT:    s_addc_u32 s5, s1, 0
8661 ; GFX7-NEXT:    v_mov_b32_e32 v0, s4
8662 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
8663 ; GFX7-NEXT:    v_mov_b32_e32 v1, s5
8664 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
8665 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8666 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
8667 ; GFX7-NEXT:    buffer_wbinvl1_vol
8668 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
8669 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
8670 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
8671 ; GFX7-NEXT:    s_endpgm
8673 ; GFX10-WGP-LABEL: global_agent_one_as_monotonic_acquire_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:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8683 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
8684 ; GFX10-WGP-NEXT:    buffer_gl0_inv
8685 ; GFX10-WGP-NEXT:    buffer_gl1_inv
8686 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
8687 ; GFX10-WGP-NEXT:    s_endpgm
8689 ; GFX10-CU-LABEL: global_agent_one_as_monotonic_acquire_ret_cmpxchg:
8690 ; GFX10-CU:       ; %bb.0: ; %entry
8691 ; GFX10-CU-NEXT:    s_clause 0x1
8692 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
8693 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
8694 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
8695 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
8696 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
8697 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
8698 ; GFX10-CU-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8699 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
8700 ; GFX10-CU-NEXT:    buffer_gl0_inv
8701 ; GFX10-CU-NEXT:    buffer_gl1_inv
8702 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
8703 ; GFX10-CU-NEXT:    s_endpgm
8705 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_monotonic_acquire_ret_cmpxchg:
8706 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
8707 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
8708 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
8709 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
8710 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
8711 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
8712 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
8713 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
8714 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
8715 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
8716 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
8717 ; SKIP-CACHE-INV-NEXT:    s_endpgm
8719 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_monotonic_acquire_ret_cmpxchg:
8720 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
8721 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8722 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
8723 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
8724 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
8725 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8726 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8727 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
8728 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
8729 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
8730 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
8732 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_monotonic_acquire_ret_cmpxchg:
8733 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
8734 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8735 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
8736 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
8737 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
8738 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8739 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8740 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
8741 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
8742 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
8743 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
8744     i32 addrspace(1)* %out, i32 %in, i32 %old) {
8745 entry:
8746   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
8747   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") monotonic acquire
8748   %val0 = extractvalue { i32, i1 } %val, 0
8749   store i32 %val0, i32 addrspace(1)* %out, align 4
8750   ret void
8753 define amdgpu_kernel void @global_agent_one_as_acquire_acquire_ret_cmpxchg(
8754 ; GFX6-LABEL: global_agent_one_as_acquire_acquire_ret_cmpxchg:
8755 ; GFX6:       ; %bb.0: ; %entry
8756 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8757 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
8758 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
8759 ; GFX6-NEXT:    s_mov_b32 s2, -1
8760 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
8761 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
8762 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
8763 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
8764 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
8765 ; GFX6-NEXT:    buffer_wbinvl1
8766 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
8767 ; GFX6-NEXT:    s_endpgm
8769 ; GFX7-LABEL: global_agent_one_as_acquire_acquire_ret_cmpxchg:
8770 ; GFX7:       ; %bb.0: ; %entry
8771 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8772 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
8773 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
8774 ; GFX7-NEXT:    s_add_u32 s4, s0, 16
8775 ; GFX7-NEXT:    s_addc_u32 s5, s1, 0
8776 ; GFX7-NEXT:    v_mov_b32_e32 v0, s4
8777 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
8778 ; GFX7-NEXT:    v_mov_b32_e32 v1, s5
8779 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
8780 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8781 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
8782 ; GFX7-NEXT:    buffer_wbinvl1_vol
8783 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
8784 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
8785 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
8786 ; GFX7-NEXT:    s_endpgm
8788 ; GFX10-WGP-LABEL: global_agent_one_as_acquire_acquire_ret_cmpxchg:
8789 ; GFX10-WGP:       ; %bb.0: ; %entry
8790 ; GFX10-WGP-NEXT:    s_clause 0x1
8791 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
8792 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
8793 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
8794 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
8795 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
8796 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
8797 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8798 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
8799 ; GFX10-WGP-NEXT:    buffer_gl0_inv
8800 ; GFX10-WGP-NEXT:    buffer_gl1_inv
8801 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
8802 ; GFX10-WGP-NEXT:    s_endpgm
8804 ; GFX10-CU-LABEL: global_agent_one_as_acquire_acquire_ret_cmpxchg:
8805 ; GFX10-CU:       ; %bb.0: ; %entry
8806 ; GFX10-CU-NEXT:    s_clause 0x1
8807 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
8808 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
8809 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
8810 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
8811 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
8812 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
8813 ; GFX10-CU-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8814 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
8815 ; GFX10-CU-NEXT:    buffer_gl0_inv
8816 ; GFX10-CU-NEXT:    buffer_gl1_inv
8817 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
8818 ; GFX10-CU-NEXT:    s_endpgm
8820 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_acquire_acquire_ret_cmpxchg:
8821 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
8822 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
8823 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
8824 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
8825 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
8826 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
8827 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
8828 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
8829 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
8830 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
8831 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
8832 ; SKIP-CACHE-INV-NEXT:    s_endpgm
8834 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_acquire_acquire_ret_cmpxchg:
8835 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
8836 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8837 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
8838 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
8839 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
8840 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8841 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8842 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
8843 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
8844 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
8845 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
8847 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_acquire_acquire_ret_cmpxchg:
8848 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
8849 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8850 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
8851 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
8852 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
8853 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8854 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8855 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
8856 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
8857 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
8858 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
8859     i32 addrspace(1)* %out, i32 %in, i32 %old) {
8860 entry:
8861   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
8862   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") acquire acquire
8863   %val0 = extractvalue { i32, i1 } %val, 0
8864   store i32 %val0, i32 addrspace(1)* %out, align 4
8865   ret void
8868 define amdgpu_kernel void @global_agent_one_as_release_acquire_ret_cmpxchg(
8869 ; GFX6-LABEL: global_agent_one_as_release_acquire_ret_cmpxchg:
8870 ; GFX6:       ; %bb.0: ; %entry
8871 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8872 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
8873 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
8874 ; GFX6-NEXT:    s_mov_b32 s2, -1
8875 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
8876 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
8877 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
8878 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
8879 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
8880 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
8881 ; GFX6-NEXT:    buffer_wbinvl1
8882 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
8883 ; GFX6-NEXT:    s_endpgm
8885 ; GFX7-LABEL: global_agent_one_as_release_acquire_ret_cmpxchg:
8886 ; GFX7:       ; %bb.0: ; %entry
8887 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8888 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
8889 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
8890 ; GFX7-NEXT:    s_add_u32 s4, s0, 16
8891 ; GFX7-NEXT:    s_addc_u32 s5, s1, 0
8892 ; GFX7-NEXT:    v_mov_b32_e32 v0, s4
8893 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
8894 ; GFX7-NEXT:    v_mov_b32_e32 v1, s5
8895 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
8896 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
8897 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8898 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
8899 ; GFX7-NEXT:    buffer_wbinvl1_vol
8900 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
8901 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
8902 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
8903 ; GFX7-NEXT:    s_endpgm
8905 ; GFX10-WGP-LABEL: global_agent_one_as_release_acquire_ret_cmpxchg:
8906 ; GFX10-WGP:       ; %bb.0: ; %entry
8907 ; GFX10-WGP-NEXT:    s_clause 0x1
8908 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
8909 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
8910 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
8911 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
8912 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
8913 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
8914 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
8915 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
8916 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8917 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
8918 ; GFX10-WGP-NEXT:    buffer_gl0_inv
8919 ; GFX10-WGP-NEXT:    buffer_gl1_inv
8920 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
8921 ; GFX10-WGP-NEXT:    s_endpgm
8923 ; GFX10-CU-LABEL: global_agent_one_as_release_acquire_ret_cmpxchg:
8924 ; GFX10-CU:       ; %bb.0: ; %entry
8925 ; GFX10-CU-NEXT:    s_clause 0x1
8926 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
8927 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
8928 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
8929 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
8930 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
8931 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
8932 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
8933 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
8934 ; GFX10-CU-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
8935 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
8936 ; GFX10-CU-NEXT:    buffer_gl0_inv
8937 ; GFX10-CU-NEXT:    buffer_gl1_inv
8938 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
8939 ; GFX10-CU-NEXT:    s_endpgm
8941 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_release_acquire_ret_cmpxchg:
8942 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
8943 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
8944 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
8945 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
8946 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
8947 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
8948 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
8949 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
8950 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
8951 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
8952 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
8953 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
8954 ; SKIP-CACHE-INV-NEXT:    s_endpgm
8956 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_release_acquire_ret_cmpxchg:
8957 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
8958 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8959 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
8960 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
8961 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
8962 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8963 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
8964 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8965 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
8966 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
8967 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
8968 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
8970 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_release_acquire_ret_cmpxchg:
8971 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
8972 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8973 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
8974 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
8975 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
8976 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
8977 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
8978 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
8979 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
8980 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
8981 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
8982 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
8983     i32 addrspace(1)* %out, i32 %in, i32 %old) {
8984 entry:
8985   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
8986   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") release acquire
8987   %val0 = extractvalue { i32, i1 } %val, 0
8988   store i32 %val0, i32 addrspace(1)* %out, align 4
8989   ret void
8992 define amdgpu_kernel void @global_agent_one_as_acq_rel_acquire_ret_cmpxchg(
8993 ; GFX6-LABEL: global_agent_one_as_acq_rel_acquire_ret_cmpxchg:
8994 ; GFX6:       ; %bb.0: ; %entry
8995 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
8996 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
8997 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
8998 ; GFX6-NEXT:    s_mov_b32 s2, -1
8999 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
9000 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
9001 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
9002 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
9003 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
9004 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
9005 ; GFX6-NEXT:    buffer_wbinvl1
9006 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
9007 ; GFX6-NEXT:    s_endpgm
9009 ; GFX7-LABEL: global_agent_one_as_acq_rel_acquire_ret_cmpxchg:
9010 ; GFX7:       ; %bb.0: ; %entry
9011 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
9012 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
9013 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
9014 ; GFX7-NEXT:    s_add_u32 s4, s0, 16
9015 ; GFX7-NEXT:    s_addc_u32 s5, s1, 0
9016 ; GFX7-NEXT:    v_mov_b32_e32 v0, s4
9017 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
9018 ; GFX7-NEXT:    v_mov_b32_e32 v1, s5
9019 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
9020 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
9021 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9022 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
9023 ; GFX7-NEXT:    buffer_wbinvl1_vol
9024 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
9025 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
9026 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
9027 ; GFX7-NEXT:    s_endpgm
9029 ; GFX10-WGP-LABEL: global_agent_one_as_acq_rel_acquire_ret_cmpxchg:
9030 ; GFX10-WGP:       ; %bb.0: ; %entry
9031 ; GFX10-WGP-NEXT:    s_clause 0x1
9032 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
9033 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
9034 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
9035 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
9036 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
9037 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
9038 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
9039 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
9040 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
9041 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
9042 ; GFX10-WGP-NEXT:    buffer_gl0_inv
9043 ; GFX10-WGP-NEXT:    buffer_gl1_inv
9044 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
9045 ; GFX10-WGP-NEXT:    s_endpgm
9047 ; GFX10-CU-LABEL: global_agent_one_as_acq_rel_acquire_ret_cmpxchg:
9048 ; GFX10-CU:       ; %bb.0: ; %entry
9049 ; GFX10-CU-NEXT:    s_clause 0x1
9050 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
9051 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
9052 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
9053 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
9054 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
9055 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
9056 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
9057 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
9058 ; GFX10-CU-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
9059 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
9060 ; GFX10-CU-NEXT:    buffer_gl0_inv
9061 ; GFX10-CU-NEXT:    buffer_gl1_inv
9062 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
9063 ; GFX10-CU-NEXT:    s_endpgm
9065 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_acq_rel_acquire_ret_cmpxchg:
9066 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
9067 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
9068 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
9069 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
9070 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
9071 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
9072 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
9073 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
9074 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
9075 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
9076 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
9077 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
9078 ; SKIP-CACHE-INV-NEXT:    s_endpgm
9080 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_acq_rel_acquire_ret_cmpxchg:
9081 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
9082 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
9083 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
9084 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
9085 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
9086 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9087 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
9088 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
9089 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
9090 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
9091 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
9092 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
9094 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_acq_rel_acquire_ret_cmpxchg:
9095 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
9096 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
9097 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
9098 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
9099 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
9100 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9101 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
9102 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
9103 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
9104 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
9105 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
9106 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
9107     i32 addrspace(1)* %out, i32 %in, i32 %old) {
9108 entry:
9109   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
9110   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") acq_rel acquire
9111   %val0 = extractvalue { i32, i1 } %val, 0
9112   store i32 %val0, i32 addrspace(1)* %out, align 4
9113   ret void
9116 define amdgpu_kernel void @global_agent_one_as_seq_cst_acquire_ret_cmpxchg(
9117 ; GFX6-LABEL: global_agent_one_as_seq_cst_acquire_ret_cmpxchg:
9118 ; GFX6:       ; %bb.0: ; %entry
9119 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
9120 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
9121 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
9122 ; GFX6-NEXT:    s_mov_b32 s2, -1
9123 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
9124 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
9125 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
9126 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
9127 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
9128 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
9129 ; GFX6-NEXT:    buffer_wbinvl1
9130 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
9131 ; GFX6-NEXT:    s_endpgm
9133 ; GFX7-LABEL: global_agent_one_as_seq_cst_acquire_ret_cmpxchg:
9134 ; GFX7:       ; %bb.0: ; %entry
9135 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
9136 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
9137 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
9138 ; GFX7-NEXT:    s_add_u32 s4, s0, 16
9139 ; GFX7-NEXT:    s_addc_u32 s5, s1, 0
9140 ; GFX7-NEXT:    v_mov_b32_e32 v0, s4
9141 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
9142 ; GFX7-NEXT:    v_mov_b32_e32 v1, s5
9143 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
9144 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
9145 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9146 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
9147 ; GFX7-NEXT:    buffer_wbinvl1_vol
9148 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
9149 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
9150 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
9151 ; GFX7-NEXT:    s_endpgm
9153 ; GFX10-WGP-LABEL: global_agent_one_as_seq_cst_acquire_ret_cmpxchg:
9154 ; GFX10-WGP:       ; %bb.0: ; %entry
9155 ; GFX10-WGP-NEXT:    s_clause 0x1
9156 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
9157 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
9158 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
9159 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
9160 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
9161 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
9162 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
9163 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
9164 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
9165 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
9166 ; GFX10-WGP-NEXT:    buffer_gl0_inv
9167 ; GFX10-WGP-NEXT:    buffer_gl1_inv
9168 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
9169 ; GFX10-WGP-NEXT:    s_endpgm
9171 ; GFX10-CU-LABEL: global_agent_one_as_seq_cst_acquire_ret_cmpxchg:
9172 ; GFX10-CU:       ; %bb.0: ; %entry
9173 ; GFX10-CU-NEXT:    s_clause 0x1
9174 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
9175 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
9176 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
9177 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
9178 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
9179 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
9180 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
9181 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
9182 ; GFX10-CU-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
9183 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
9184 ; GFX10-CU-NEXT:    buffer_gl0_inv
9185 ; GFX10-CU-NEXT:    buffer_gl1_inv
9186 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
9187 ; GFX10-CU-NEXT:    s_endpgm
9189 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_seq_cst_acquire_ret_cmpxchg:
9190 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
9191 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
9192 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
9193 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
9194 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
9195 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
9196 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
9197 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
9198 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
9199 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
9200 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
9201 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
9202 ; SKIP-CACHE-INV-NEXT:    s_endpgm
9204 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_seq_cst_acquire_ret_cmpxchg:
9205 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
9206 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
9207 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
9208 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
9209 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
9210 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9211 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
9212 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
9213 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
9214 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
9215 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
9216 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
9218 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_seq_cst_acquire_ret_cmpxchg:
9219 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
9220 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
9221 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
9222 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
9223 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
9224 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9225 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
9226 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
9227 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
9228 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
9229 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
9230 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
9231     i32 addrspace(1)* %out, i32 %in, i32 %old) {
9232 entry:
9233   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
9234   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") seq_cst acquire
9235   %val0 = extractvalue { i32, i1 } %val, 0
9236   store i32 %val0, i32 addrspace(1)* %out, align 4
9237   ret void
9240 define amdgpu_kernel void @global_agent_one_as_monotonic_seq_cst_ret_cmpxchg(
9241 ; GFX6-LABEL: global_agent_one_as_monotonic_seq_cst_ret_cmpxchg:
9242 ; GFX6:       ; %bb.0: ; %entry
9243 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
9244 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
9245 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
9246 ; GFX6-NEXT:    s_mov_b32 s2, -1
9247 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
9248 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
9249 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
9250 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
9251 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
9252 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
9253 ; GFX6-NEXT:    buffer_wbinvl1
9254 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
9255 ; GFX6-NEXT:    s_endpgm
9257 ; GFX7-LABEL: global_agent_one_as_monotonic_seq_cst_ret_cmpxchg:
9258 ; GFX7:       ; %bb.0: ; %entry
9259 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
9260 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
9261 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
9262 ; GFX7-NEXT:    s_add_u32 s4, s0, 16
9263 ; GFX7-NEXT:    s_addc_u32 s5, s1, 0
9264 ; GFX7-NEXT:    v_mov_b32_e32 v0, s4
9265 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
9266 ; GFX7-NEXT:    v_mov_b32_e32 v1, s5
9267 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
9268 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
9269 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9270 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
9271 ; GFX7-NEXT:    buffer_wbinvl1_vol
9272 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
9273 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
9274 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
9275 ; GFX7-NEXT:    s_endpgm
9277 ; GFX10-WGP-LABEL: global_agent_one_as_monotonic_seq_cst_ret_cmpxchg:
9278 ; GFX10-WGP:       ; %bb.0: ; %entry
9279 ; GFX10-WGP-NEXT:    s_clause 0x1
9280 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
9281 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
9282 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
9283 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
9284 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
9285 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
9286 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
9287 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
9288 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
9289 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
9290 ; GFX10-WGP-NEXT:    buffer_gl0_inv
9291 ; GFX10-WGP-NEXT:    buffer_gl1_inv
9292 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
9293 ; GFX10-WGP-NEXT:    s_endpgm
9295 ; GFX10-CU-LABEL: global_agent_one_as_monotonic_seq_cst_ret_cmpxchg:
9296 ; GFX10-CU:       ; %bb.0: ; %entry
9297 ; GFX10-CU-NEXT:    s_clause 0x1
9298 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
9299 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
9300 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
9301 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
9302 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
9303 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
9304 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
9305 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
9306 ; GFX10-CU-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
9307 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
9308 ; GFX10-CU-NEXT:    buffer_gl0_inv
9309 ; GFX10-CU-NEXT:    buffer_gl1_inv
9310 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
9311 ; GFX10-CU-NEXT:    s_endpgm
9313 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_monotonic_seq_cst_ret_cmpxchg:
9314 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
9315 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
9316 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
9317 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
9318 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
9319 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
9320 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
9321 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
9322 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
9323 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
9324 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
9325 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
9326 ; SKIP-CACHE-INV-NEXT:    s_endpgm
9328 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_monotonic_seq_cst_ret_cmpxchg:
9329 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
9330 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
9331 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
9332 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
9333 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
9334 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9335 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
9336 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
9337 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
9338 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
9339 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
9340 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
9342 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_monotonic_seq_cst_ret_cmpxchg:
9343 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
9344 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
9345 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
9346 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
9347 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
9348 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9349 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
9350 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
9351 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
9352 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
9353 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
9354 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
9355     i32 addrspace(1)* %out, i32 %in, i32 %old) {
9356 entry:
9357   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
9358   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") monotonic seq_cst
9359   %val0 = extractvalue { i32, i1 } %val, 0
9360   store i32 %val0, i32 addrspace(1)* %out, align 4
9361   ret void
9364 define amdgpu_kernel void @global_agent_one_as_acquire_seq_cst_ret_cmpxchg(
9365 ; GFX6-LABEL: global_agent_one_as_acquire_seq_cst_ret_cmpxchg:
9366 ; GFX6:       ; %bb.0: ; %entry
9367 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
9368 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
9369 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
9370 ; GFX6-NEXT:    s_mov_b32 s2, -1
9371 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
9372 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
9373 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
9374 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
9375 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
9376 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
9377 ; GFX6-NEXT:    buffer_wbinvl1
9378 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
9379 ; GFX6-NEXT:    s_endpgm
9381 ; GFX7-LABEL: global_agent_one_as_acquire_seq_cst_ret_cmpxchg:
9382 ; GFX7:       ; %bb.0: ; %entry
9383 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
9384 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
9385 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
9386 ; GFX7-NEXT:    s_add_u32 s4, s0, 16
9387 ; GFX7-NEXT:    s_addc_u32 s5, s1, 0
9388 ; GFX7-NEXT:    v_mov_b32_e32 v0, s4
9389 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
9390 ; GFX7-NEXT:    v_mov_b32_e32 v1, s5
9391 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
9392 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
9393 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9394 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
9395 ; GFX7-NEXT:    buffer_wbinvl1_vol
9396 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
9397 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
9398 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
9399 ; GFX7-NEXT:    s_endpgm
9401 ; GFX10-WGP-LABEL: global_agent_one_as_acquire_seq_cst_ret_cmpxchg:
9402 ; GFX10-WGP:       ; %bb.0: ; %entry
9403 ; GFX10-WGP-NEXT:    s_clause 0x1
9404 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
9405 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
9406 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
9407 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
9408 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
9409 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
9410 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
9411 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
9412 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
9413 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
9414 ; GFX10-WGP-NEXT:    buffer_gl0_inv
9415 ; GFX10-WGP-NEXT:    buffer_gl1_inv
9416 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
9417 ; GFX10-WGP-NEXT:    s_endpgm
9419 ; GFX10-CU-LABEL: global_agent_one_as_acquire_seq_cst_ret_cmpxchg:
9420 ; GFX10-CU:       ; %bb.0: ; %entry
9421 ; GFX10-CU-NEXT:    s_clause 0x1
9422 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
9423 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
9424 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
9425 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
9426 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
9427 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
9428 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
9429 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
9430 ; GFX10-CU-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
9431 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
9432 ; GFX10-CU-NEXT:    buffer_gl0_inv
9433 ; GFX10-CU-NEXT:    buffer_gl1_inv
9434 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
9435 ; GFX10-CU-NEXT:    s_endpgm
9437 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_acquire_seq_cst_ret_cmpxchg:
9438 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
9439 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
9440 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
9441 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
9442 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
9443 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
9444 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
9445 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
9446 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
9447 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
9448 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
9449 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
9450 ; SKIP-CACHE-INV-NEXT:    s_endpgm
9452 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_acquire_seq_cst_ret_cmpxchg:
9453 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
9454 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
9455 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
9456 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
9457 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
9458 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9459 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
9460 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
9461 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
9462 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
9463 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
9464 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
9466 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_acquire_seq_cst_ret_cmpxchg:
9467 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
9468 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
9469 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
9470 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
9471 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
9472 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9473 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
9474 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
9475 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
9476 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
9477 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
9478 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
9479     i32 addrspace(1)* %out, i32 %in, i32 %old) {
9480 entry:
9481   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
9482   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") acquire seq_cst
9483   %val0 = extractvalue { i32, i1 } %val, 0
9484   store i32 %val0, i32 addrspace(1)* %out, align 4
9485   ret void
9488 define amdgpu_kernel void @global_agent_one_as_release_seq_cst_ret_cmpxchg(
9489 ; GFX6-LABEL: global_agent_one_as_release_seq_cst_ret_cmpxchg:
9490 ; GFX6:       ; %bb.0: ; %entry
9491 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
9492 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
9493 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
9494 ; GFX6-NEXT:    s_mov_b32 s2, -1
9495 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
9496 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
9497 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
9498 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
9499 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
9500 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
9501 ; GFX6-NEXT:    buffer_wbinvl1
9502 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
9503 ; GFX6-NEXT:    s_endpgm
9505 ; GFX7-LABEL: global_agent_one_as_release_seq_cst_ret_cmpxchg:
9506 ; GFX7:       ; %bb.0: ; %entry
9507 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
9508 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
9509 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
9510 ; GFX7-NEXT:    s_add_u32 s4, s0, 16
9511 ; GFX7-NEXT:    s_addc_u32 s5, s1, 0
9512 ; GFX7-NEXT:    v_mov_b32_e32 v0, s4
9513 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
9514 ; GFX7-NEXT:    v_mov_b32_e32 v1, s5
9515 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
9516 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
9517 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9518 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
9519 ; GFX7-NEXT:    buffer_wbinvl1_vol
9520 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
9521 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
9522 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
9523 ; GFX7-NEXT:    s_endpgm
9525 ; GFX10-WGP-LABEL: global_agent_one_as_release_seq_cst_ret_cmpxchg:
9526 ; GFX10-WGP:       ; %bb.0: ; %entry
9527 ; GFX10-WGP-NEXT:    s_clause 0x1
9528 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
9529 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
9530 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
9531 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
9532 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
9533 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
9534 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
9535 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
9536 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
9537 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
9538 ; GFX10-WGP-NEXT:    buffer_gl0_inv
9539 ; GFX10-WGP-NEXT:    buffer_gl1_inv
9540 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
9541 ; GFX10-WGP-NEXT:    s_endpgm
9543 ; GFX10-CU-LABEL: global_agent_one_as_release_seq_cst_ret_cmpxchg:
9544 ; GFX10-CU:       ; %bb.0: ; %entry
9545 ; GFX10-CU-NEXT:    s_clause 0x1
9546 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
9547 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
9548 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
9549 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
9550 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
9551 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
9552 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
9553 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
9554 ; GFX10-CU-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
9555 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
9556 ; GFX10-CU-NEXT:    buffer_gl0_inv
9557 ; GFX10-CU-NEXT:    buffer_gl1_inv
9558 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
9559 ; GFX10-CU-NEXT:    s_endpgm
9561 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_release_seq_cst_ret_cmpxchg:
9562 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
9563 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
9564 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
9565 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
9566 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
9567 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
9568 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
9569 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
9570 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
9571 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
9572 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
9573 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
9574 ; SKIP-CACHE-INV-NEXT:    s_endpgm
9576 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_release_seq_cst_ret_cmpxchg:
9577 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
9578 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
9579 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
9580 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
9581 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
9582 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9583 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
9584 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
9585 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
9586 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
9587 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
9588 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
9590 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_release_seq_cst_ret_cmpxchg:
9591 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
9592 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
9593 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
9594 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
9595 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
9596 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9597 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
9598 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
9599 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
9600 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
9601 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
9602 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
9603     i32 addrspace(1)* %out, i32 %in, i32 %old) {
9604 entry:
9605   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
9606   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") release seq_cst
9607   %val0 = extractvalue { i32, i1 } %val, 0
9608   store i32 %val0, i32 addrspace(1)* %out, align 4
9609   ret void
9612 define amdgpu_kernel void @global_agent_one_as_acq_rel_seq_cst_ret_cmpxchg(
9613 ; GFX6-LABEL: global_agent_one_as_acq_rel_seq_cst_ret_cmpxchg:
9614 ; GFX6:       ; %bb.0: ; %entry
9615 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
9616 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
9617 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
9618 ; GFX6-NEXT:    s_mov_b32 s2, -1
9619 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
9620 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
9621 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
9622 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
9623 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
9624 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
9625 ; GFX6-NEXT:    buffer_wbinvl1
9626 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
9627 ; GFX6-NEXT:    s_endpgm
9629 ; GFX7-LABEL: global_agent_one_as_acq_rel_seq_cst_ret_cmpxchg:
9630 ; GFX7:       ; %bb.0: ; %entry
9631 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
9632 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
9633 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
9634 ; GFX7-NEXT:    s_add_u32 s4, s0, 16
9635 ; GFX7-NEXT:    s_addc_u32 s5, s1, 0
9636 ; GFX7-NEXT:    v_mov_b32_e32 v0, s4
9637 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
9638 ; GFX7-NEXT:    v_mov_b32_e32 v1, s5
9639 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
9640 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
9641 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9642 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
9643 ; GFX7-NEXT:    buffer_wbinvl1_vol
9644 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
9645 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
9646 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
9647 ; GFX7-NEXT:    s_endpgm
9649 ; GFX10-WGP-LABEL: global_agent_one_as_acq_rel_seq_cst_ret_cmpxchg:
9650 ; GFX10-WGP:       ; %bb.0: ; %entry
9651 ; GFX10-WGP-NEXT:    s_clause 0x1
9652 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
9653 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
9654 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
9655 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
9656 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
9657 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
9658 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
9659 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
9660 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
9661 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
9662 ; GFX10-WGP-NEXT:    buffer_gl0_inv
9663 ; GFX10-WGP-NEXT:    buffer_gl1_inv
9664 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
9665 ; GFX10-WGP-NEXT:    s_endpgm
9667 ; GFX10-CU-LABEL: global_agent_one_as_acq_rel_seq_cst_ret_cmpxchg:
9668 ; GFX10-CU:       ; %bb.0: ; %entry
9669 ; GFX10-CU-NEXT:    s_clause 0x1
9670 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
9671 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
9672 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
9673 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
9674 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
9675 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
9676 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
9677 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
9678 ; GFX10-CU-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
9679 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
9680 ; GFX10-CU-NEXT:    buffer_gl0_inv
9681 ; GFX10-CU-NEXT:    buffer_gl1_inv
9682 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
9683 ; GFX10-CU-NEXT:    s_endpgm
9685 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_acq_rel_seq_cst_ret_cmpxchg:
9686 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
9687 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
9688 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
9689 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
9690 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
9691 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
9692 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
9693 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
9694 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
9695 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
9696 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
9697 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
9698 ; SKIP-CACHE-INV-NEXT:    s_endpgm
9700 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_acq_rel_seq_cst_ret_cmpxchg:
9701 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
9702 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
9703 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
9704 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
9705 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
9706 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9707 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
9708 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
9709 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
9710 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
9711 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
9712 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
9714 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_acq_rel_seq_cst_ret_cmpxchg:
9715 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
9716 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
9717 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
9718 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
9719 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
9720 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9721 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
9722 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
9723 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
9724 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
9725 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
9726 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
9727     i32 addrspace(1)* %out, i32 %in, i32 %old) {
9728 entry:
9729   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
9730   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") acq_rel seq_cst
9731   %val0 = extractvalue { i32, i1 } %val, 0
9732   store i32 %val0, i32 addrspace(1)* %out, align 4
9733   ret void
9736 define amdgpu_kernel void @global_agent_one_as_seq_cst_seq_cst_ret_cmpxchg(
9737 ; GFX6-LABEL: global_agent_one_as_seq_cst_seq_cst_ret_cmpxchg:
9738 ; GFX6:       ; %bb.0: ; %entry
9739 ; GFX6-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
9740 ; GFX6-NEXT:    s_load_dwordx2 s[4:5], s[4:5], 0x2
9741 ; GFX6-NEXT:    s_mov_b32 s3, 0x100f000
9742 ; GFX6-NEXT:    s_mov_b32 s2, -1
9743 ; GFX6-NEXT:    s_waitcnt lgkmcnt(0)
9744 ; GFX6-NEXT:    v_mov_b32_e32 v0, s4
9745 ; GFX6-NEXT:    v_mov_b32_e32 v1, s5
9746 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
9747 ; GFX6-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
9748 ; GFX6-NEXT:    s_waitcnt vmcnt(0)
9749 ; GFX6-NEXT:    buffer_wbinvl1
9750 ; GFX6-NEXT:    buffer_store_dword v0, off, s[0:3], 0
9751 ; GFX6-NEXT:    s_endpgm
9753 ; GFX7-LABEL: global_agent_one_as_seq_cst_seq_cst_ret_cmpxchg:
9754 ; GFX7:       ; %bb.0: ; %entry
9755 ; GFX7-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
9756 ; GFX7-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x2
9757 ; GFX7-NEXT:    s_waitcnt lgkmcnt(0)
9758 ; GFX7-NEXT:    s_add_u32 s4, s0, 16
9759 ; GFX7-NEXT:    s_addc_u32 s5, s1, 0
9760 ; GFX7-NEXT:    v_mov_b32_e32 v0, s4
9761 ; GFX7-NEXT:    v_mov_b32_e32 v2, s2
9762 ; GFX7-NEXT:    v_mov_b32_e32 v1, s5
9763 ; GFX7-NEXT:    v_mov_b32_e32 v3, s3
9764 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
9765 ; GFX7-NEXT:    flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9766 ; GFX7-NEXT:    s_waitcnt vmcnt(0)
9767 ; GFX7-NEXT:    buffer_wbinvl1_vol
9768 ; GFX7-NEXT:    v_mov_b32_e32 v0, s0
9769 ; GFX7-NEXT:    v_mov_b32_e32 v1, s1
9770 ; GFX7-NEXT:    flat_store_dword v[0:1], v2
9771 ; GFX7-NEXT:    s_endpgm
9773 ; GFX10-WGP-LABEL: global_agent_one_as_seq_cst_seq_cst_ret_cmpxchg:
9774 ; GFX10-WGP:       ; %bb.0: ; %entry
9775 ; GFX10-WGP-NEXT:    s_clause 0x1
9776 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
9777 ; GFX10-WGP-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
9778 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v2, 0
9779 ; GFX10-WGP-NEXT:    s_waitcnt lgkmcnt(0)
9780 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v0, s0
9781 ; GFX10-WGP-NEXT:    v_mov_b32_e32 v1, s1
9782 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
9783 ; GFX10-WGP-NEXT:    s_waitcnt_vscnt null, 0x0
9784 ; GFX10-WGP-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
9785 ; GFX10-WGP-NEXT:    s_waitcnt vmcnt(0)
9786 ; GFX10-WGP-NEXT:    buffer_gl0_inv
9787 ; GFX10-WGP-NEXT:    buffer_gl1_inv
9788 ; GFX10-WGP-NEXT:    global_store_dword v2, v0, s[2:3]
9789 ; GFX10-WGP-NEXT:    s_endpgm
9791 ; GFX10-CU-LABEL: global_agent_one_as_seq_cst_seq_cst_ret_cmpxchg:
9792 ; GFX10-CU:       ; %bb.0: ; %entry
9793 ; GFX10-CU-NEXT:    s_clause 0x1
9794 ; GFX10-CU-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x8
9795 ; GFX10-CU-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x0
9796 ; GFX10-CU-NEXT:    v_mov_b32_e32 v2, 0
9797 ; GFX10-CU-NEXT:    s_waitcnt lgkmcnt(0)
9798 ; GFX10-CU-NEXT:    v_mov_b32_e32 v0, s0
9799 ; GFX10-CU-NEXT:    v_mov_b32_e32 v1, s1
9800 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
9801 ; GFX10-CU-NEXT:    s_waitcnt_vscnt null, 0x0
9802 ; GFX10-CU-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[2:3] offset:16 glc
9803 ; GFX10-CU-NEXT:    s_waitcnt vmcnt(0)
9804 ; GFX10-CU-NEXT:    buffer_gl0_inv
9805 ; GFX10-CU-NEXT:    buffer_gl1_inv
9806 ; GFX10-CU-NEXT:    global_store_dword v2, v0, s[2:3]
9807 ; GFX10-CU-NEXT:    s_endpgm
9809 ; SKIP-CACHE-INV-LABEL: global_agent_one_as_seq_cst_seq_cst_ret_cmpxchg:
9810 ; SKIP-CACHE-INV:       ; %bb.0: ; %entry
9811 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[4:5], s[0:1], 0x9
9812 ; SKIP-CACHE-INV-NEXT:    s_load_dwordx2 s[0:1], s[0:1], 0xb
9813 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s7, 0xf000
9814 ; SKIP-CACHE-INV-NEXT:    s_mov_b32 s6, -1
9815 ; SKIP-CACHE-INV-NEXT:    s_waitcnt lgkmcnt(0)
9816 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v0, s0
9817 ; SKIP-CACHE-INV-NEXT:    v_mov_b32_e32 v1, s1
9818 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
9819 ; SKIP-CACHE-INV-NEXT:    buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
9820 ; SKIP-CACHE-INV-NEXT:    s_waitcnt vmcnt(0)
9821 ; SKIP-CACHE-INV-NEXT:    buffer_store_dword v0, off, s[4:7], 0
9822 ; SKIP-CACHE-INV-NEXT:    s_endpgm
9824 ; GFX90A-NOTTGSPLIT-LABEL: global_agent_one_as_seq_cst_seq_cst_ret_cmpxchg:
9825 ; GFX90A-NOTTGSPLIT:       ; %bb.0: ; %entry
9826 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
9827 ; GFX90A-NOTTGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
9828 ; GFX90A-NOTTGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
9829 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
9830 ; GFX90A-NOTTGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9831 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
9832 ; GFX90A-NOTTGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
9833 ; GFX90A-NOTTGSPLIT-NEXT:    s_waitcnt vmcnt(0)
9834 ; GFX90A-NOTTGSPLIT-NEXT:    buffer_wbinvl1_vol
9835 ; GFX90A-NOTTGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
9836 ; GFX90A-NOTTGSPLIT-NEXT:    s_endpgm
9838 ; GFX90A-TGSPLIT-LABEL: global_agent_one_as_seq_cst_seq_cst_ret_cmpxchg:
9839 ; GFX90A-TGSPLIT:       ; %bb.0: ; %entry
9840 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[0:1], s[4:5], 0x0
9841 ; GFX90A-TGSPLIT-NEXT:    s_load_dwordx2 s[2:3], s[4:5], 0x8
9842 ; GFX90A-TGSPLIT-NEXT:    v_mov_b32_e32 v2, 0
9843 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt lgkmcnt(0)
9844 ; GFX90A-TGSPLIT-NEXT:    v_pk_mov_b32 v[0:1], s[2:3], s[2:3] op_sel:[0,1]
9845 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
9846 ; GFX90A-TGSPLIT-NEXT:    global_atomic_cmpswap v0, v2, v[0:1], s[0:1] offset:16 glc
9847 ; GFX90A-TGSPLIT-NEXT:    s_waitcnt vmcnt(0)
9848 ; GFX90A-TGSPLIT-NEXT:    buffer_wbinvl1_vol
9849 ; GFX90A-TGSPLIT-NEXT:    global_store_dword v2, v0, s[0:1]
9850 ; GFX90A-TGSPLIT-NEXT:    s_endpgm
9851     i32 addrspace(1)* %out, i32 %in, i32 %old) {
9852 entry:
9853   %gep = getelementptr i32, i32 addrspace(1)* %out, i32 4
9854   %val = cmpxchg volatile i32 addrspace(1)* %gep, i32 %old, i32 %in syncscope("agent-one-as") seq_cst seq_cst
9855   %val0 = extractvalue { i32, i1 } %val, 0
9856   store i32 %val0, i32 addrspace(1)* %out, align 4
9857   ret void