1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx700 -verify-machineinstrs < %s | FileCheck --check-prefixes=GFX7 %s
3 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -verify-machineinstrs < %s | FileCheck --check-prefixes=GFX10-WGP %s
4 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -mattr=+cumode -verify-machineinstrs < %s | FileCheck --check-prefixes=GFX10-CU %s
5 ; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx700 -amdgcn-skip-cache-invalidations -verify-machineinstrs < %s | FileCheck --check-prefixes=SKIP-CACHE-INV %s
6 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx90a -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX90A-NOTTGSPLIT %s
7 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx90a -mattr=+tgsplit -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX90A-TGSPLIT %s
8 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx940 -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX940-NOTTGSPLIT %s
9 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx940 -mattr=+tgsplit -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX940-TGSPLIT %s
10 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1100 -verify-machineinstrs < %s | FileCheck --check-prefixes=GFX11-WGP %s
11 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1100 -mattr=+cumode -verify-machineinstrs < %s | FileCheck --check-prefixes=GFX11-CU %s
13 define amdgpu_kernel void @flat_workgroup_unordered_load(
14 ; GFX7-LABEL: flat_workgroup_unordered_load:
15 ; GFX7: ; %bb.0: ; %entry
16 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
17 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
18 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
19 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
20 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
21 ; GFX7-NEXT: v_mov_b32_e32 v0, s2
22 ; GFX7-NEXT: v_mov_b32_e32 v1, s3
23 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
24 ; GFX7-NEXT: flat_store_dword v[0:1], v2
27 ; GFX10-WGP-LABEL: flat_workgroup_unordered_load:
28 ; GFX10-WGP: ; %bb.0: ; %entry
29 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
30 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
31 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
32 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
33 ; GFX10-WGP-NEXT: flat_load_dword v2, v[0:1]
34 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
35 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
36 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
37 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
38 ; GFX10-WGP-NEXT: s_endpgm
40 ; GFX10-CU-LABEL: flat_workgroup_unordered_load:
41 ; GFX10-CU: ; %bb.0: ; %entry
42 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
43 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
44 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
45 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
46 ; GFX10-CU-NEXT: flat_load_dword v2, v[0:1]
47 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
48 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
49 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
50 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
51 ; GFX10-CU-NEXT: s_endpgm
53 ; SKIP-CACHE-INV-LABEL: flat_workgroup_unordered_load:
54 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
55 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
56 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
57 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
58 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
59 ; SKIP-CACHE-INV-NEXT: flat_load_dword v2, v[0:1]
60 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
61 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
62 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
63 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
64 ; SKIP-CACHE-INV-NEXT: s_endpgm
66 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_unordered_load:
67 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
68 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
69 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
70 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s0
71 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s1
72 ; GFX90A-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1]
73 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
74 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s3
75 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
76 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
77 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
79 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_unordered_load:
80 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
81 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
82 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
83 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s0
84 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s1
85 ; GFX90A-TGSPLIT-NEXT: flat_load_dword v2, v[0:1]
86 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
87 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s3
88 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
89 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
90 ; GFX90A-TGSPLIT-NEXT: s_endpgm
92 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_unordered_load:
93 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
94 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
95 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
96 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s0
97 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s1
98 ; GFX940-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1]
99 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
100 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s3
101 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
102 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
103 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
105 ; GFX940-TGSPLIT-LABEL: flat_workgroup_unordered_load:
106 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
107 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
108 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
109 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s0
110 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s1
111 ; GFX940-TGSPLIT-NEXT: flat_load_dword v2, v[0:1]
112 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
113 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s3
114 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
115 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
116 ; GFX940-TGSPLIT-NEXT: s_endpgm
118 ; GFX11-WGP-LABEL: flat_workgroup_unordered_load:
119 ; GFX11-WGP: ; %bb.0: ; %entry
120 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
121 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
122 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
123 ; GFX11-WGP-NEXT: flat_load_b32 v2, v[0:1]
124 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
125 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
126 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
127 ; GFX11-WGP-NEXT: s_endpgm
129 ; GFX11-CU-LABEL: flat_workgroup_unordered_load:
130 ; GFX11-CU: ; %bb.0: ; %entry
131 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
132 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
133 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
134 ; GFX11-CU-NEXT: flat_load_b32 v2, v[0:1]
135 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
136 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
137 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
138 ; GFX11-CU-NEXT: s_endpgm
141 %val = load atomic i32, ptr %in syncscope("workgroup") unordered, align 4
142 store i32 %val, ptr %out
146 define amdgpu_kernel void @flat_workgroup_monotonic_load(
147 ; GFX7-LABEL: flat_workgroup_monotonic_load:
148 ; GFX7: ; %bb.0: ; %entry
149 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
150 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
151 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
152 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
153 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
154 ; GFX7-NEXT: v_mov_b32_e32 v0, s2
155 ; GFX7-NEXT: v_mov_b32_e32 v1, s3
156 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
157 ; GFX7-NEXT: flat_store_dword v[0:1], v2
158 ; GFX7-NEXT: s_endpgm
160 ; GFX10-WGP-LABEL: flat_workgroup_monotonic_load:
161 ; GFX10-WGP: ; %bb.0: ; %entry
162 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
163 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
164 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
165 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
166 ; GFX10-WGP-NEXT: flat_load_dword v2, v[0:1] glc
167 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
168 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
169 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
170 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
171 ; GFX10-WGP-NEXT: s_endpgm
173 ; GFX10-CU-LABEL: flat_workgroup_monotonic_load:
174 ; GFX10-CU: ; %bb.0: ; %entry
175 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
176 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
177 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
178 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
179 ; GFX10-CU-NEXT: flat_load_dword v2, v[0:1]
180 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
181 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
182 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
183 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
184 ; GFX10-CU-NEXT: s_endpgm
186 ; SKIP-CACHE-INV-LABEL: flat_workgroup_monotonic_load:
187 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
188 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
189 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
190 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
191 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
192 ; SKIP-CACHE-INV-NEXT: flat_load_dword v2, v[0:1]
193 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
194 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
195 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
196 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
197 ; SKIP-CACHE-INV-NEXT: s_endpgm
199 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_monotonic_load:
200 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
201 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
202 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
203 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s0
204 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s1
205 ; GFX90A-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1]
206 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
207 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s3
208 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
209 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
210 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
212 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_monotonic_load:
213 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
214 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
215 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
216 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s0
217 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s1
218 ; GFX90A-TGSPLIT-NEXT: flat_load_dword v2, v[0:1] glc
219 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
220 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s3
221 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
222 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
223 ; GFX90A-TGSPLIT-NEXT: s_endpgm
225 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_monotonic_load:
226 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
227 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
228 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
229 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s0
230 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s1
231 ; GFX940-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1] sc0
232 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
233 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s3
234 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
235 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
236 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
238 ; GFX940-TGSPLIT-LABEL: flat_workgroup_monotonic_load:
239 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
240 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
241 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
242 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s0
243 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s1
244 ; GFX940-TGSPLIT-NEXT: flat_load_dword v2, v[0:1] sc0
245 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
246 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s3
247 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
248 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
249 ; GFX940-TGSPLIT-NEXT: s_endpgm
251 ; GFX11-WGP-LABEL: flat_workgroup_monotonic_load:
252 ; GFX11-WGP: ; %bb.0: ; %entry
253 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
254 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
255 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
256 ; GFX11-WGP-NEXT: flat_load_b32 v2, v[0:1] glc
257 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
258 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
259 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
260 ; GFX11-WGP-NEXT: s_endpgm
262 ; GFX11-CU-LABEL: flat_workgroup_monotonic_load:
263 ; GFX11-CU: ; %bb.0: ; %entry
264 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
265 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
266 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
267 ; GFX11-CU-NEXT: flat_load_b32 v2, v[0:1]
268 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
269 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
270 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
271 ; GFX11-CU-NEXT: s_endpgm
274 %val = load atomic i32, ptr %in syncscope("workgroup") monotonic, align 4
275 store i32 %val, ptr %out
279 define amdgpu_kernel void @flat_workgroup_acquire_load(
280 ; GFX7-LABEL: flat_workgroup_acquire_load:
281 ; GFX7: ; %bb.0: ; %entry
282 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
283 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
284 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
285 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
286 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
287 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
288 ; GFX7-NEXT: v_mov_b32_e32 v0, s2
289 ; GFX7-NEXT: v_mov_b32_e32 v1, s3
290 ; GFX7-NEXT: s_waitcnt vmcnt(0)
291 ; GFX7-NEXT: flat_store_dword v[0:1], v2
292 ; GFX7-NEXT: s_endpgm
294 ; GFX10-WGP-LABEL: flat_workgroup_acquire_load:
295 ; GFX10-WGP: ; %bb.0: ; %entry
296 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
297 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
298 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
299 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
300 ; GFX10-WGP-NEXT: flat_load_dword v2, v[0:1] glc
301 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
302 ; GFX10-WGP-NEXT: buffer_gl0_inv
303 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
304 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
305 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
306 ; GFX10-WGP-NEXT: s_endpgm
308 ; GFX10-CU-LABEL: flat_workgroup_acquire_load:
309 ; GFX10-CU: ; %bb.0: ; %entry
310 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
311 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
312 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
313 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
314 ; GFX10-CU-NEXT: flat_load_dword v2, v[0:1]
315 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
316 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
317 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
318 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
319 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
320 ; GFX10-CU-NEXT: s_endpgm
322 ; SKIP-CACHE-INV-LABEL: flat_workgroup_acquire_load:
323 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
324 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
325 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
326 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
327 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
328 ; SKIP-CACHE-INV-NEXT: flat_load_dword v2, v[0:1]
329 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
330 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
331 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
332 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
333 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
334 ; SKIP-CACHE-INV-NEXT: s_endpgm
336 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_acquire_load:
337 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
338 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
339 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
340 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s0
341 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s1
342 ; GFX90A-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1]
343 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
344 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
345 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s3
346 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
347 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
348 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
350 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_acquire_load:
351 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
352 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
353 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
354 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s0
355 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s1
356 ; GFX90A-TGSPLIT-NEXT: flat_load_dword v2, v[0:1] glc
357 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
358 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
359 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
360 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s3
361 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
362 ; GFX90A-TGSPLIT-NEXT: s_endpgm
364 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_acquire_load:
365 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
366 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
367 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
368 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s0
369 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s1
370 ; GFX940-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1] sc0
371 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
372 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
373 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s3
374 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
375 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
376 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
378 ; GFX940-TGSPLIT-LABEL: flat_workgroup_acquire_load:
379 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
380 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
381 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
382 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s0
383 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s1
384 ; GFX940-TGSPLIT-NEXT: flat_load_dword v2, v[0:1] sc0
385 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
386 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
387 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
388 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s3
389 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
390 ; GFX940-TGSPLIT-NEXT: s_endpgm
392 ; GFX11-WGP-LABEL: flat_workgroup_acquire_load:
393 ; GFX11-WGP: ; %bb.0: ; %entry
394 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
395 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
396 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
397 ; GFX11-WGP-NEXT: flat_load_b32 v2, v[0:1] glc
398 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
399 ; GFX11-WGP-NEXT: buffer_gl0_inv
400 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
401 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
402 ; GFX11-WGP-NEXT: s_endpgm
404 ; GFX11-CU-LABEL: flat_workgroup_acquire_load:
405 ; GFX11-CU: ; %bb.0: ; %entry
406 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
407 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
408 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
409 ; GFX11-CU-NEXT: flat_load_b32 v2, v[0:1]
410 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
411 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
412 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
413 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
414 ; GFX11-CU-NEXT: s_endpgm
417 %val = load atomic i32, ptr %in syncscope("workgroup") acquire, align 4
418 store i32 %val, ptr %out
422 define amdgpu_kernel void @flat_workgroup_seq_cst_load(
423 ; GFX7-LABEL: flat_workgroup_seq_cst_load:
424 ; GFX7: ; %bb.0: ; %entry
425 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
426 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
427 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
428 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
429 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
430 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
431 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
432 ; GFX7-NEXT: v_mov_b32_e32 v0, s2
433 ; GFX7-NEXT: v_mov_b32_e32 v1, s3
434 ; GFX7-NEXT: s_waitcnt vmcnt(0)
435 ; GFX7-NEXT: flat_store_dword v[0:1], v2
436 ; GFX7-NEXT: s_endpgm
438 ; GFX10-WGP-LABEL: flat_workgroup_seq_cst_load:
439 ; GFX10-WGP: ; %bb.0: ; %entry
440 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
441 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
442 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
443 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
444 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
445 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
446 ; GFX10-WGP-NEXT: flat_load_dword v2, v[0:1] glc
447 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
448 ; GFX10-WGP-NEXT: buffer_gl0_inv
449 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
450 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
451 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
452 ; GFX10-WGP-NEXT: s_endpgm
454 ; GFX10-CU-LABEL: flat_workgroup_seq_cst_load:
455 ; GFX10-CU: ; %bb.0: ; %entry
456 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
457 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
458 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
459 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
460 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
461 ; GFX10-CU-NEXT: flat_load_dword v2, v[0:1]
462 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
463 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
464 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
465 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
466 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
467 ; GFX10-CU-NEXT: s_endpgm
469 ; SKIP-CACHE-INV-LABEL: flat_workgroup_seq_cst_load:
470 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
471 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
472 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
473 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
474 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
475 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
476 ; SKIP-CACHE-INV-NEXT: flat_load_dword v2, v[0:1]
477 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
478 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
479 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
480 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
481 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
482 ; SKIP-CACHE-INV-NEXT: s_endpgm
484 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_seq_cst_load:
485 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
486 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
487 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
488 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s0
489 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s1
490 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
491 ; GFX90A-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1]
492 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
493 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
494 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s3
495 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
496 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
497 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
499 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_seq_cst_load:
500 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
501 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
502 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
503 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s0
504 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s1
505 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
506 ; GFX90A-TGSPLIT-NEXT: flat_load_dword v2, v[0:1] glc
507 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
508 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
509 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
510 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s3
511 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
512 ; GFX90A-TGSPLIT-NEXT: s_endpgm
514 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_seq_cst_load:
515 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
516 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
517 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
518 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s0
519 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s1
520 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
521 ; GFX940-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1] sc0
522 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
523 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
524 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s3
525 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
526 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
527 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
529 ; GFX940-TGSPLIT-LABEL: flat_workgroup_seq_cst_load:
530 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
531 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
532 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
533 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s0
534 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s1
535 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
536 ; GFX940-TGSPLIT-NEXT: flat_load_dword v2, v[0:1] sc0
537 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
538 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
539 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
540 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s3
541 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
542 ; GFX940-TGSPLIT-NEXT: s_endpgm
544 ; GFX11-WGP-LABEL: flat_workgroup_seq_cst_load:
545 ; GFX11-WGP: ; %bb.0: ; %entry
546 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
547 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
548 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
549 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
550 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
551 ; GFX11-WGP-NEXT: flat_load_b32 v2, v[0:1] glc
552 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
553 ; GFX11-WGP-NEXT: buffer_gl0_inv
554 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
555 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
556 ; GFX11-WGP-NEXT: s_endpgm
558 ; GFX11-CU-LABEL: flat_workgroup_seq_cst_load:
559 ; GFX11-CU: ; %bb.0: ; %entry
560 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
561 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
562 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
563 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
564 ; GFX11-CU-NEXT: flat_load_b32 v2, v[0:1]
565 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
566 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
567 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
568 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
569 ; GFX11-CU-NEXT: s_endpgm
572 %val = load atomic i32, ptr %in syncscope("workgroup") seq_cst, align 4
573 store i32 %val, ptr %out
577 define amdgpu_kernel void @flat_workgroup_unordered_store(
578 ; GFX7-LABEL: flat_workgroup_unordered_store:
579 ; GFX7: ; %bb.0: ; %entry
580 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
581 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x0
582 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
583 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
584 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
585 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
586 ; GFX7-NEXT: flat_store_dword v[0:1], v2
587 ; GFX7-NEXT: s_endpgm
589 ; GFX10-WGP-LABEL: flat_workgroup_unordered_store:
590 ; GFX10-WGP: ; %bb.0: ; %entry
591 ; GFX10-WGP-NEXT: s_clause 0x1
592 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
593 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x0
594 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
595 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
596 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
597 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
598 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
599 ; GFX10-WGP-NEXT: s_endpgm
601 ; GFX10-CU-LABEL: flat_workgroup_unordered_store:
602 ; GFX10-CU: ; %bb.0: ; %entry
603 ; GFX10-CU-NEXT: s_clause 0x1
604 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
605 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x0
606 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
607 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
608 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
609 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
610 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
611 ; GFX10-CU-NEXT: s_endpgm
613 ; SKIP-CACHE-INV-LABEL: flat_workgroup_unordered_store:
614 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
615 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x2
616 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x0
617 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
618 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
619 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
620 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
621 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
622 ; SKIP-CACHE-INV-NEXT: s_endpgm
624 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_unordered_store:
625 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
626 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
627 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
628 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
629 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
630 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
631 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
632 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
634 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_unordered_store:
635 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
636 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
637 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
638 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
639 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
640 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
641 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
642 ; GFX90A-TGSPLIT-NEXT: s_endpgm
644 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_unordered_store:
645 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
646 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
647 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
648 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
649 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
650 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
651 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
652 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
654 ; GFX940-TGSPLIT-LABEL: flat_workgroup_unordered_store:
655 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
656 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
657 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
658 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
659 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
660 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
661 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
662 ; GFX940-TGSPLIT-NEXT: s_endpgm
664 ; GFX11-WGP-LABEL: flat_workgroup_unordered_store:
665 ; GFX11-WGP: ; %bb.0: ; %entry
666 ; GFX11-WGP-NEXT: s_clause 0x1
667 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x8
668 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x0
669 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
670 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
671 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
672 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
673 ; GFX11-WGP-NEXT: s_endpgm
675 ; GFX11-CU-LABEL: flat_workgroup_unordered_store:
676 ; GFX11-CU: ; %bb.0: ; %entry
677 ; GFX11-CU-NEXT: s_clause 0x1
678 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x8
679 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x0
680 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
681 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
682 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
683 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
684 ; GFX11-CU-NEXT: s_endpgm
687 store atomic i32 %in, ptr %out syncscope("workgroup") unordered, align 4
691 define amdgpu_kernel void @flat_workgroup_monotonic_store(
692 ; GFX7-LABEL: flat_workgroup_monotonic_store:
693 ; GFX7: ; %bb.0: ; %entry
694 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
695 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x0
696 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
697 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
698 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
699 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
700 ; GFX7-NEXT: flat_store_dword v[0:1], v2
701 ; GFX7-NEXT: s_endpgm
703 ; GFX10-WGP-LABEL: flat_workgroup_monotonic_store:
704 ; GFX10-WGP: ; %bb.0: ; %entry
705 ; GFX10-WGP-NEXT: s_clause 0x1
706 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
707 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x0
708 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
709 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
710 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
711 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
712 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
713 ; GFX10-WGP-NEXT: s_endpgm
715 ; GFX10-CU-LABEL: flat_workgroup_monotonic_store:
716 ; GFX10-CU: ; %bb.0: ; %entry
717 ; GFX10-CU-NEXT: s_clause 0x1
718 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
719 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x0
720 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
721 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
722 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
723 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
724 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
725 ; GFX10-CU-NEXT: s_endpgm
727 ; SKIP-CACHE-INV-LABEL: flat_workgroup_monotonic_store:
728 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
729 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x2
730 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x0
731 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
732 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
733 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
734 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
735 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
736 ; SKIP-CACHE-INV-NEXT: s_endpgm
738 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_monotonic_store:
739 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
740 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
741 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
742 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
743 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
744 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
745 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
746 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
748 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_monotonic_store:
749 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
750 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
751 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
752 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
753 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
754 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
755 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
756 ; GFX90A-TGSPLIT-NEXT: s_endpgm
758 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_monotonic_store:
759 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
760 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
761 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
762 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
763 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
764 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
765 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
766 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
768 ; GFX940-TGSPLIT-LABEL: flat_workgroup_monotonic_store:
769 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
770 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
771 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
772 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
773 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
774 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
775 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
776 ; GFX940-TGSPLIT-NEXT: s_endpgm
778 ; GFX11-WGP-LABEL: flat_workgroup_monotonic_store:
779 ; GFX11-WGP: ; %bb.0: ; %entry
780 ; GFX11-WGP-NEXT: s_clause 0x1
781 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x8
782 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x0
783 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
784 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
785 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
786 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
787 ; GFX11-WGP-NEXT: s_endpgm
789 ; GFX11-CU-LABEL: flat_workgroup_monotonic_store:
790 ; GFX11-CU: ; %bb.0: ; %entry
791 ; GFX11-CU-NEXT: s_clause 0x1
792 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x8
793 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x0
794 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
795 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
796 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
797 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
798 ; GFX11-CU-NEXT: s_endpgm
801 store atomic i32 %in, ptr %out syncscope("workgroup") monotonic, align 4
805 define amdgpu_kernel void @flat_workgroup_release_store(
806 ; GFX7-LABEL: flat_workgroup_release_store:
807 ; GFX7: ; %bb.0: ; %entry
808 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
809 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x0
810 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
811 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
812 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
813 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
814 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
815 ; GFX7-NEXT: flat_store_dword v[0:1], v2
816 ; GFX7-NEXT: s_endpgm
818 ; GFX10-WGP-LABEL: flat_workgroup_release_store:
819 ; GFX10-WGP: ; %bb.0: ; %entry
820 ; GFX10-WGP-NEXT: s_clause 0x1
821 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
822 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x0
823 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
824 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
825 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
826 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
827 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
828 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
829 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
830 ; GFX10-WGP-NEXT: s_endpgm
832 ; GFX10-CU-LABEL: flat_workgroup_release_store:
833 ; GFX10-CU: ; %bb.0: ; %entry
834 ; GFX10-CU-NEXT: s_clause 0x1
835 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
836 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x0
837 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
838 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
839 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
840 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
841 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
842 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
843 ; GFX10-CU-NEXT: s_endpgm
845 ; SKIP-CACHE-INV-LABEL: flat_workgroup_release_store:
846 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
847 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x2
848 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x0
849 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
850 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
851 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
852 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
853 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
854 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
855 ; SKIP-CACHE-INV-NEXT: s_endpgm
857 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_release_store:
858 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
859 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
860 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
861 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
862 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
863 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
864 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
865 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
866 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
868 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_release_store:
869 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
870 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
871 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
872 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
873 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
874 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
875 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
876 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
877 ; GFX90A-TGSPLIT-NEXT: s_endpgm
879 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_release_store:
880 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
881 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
882 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
883 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
884 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
885 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
886 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
887 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
888 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
890 ; GFX940-TGSPLIT-LABEL: flat_workgroup_release_store:
891 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
892 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
893 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
894 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
895 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
896 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
897 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
898 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
899 ; GFX940-TGSPLIT-NEXT: s_endpgm
901 ; GFX11-WGP-LABEL: flat_workgroup_release_store:
902 ; GFX11-WGP: ; %bb.0: ; %entry
903 ; GFX11-WGP-NEXT: s_clause 0x1
904 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x8
905 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x0
906 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
907 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
908 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
909 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
910 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
911 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
912 ; GFX11-WGP-NEXT: s_endpgm
914 ; GFX11-CU-LABEL: flat_workgroup_release_store:
915 ; GFX11-CU: ; %bb.0: ; %entry
916 ; GFX11-CU-NEXT: s_clause 0x1
917 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x8
918 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x0
919 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
920 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
921 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
922 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
923 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
924 ; GFX11-CU-NEXT: s_endpgm
927 store atomic i32 %in, ptr %out syncscope("workgroup") release, align 4
931 define amdgpu_kernel void @flat_workgroup_seq_cst_store(
932 ; GFX7-LABEL: flat_workgroup_seq_cst_store:
933 ; GFX7: ; %bb.0: ; %entry
934 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
935 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x0
936 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
937 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
938 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
939 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
940 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
941 ; GFX7-NEXT: flat_store_dword v[0:1], v2
942 ; GFX7-NEXT: s_endpgm
944 ; GFX10-WGP-LABEL: flat_workgroup_seq_cst_store:
945 ; GFX10-WGP: ; %bb.0: ; %entry
946 ; GFX10-WGP-NEXT: s_clause 0x1
947 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
948 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x0
949 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
950 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
951 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
952 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
953 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
954 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
955 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
956 ; GFX10-WGP-NEXT: s_endpgm
958 ; GFX10-CU-LABEL: flat_workgroup_seq_cst_store:
959 ; GFX10-CU: ; %bb.0: ; %entry
960 ; GFX10-CU-NEXT: s_clause 0x1
961 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
962 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x0
963 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
964 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
965 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
966 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
967 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
968 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
969 ; GFX10-CU-NEXT: s_endpgm
971 ; SKIP-CACHE-INV-LABEL: flat_workgroup_seq_cst_store:
972 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
973 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x2
974 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x0
975 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
976 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
977 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
978 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
979 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
980 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
981 ; SKIP-CACHE-INV-NEXT: s_endpgm
983 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_seq_cst_store:
984 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
985 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
986 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
987 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
988 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
989 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
990 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
991 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
992 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
994 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_seq_cst_store:
995 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
996 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
997 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
998 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
999 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
1000 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
1001 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1002 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
1003 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1005 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_seq_cst_store:
1006 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
1007 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
1008 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
1009 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1010 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
1011 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1012 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1013 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
1014 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
1016 ; GFX940-TGSPLIT-LABEL: flat_workgroup_seq_cst_store:
1017 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
1018 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
1019 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
1020 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1021 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
1022 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1023 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1024 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
1025 ; GFX940-TGSPLIT-NEXT: s_endpgm
1027 ; GFX11-WGP-LABEL: flat_workgroup_seq_cst_store:
1028 ; GFX11-WGP: ; %bb.0: ; %entry
1029 ; GFX11-WGP-NEXT: s_clause 0x1
1030 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x8
1031 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x0
1032 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1033 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
1034 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
1035 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1036 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1037 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
1038 ; GFX11-WGP-NEXT: s_endpgm
1040 ; GFX11-CU-LABEL: flat_workgroup_seq_cst_store:
1041 ; GFX11-CU: ; %bb.0: ; %entry
1042 ; GFX11-CU-NEXT: s_clause 0x1
1043 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x8
1044 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x0
1045 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1046 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
1047 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
1048 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1049 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
1050 ; GFX11-CU-NEXT: s_endpgm
1051 i32 %in, ptr %out) {
1053 store atomic i32 %in, ptr %out syncscope("workgroup") seq_cst, align 4
1057 define amdgpu_kernel void @flat_workgroup_monotonic_atomicrmw(
1058 ; GFX7-LABEL: flat_workgroup_monotonic_atomicrmw:
1059 ; GFX7: ; %bb.0: ; %entry
1060 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1061 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
1062 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1063 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
1064 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
1065 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
1066 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
1067 ; GFX7-NEXT: s_endpgm
1069 ; GFX10-WGP-LABEL: flat_workgroup_monotonic_atomicrmw:
1070 ; GFX10-WGP: ; %bb.0: ; %entry
1071 ; GFX10-WGP-NEXT: s_clause 0x1
1072 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1073 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
1074 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1075 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
1076 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
1077 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
1078 ; GFX10-WGP-NEXT: flat_atomic_swap v[0:1], v2
1079 ; GFX10-WGP-NEXT: s_endpgm
1081 ; GFX10-CU-LABEL: flat_workgroup_monotonic_atomicrmw:
1082 ; GFX10-CU: ; %bb.0: ; %entry
1083 ; GFX10-CU-NEXT: s_clause 0x1
1084 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1085 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
1086 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1087 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
1088 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
1089 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
1090 ; GFX10-CU-NEXT: flat_atomic_swap v[0:1], v2
1091 ; GFX10-CU-NEXT: s_endpgm
1093 ; SKIP-CACHE-INV-LABEL: flat_workgroup_monotonic_atomicrmw:
1094 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1095 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1096 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x2
1097 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1098 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
1099 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
1100 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
1101 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v[0:1], v2
1102 ; SKIP-CACHE-INV-NEXT: s_endpgm
1104 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_monotonic_atomicrmw:
1105 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1106 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1107 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1108 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1109 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
1110 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
1111 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1112 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1114 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_monotonic_atomicrmw:
1115 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1116 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1117 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1118 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1119 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
1120 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
1121 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1122 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1124 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_monotonic_atomicrmw:
1125 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
1126 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1127 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
1128 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1129 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
1130 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1131 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1132 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
1134 ; GFX940-TGSPLIT-LABEL: flat_workgroup_monotonic_atomicrmw:
1135 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
1136 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1137 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
1138 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1139 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
1140 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1141 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1142 ; GFX940-TGSPLIT-NEXT: s_endpgm
1144 ; GFX11-WGP-LABEL: flat_workgroup_monotonic_atomicrmw:
1145 ; GFX11-WGP: ; %bb.0: ; %entry
1146 ; GFX11-WGP-NEXT: s_clause 0x1
1147 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1148 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
1149 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1150 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
1151 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
1152 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
1153 ; GFX11-WGP-NEXT: s_endpgm
1155 ; GFX11-CU-LABEL: flat_workgroup_monotonic_atomicrmw:
1156 ; GFX11-CU: ; %bb.0: ; %entry
1157 ; GFX11-CU-NEXT: s_clause 0x1
1158 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1159 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
1160 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1161 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
1162 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
1163 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
1164 ; GFX11-CU-NEXT: s_endpgm
1165 ptr %out, i32 %in) {
1167 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("workgroup") monotonic
1171 define amdgpu_kernel void @flat_workgroup_acquire_atomicrmw(
1172 ; GFX7-LABEL: flat_workgroup_acquire_atomicrmw:
1173 ; GFX7: ; %bb.0: ; %entry
1174 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1175 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
1176 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1177 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
1178 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
1179 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
1180 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
1181 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1182 ; GFX7-NEXT: s_endpgm
1184 ; GFX10-WGP-LABEL: flat_workgroup_acquire_atomicrmw:
1185 ; GFX10-WGP: ; %bb.0: ; %entry
1186 ; GFX10-WGP-NEXT: s_clause 0x1
1187 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1188 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
1189 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1190 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
1191 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
1192 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
1193 ; GFX10-WGP-NEXT: flat_atomic_swap v[0:1], v2
1194 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1195 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1196 ; GFX10-WGP-NEXT: buffer_gl0_inv
1197 ; GFX10-WGP-NEXT: s_endpgm
1199 ; GFX10-CU-LABEL: flat_workgroup_acquire_atomicrmw:
1200 ; GFX10-CU: ; %bb.0: ; %entry
1201 ; GFX10-CU-NEXT: s_clause 0x1
1202 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1203 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
1204 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1205 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
1206 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
1207 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
1208 ; GFX10-CU-NEXT: flat_atomic_swap v[0:1], v2
1209 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1210 ; GFX10-CU-NEXT: s_endpgm
1212 ; SKIP-CACHE-INV-LABEL: flat_workgroup_acquire_atomicrmw:
1213 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1214 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1215 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x2
1216 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1217 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
1218 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
1219 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
1220 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v[0:1], v2
1221 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1222 ; SKIP-CACHE-INV-NEXT: s_endpgm
1224 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_acquire_atomicrmw:
1225 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1226 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1227 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1228 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1229 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
1230 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
1231 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1232 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1233 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1235 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_acquire_atomicrmw:
1236 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1237 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1238 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1239 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1240 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
1241 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
1242 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1243 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1244 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
1245 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1247 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_acquire_atomicrmw:
1248 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
1249 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1250 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
1251 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1252 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
1253 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1254 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1255 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1256 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
1258 ; GFX940-TGSPLIT-LABEL: flat_workgroup_acquire_atomicrmw:
1259 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
1260 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1261 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
1262 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1263 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
1264 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1265 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1266 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1267 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
1268 ; GFX940-TGSPLIT-NEXT: s_endpgm
1270 ; GFX11-WGP-LABEL: flat_workgroup_acquire_atomicrmw:
1271 ; GFX11-WGP: ; %bb.0: ; %entry
1272 ; GFX11-WGP-NEXT: s_clause 0x1
1273 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1274 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
1275 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1276 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
1277 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
1278 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
1279 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1280 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1281 ; GFX11-WGP-NEXT: buffer_gl0_inv
1282 ; GFX11-WGP-NEXT: s_endpgm
1284 ; GFX11-CU-LABEL: flat_workgroup_acquire_atomicrmw:
1285 ; GFX11-CU: ; %bb.0: ; %entry
1286 ; GFX11-CU-NEXT: s_clause 0x1
1287 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1288 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
1289 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1290 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
1291 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
1292 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
1293 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1294 ; GFX11-CU-NEXT: s_endpgm
1295 ptr %out, i32 %in) {
1297 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("workgroup") acquire
1301 define amdgpu_kernel void @flat_workgroup_release_atomicrmw(
1302 ; GFX7-LABEL: flat_workgroup_release_atomicrmw:
1303 ; GFX7: ; %bb.0: ; %entry
1304 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1305 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
1306 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1307 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
1308 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
1309 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
1310 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1311 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
1312 ; GFX7-NEXT: s_endpgm
1314 ; GFX10-WGP-LABEL: flat_workgroup_release_atomicrmw:
1315 ; GFX10-WGP: ; %bb.0: ; %entry
1316 ; GFX10-WGP-NEXT: s_clause 0x1
1317 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1318 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
1319 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1320 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
1321 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
1322 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
1323 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1324 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1325 ; GFX10-WGP-NEXT: flat_atomic_swap v[0:1], v2
1326 ; GFX10-WGP-NEXT: s_endpgm
1328 ; GFX10-CU-LABEL: flat_workgroup_release_atomicrmw:
1329 ; GFX10-CU: ; %bb.0: ; %entry
1330 ; GFX10-CU-NEXT: s_clause 0x1
1331 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1332 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
1333 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1334 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
1335 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
1336 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
1337 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1338 ; GFX10-CU-NEXT: flat_atomic_swap v[0:1], v2
1339 ; GFX10-CU-NEXT: s_endpgm
1341 ; SKIP-CACHE-INV-LABEL: flat_workgroup_release_atomicrmw:
1342 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1343 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1344 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x2
1345 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1346 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
1347 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
1348 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
1349 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1350 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v[0:1], v2
1351 ; SKIP-CACHE-INV-NEXT: s_endpgm
1353 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_release_atomicrmw:
1354 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1355 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1356 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1357 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1358 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
1359 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
1360 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1361 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1362 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1364 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_release_atomicrmw:
1365 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1366 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1367 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1368 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1369 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
1370 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
1371 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1372 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1373 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1375 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_release_atomicrmw:
1376 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
1377 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1378 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
1379 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1380 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
1381 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1382 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1383 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1384 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
1386 ; GFX940-TGSPLIT-LABEL: flat_workgroup_release_atomicrmw:
1387 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
1388 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1389 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
1390 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1391 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
1392 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1393 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1394 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1395 ; GFX940-TGSPLIT-NEXT: s_endpgm
1397 ; GFX11-WGP-LABEL: flat_workgroup_release_atomicrmw:
1398 ; GFX11-WGP: ; %bb.0: ; %entry
1399 ; GFX11-WGP-NEXT: s_clause 0x1
1400 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1401 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
1402 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1403 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
1404 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
1405 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1406 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1407 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
1408 ; GFX11-WGP-NEXT: s_endpgm
1410 ; GFX11-CU-LABEL: flat_workgroup_release_atomicrmw:
1411 ; GFX11-CU: ; %bb.0: ; %entry
1412 ; GFX11-CU-NEXT: s_clause 0x1
1413 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1414 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
1415 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1416 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
1417 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
1418 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1419 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
1420 ; GFX11-CU-NEXT: s_endpgm
1421 ptr %out, i32 %in) {
1423 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("workgroup") release
1427 define amdgpu_kernel void @flat_workgroup_acq_rel_atomicrmw(
1428 ; GFX7-LABEL: flat_workgroup_acq_rel_atomicrmw:
1429 ; GFX7: ; %bb.0: ; %entry
1430 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1431 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
1432 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1433 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
1434 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
1435 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
1436 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1437 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
1438 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1439 ; GFX7-NEXT: s_endpgm
1441 ; GFX10-WGP-LABEL: flat_workgroup_acq_rel_atomicrmw:
1442 ; GFX10-WGP: ; %bb.0: ; %entry
1443 ; GFX10-WGP-NEXT: s_clause 0x1
1444 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1445 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
1446 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1447 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
1448 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
1449 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
1450 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1451 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1452 ; GFX10-WGP-NEXT: flat_atomic_swap v[0:1], v2
1453 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1454 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1455 ; GFX10-WGP-NEXT: buffer_gl0_inv
1456 ; GFX10-WGP-NEXT: s_endpgm
1458 ; GFX10-CU-LABEL: flat_workgroup_acq_rel_atomicrmw:
1459 ; GFX10-CU: ; %bb.0: ; %entry
1460 ; GFX10-CU-NEXT: s_clause 0x1
1461 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1462 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
1463 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1464 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
1465 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
1466 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
1467 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1468 ; GFX10-CU-NEXT: flat_atomic_swap v[0:1], v2
1469 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1470 ; GFX10-CU-NEXT: s_endpgm
1472 ; SKIP-CACHE-INV-LABEL: flat_workgroup_acq_rel_atomicrmw:
1473 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1474 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1475 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x2
1476 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1477 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
1478 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
1479 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
1480 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1481 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v[0:1], v2
1482 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1483 ; SKIP-CACHE-INV-NEXT: s_endpgm
1485 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_acq_rel_atomicrmw:
1486 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1487 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1488 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1489 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1490 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
1491 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
1492 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1493 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1494 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1495 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1497 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_acq_rel_atomicrmw:
1498 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1499 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1500 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1501 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1502 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
1503 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
1504 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1505 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1506 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1507 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
1508 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1510 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_acq_rel_atomicrmw:
1511 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
1512 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1513 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
1514 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1515 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
1516 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1517 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1518 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1519 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1520 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
1522 ; GFX940-TGSPLIT-LABEL: flat_workgroup_acq_rel_atomicrmw:
1523 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
1524 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1525 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
1526 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1527 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
1528 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1529 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1530 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1531 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1532 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
1533 ; GFX940-TGSPLIT-NEXT: s_endpgm
1535 ; GFX11-WGP-LABEL: flat_workgroup_acq_rel_atomicrmw:
1536 ; GFX11-WGP: ; %bb.0: ; %entry
1537 ; GFX11-WGP-NEXT: s_clause 0x1
1538 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1539 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
1540 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1541 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
1542 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
1543 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1544 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1545 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
1546 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1547 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1548 ; GFX11-WGP-NEXT: buffer_gl0_inv
1549 ; GFX11-WGP-NEXT: s_endpgm
1551 ; GFX11-CU-LABEL: flat_workgroup_acq_rel_atomicrmw:
1552 ; GFX11-CU: ; %bb.0: ; %entry
1553 ; GFX11-CU-NEXT: s_clause 0x1
1554 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1555 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
1556 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1557 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
1558 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
1559 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1560 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
1561 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1562 ; GFX11-CU-NEXT: s_endpgm
1563 ptr %out, i32 %in) {
1565 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("workgroup") acq_rel
1569 define amdgpu_kernel void @flat_workgroup_seq_cst_atomicrmw(
1570 ; GFX7-LABEL: flat_workgroup_seq_cst_atomicrmw:
1571 ; GFX7: ; %bb.0: ; %entry
1572 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1573 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
1574 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1575 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
1576 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
1577 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
1578 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1579 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
1580 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1581 ; GFX7-NEXT: s_endpgm
1583 ; GFX10-WGP-LABEL: flat_workgroup_seq_cst_atomicrmw:
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], 0x0
1587 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
1588 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1589 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
1590 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
1591 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
1592 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1593 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1594 ; GFX10-WGP-NEXT: flat_atomic_swap v[0:1], v2
1595 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1596 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1597 ; GFX10-WGP-NEXT: buffer_gl0_inv
1598 ; GFX10-WGP-NEXT: s_endpgm
1600 ; GFX10-CU-LABEL: flat_workgroup_seq_cst_atomicrmw:
1601 ; GFX10-CU: ; %bb.0: ; %entry
1602 ; GFX10-CU-NEXT: s_clause 0x1
1603 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1604 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
1605 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1606 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
1607 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
1608 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
1609 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1610 ; GFX10-CU-NEXT: flat_atomic_swap v[0:1], v2
1611 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1612 ; GFX10-CU-NEXT: s_endpgm
1614 ; SKIP-CACHE-INV-LABEL: flat_workgroup_seq_cst_atomicrmw:
1615 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1616 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1617 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x2
1618 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1619 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
1620 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
1621 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
1622 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1623 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v[0:1], v2
1624 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1625 ; SKIP-CACHE-INV-NEXT: s_endpgm
1627 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_seq_cst_atomicrmw:
1628 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1629 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1630 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1631 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1632 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
1633 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
1634 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1635 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1636 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1637 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1639 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_seq_cst_atomicrmw:
1640 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1641 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1642 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1643 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1644 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
1645 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
1646 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1647 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1648 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1649 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
1650 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1652 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_seq_cst_atomicrmw:
1653 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
1654 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1655 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
1656 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1657 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
1658 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1659 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1660 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1661 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1662 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
1664 ; GFX940-TGSPLIT-LABEL: flat_workgroup_seq_cst_atomicrmw:
1665 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
1666 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1667 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
1668 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1669 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
1670 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1671 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1672 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1673 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1674 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
1675 ; GFX940-TGSPLIT-NEXT: s_endpgm
1677 ; GFX11-WGP-LABEL: flat_workgroup_seq_cst_atomicrmw:
1678 ; GFX11-WGP: ; %bb.0: ; %entry
1679 ; GFX11-WGP-NEXT: s_clause 0x1
1680 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1681 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
1682 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1683 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
1684 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
1685 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1686 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1687 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
1688 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1689 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1690 ; GFX11-WGP-NEXT: buffer_gl0_inv
1691 ; GFX11-WGP-NEXT: s_endpgm
1693 ; GFX11-CU-LABEL: flat_workgroup_seq_cst_atomicrmw:
1694 ; GFX11-CU: ; %bb.0: ; %entry
1695 ; GFX11-CU-NEXT: s_clause 0x1
1696 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1697 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
1698 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1699 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
1700 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
1701 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1702 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
1703 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1704 ; GFX11-CU-NEXT: s_endpgm
1705 ptr %out, i32 %in) {
1707 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("workgroup") seq_cst
1711 define amdgpu_kernel void @flat_workgroup_acquire_ret_atomicrmw(
1712 ; GFX7-LABEL: flat_workgroup_acquire_ret_atomicrmw:
1713 ; GFX7: ; %bb.0: ; %entry
1714 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1715 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
1716 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1717 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
1718 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
1719 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
1720 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
1721 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1722 ; GFX7-NEXT: flat_store_dword v[0:1], v2
1723 ; GFX7-NEXT: s_endpgm
1725 ; GFX10-WGP-LABEL: flat_workgroup_acquire_ret_atomicrmw:
1726 ; GFX10-WGP: ; %bb.0: ; %entry
1727 ; GFX10-WGP-NEXT: s_clause 0x1
1728 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1729 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
1730 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1731 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
1732 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
1733 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
1734 ; GFX10-WGP-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
1735 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1736 ; GFX10-WGP-NEXT: buffer_gl0_inv
1737 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
1738 ; GFX10-WGP-NEXT: s_endpgm
1740 ; GFX10-CU-LABEL: flat_workgroup_acquire_ret_atomicrmw:
1741 ; GFX10-CU: ; %bb.0: ; %entry
1742 ; GFX10-CU-NEXT: s_clause 0x1
1743 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1744 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
1745 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1746 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
1747 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
1748 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
1749 ; GFX10-CU-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
1750 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1751 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
1752 ; GFX10-CU-NEXT: s_endpgm
1754 ; SKIP-CACHE-INV-LABEL: flat_workgroup_acquire_ret_atomicrmw:
1755 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1756 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1757 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x2
1758 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1759 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
1760 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
1761 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
1762 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
1763 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1764 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
1765 ; SKIP-CACHE-INV-NEXT: s_endpgm
1767 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_acquire_ret_atomicrmw:
1768 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1769 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1770 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1771 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1772 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
1773 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
1774 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
1775 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1776 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
1777 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1779 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_acquire_ret_atomicrmw:
1780 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1781 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1782 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1783 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1784 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
1785 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
1786 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
1787 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1788 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
1789 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
1790 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1792 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_acquire_ret_atomicrmw:
1793 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
1794 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1795 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
1796 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1797 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
1798 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1799 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 sc0
1800 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1801 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
1802 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
1804 ; GFX940-TGSPLIT-LABEL: flat_workgroup_acquire_ret_atomicrmw:
1805 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
1806 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1807 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
1808 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1809 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
1810 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1811 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 sc0
1812 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1813 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
1814 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
1815 ; GFX940-TGSPLIT-NEXT: s_endpgm
1817 ; GFX11-WGP-LABEL: flat_workgroup_acquire_ret_atomicrmw:
1818 ; GFX11-WGP: ; %bb.0: ; %entry
1819 ; GFX11-WGP-NEXT: s_clause 0x1
1820 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1821 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
1822 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1823 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
1824 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
1825 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 glc
1826 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1827 ; GFX11-WGP-NEXT: buffer_gl0_inv
1828 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
1829 ; GFX11-WGP-NEXT: s_endpgm
1831 ; GFX11-CU-LABEL: flat_workgroup_acquire_ret_atomicrmw:
1832 ; GFX11-CU: ; %bb.0: ; %entry
1833 ; GFX11-CU-NEXT: s_clause 0x1
1834 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1835 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
1836 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1837 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
1838 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
1839 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 glc
1840 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1841 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
1842 ; GFX11-CU-NEXT: s_endpgm
1843 ptr %out, i32 %in) {
1845 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("workgroup") acquire
1846 store i32 %val, ptr %out, align 4
1850 define amdgpu_kernel void @flat_workgroup_acq_rel_ret_atomicrmw(
1851 ; GFX7-LABEL: flat_workgroup_acq_rel_ret_atomicrmw:
1852 ; GFX7: ; %bb.0: ; %entry
1853 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1854 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
1855 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1856 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
1857 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
1858 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
1859 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1860 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
1861 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1862 ; GFX7-NEXT: flat_store_dword v[0:1], v2
1863 ; GFX7-NEXT: s_endpgm
1865 ; GFX10-WGP-LABEL: flat_workgroup_acq_rel_ret_atomicrmw:
1866 ; GFX10-WGP: ; %bb.0: ; %entry
1867 ; GFX10-WGP-NEXT: s_clause 0x1
1868 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1869 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
1870 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1871 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
1872 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
1873 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
1874 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1875 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1876 ; GFX10-WGP-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
1877 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1878 ; GFX10-WGP-NEXT: buffer_gl0_inv
1879 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
1880 ; GFX10-WGP-NEXT: s_endpgm
1882 ; GFX10-CU-LABEL: flat_workgroup_acq_rel_ret_atomicrmw:
1883 ; GFX10-CU: ; %bb.0: ; %entry
1884 ; GFX10-CU-NEXT: s_clause 0x1
1885 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1886 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
1887 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1888 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
1889 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
1890 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
1891 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1892 ; GFX10-CU-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
1893 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1894 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
1895 ; GFX10-CU-NEXT: s_endpgm
1897 ; SKIP-CACHE-INV-LABEL: flat_workgroup_acq_rel_ret_atomicrmw:
1898 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1899 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1900 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x2
1901 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1902 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
1903 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
1904 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
1905 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1906 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
1907 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1908 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
1909 ; SKIP-CACHE-INV-NEXT: s_endpgm
1911 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_acq_rel_ret_atomicrmw:
1912 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1913 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1914 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1915 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1916 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
1917 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
1918 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1919 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
1920 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1921 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
1922 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1924 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_acq_rel_ret_atomicrmw:
1925 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1926 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1927 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1928 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1929 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
1930 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
1931 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1932 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
1933 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1934 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
1935 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
1936 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1938 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_acq_rel_ret_atomicrmw:
1939 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
1940 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1941 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
1942 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1943 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
1944 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1945 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1946 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 sc0
1947 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1948 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
1949 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
1951 ; GFX940-TGSPLIT-LABEL: flat_workgroup_acq_rel_ret_atomicrmw:
1952 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
1953 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1954 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
1955 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1956 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
1957 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1958 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1959 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 sc0
1960 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1961 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
1962 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
1963 ; GFX940-TGSPLIT-NEXT: s_endpgm
1965 ; GFX11-WGP-LABEL: flat_workgroup_acq_rel_ret_atomicrmw:
1966 ; GFX11-WGP: ; %bb.0: ; %entry
1967 ; GFX11-WGP-NEXT: s_clause 0x1
1968 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1969 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
1970 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1971 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
1972 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
1973 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1974 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1975 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 glc
1976 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1977 ; GFX11-WGP-NEXT: buffer_gl0_inv
1978 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
1979 ; GFX11-WGP-NEXT: s_endpgm
1981 ; GFX11-CU-LABEL: flat_workgroup_acq_rel_ret_atomicrmw:
1982 ; GFX11-CU: ; %bb.0: ; %entry
1983 ; GFX11-CU-NEXT: s_clause 0x1
1984 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1985 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
1986 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1987 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
1988 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
1989 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1990 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 glc
1991 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1992 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
1993 ; GFX11-CU-NEXT: s_endpgm
1994 ptr %out, i32 %in) {
1996 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("workgroup") acq_rel
1997 store i32 %val, ptr %out, align 4
2001 define amdgpu_kernel void @flat_workgroup_seq_cst_ret_atomicrmw(
2002 ; GFX7-LABEL: flat_workgroup_seq_cst_ret_atomicrmw:
2003 ; GFX7: ; %bb.0: ; %entry
2004 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2005 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
2006 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2007 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
2008 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
2009 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
2010 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2011 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
2012 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2013 ; GFX7-NEXT: flat_store_dword v[0:1], v2
2014 ; GFX7-NEXT: s_endpgm
2016 ; GFX10-WGP-LABEL: flat_workgroup_seq_cst_ret_atomicrmw:
2017 ; GFX10-WGP: ; %bb.0: ; %entry
2018 ; GFX10-WGP-NEXT: s_clause 0x1
2019 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2020 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
2021 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2022 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
2023 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
2024 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
2025 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2026 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2027 ; GFX10-WGP-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
2028 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2029 ; GFX10-WGP-NEXT: buffer_gl0_inv
2030 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
2031 ; GFX10-WGP-NEXT: s_endpgm
2033 ; GFX10-CU-LABEL: flat_workgroup_seq_cst_ret_atomicrmw:
2034 ; GFX10-CU: ; %bb.0: ; %entry
2035 ; GFX10-CU-NEXT: s_clause 0x1
2036 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2037 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
2038 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2039 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
2040 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
2041 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
2042 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2043 ; GFX10-CU-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
2044 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2045 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
2046 ; GFX10-CU-NEXT: s_endpgm
2048 ; SKIP-CACHE-INV-LABEL: flat_workgroup_seq_cst_ret_atomicrmw:
2049 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2050 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
2051 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x2
2052 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2053 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
2054 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
2055 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
2056 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2057 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
2058 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2059 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
2060 ; SKIP-CACHE-INV-NEXT: s_endpgm
2062 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_seq_cst_ret_atomicrmw:
2063 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2064 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2065 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
2066 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2067 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
2068 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
2069 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2070 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
2071 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2072 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
2073 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2075 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_seq_cst_ret_atomicrmw:
2076 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2077 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2078 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
2079 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2080 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
2081 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
2082 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2083 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
2084 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2085 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
2086 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
2087 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2089 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_seq_cst_ret_atomicrmw:
2090 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
2091 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
2092 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
2093 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2094 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
2095 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
2096 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2097 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 sc0
2098 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2099 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
2100 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
2102 ; GFX940-TGSPLIT-LABEL: flat_workgroup_seq_cst_ret_atomicrmw:
2103 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
2104 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
2105 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
2106 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2107 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
2108 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
2109 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2110 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 sc0
2111 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2112 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
2113 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
2114 ; GFX940-TGSPLIT-NEXT: s_endpgm
2116 ; GFX11-WGP-LABEL: flat_workgroup_seq_cst_ret_atomicrmw:
2117 ; GFX11-WGP: ; %bb.0: ; %entry
2118 ; GFX11-WGP-NEXT: s_clause 0x1
2119 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
2120 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
2121 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
2122 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
2123 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
2124 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2125 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2126 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 glc
2127 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2128 ; GFX11-WGP-NEXT: buffer_gl0_inv
2129 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
2130 ; GFX11-WGP-NEXT: s_endpgm
2132 ; GFX11-CU-LABEL: flat_workgroup_seq_cst_ret_atomicrmw:
2133 ; GFX11-CU: ; %bb.0: ; %entry
2134 ; GFX11-CU-NEXT: s_clause 0x1
2135 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
2136 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
2137 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2138 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
2139 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
2140 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2141 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 glc
2142 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2143 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
2144 ; GFX11-CU-NEXT: s_endpgm
2145 ptr %out, i32 %in) {
2147 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("workgroup") seq_cst
2148 store i32 %val, ptr %out, align 4
2152 define amdgpu_kernel void @flat_workgroup_monotonic_monotonic_cmpxchg(
2153 ; GFX7-LABEL: flat_workgroup_monotonic_monotonic_cmpxchg:
2154 ; GFX7: ; %bb.0: ; %entry
2155 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2156 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2157 ; GFX7-NEXT: s_add_u32 s0, s0, 16
2158 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
2159 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
2160 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
2161 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
2162 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
2163 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2164 ; GFX7-NEXT: s_endpgm
2166 ; GFX10-WGP-LABEL: flat_workgroup_monotonic_monotonic_cmpxchg:
2167 ; GFX10-WGP: ; %bb.0: ; %entry
2168 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2169 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2170 ; GFX10-WGP-NEXT: s_add_u32 s0, s0, 16
2171 ; GFX10-WGP-NEXT: s_addc_u32 s1, s1, 0
2172 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
2173 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
2174 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
2175 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
2176 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2177 ; GFX10-WGP-NEXT: s_endpgm
2179 ; GFX10-CU-LABEL: flat_workgroup_monotonic_monotonic_cmpxchg:
2180 ; GFX10-CU: ; %bb.0: ; %entry
2181 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2182 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2183 ; GFX10-CU-NEXT: s_add_u32 s0, s0, 16
2184 ; GFX10-CU-NEXT: s_addc_u32 s1, s1, 0
2185 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
2186 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
2187 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
2188 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
2189 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2190 ; GFX10-CU-NEXT: s_endpgm
2192 ; SKIP-CACHE-INV-LABEL: flat_workgroup_monotonic_monotonic_cmpxchg:
2193 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2194 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2195 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2196 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, 16
2197 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s1, s1, 0
2198 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
2199 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
2200 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
2201 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
2202 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2203 ; SKIP-CACHE-INV-NEXT: s_endpgm
2205 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_monotonic_monotonic_cmpxchg:
2206 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2207 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2208 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2209 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
2210 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
2211 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2212 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2214 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_monotonic_monotonic_cmpxchg:
2215 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2216 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2217 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2218 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
2219 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
2220 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2221 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2223 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_monotonic_monotonic_cmpxchg:
2224 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
2225 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2226 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2227 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
2228 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
2229 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2230 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
2232 ; GFX940-TGSPLIT-LABEL: flat_workgroup_monotonic_monotonic_cmpxchg:
2233 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
2234 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2235 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2236 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
2237 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
2238 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2239 ; GFX940-TGSPLIT-NEXT: s_endpgm
2241 ; GFX11-WGP-LABEL: flat_workgroup_monotonic_monotonic_cmpxchg:
2242 ; GFX11-WGP: ; %bb.0: ; %entry
2243 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
2244 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
2245 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
2246 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
2247 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
2248 ; GFX11-WGP-NEXT: s_endpgm
2250 ; GFX11-CU-LABEL: flat_workgroup_monotonic_monotonic_cmpxchg:
2251 ; GFX11-CU: ; %bb.0: ; %entry
2252 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
2253 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2254 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
2255 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
2256 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
2257 ; GFX11-CU-NEXT: s_endpgm
2258 ptr %out, i32 %in, i32 %old) {
2260 %gep = getelementptr i32, ptr %out, i32 4
2261 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup") monotonic monotonic
2265 define amdgpu_kernel void @flat_workgroup_acquire_monotonic_cmpxchg(
2266 ; GFX7-LABEL: flat_workgroup_acquire_monotonic_cmpxchg:
2267 ; GFX7: ; %bb.0: ; %entry
2268 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2269 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2270 ; GFX7-NEXT: s_add_u32 s0, s0, 16
2271 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
2272 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
2273 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
2274 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
2275 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
2276 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2277 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2278 ; GFX7-NEXT: s_endpgm
2280 ; GFX10-WGP-LABEL: flat_workgroup_acquire_monotonic_cmpxchg:
2281 ; GFX10-WGP: ; %bb.0: ; %entry
2282 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2283 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2284 ; GFX10-WGP-NEXT: s_add_u32 s0, s0, 16
2285 ; GFX10-WGP-NEXT: s_addc_u32 s1, s1, 0
2286 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
2287 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
2288 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
2289 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
2290 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2291 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2292 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2293 ; GFX10-WGP-NEXT: buffer_gl0_inv
2294 ; GFX10-WGP-NEXT: s_endpgm
2296 ; GFX10-CU-LABEL: flat_workgroup_acquire_monotonic_cmpxchg:
2297 ; GFX10-CU: ; %bb.0: ; %entry
2298 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2299 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2300 ; GFX10-CU-NEXT: s_add_u32 s0, s0, 16
2301 ; GFX10-CU-NEXT: s_addc_u32 s1, s1, 0
2302 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
2303 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
2304 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
2305 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
2306 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2307 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2308 ; GFX10-CU-NEXT: s_endpgm
2310 ; SKIP-CACHE-INV-LABEL: flat_workgroup_acquire_monotonic_cmpxchg:
2311 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2312 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2313 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2314 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, 16
2315 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s1, s1, 0
2316 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
2317 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
2318 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
2319 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
2320 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2321 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2322 ; SKIP-CACHE-INV-NEXT: s_endpgm
2324 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_acquire_monotonic_cmpxchg:
2325 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2326 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2327 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2328 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
2329 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
2330 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2331 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2332 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2334 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_acquire_monotonic_cmpxchg:
2335 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2336 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2337 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2338 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
2339 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
2340 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2341 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2342 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
2343 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2345 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_acquire_monotonic_cmpxchg:
2346 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
2347 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2348 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2349 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
2350 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
2351 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2352 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2353 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
2355 ; GFX940-TGSPLIT-LABEL: flat_workgroup_acquire_monotonic_cmpxchg:
2356 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
2357 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2358 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2359 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
2360 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
2361 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2362 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2363 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
2364 ; GFX940-TGSPLIT-NEXT: s_endpgm
2366 ; GFX11-WGP-LABEL: flat_workgroup_acquire_monotonic_cmpxchg:
2367 ; GFX11-WGP: ; %bb.0: ; %entry
2368 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
2369 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
2370 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
2371 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
2372 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
2373 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
2374 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2375 ; GFX11-WGP-NEXT: buffer_gl0_inv
2376 ; GFX11-WGP-NEXT: s_endpgm
2378 ; GFX11-CU-LABEL: flat_workgroup_acquire_monotonic_cmpxchg:
2379 ; GFX11-CU: ; %bb.0: ; %entry
2380 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
2381 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2382 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
2383 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
2384 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
2385 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2386 ; GFX11-CU-NEXT: s_endpgm
2387 ptr %out, i32 %in, i32 %old) {
2389 %gep = getelementptr i32, ptr %out, i32 4
2390 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup") acquire monotonic
2394 define amdgpu_kernel void @flat_workgroup_release_monotonic_cmpxchg(
2395 ; GFX7-LABEL: flat_workgroup_release_monotonic_cmpxchg:
2396 ; GFX7: ; %bb.0: ; %entry
2397 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2398 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2399 ; GFX7-NEXT: s_add_u32 s0, s0, 16
2400 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
2401 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
2402 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
2403 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
2404 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
2405 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2406 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2407 ; GFX7-NEXT: s_endpgm
2409 ; GFX10-WGP-LABEL: flat_workgroup_release_monotonic_cmpxchg:
2410 ; GFX10-WGP: ; %bb.0: ; %entry
2411 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2412 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2413 ; GFX10-WGP-NEXT: s_add_u32 s0, s0, 16
2414 ; GFX10-WGP-NEXT: s_addc_u32 s1, s1, 0
2415 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
2416 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
2417 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
2418 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
2419 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2420 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2421 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2422 ; GFX10-WGP-NEXT: s_endpgm
2424 ; GFX10-CU-LABEL: flat_workgroup_release_monotonic_cmpxchg:
2425 ; GFX10-CU: ; %bb.0: ; %entry
2426 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2427 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2428 ; GFX10-CU-NEXT: s_add_u32 s0, s0, 16
2429 ; GFX10-CU-NEXT: s_addc_u32 s1, s1, 0
2430 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
2431 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
2432 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
2433 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
2434 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2435 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2436 ; GFX10-CU-NEXT: s_endpgm
2438 ; SKIP-CACHE-INV-LABEL: flat_workgroup_release_monotonic_cmpxchg:
2439 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2440 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2441 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2442 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, 16
2443 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s1, s1, 0
2444 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
2445 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
2446 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
2447 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
2448 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2449 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2450 ; SKIP-CACHE-INV-NEXT: s_endpgm
2452 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_release_monotonic_cmpxchg:
2453 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2454 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2455 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2456 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
2457 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
2458 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2459 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2460 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2462 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_release_monotonic_cmpxchg:
2463 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2464 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2465 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2466 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
2467 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
2468 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2469 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2470 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2472 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_release_monotonic_cmpxchg:
2473 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
2474 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2475 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2476 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
2477 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
2478 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2479 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2480 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
2482 ; GFX940-TGSPLIT-LABEL: flat_workgroup_release_monotonic_cmpxchg:
2483 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
2484 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2485 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2486 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
2487 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
2488 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2489 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2490 ; GFX940-TGSPLIT-NEXT: s_endpgm
2492 ; GFX11-WGP-LABEL: flat_workgroup_release_monotonic_cmpxchg:
2493 ; GFX11-WGP: ; %bb.0: ; %entry
2494 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
2495 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
2496 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
2497 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
2498 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2499 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2500 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
2501 ; GFX11-WGP-NEXT: s_endpgm
2503 ; GFX11-CU-LABEL: flat_workgroup_release_monotonic_cmpxchg:
2504 ; GFX11-CU: ; %bb.0: ; %entry
2505 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
2506 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2507 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
2508 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
2509 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2510 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
2511 ; GFX11-CU-NEXT: s_endpgm
2512 ptr %out, i32 %in, i32 %old) {
2514 %gep = getelementptr i32, ptr %out, i32 4
2515 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup") release monotonic
2519 define amdgpu_kernel void @flat_workgroup_acq_rel_monotonic_cmpxchg(
2520 ; GFX7-LABEL: flat_workgroup_acq_rel_monotonic_cmpxchg:
2521 ; GFX7: ; %bb.0: ; %entry
2522 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2523 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2524 ; GFX7-NEXT: s_add_u32 s0, s0, 16
2525 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
2526 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
2527 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
2528 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
2529 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
2530 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2531 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2532 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2533 ; GFX7-NEXT: s_endpgm
2535 ; GFX10-WGP-LABEL: flat_workgroup_acq_rel_monotonic_cmpxchg:
2536 ; GFX10-WGP: ; %bb.0: ; %entry
2537 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2538 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2539 ; GFX10-WGP-NEXT: s_add_u32 s0, s0, 16
2540 ; GFX10-WGP-NEXT: s_addc_u32 s1, s1, 0
2541 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
2542 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
2543 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
2544 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
2545 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2546 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2547 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2548 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2549 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2550 ; GFX10-WGP-NEXT: buffer_gl0_inv
2551 ; GFX10-WGP-NEXT: s_endpgm
2553 ; GFX10-CU-LABEL: flat_workgroup_acq_rel_monotonic_cmpxchg:
2554 ; GFX10-CU: ; %bb.0: ; %entry
2555 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2556 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2557 ; GFX10-CU-NEXT: s_add_u32 s0, s0, 16
2558 ; GFX10-CU-NEXT: s_addc_u32 s1, s1, 0
2559 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
2560 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
2561 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
2562 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
2563 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2564 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2565 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2566 ; GFX10-CU-NEXT: s_endpgm
2568 ; SKIP-CACHE-INV-LABEL: flat_workgroup_acq_rel_monotonic_cmpxchg:
2569 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2570 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2571 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2572 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, 16
2573 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s1, s1, 0
2574 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
2575 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
2576 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
2577 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
2578 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2579 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2580 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2581 ; SKIP-CACHE-INV-NEXT: s_endpgm
2583 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_acq_rel_monotonic_cmpxchg:
2584 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2585 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2586 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2587 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
2588 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
2589 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2590 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2591 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2592 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2594 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_acq_rel_monotonic_cmpxchg:
2595 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2596 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2597 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2598 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
2599 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
2600 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2601 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2602 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2603 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
2604 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2606 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_acq_rel_monotonic_cmpxchg:
2607 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
2608 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2609 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2610 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
2611 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
2612 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2613 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2614 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2615 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
2617 ; GFX940-TGSPLIT-LABEL: flat_workgroup_acq_rel_monotonic_cmpxchg:
2618 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
2619 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2620 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2621 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
2622 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
2623 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2624 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2625 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2626 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
2627 ; GFX940-TGSPLIT-NEXT: s_endpgm
2629 ; GFX11-WGP-LABEL: flat_workgroup_acq_rel_monotonic_cmpxchg:
2630 ; GFX11-WGP: ; %bb.0: ; %entry
2631 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
2632 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
2633 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
2634 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
2635 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2636 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2637 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
2638 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
2639 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2640 ; GFX11-WGP-NEXT: buffer_gl0_inv
2641 ; GFX11-WGP-NEXT: s_endpgm
2643 ; GFX11-CU-LABEL: flat_workgroup_acq_rel_monotonic_cmpxchg:
2644 ; GFX11-CU: ; %bb.0: ; %entry
2645 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
2646 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2647 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
2648 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
2649 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2650 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
2651 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2652 ; GFX11-CU-NEXT: s_endpgm
2653 ptr %out, i32 %in, i32 %old) {
2655 %gep = getelementptr i32, ptr %out, i32 4
2656 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup") acq_rel monotonic
2660 define amdgpu_kernel void @flat_workgroup_seq_cst_monotonic_cmpxchg(
2661 ; GFX7-LABEL: flat_workgroup_seq_cst_monotonic_cmpxchg:
2662 ; GFX7: ; %bb.0: ; %entry
2663 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2664 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2665 ; GFX7-NEXT: s_add_u32 s0, s0, 16
2666 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
2667 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
2668 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
2669 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
2670 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
2671 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2672 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2673 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2674 ; GFX7-NEXT: s_endpgm
2676 ; GFX10-WGP-LABEL: flat_workgroup_seq_cst_monotonic_cmpxchg:
2677 ; GFX10-WGP: ; %bb.0: ; %entry
2678 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2679 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2680 ; GFX10-WGP-NEXT: s_add_u32 s0, s0, 16
2681 ; GFX10-WGP-NEXT: s_addc_u32 s1, s1, 0
2682 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
2683 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
2684 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
2685 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
2686 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2687 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2688 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2689 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2690 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2691 ; GFX10-WGP-NEXT: buffer_gl0_inv
2692 ; GFX10-WGP-NEXT: s_endpgm
2694 ; GFX10-CU-LABEL: flat_workgroup_seq_cst_monotonic_cmpxchg:
2695 ; GFX10-CU: ; %bb.0: ; %entry
2696 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2697 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2698 ; GFX10-CU-NEXT: s_add_u32 s0, s0, 16
2699 ; GFX10-CU-NEXT: s_addc_u32 s1, s1, 0
2700 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
2701 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
2702 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
2703 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
2704 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2705 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2706 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2707 ; GFX10-CU-NEXT: s_endpgm
2709 ; SKIP-CACHE-INV-LABEL: flat_workgroup_seq_cst_monotonic_cmpxchg:
2710 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2711 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2712 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2713 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, 16
2714 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s1, s1, 0
2715 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
2716 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
2717 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
2718 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
2719 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2720 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2721 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2722 ; SKIP-CACHE-INV-NEXT: s_endpgm
2724 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_seq_cst_monotonic_cmpxchg:
2725 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2726 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2727 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2728 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
2729 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
2730 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2731 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2732 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2733 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2735 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_seq_cst_monotonic_cmpxchg:
2736 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2737 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2738 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2739 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
2740 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
2741 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2742 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2743 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2744 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
2745 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2747 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_seq_cst_monotonic_cmpxchg:
2748 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
2749 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2750 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2751 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
2752 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
2753 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2754 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2755 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2756 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
2758 ; GFX940-TGSPLIT-LABEL: flat_workgroup_seq_cst_monotonic_cmpxchg:
2759 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
2760 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2761 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2762 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
2763 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
2764 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2765 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2766 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2767 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
2768 ; GFX940-TGSPLIT-NEXT: s_endpgm
2770 ; GFX11-WGP-LABEL: flat_workgroup_seq_cst_monotonic_cmpxchg:
2771 ; GFX11-WGP: ; %bb.0: ; %entry
2772 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
2773 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
2774 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
2775 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
2776 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2777 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2778 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
2779 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
2780 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2781 ; GFX11-WGP-NEXT: buffer_gl0_inv
2782 ; GFX11-WGP-NEXT: s_endpgm
2784 ; GFX11-CU-LABEL: flat_workgroup_seq_cst_monotonic_cmpxchg:
2785 ; GFX11-CU: ; %bb.0: ; %entry
2786 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
2787 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2788 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
2789 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
2790 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2791 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
2792 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2793 ; GFX11-CU-NEXT: s_endpgm
2794 ptr %out, i32 %in, i32 %old) {
2796 %gep = getelementptr i32, ptr %out, i32 4
2797 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup") seq_cst monotonic
2801 define amdgpu_kernel void @flat_workgroup_monotonic_acquire_cmpxchg(
2802 ; GFX7-LABEL: flat_workgroup_monotonic_acquire_cmpxchg:
2803 ; GFX7: ; %bb.0: ; %entry
2804 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2805 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2806 ; GFX7-NEXT: s_add_u32 s0, s0, 16
2807 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
2808 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
2809 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
2810 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
2811 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
2812 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2813 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2814 ; GFX7-NEXT: s_endpgm
2816 ; GFX10-WGP-LABEL: flat_workgroup_monotonic_acquire_cmpxchg:
2817 ; GFX10-WGP: ; %bb.0: ; %entry
2818 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2819 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2820 ; GFX10-WGP-NEXT: s_add_u32 s0, s0, 16
2821 ; GFX10-WGP-NEXT: s_addc_u32 s1, s1, 0
2822 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
2823 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
2824 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
2825 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
2826 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2827 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2828 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2829 ; GFX10-WGP-NEXT: buffer_gl0_inv
2830 ; GFX10-WGP-NEXT: s_endpgm
2832 ; GFX10-CU-LABEL: flat_workgroup_monotonic_acquire_cmpxchg:
2833 ; GFX10-CU: ; %bb.0: ; %entry
2834 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2835 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2836 ; GFX10-CU-NEXT: s_add_u32 s0, s0, 16
2837 ; GFX10-CU-NEXT: s_addc_u32 s1, s1, 0
2838 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
2839 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
2840 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
2841 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
2842 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2843 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2844 ; GFX10-CU-NEXT: s_endpgm
2846 ; SKIP-CACHE-INV-LABEL: flat_workgroup_monotonic_acquire_cmpxchg:
2847 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2848 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2849 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2850 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, 16
2851 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s1, s1, 0
2852 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
2853 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
2854 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
2855 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
2856 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2857 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2858 ; SKIP-CACHE-INV-NEXT: s_endpgm
2860 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_monotonic_acquire_cmpxchg:
2861 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2862 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2863 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2864 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
2865 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
2866 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2867 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2868 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2870 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_monotonic_acquire_cmpxchg:
2871 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2872 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2873 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2874 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
2875 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
2876 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2877 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2878 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
2879 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2881 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_monotonic_acquire_cmpxchg:
2882 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
2883 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2884 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2885 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
2886 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
2887 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2888 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2889 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
2891 ; GFX940-TGSPLIT-LABEL: flat_workgroup_monotonic_acquire_cmpxchg:
2892 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
2893 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2894 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2895 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
2896 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
2897 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2898 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2899 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
2900 ; GFX940-TGSPLIT-NEXT: s_endpgm
2902 ; GFX11-WGP-LABEL: flat_workgroup_monotonic_acquire_cmpxchg:
2903 ; GFX11-WGP: ; %bb.0: ; %entry
2904 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
2905 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
2906 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
2907 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
2908 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
2909 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
2910 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2911 ; GFX11-WGP-NEXT: buffer_gl0_inv
2912 ; GFX11-WGP-NEXT: s_endpgm
2914 ; GFX11-CU-LABEL: flat_workgroup_monotonic_acquire_cmpxchg:
2915 ; GFX11-CU: ; %bb.0: ; %entry
2916 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
2917 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2918 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
2919 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
2920 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
2921 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2922 ; GFX11-CU-NEXT: s_endpgm
2923 ptr %out, i32 %in, i32 %old) {
2925 %gep = getelementptr i32, ptr %out, i32 4
2926 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup") monotonic acquire
2930 define amdgpu_kernel void @flat_workgroup_acquire_acquire_cmpxchg(
2931 ; GFX7-LABEL: flat_workgroup_acquire_acquire_cmpxchg:
2932 ; GFX7: ; %bb.0: ; %entry
2933 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2934 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2935 ; GFX7-NEXT: s_add_u32 s0, s0, 16
2936 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
2937 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
2938 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
2939 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
2940 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
2941 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2942 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2943 ; GFX7-NEXT: s_endpgm
2945 ; GFX10-WGP-LABEL: flat_workgroup_acquire_acquire_cmpxchg:
2946 ; GFX10-WGP: ; %bb.0: ; %entry
2947 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2948 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2949 ; GFX10-WGP-NEXT: s_add_u32 s0, s0, 16
2950 ; GFX10-WGP-NEXT: s_addc_u32 s1, s1, 0
2951 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
2952 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
2953 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
2954 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
2955 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2956 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2957 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2958 ; GFX10-WGP-NEXT: buffer_gl0_inv
2959 ; GFX10-WGP-NEXT: s_endpgm
2961 ; GFX10-CU-LABEL: flat_workgroup_acquire_acquire_cmpxchg:
2962 ; GFX10-CU: ; %bb.0: ; %entry
2963 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2964 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2965 ; GFX10-CU-NEXT: s_add_u32 s0, s0, 16
2966 ; GFX10-CU-NEXT: s_addc_u32 s1, s1, 0
2967 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
2968 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
2969 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
2970 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
2971 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2972 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2973 ; GFX10-CU-NEXT: s_endpgm
2975 ; SKIP-CACHE-INV-LABEL: flat_workgroup_acquire_acquire_cmpxchg:
2976 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2977 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
2978 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2979 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, 16
2980 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s1, s1, 0
2981 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
2982 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
2983 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
2984 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
2985 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2986 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2987 ; SKIP-CACHE-INV-NEXT: s_endpgm
2989 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_acquire_acquire_cmpxchg:
2990 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2991 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
2992 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2993 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
2994 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
2995 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2996 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2997 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2999 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_acquire_acquire_cmpxchg:
3000 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3001 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3002 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3003 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
3004 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
3005 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3006 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3007 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
3008 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3010 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_acquire_acquire_cmpxchg:
3011 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
3012 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3013 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3014 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
3015 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
3016 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3017 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3018 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
3020 ; GFX940-TGSPLIT-LABEL: flat_workgroup_acquire_acquire_cmpxchg:
3021 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
3022 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3023 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3024 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
3025 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
3026 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3027 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3028 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
3029 ; GFX940-TGSPLIT-NEXT: s_endpgm
3031 ; GFX11-WGP-LABEL: flat_workgroup_acquire_acquire_cmpxchg:
3032 ; GFX11-WGP: ; %bb.0: ; %entry
3033 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
3034 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3035 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
3036 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
3037 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3038 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3039 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3040 ; GFX11-WGP-NEXT: buffer_gl0_inv
3041 ; GFX11-WGP-NEXT: s_endpgm
3043 ; GFX11-CU-LABEL: flat_workgroup_acquire_acquire_cmpxchg:
3044 ; GFX11-CU: ; %bb.0: ; %entry
3045 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
3046 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3047 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
3048 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
3049 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3050 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3051 ; GFX11-CU-NEXT: s_endpgm
3052 ptr %out, i32 %in, i32 %old) {
3054 %gep = getelementptr i32, ptr %out, i32 4
3055 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup") acquire acquire
3059 define amdgpu_kernel void @flat_workgroup_release_acquire_cmpxchg(
3060 ; GFX7-LABEL: flat_workgroup_release_acquire_cmpxchg:
3061 ; GFX7: ; %bb.0: ; %entry
3062 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3063 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3064 ; GFX7-NEXT: s_add_u32 s0, s0, 16
3065 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
3066 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
3067 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
3068 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
3069 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
3070 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3071 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3072 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3073 ; GFX7-NEXT: s_endpgm
3075 ; GFX10-WGP-LABEL: flat_workgroup_release_acquire_cmpxchg:
3076 ; GFX10-WGP: ; %bb.0: ; %entry
3077 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3078 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3079 ; GFX10-WGP-NEXT: s_add_u32 s0, s0, 16
3080 ; GFX10-WGP-NEXT: s_addc_u32 s1, s1, 0
3081 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
3082 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
3083 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
3084 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
3085 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3086 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3087 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3088 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3089 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3090 ; GFX10-WGP-NEXT: buffer_gl0_inv
3091 ; GFX10-WGP-NEXT: s_endpgm
3093 ; GFX10-CU-LABEL: flat_workgroup_release_acquire_cmpxchg:
3094 ; GFX10-CU: ; %bb.0: ; %entry
3095 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3096 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3097 ; GFX10-CU-NEXT: s_add_u32 s0, s0, 16
3098 ; GFX10-CU-NEXT: s_addc_u32 s1, s1, 0
3099 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
3100 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
3101 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
3102 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
3103 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3104 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3105 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3106 ; GFX10-CU-NEXT: s_endpgm
3108 ; SKIP-CACHE-INV-LABEL: flat_workgroup_release_acquire_cmpxchg:
3109 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3110 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3111 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3112 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, 16
3113 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s1, s1, 0
3114 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
3115 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
3116 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
3117 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
3118 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3119 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3120 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3121 ; SKIP-CACHE-INV-NEXT: s_endpgm
3123 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_release_acquire_cmpxchg:
3124 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3125 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3126 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3127 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
3128 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
3129 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3130 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3131 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3132 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3134 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_release_acquire_cmpxchg:
3135 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3136 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3137 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3138 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
3139 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
3140 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3141 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3142 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3143 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
3144 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3146 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_release_acquire_cmpxchg:
3147 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
3148 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3149 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3150 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
3151 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
3152 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3153 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3154 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3155 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
3157 ; GFX940-TGSPLIT-LABEL: flat_workgroup_release_acquire_cmpxchg:
3158 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
3159 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3160 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3161 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
3162 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
3163 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3164 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3165 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3166 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
3167 ; GFX940-TGSPLIT-NEXT: s_endpgm
3169 ; GFX11-WGP-LABEL: flat_workgroup_release_acquire_cmpxchg:
3170 ; GFX11-WGP: ; %bb.0: ; %entry
3171 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
3172 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3173 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
3174 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
3175 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3176 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3177 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3178 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3179 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3180 ; GFX11-WGP-NEXT: buffer_gl0_inv
3181 ; GFX11-WGP-NEXT: s_endpgm
3183 ; GFX11-CU-LABEL: flat_workgroup_release_acquire_cmpxchg:
3184 ; GFX11-CU: ; %bb.0: ; %entry
3185 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
3186 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3187 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
3188 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
3189 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3190 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3191 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3192 ; GFX11-CU-NEXT: s_endpgm
3193 ptr %out, i32 %in, i32 %old) {
3195 %gep = getelementptr i32, ptr %out, i32 4
3196 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup") release acquire
3200 define amdgpu_kernel void @flat_workgroup_acq_rel_acquire_cmpxchg(
3201 ; GFX7-LABEL: flat_workgroup_acq_rel_acquire_cmpxchg:
3202 ; GFX7: ; %bb.0: ; %entry
3203 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3204 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3205 ; GFX7-NEXT: s_add_u32 s0, s0, 16
3206 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
3207 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
3208 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
3209 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
3210 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
3211 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3212 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3213 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3214 ; GFX7-NEXT: s_endpgm
3216 ; GFX10-WGP-LABEL: flat_workgroup_acq_rel_acquire_cmpxchg:
3217 ; GFX10-WGP: ; %bb.0: ; %entry
3218 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3219 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3220 ; GFX10-WGP-NEXT: s_add_u32 s0, s0, 16
3221 ; GFX10-WGP-NEXT: s_addc_u32 s1, s1, 0
3222 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
3223 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
3224 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
3225 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
3226 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3227 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3228 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3229 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3230 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3231 ; GFX10-WGP-NEXT: buffer_gl0_inv
3232 ; GFX10-WGP-NEXT: s_endpgm
3234 ; GFX10-CU-LABEL: flat_workgroup_acq_rel_acquire_cmpxchg:
3235 ; GFX10-CU: ; %bb.0: ; %entry
3236 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3237 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3238 ; GFX10-CU-NEXT: s_add_u32 s0, s0, 16
3239 ; GFX10-CU-NEXT: s_addc_u32 s1, s1, 0
3240 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
3241 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
3242 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
3243 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
3244 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3245 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3246 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3247 ; GFX10-CU-NEXT: s_endpgm
3249 ; SKIP-CACHE-INV-LABEL: flat_workgroup_acq_rel_acquire_cmpxchg:
3250 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3251 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3252 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3253 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, 16
3254 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s1, s1, 0
3255 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
3256 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
3257 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
3258 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
3259 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3260 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3261 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3262 ; SKIP-CACHE-INV-NEXT: s_endpgm
3264 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_acq_rel_acquire_cmpxchg:
3265 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3266 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3267 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3268 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
3269 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
3270 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3271 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3272 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3273 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3275 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_acq_rel_acquire_cmpxchg:
3276 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3277 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3278 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3279 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
3280 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
3281 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3282 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3283 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3284 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
3285 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3287 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_acq_rel_acquire_cmpxchg:
3288 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
3289 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3290 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3291 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
3292 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
3293 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3294 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3295 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3296 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
3298 ; GFX940-TGSPLIT-LABEL: flat_workgroup_acq_rel_acquire_cmpxchg:
3299 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
3300 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3301 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3302 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
3303 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
3304 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3305 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3306 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3307 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
3308 ; GFX940-TGSPLIT-NEXT: s_endpgm
3310 ; GFX11-WGP-LABEL: flat_workgroup_acq_rel_acquire_cmpxchg:
3311 ; GFX11-WGP: ; %bb.0: ; %entry
3312 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
3313 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3314 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
3315 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
3316 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3317 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3318 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3319 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3320 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3321 ; GFX11-WGP-NEXT: buffer_gl0_inv
3322 ; GFX11-WGP-NEXT: s_endpgm
3324 ; GFX11-CU-LABEL: flat_workgroup_acq_rel_acquire_cmpxchg:
3325 ; GFX11-CU: ; %bb.0: ; %entry
3326 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
3327 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3328 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
3329 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
3330 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3331 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3332 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3333 ; GFX11-CU-NEXT: s_endpgm
3334 ptr %out, i32 %in, i32 %old) {
3336 %gep = getelementptr i32, ptr %out, i32 4
3337 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup") acq_rel acquire
3341 define amdgpu_kernel void @flat_workgroup_seq_cst_acquire_cmpxchg(
3342 ; GFX7-LABEL: flat_workgroup_seq_cst_acquire_cmpxchg:
3343 ; GFX7: ; %bb.0: ; %entry
3344 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3345 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3346 ; GFX7-NEXT: s_add_u32 s0, s0, 16
3347 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
3348 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
3349 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
3350 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
3351 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
3352 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3353 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3354 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3355 ; GFX7-NEXT: s_endpgm
3357 ; GFX10-WGP-LABEL: flat_workgroup_seq_cst_acquire_cmpxchg:
3358 ; GFX10-WGP: ; %bb.0: ; %entry
3359 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3360 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3361 ; GFX10-WGP-NEXT: s_add_u32 s0, s0, 16
3362 ; GFX10-WGP-NEXT: s_addc_u32 s1, s1, 0
3363 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
3364 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
3365 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
3366 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
3367 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3368 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3369 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3370 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3371 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3372 ; GFX10-WGP-NEXT: buffer_gl0_inv
3373 ; GFX10-WGP-NEXT: s_endpgm
3375 ; GFX10-CU-LABEL: flat_workgroup_seq_cst_acquire_cmpxchg:
3376 ; GFX10-CU: ; %bb.0: ; %entry
3377 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3378 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3379 ; GFX10-CU-NEXT: s_add_u32 s0, s0, 16
3380 ; GFX10-CU-NEXT: s_addc_u32 s1, s1, 0
3381 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
3382 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
3383 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
3384 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
3385 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3386 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3387 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3388 ; GFX10-CU-NEXT: s_endpgm
3390 ; SKIP-CACHE-INV-LABEL: flat_workgroup_seq_cst_acquire_cmpxchg:
3391 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3392 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3393 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3394 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, 16
3395 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s1, s1, 0
3396 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
3397 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
3398 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
3399 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
3400 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3401 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3402 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3403 ; SKIP-CACHE-INV-NEXT: s_endpgm
3405 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_seq_cst_acquire_cmpxchg:
3406 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3407 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3408 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3409 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
3410 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
3411 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3412 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3413 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3414 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3416 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_seq_cst_acquire_cmpxchg:
3417 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3418 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3419 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3420 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
3421 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
3422 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3423 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3424 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3425 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
3426 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3428 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_seq_cst_acquire_cmpxchg:
3429 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
3430 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3431 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3432 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
3433 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
3434 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3435 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3436 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3437 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
3439 ; GFX940-TGSPLIT-LABEL: flat_workgroup_seq_cst_acquire_cmpxchg:
3440 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
3441 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3442 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3443 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
3444 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
3445 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3446 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3447 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3448 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
3449 ; GFX940-TGSPLIT-NEXT: s_endpgm
3451 ; GFX11-WGP-LABEL: flat_workgroup_seq_cst_acquire_cmpxchg:
3452 ; GFX11-WGP: ; %bb.0: ; %entry
3453 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
3454 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3455 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
3456 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
3457 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3458 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3459 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3460 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3461 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3462 ; GFX11-WGP-NEXT: buffer_gl0_inv
3463 ; GFX11-WGP-NEXT: s_endpgm
3465 ; GFX11-CU-LABEL: flat_workgroup_seq_cst_acquire_cmpxchg:
3466 ; GFX11-CU: ; %bb.0: ; %entry
3467 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
3468 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3469 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
3470 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
3471 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3472 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3473 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3474 ; GFX11-CU-NEXT: s_endpgm
3475 ptr %out, i32 %in, i32 %old) {
3477 %gep = getelementptr i32, ptr %out, i32 4
3478 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup") seq_cst acquire
3482 define amdgpu_kernel void @flat_workgroup_seq_cst_seq_cst_cmpxchg(
3483 ; GFX7-LABEL: flat_workgroup_seq_cst_seq_cst_cmpxchg:
3484 ; GFX7: ; %bb.0: ; %entry
3485 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3486 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3487 ; GFX7-NEXT: s_add_u32 s0, s0, 16
3488 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
3489 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
3490 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
3491 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
3492 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
3493 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3494 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3495 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3496 ; GFX7-NEXT: s_endpgm
3498 ; GFX10-WGP-LABEL: flat_workgroup_seq_cst_seq_cst_cmpxchg:
3499 ; GFX10-WGP: ; %bb.0: ; %entry
3500 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3501 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3502 ; GFX10-WGP-NEXT: s_add_u32 s0, s0, 16
3503 ; GFX10-WGP-NEXT: s_addc_u32 s1, s1, 0
3504 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
3505 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
3506 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
3507 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
3508 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3509 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3510 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3511 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3512 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3513 ; GFX10-WGP-NEXT: buffer_gl0_inv
3514 ; GFX10-WGP-NEXT: s_endpgm
3516 ; GFX10-CU-LABEL: flat_workgroup_seq_cst_seq_cst_cmpxchg:
3517 ; GFX10-CU: ; %bb.0: ; %entry
3518 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3519 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3520 ; GFX10-CU-NEXT: s_add_u32 s0, s0, 16
3521 ; GFX10-CU-NEXT: s_addc_u32 s1, s1, 0
3522 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
3523 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
3524 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
3525 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
3526 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3527 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3528 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3529 ; GFX10-CU-NEXT: s_endpgm
3531 ; SKIP-CACHE-INV-LABEL: flat_workgroup_seq_cst_seq_cst_cmpxchg:
3532 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3533 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3534 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3535 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, 16
3536 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s1, s1, 0
3537 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
3538 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
3539 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
3540 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
3541 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3542 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3543 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3544 ; SKIP-CACHE-INV-NEXT: s_endpgm
3546 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_seq_cst_seq_cst_cmpxchg:
3547 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3548 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3549 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3550 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
3551 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
3552 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3553 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3554 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3555 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3557 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_seq_cst_seq_cst_cmpxchg:
3558 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3559 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3560 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3561 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
3562 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
3563 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3564 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3565 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3566 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
3567 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3569 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_seq_cst_seq_cst_cmpxchg:
3570 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
3571 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3572 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3573 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
3574 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
3575 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3576 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3577 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3578 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
3580 ; GFX940-TGSPLIT-LABEL: flat_workgroup_seq_cst_seq_cst_cmpxchg:
3581 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
3582 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3583 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3584 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
3585 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
3586 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3587 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3588 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3589 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
3590 ; GFX940-TGSPLIT-NEXT: s_endpgm
3592 ; GFX11-WGP-LABEL: flat_workgroup_seq_cst_seq_cst_cmpxchg:
3593 ; GFX11-WGP: ; %bb.0: ; %entry
3594 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
3595 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3596 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
3597 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
3598 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3599 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3600 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3601 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3602 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3603 ; GFX11-WGP-NEXT: buffer_gl0_inv
3604 ; GFX11-WGP-NEXT: s_endpgm
3606 ; GFX11-CU-LABEL: flat_workgroup_seq_cst_seq_cst_cmpxchg:
3607 ; GFX11-CU: ; %bb.0: ; %entry
3608 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
3609 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3610 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
3611 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
3612 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3613 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3614 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3615 ; GFX11-CU-NEXT: s_endpgm
3616 ptr %out, i32 %in, i32 %old) {
3618 %gep = getelementptr i32, ptr %out, i32 4
3619 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup") seq_cst seq_cst
3623 define amdgpu_kernel void @flat_workgroup_monotonic_monotonic_ret_cmpxchg(
3624 ; GFX7-LABEL: flat_workgroup_monotonic_monotonic_ret_cmpxchg:
3625 ; GFX7: ; %bb.0: ; %entry
3626 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3627 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3628 ; GFX7-NEXT: s_add_u32 s4, s0, 16
3629 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
3630 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
3631 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
3632 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
3633 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
3634 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
3635 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
3636 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
3637 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3638 ; GFX7-NEXT: flat_store_dword v[0:1], v2
3639 ; GFX7-NEXT: s_endpgm
3641 ; GFX10-WGP-LABEL: flat_workgroup_monotonic_monotonic_ret_cmpxchg:
3642 ; GFX10-WGP: ; %bb.0: ; %entry
3643 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3644 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3645 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
3646 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
3647 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
3648 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
3649 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
3650 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
3651 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
3652 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
3653 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
3654 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3655 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
3656 ; GFX10-WGP-NEXT: s_endpgm
3658 ; GFX10-CU-LABEL: flat_workgroup_monotonic_monotonic_ret_cmpxchg:
3659 ; GFX10-CU: ; %bb.0: ; %entry
3660 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3661 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3662 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
3663 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
3664 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
3665 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
3666 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
3667 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
3668 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
3669 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
3670 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
3671 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3672 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
3673 ; GFX10-CU-NEXT: s_endpgm
3675 ; SKIP-CACHE-INV-LABEL: flat_workgroup_monotonic_monotonic_ret_cmpxchg:
3676 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3677 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3678 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3679 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
3680 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
3681 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
3682 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
3683 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
3684 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
3685 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
3686 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
3687 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
3688 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3689 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
3690 ; SKIP-CACHE-INV-NEXT: s_endpgm
3692 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_monotonic_monotonic_ret_cmpxchg:
3693 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3694 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3695 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3696 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
3697 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
3698 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
3699 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3700 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
3701 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3703 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_monotonic_monotonic_ret_cmpxchg:
3704 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3705 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3706 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3707 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
3708 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
3709 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
3710 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3711 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
3712 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3714 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_monotonic_monotonic_ret_cmpxchg:
3715 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
3716 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3717 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3718 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
3719 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
3720 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
3721 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3722 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
3723 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
3725 ; GFX940-TGSPLIT-LABEL: flat_workgroup_monotonic_monotonic_ret_cmpxchg:
3726 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
3727 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3728 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3729 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
3730 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
3731 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
3732 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3733 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
3734 ; GFX940-TGSPLIT-NEXT: s_endpgm
3736 ; GFX11-WGP-LABEL: flat_workgroup_monotonic_monotonic_ret_cmpxchg:
3737 ; GFX11-WGP: ; %bb.0: ; %entry
3738 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
3739 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3740 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
3741 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
3742 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
3743 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3744 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
3745 ; GFX11-WGP-NEXT: s_endpgm
3747 ; GFX11-CU-LABEL: flat_workgroup_monotonic_monotonic_ret_cmpxchg:
3748 ; GFX11-CU: ; %bb.0: ; %entry
3749 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
3750 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3751 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
3752 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
3753 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
3754 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3755 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
3756 ; GFX11-CU-NEXT: s_endpgm
3757 ptr %out, i32 %in, i32 %old) {
3759 %gep = getelementptr i32, ptr %out, i32 4
3760 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup") monotonic monotonic
3761 %val0 = extractvalue { i32, i1 } %val, 0
3762 store i32 %val0, ptr %out, align 4
3766 define amdgpu_kernel void @flat_workgroup_acquire_monotonic_ret_cmpxchg(
3767 ; GFX7-LABEL: flat_workgroup_acquire_monotonic_ret_cmpxchg:
3768 ; GFX7: ; %bb.0: ; %entry
3769 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3770 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3771 ; GFX7-NEXT: s_add_u32 s4, s0, 16
3772 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
3773 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
3774 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
3775 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
3776 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
3777 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
3778 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3779 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
3780 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
3781 ; GFX7-NEXT: s_waitcnt vmcnt(0)
3782 ; GFX7-NEXT: flat_store_dword v[0:1], v2
3783 ; GFX7-NEXT: s_endpgm
3785 ; GFX10-WGP-LABEL: flat_workgroup_acquire_monotonic_ret_cmpxchg:
3786 ; GFX10-WGP: ; %bb.0: ; %entry
3787 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3788 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3789 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
3790 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
3791 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
3792 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
3793 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
3794 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
3795 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
3796 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3797 ; GFX10-WGP-NEXT: buffer_gl0_inv
3798 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
3799 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
3800 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
3801 ; GFX10-WGP-NEXT: s_endpgm
3803 ; GFX10-CU-LABEL: flat_workgroup_acquire_monotonic_ret_cmpxchg:
3804 ; GFX10-CU: ; %bb.0: ; %entry
3805 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3806 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3807 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
3808 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
3809 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
3810 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
3811 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
3812 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
3813 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
3814 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3815 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
3816 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
3817 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
3818 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
3819 ; GFX10-CU-NEXT: s_endpgm
3821 ; SKIP-CACHE-INV-LABEL: flat_workgroup_acquire_monotonic_ret_cmpxchg:
3822 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3823 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3824 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3825 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
3826 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
3827 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
3828 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
3829 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
3830 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
3831 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
3832 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3833 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
3834 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
3835 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
3836 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
3837 ; SKIP-CACHE-INV-NEXT: s_endpgm
3839 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_acquire_monotonic_ret_cmpxchg:
3840 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3841 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3842 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3843 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
3844 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
3845 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
3846 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3847 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
3848 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3850 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_acquire_monotonic_ret_cmpxchg:
3851 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3852 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3853 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3854 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
3855 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
3856 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
3857 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3858 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
3859 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
3860 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3862 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_acquire_monotonic_ret_cmpxchg:
3863 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
3864 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3865 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3866 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
3867 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
3868 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
3869 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3870 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
3871 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
3873 ; GFX940-TGSPLIT-LABEL: flat_workgroup_acquire_monotonic_ret_cmpxchg:
3874 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
3875 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3876 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3877 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
3878 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
3879 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
3880 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3881 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
3882 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
3883 ; GFX940-TGSPLIT-NEXT: s_endpgm
3885 ; GFX11-WGP-LABEL: flat_workgroup_acquire_monotonic_ret_cmpxchg:
3886 ; GFX11-WGP: ; %bb.0: ; %entry
3887 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
3888 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3889 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
3890 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
3891 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
3892 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3893 ; GFX11-WGP-NEXT: buffer_gl0_inv
3894 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
3895 ; GFX11-WGP-NEXT: s_endpgm
3897 ; GFX11-CU-LABEL: flat_workgroup_acquire_monotonic_ret_cmpxchg:
3898 ; GFX11-CU: ; %bb.0: ; %entry
3899 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
3900 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3901 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
3902 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
3903 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
3904 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3905 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
3906 ; GFX11-CU-NEXT: s_endpgm
3907 ptr %out, i32 %in, i32 %old) {
3909 %gep = getelementptr i32, ptr %out, i32 4
3910 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup") acquire monotonic
3911 %val0 = extractvalue { i32, i1 } %val, 0
3912 store i32 %val0, ptr %out, align 4
3916 define amdgpu_kernel void @flat_workgroup_release_monotonic_ret_cmpxchg(
3917 ; GFX7-LABEL: flat_workgroup_release_monotonic_ret_cmpxchg:
3918 ; GFX7: ; %bb.0: ; %entry
3919 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3920 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3921 ; GFX7-NEXT: s_add_u32 s4, s0, 16
3922 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
3923 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
3924 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
3925 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
3926 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
3927 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3928 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
3929 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
3930 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
3931 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3932 ; GFX7-NEXT: flat_store_dword v[0:1], v2
3933 ; GFX7-NEXT: s_endpgm
3935 ; GFX10-WGP-LABEL: flat_workgroup_release_monotonic_ret_cmpxchg:
3936 ; GFX10-WGP: ; %bb.0: ; %entry
3937 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3938 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3939 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
3940 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
3941 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
3942 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
3943 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
3944 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
3945 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3946 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3947 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
3948 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
3949 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
3950 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3951 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
3952 ; GFX10-WGP-NEXT: s_endpgm
3954 ; GFX10-CU-LABEL: flat_workgroup_release_monotonic_ret_cmpxchg:
3955 ; GFX10-CU: ; %bb.0: ; %entry
3956 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3957 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3958 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
3959 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
3960 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
3961 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
3962 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
3963 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
3964 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3965 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
3966 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
3967 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
3968 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3969 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
3970 ; GFX10-CU-NEXT: s_endpgm
3972 ; SKIP-CACHE-INV-LABEL: flat_workgroup_release_monotonic_ret_cmpxchg:
3973 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3974 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
3975 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3976 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
3977 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
3978 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
3979 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
3980 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
3981 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
3982 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3983 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
3984 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
3985 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
3986 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3987 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
3988 ; SKIP-CACHE-INV-NEXT: s_endpgm
3990 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_release_monotonic_ret_cmpxchg:
3991 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3992 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
3993 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3994 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
3995 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
3996 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3997 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
3998 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3999 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
4000 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4002 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_release_monotonic_ret_cmpxchg:
4003 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4004 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4005 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4006 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
4007 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
4008 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4009 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
4010 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4011 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
4012 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4014 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_release_monotonic_ret_cmpxchg:
4015 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
4016 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4017 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4018 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
4019 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
4020 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4021 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
4022 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4023 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
4024 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
4026 ; GFX940-TGSPLIT-LABEL: flat_workgroup_release_monotonic_ret_cmpxchg:
4027 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
4028 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4029 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4030 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
4031 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
4032 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4033 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
4034 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4035 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
4036 ; GFX940-TGSPLIT-NEXT: s_endpgm
4038 ; GFX11-WGP-LABEL: flat_workgroup_release_monotonic_ret_cmpxchg:
4039 ; GFX11-WGP: ; %bb.0: ; %entry
4040 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
4041 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
4042 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
4043 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
4044 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4045 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4046 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
4047 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4048 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
4049 ; GFX11-WGP-NEXT: s_endpgm
4051 ; GFX11-CU-LABEL: flat_workgroup_release_monotonic_ret_cmpxchg:
4052 ; GFX11-CU: ; %bb.0: ; %entry
4053 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
4054 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4055 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
4056 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
4057 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4058 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
4059 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4060 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
4061 ; GFX11-CU-NEXT: s_endpgm
4062 ptr %out, i32 %in, i32 %old) {
4064 %gep = getelementptr i32, ptr %out, i32 4
4065 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup") release monotonic
4066 %val0 = extractvalue { i32, i1 } %val, 0
4067 store i32 %val0, ptr %out, align 4
4071 define amdgpu_kernel void @flat_workgroup_acq_rel_monotonic_ret_cmpxchg(
4072 ; GFX7-LABEL: flat_workgroup_acq_rel_monotonic_ret_cmpxchg:
4073 ; GFX7: ; %bb.0: ; %entry
4074 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4075 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4076 ; GFX7-NEXT: s_add_u32 s4, s0, 16
4077 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
4078 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
4079 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
4080 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
4081 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
4082 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4083 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4084 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4085 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
4086 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
4087 ; GFX7-NEXT: s_waitcnt vmcnt(0)
4088 ; GFX7-NEXT: flat_store_dword v[0:1], v2
4089 ; GFX7-NEXT: s_endpgm
4091 ; GFX10-WGP-LABEL: flat_workgroup_acq_rel_monotonic_ret_cmpxchg:
4092 ; GFX10-WGP: ; %bb.0: ; %entry
4093 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4094 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4095 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
4096 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
4097 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
4098 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
4099 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
4100 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
4101 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4102 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4103 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4104 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4105 ; GFX10-WGP-NEXT: buffer_gl0_inv
4106 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
4107 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
4108 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
4109 ; GFX10-WGP-NEXT: s_endpgm
4111 ; GFX10-CU-LABEL: flat_workgroup_acq_rel_monotonic_ret_cmpxchg:
4112 ; GFX10-CU: ; %bb.0: ; %entry
4113 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4114 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4115 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
4116 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
4117 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
4118 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
4119 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
4120 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
4121 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4122 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4123 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4124 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
4125 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
4126 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
4127 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
4128 ; GFX10-CU-NEXT: s_endpgm
4130 ; SKIP-CACHE-INV-LABEL: flat_workgroup_acq_rel_monotonic_ret_cmpxchg:
4131 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4132 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4133 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4134 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
4135 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
4136 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
4137 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
4138 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
4139 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
4140 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4141 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4142 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4143 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
4144 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
4145 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
4146 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
4147 ; SKIP-CACHE-INV-NEXT: s_endpgm
4149 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_acq_rel_monotonic_ret_cmpxchg:
4150 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4151 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4152 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4153 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
4154 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
4155 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4156 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
4157 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4158 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
4159 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4161 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_acq_rel_monotonic_ret_cmpxchg:
4162 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4163 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4164 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4165 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
4166 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
4167 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4168 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
4169 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4170 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
4171 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
4172 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4174 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_acq_rel_monotonic_ret_cmpxchg:
4175 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
4176 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4177 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4178 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
4179 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
4180 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4181 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
4182 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4183 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
4184 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
4186 ; GFX940-TGSPLIT-LABEL: flat_workgroup_acq_rel_monotonic_ret_cmpxchg:
4187 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
4188 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4189 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4190 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
4191 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
4192 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4193 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
4194 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4195 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
4196 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
4197 ; GFX940-TGSPLIT-NEXT: s_endpgm
4199 ; GFX11-WGP-LABEL: flat_workgroup_acq_rel_monotonic_ret_cmpxchg:
4200 ; GFX11-WGP: ; %bb.0: ; %entry
4201 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
4202 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
4203 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
4204 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
4205 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4206 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4207 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
4208 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4209 ; GFX11-WGP-NEXT: buffer_gl0_inv
4210 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
4211 ; GFX11-WGP-NEXT: s_endpgm
4213 ; GFX11-CU-LABEL: flat_workgroup_acq_rel_monotonic_ret_cmpxchg:
4214 ; GFX11-CU: ; %bb.0: ; %entry
4215 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
4216 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4217 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
4218 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
4219 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4220 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
4221 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4222 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
4223 ; GFX11-CU-NEXT: s_endpgm
4224 ptr %out, i32 %in, i32 %old) {
4226 %gep = getelementptr i32, ptr %out, i32 4
4227 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup") acq_rel monotonic
4228 %val0 = extractvalue { i32, i1 } %val, 0
4229 store i32 %val0, ptr %out, align 4
4233 define amdgpu_kernel void @flat_workgroup_seq_cst_monotonic_ret_cmpxchg(
4234 ; GFX7-LABEL: flat_workgroup_seq_cst_monotonic_ret_cmpxchg:
4235 ; GFX7: ; %bb.0: ; %entry
4236 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4237 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4238 ; GFX7-NEXT: s_add_u32 s4, s0, 16
4239 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
4240 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
4241 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
4242 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
4243 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
4244 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4245 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4246 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4247 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
4248 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
4249 ; GFX7-NEXT: s_waitcnt vmcnt(0)
4250 ; GFX7-NEXT: flat_store_dword v[0:1], v2
4251 ; GFX7-NEXT: s_endpgm
4253 ; GFX10-WGP-LABEL: flat_workgroup_seq_cst_monotonic_ret_cmpxchg:
4254 ; GFX10-WGP: ; %bb.0: ; %entry
4255 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4256 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4257 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
4258 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
4259 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
4260 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
4261 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
4262 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
4263 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4264 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4265 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4266 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4267 ; GFX10-WGP-NEXT: buffer_gl0_inv
4268 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
4269 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
4270 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
4271 ; GFX10-WGP-NEXT: s_endpgm
4273 ; GFX10-CU-LABEL: flat_workgroup_seq_cst_monotonic_ret_cmpxchg:
4274 ; GFX10-CU: ; %bb.0: ; %entry
4275 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4276 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4277 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
4278 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
4279 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
4280 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
4281 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
4282 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
4283 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4284 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4285 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4286 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
4287 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
4288 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
4289 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
4290 ; GFX10-CU-NEXT: s_endpgm
4292 ; SKIP-CACHE-INV-LABEL: flat_workgroup_seq_cst_monotonic_ret_cmpxchg:
4293 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4294 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4295 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4296 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
4297 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
4298 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
4299 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
4300 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
4301 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
4302 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4303 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4304 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4305 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
4306 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
4307 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
4308 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
4309 ; SKIP-CACHE-INV-NEXT: s_endpgm
4311 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_seq_cst_monotonic_ret_cmpxchg:
4312 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4313 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4314 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4315 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
4316 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
4317 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4318 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
4319 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4320 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
4321 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4323 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_seq_cst_monotonic_ret_cmpxchg:
4324 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4325 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4326 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4327 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
4328 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
4329 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4330 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
4331 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4332 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
4333 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
4334 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4336 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_seq_cst_monotonic_ret_cmpxchg:
4337 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
4338 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4339 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4340 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
4341 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
4342 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4343 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
4344 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4345 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
4346 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
4348 ; GFX940-TGSPLIT-LABEL: flat_workgroup_seq_cst_monotonic_ret_cmpxchg:
4349 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
4350 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4351 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4352 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
4353 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
4354 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4355 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
4356 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4357 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
4358 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
4359 ; GFX940-TGSPLIT-NEXT: s_endpgm
4361 ; GFX11-WGP-LABEL: flat_workgroup_seq_cst_monotonic_ret_cmpxchg:
4362 ; GFX11-WGP: ; %bb.0: ; %entry
4363 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
4364 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
4365 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
4366 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
4367 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4368 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4369 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
4370 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4371 ; GFX11-WGP-NEXT: buffer_gl0_inv
4372 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
4373 ; GFX11-WGP-NEXT: s_endpgm
4375 ; GFX11-CU-LABEL: flat_workgroup_seq_cst_monotonic_ret_cmpxchg:
4376 ; GFX11-CU: ; %bb.0: ; %entry
4377 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
4378 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4379 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
4380 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
4381 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4382 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
4383 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4384 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
4385 ; GFX11-CU-NEXT: s_endpgm
4386 ptr %out, i32 %in, i32 %old) {
4388 %gep = getelementptr i32, ptr %out, i32 4
4389 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup") seq_cst monotonic
4390 %val0 = extractvalue { i32, i1 } %val, 0
4391 store i32 %val0, ptr %out, align 4
4395 define amdgpu_kernel void @flat_workgroup_monotonic_acquire_ret_cmpxchg(
4396 ; GFX7-LABEL: flat_workgroup_monotonic_acquire_ret_cmpxchg:
4397 ; GFX7: ; %bb.0: ; %entry
4398 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4399 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4400 ; GFX7-NEXT: s_add_u32 s4, s0, 16
4401 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
4402 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
4403 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
4404 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
4405 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
4406 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4407 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4408 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
4409 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
4410 ; GFX7-NEXT: s_waitcnt vmcnt(0)
4411 ; GFX7-NEXT: flat_store_dword v[0:1], v2
4412 ; GFX7-NEXT: s_endpgm
4414 ; GFX10-WGP-LABEL: flat_workgroup_monotonic_acquire_ret_cmpxchg:
4415 ; GFX10-WGP: ; %bb.0: ; %entry
4416 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4417 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4418 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
4419 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
4420 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
4421 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
4422 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
4423 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
4424 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4425 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4426 ; GFX10-WGP-NEXT: buffer_gl0_inv
4427 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
4428 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
4429 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
4430 ; GFX10-WGP-NEXT: s_endpgm
4432 ; GFX10-CU-LABEL: flat_workgroup_monotonic_acquire_ret_cmpxchg:
4433 ; GFX10-CU: ; %bb.0: ; %entry
4434 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4435 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4436 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
4437 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
4438 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
4439 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
4440 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
4441 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
4442 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4443 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4444 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
4445 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
4446 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
4447 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
4448 ; GFX10-CU-NEXT: s_endpgm
4450 ; SKIP-CACHE-INV-LABEL: flat_workgroup_monotonic_acquire_ret_cmpxchg:
4451 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4452 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4453 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4454 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
4455 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
4456 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
4457 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
4458 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
4459 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
4460 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4461 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4462 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
4463 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
4464 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
4465 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
4466 ; SKIP-CACHE-INV-NEXT: s_endpgm
4468 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_monotonic_acquire_ret_cmpxchg:
4469 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4470 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4471 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4472 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
4473 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
4474 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
4475 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4476 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
4477 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4479 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_monotonic_acquire_ret_cmpxchg:
4480 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4481 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4482 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4483 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
4484 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
4485 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
4486 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4487 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
4488 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
4489 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4491 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_monotonic_acquire_ret_cmpxchg:
4492 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
4493 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4494 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4495 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
4496 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
4497 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
4498 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4499 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
4500 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
4502 ; GFX940-TGSPLIT-LABEL: flat_workgroup_monotonic_acquire_ret_cmpxchg:
4503 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
4504 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4505 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4506 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
4507 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
4508 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
4509 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4510 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
4511 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
4512 ; GFX940-TGSPLIT-NEXT: s_endpgm
4514 ; GFX11-WGP-LABEL: flat_workgroup_monotonic_acquire_ret_cmpxchg:
4515 ; GFX11-WGP: ; %bb.0: ; %entry
4516 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
4517 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
4518 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
4519 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
4520 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
4521 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4522 ; GFX11-WGP-NEXT: buffer_gl0_inv
4523 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
4524 ; GFX11-WGP-NEXT: s_endpgm
4526 ; GFX11-CU-LABEL: flat_workgroup_monotonic_acquire_ret_cmpxchg:
4527 ; GFX11-CU: ; %bb.0: ; %entry
4528 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
4529 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4530 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
4531 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
4532 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
4533 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4534 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
4535 ; GFX11-CU-NEXT: s_endpgm
4536 ptr %out, i32 %in, i32 %old) {
4538 %gep = getelementptr i32, ptr %out, i32 4
4539 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup") monotonic acquire
4540 %val0 = extractvalue { i32, i1 } %val, 0
4541 store i32 %val0, ptr %out, align 4
4545 define amdgpu_kernel void @flat_workgroup_acquire_acquire_ret_cmpxchg(
4546 ; GFX7-LABEL: flat_workgroup_acquire_acquire_ret_cmpxchg:
4547 ; GFX7: ; %bb.0: ; %entry
4548 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4549 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4550 ; GFX7-NEXT: s_add_u32 s4, s0, 16
4551 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
4552 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
4553 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
4554 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
4555 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
4556 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4557 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4558 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
4559 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
4560 ; GFX7-NEXT: s_waitcnt vmcnt(0)
4561 ; GFX7-NEXT: flat_store_dword v[0:1], v2
4562 ; GFX7-NEXT: s_endpgm
4564 ; GFX10-WGP-LABEL: flat_workgroup_acquire_acquire_ret_cmpxchg:
4565 ; GFX10-WGP: ; %bb.0: ; %entry
4566 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4567 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4568 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
4569 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
4570 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
4571 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
4572 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
4573 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
4574 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4575 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4576 ; GFX10-WGP-NEXT: buffer_gl0_inv
4577 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
4578 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
4579 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
4580 ; GFX10-WGP-NEXT: s_endpgm
4582 ; GFX10-CU-LABEL: flat_workgroup_acquire_acquire_ret_cmpxchg:
4583 ; GFX10-CU: ; %bb.0: ; %entry
4584 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4585 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4586 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
4587 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
4588 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
4589 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
4590 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
4591 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
4592 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4593 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4594 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
4595 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
4596 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
4597 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
4598 ; GFX10-CU-NEXT: s_endpgm
4600 ; SKIP-CACHE-INV-LABEL: flat_workgroup_acquire_acquire_ret_cmpxchg:
4601 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4602 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4603 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4604 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
4605 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
4606 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
4607 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
4608 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
4609 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
4610 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4611 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4612 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
4613 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
4614 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
4615 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
4616 ; SKIP-CACHE-INV-NEXT: s_endpgm
4618 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_acquire_acquire_ret_cmpxchg:
4619 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4620 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4621 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4622 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
4623 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
4624 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
4625 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4626 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
4627 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4629 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_acquire_acquire_ret_cmpxchg:
4630 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4631 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4632 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4633 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
4634 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
4635 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
4636 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4637 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
4638 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
4639 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4641 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_acquire_acquire_ret_cmpxchg:
4642 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
4643 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4644 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4645 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
4646 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
4647 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
4648 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4649 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
4650 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
4652 ; GFX940-TGSPLIT-LABEL: flat_workgroup_acquire_acquire_ret_cmpxchg:
4653 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
4654 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4655 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4656 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
4657 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
4658 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
4659 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4660 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
4661 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
4662 ; GFX940-TGSPLIT-NEXT: s_endpgm
4664 ; GFX11-WGP-LABEL: flat_workgroup_acquire_acquire_ret_cmpxchg:
4665 ; GFX11-WGP: ; %bb.0: ; %entry
4666 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
4667 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
4668 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
4669 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
4670 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
4671 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4672 ; GFX11-WGP-NEXT: buffer_gl0_inv
4673 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
4674 ; GFX11-WGP-NEXT: s_endpgm
4676 ; GFX11-CU-LABEL: flat_workgroup_acquire_acquire_ret_cmpxchg:
4677 ; GFX11-CU: ; %bb.0: ; %entry
4678 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
4679 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4680 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
4681 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
4682 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
4683 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4684 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
4685 ; GFX11-CU-NEXT: s_endpgm
4686 ptr %out, i32 %in, i32 %old) {
4688 %gep = getelementptr i32, ptr %out, i32 4
4689 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup") acquire acquire
4690 %val0 = extractvalue { i32, i1 } %val, 0
4691 store i32 %val0, ptr %out, align 4
4695 define amdgpu_kernel void @flat_workgroup_release_acquire_ret_cmpxchg(
4696 ; GFX7-LABEL: flat_workgroup_release_acquire_ret_cmpxchg:
4697 ; GFX7: ; %bb.0: ; %entry
4698 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4699 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4700 ; GFX7-NEXT: s_add_u32 s4, s0, 16
4701 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
4702 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
4703 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
4704 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
4705 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
4706 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4707 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4708 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4709 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
4710 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
4711 ; GFX7-NEXT: s_waitcnt vmcnt(0)
4712 ; GFX7-NEXT: flat_store_dword v[0:1], v2
4713 ; GFX7-NEXT: s_endpgm
4715 ; GFX10-WGP-LABEL: flat_workgroup_release_acquire_ret_cmpxchg:
4716 ; GFX10-WGP: ; %bb.0: ; %entry
4717 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4718 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4719 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
4720 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
4721 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
4722 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
4723 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
4724 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
4725 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4726 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4727 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4728 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4729 ; GFX10-WGP-NEXT: buffer_gl0_inv
4730 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
4731 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
4732 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
4733 ; GFX10-WGP-NEXT: s_endpgm
4735 ; GFX10-CU-LABEL: flat_workgroup_release_acquire_ret_cmpxchg:
4736 ; GFX10-CU: ; %bb.0: ; %entry
4737 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4738 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4739 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
4740 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
4741 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
4742 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
4743 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
4744 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
4745 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4746 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4747 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4748 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
4749 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
4750 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
4751 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
4752 ; GFX10-CU-NEXT: s_endpgm
4754 ; SKIP-CACHE-INV-LABEL: flat_workgroup_release_acquire_ret_cmpxchg:
4755 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4756 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4757 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4758 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
4759 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
4760 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
4761 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
4762 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
4763 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
4764 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4765 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4766 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4767 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
4768 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
4769 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
4770 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
4771 ; SKIP-CACHE-INV-NEXT: s_endpgm
4773 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_release_acquire_ret_cmpxchg:
4774 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4775 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4776 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4777 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
4778 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
4779 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4780 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
4781 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4782 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
4783 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4785 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_release_acquire_ret_cmpxchg:
4786 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4787 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4788 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4789 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
4790 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
4791 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4792 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
4793 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4794 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
4795 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
4796 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4798 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_release_acquire_ret_cmpxchg:
4799 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
4800 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4801 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4802 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
4803 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
4804 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4805 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
4806 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4807 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
4808 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
4810 ; GFX940-TGSPLIT-LABEL: flat_workgroup_release_acquire_ret_cmpxchg:
4811 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
4812 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4813 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4814 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
4815 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
4816 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4817 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
4818 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4819 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
4820 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
4821 ; GFX940-TGSPLIT-NEXT: s_endpgm
4823 ; GFX11-WGP-LABEL: flat_workgroup_release_acquire_ret_cmpxchg:
4824 ; GFX11-WGP: ; %bb.0: ; %entry
4825 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
4826 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
4827 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
4828 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
4829 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4830 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4831 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
4832 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4833 ; GFX11-WGP-NEXT: buffer_gl0_inv
4834 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
4835 ; GFX11-WGP-NEXT: s_endpgm
4837 ; GFX11-CU-LABEL: flat_workgroup_release_acquire_ret_cmpxchg:
4838 ; GFX11-CU: ; %bb.0: ; %entry
4839 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
4840 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4841 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
4842 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
4843 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4844 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
4845 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4846 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
4847 ; GFX11-CU-NEXT: s_endpgm
4848 ptr %out, i32 %in, i32 %old) {
4850 %gep = getelementptr i32, ptr %out, i32 4
4851 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup") release acquire
4852 %val0 = extractvalue { i32, i1 } %val, 0
4853 store i32 %val0, ptr %out, align 4
4857 define amdgpu_kernel void @flat_workgroup_acq_rel_acquire_ret_cmpxchg(
4858 ; GFX7-LABEL: flat_workgroup_acq_rel_acquire_ret_cmpxchg:
4859 ; GFX7: ; %bb.0: ; %entry
4860 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4861 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4862 ; GFX7-NEXT: s_add_u32 s4, s0, 16
4863 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
4864 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
4865 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
4866 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
4867 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
4868 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4869 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4870 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4871 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
4872 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
4873 ; GFX7-NEXT: s_waitcnt vmcnt(0)
4874 ; GFX7-NEXT: flat_store_dword v[0:1], v2
4875 ; GFX7-NEXT: s_endpgm
4877 ; GFX10-WGP-LABEL: flat_workgroup_acq_rel_acquire_ret_cmpxchg:
4878 ; GFX10-WGP: ; %bb.0: ; %entry
4879 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4880 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4881 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
4882 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
4883 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
4884 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
4885 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
4886 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
4887 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4888 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4889 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4890 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4891 ; GFX10-WGP-NEXT: buffer_gl0_inv
4892 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
4893 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
4894 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
4895 ; GFX10-WGP-NEXT: s_endpgm
4897 ; GFX10-CU-LABEL: flat_workgroup_acq_rel_acquire_ret_cmpxchg:
4898 ; GFX10-CU: ; %bb.0: ; %entry
4899 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4900 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4901 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
4902 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
4903 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
4904 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
4905 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
4906 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
4907 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4908 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4909 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4910 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
4911 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
4912 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
4913 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
4914 ; GFX10-CU-NEXT: s_endpgm
4916 ; SKIP-CACHE-INV-LABEL: flat_workgroup_acq_rel_acquire_ret_cmpxchg:
4917 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4918 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4919 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4920 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
4921 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
4922 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
4923 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
4924 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
4925 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
4926 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4927 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4928 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4929 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
4930 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
4931 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
4932 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
4933 ; SKIP-CACHE-INV-NEXT: s_endpgm
4935 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_acq_rel_acquire_ret_cmpxchg:
4936 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4937 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4938 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4939 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
4940 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
4941 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4942 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
4943 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4944 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
4945 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4947 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_acq_rel_acquire_ret_cmpxchg:
4948 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4949 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
4950 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4951 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
4952 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
4953 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4954 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
4955 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4956 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
4957 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
4958 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4960 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_acq_rel_acquire_ret_cmpxchg:
4961 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
4962 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4963 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4964 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
4965 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
4966 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4967 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
4968 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4969 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
4970 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
4972 ; GFX940-TGSPLIT-LABEL: flat_workgroup_acq_rel_acquire_ret_cmpxchg:
4973 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
4974 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
4975 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4976 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
4977 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
4978 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4979 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
4980 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4981 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
4982 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
4983 ; GFX940-TGSPLIT-NEXT: s_endpgm
4985 ; GFX11-WGP-LABEL: flat_workgroup_acq_rel_acquire_ret_cmpxchg:
4986 ; GFX11-WGP: ; %bb.0: ; %entry
4987 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
4988 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
4989 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
4990 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
4991 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4992 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4993 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
4994 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4995 ; GFX11-WGP-NEXT: buffer_gl0_inv
4996 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
4997 ; GFX11-WGP-NEXT: s_endpgm
4999 ; GFX11-CU-LABEL: flat_workgroup_acq_rel_acquire_ret_cmpxchg:
5000 ; GFX11-CU: ; %bb.0: ; %entry
5001 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
5002 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5003 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
5004 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
5005 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5006 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
5007 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5008 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
5009 ; GFX11-CU-NEXT: s_endpgm
5010 ptr %out, i32 %in, i32 %old) {
5012 %gep = getelementptr i32, ptr %out, i32 4
5013 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup") acq_rel acquire
5014 %val0 = extractvalue { i32, i1 } %val, 0
5015 store i32 %val0, ptr %out, align 4
5019 define amdgpu_kernel void @flat_workgroup_seq_cst_acquire_ret_cmpxchg(
5020 ; GFX7-LABEL: flat_workgroup_seq_cst_acquire_ret_cmpxchg:
5021 ; GFX7: ; %bb.0: ; %entry
5022 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5023 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5024 ; GFX7-NEXT: s_add_u32 s4, s0, 16
5025 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
5026 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
5027 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
5028 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
5029 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
5030 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5031 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5032 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5033 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
5034 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
5035 ; GFX7-NEXT: s_waitcnt vmcnt(0)
5036 ; GFX7-NEXT: flat_store_dword v[0:1], v2
5037 ; GFX7-NEXT: s_endpgm
5039 ; GFX10-WGP-LABEL: flat_workgroup_seq_cst_acquire_ret_cmpxchg:
5040 ; GFX10-WGP: ; %bb.0: ; %entry
5041 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5042 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5043 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
5044 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
5045 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
5046 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
5047 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
5048 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
5049 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5050 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5051 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5052 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5053 ; GFX10-WGP-NEXT: buffer_gl0_inv
5054 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
5055 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
5056 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
5057 ; GFX10-WGP-NEXT: s_endpgm
5059 ; GFX10-CU-LABEL: flat_workgroup_seq_cst_acquire_ret_cmpxchg:
5060 ; GFX10-CU: ; %bb.0: ; %entry
5061 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5062 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5063 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
5064 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
5065 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
5066 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
5067 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
5068 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
5069 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5070 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5071 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5072 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
5073 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
5074 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
5075 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
5076 ; GFX10-CU-NEXT: s_endpgm
5078 ; SKIP-CACHE-INV-LABEL: flat_workgroup_seq_cst_acquire_ret_cmpxchg:
5079 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5080 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5081 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5082 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
5083 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
5084 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
5085 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
5086 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
5087 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
5088 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5089 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5090 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5091 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
5092 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
5093 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
5094 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
5095 ; SKIP-CACHE-INV-NEXT: s_endpgm
5097 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_seq_cst_acquire_ret_cmpxchg:
5098 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5099 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5100 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5101 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
5102 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
5103 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5104 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
5105 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5106 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
5107 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5109 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_seq_cst_acquire_ret_cmpxchg:
5110 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5111 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5112 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5113 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
5114 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
5115 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5116 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
5117 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5118 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
5119 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
5120 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5122 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_seq_cst_acquire_ret_cmpxchg:
5123 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
5124 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5125 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5126 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
5127 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
5128 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5129 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
5130 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5131 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
5132 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
5134 ; GFX940-TGSPLIT-LABEL: flat_workgroup_seq_cst_acquire_ret_cmpxchg:
5135 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
5136 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5137 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5138 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
5139 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
5140 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5141 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
5142 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5143 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
5144 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
5145 ; GFX940-TGSPLIT-NEXT: s_endpgm
5147 ; GFX11-WGP-LABEL: flat_workgroup_seq_cst_acquire_ret_cmpxchg:
5148 ; GFX11-WGP: ; %bb.0: ; %entry
5149 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
5150 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
5151 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
5152 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
5153 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5154 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5155 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
5156 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5157 ; GFX11-WGP-NEXT: buffer_gl0_inv
5158 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
5159 ; GFX11-WGP-NEXT: s_endpgm
5161 ; GFX11-CU-LABEL: flat_workgroup_seq_cst_acquire_ret_cmpxchg:
5162 ; GFX11-CU: ; %bb.0: ; %entry
5163 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
5164 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5165 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
5166 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
5167 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5168 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
5169 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5170 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
5171 ; GFX11-CU-NEXT: s_endpgm
5172 ptr %out, i32 %in, i32 %old) {
5174 %gep = getelementptr i32, ptr %out, i32 4
5175 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup") seq_cst acquire
5176 %val0 = extractvalue { i32, i1 } %val, 0
5177 store i32 %val0, ptr %out, align 4
5181 define amdgpu_kernel void @flat_workgroup_monotonic_seq_cst_ret_cmpxchg(
5182 ; GFX7-LABEL: flat_workgroup_monotonic_seq_cst_ret_cmpxchg:
5183 ; GFX7: ; %bb.0: ; %entry
5184 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5185 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5186 ; GFX7-NEXT: s_add_u32 s4, s0, 16
5187 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
5188 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
5189 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
5190 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
5191 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
5192 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5193 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5194 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5195 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
5196 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
5197 ; GFX7-NEXT: s_waitcnt vmcnt(0)
5198 ; GFX7-NEXT: flat_store_dword v[0:1], v2
5199 ; GFX7-NEXT: s_endpgm
5201 ; GFX10-WGP-LABEL: flat_workgroup_monotonic_seq_cst_ret_cmpxchg:
5202 ; GFX10-WGP: ; %bb.0: ; %entry
5203 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5204 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5205 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
5206 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
5207 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
5208 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
5209 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
5210 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
5211 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5212 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5213 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5214 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5215 ; GFX10-WGP-NEXT: buffer_gl0_inv
5216 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
5217 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
5218 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
5219 ; GFX10-WGP-NEXT: s_endpgm
5221 ; GFX10-CU-LABEL: flat_workgroup_monotonic_seq_cst_ret_cmpxchg:
5222 ; GFX10-CU: ; %bb.0: ; %entry
5223 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5224 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5225 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
5226 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
5227 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
5228 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
5229 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
5230 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
5231 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5232 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5233 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5234 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
5235 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
5236 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
5237 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
5238 ; GFX10-CU-NEXT: s_endpgm
5240 ; SKIP-CACHE-INV-LABEL: flat_workgroup_monotonic_seq_cst_ret_cmpxchg:
5241 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5242 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5243 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5244 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
5245 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
5246 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
5247 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
5248 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
5249 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
5250 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5251 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5252 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5253 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
5254 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
5255 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
5256 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
5257 ; SKIP-CACHE-INV-NEXT: s_endpgm
5259 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_monotonic_seq_cst_ret_cmpxchg:
5260 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5261 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5262 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5263 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
5264 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
5265 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5266 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
5267 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5268 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
5269 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5271 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_monotonic_seq_cst_ret_cmpxchg:
5272 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5273 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5274 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5275 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
5276 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
5277 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5278 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
5279 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5280 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
5281 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
5282 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5284 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_monotonic_seq_cst_ret_cmpxchg:
5285 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
5286 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5287 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5288 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
5289 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
5290 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5291 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
5292 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5293 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
5294 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
5296 ; GFX940-TGSPLIT-LABEL: flat_workgroup_monotonic_seq_cst_ret_cmpxchg:
5297 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
5298 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5299 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5300 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
5301 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
5302 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5303 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
5304 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5305 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
5306 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
5307 ; GFX940-TGSPLIT-NEXT: s_endpgm
5309 ; GFX11-WGP-LABEL: flat_workgroup_monotonic_seq_cst_ret_cmpxchg:
5310 ; GFX11-WGP: ; %bb.0: ; %entry
5311 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
5312 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
5313 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
5314 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
5315 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5316 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5317 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
5318 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5319 ; GFX11-WGP-NEXT: buffer_gl0_inv
5320 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
5321 ; GFX11-WGP-NEXT: s_endpgm
5323 ; GFX11-CU-LABEL: flat_workgroup_monotonic_seq_cst_ret_cmpxchg:
5324 ; GFX11-CU: ; %bb.0: ; %entry
5325 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
5326 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5327 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
5328 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
5329 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5330 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
5331 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5332 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
5333 ; GFX11-CU-NEXT: s_endpgm
5334 ptr %out, i32 %in, i32 %old) {
5336 %gep = getelementptr i32, ptr %out, i32 4
5337 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup") monotonic seq_cst
5338 %val0 = extractvalue { i32, i1 } %val, 0
5339 store i32 %val0, ptr %out, align 4
5343 define amdgpu_kernel void @flat_workgroup_acquire_seq_cst_ret_cmpxchg(
5344 ; GFX7-LABEL: flat_workgroup_acquire_seq_cst_ret_cmpxchg:
5345 ; GFX7: ; %bb.0: ; %entry
5346 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5347 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5348 ; GFX7-NEXT: s_add_u32 s4, s0, 16
5349 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
5350 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
5351 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
5352 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
5353 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
5354 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5355 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5356 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5357 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
5358 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
5359 ; GFX7-NEXT: s_waitcnt vmcnt(0)
5360 ; GFX7-NEXT: flat_store_dword v[0:1], v2
5361 ; GFX7-NEXT: s_endpgm
5363 ; GFX10-WGP-LABEL: flat_workgroup_acquire_seq_cst_ret_cmpxchg:
5364 ; GFX10-WGP: ; %bb.0: ; %entry
5365 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5366 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5367 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
5368 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
5369 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
5370 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
5371 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
5372 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
5373 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5374 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5375 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5376 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5377 ; GFX10-WGP-NEXT: buffer_gl0_inv
5378 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
5379 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
5380 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
5381 ; GFX10-WGP-NEXT: s_endpgm
5383 ; GFX10-CU-LABEL: flat_workgroup_acquire_seq_cst_ret_cmpxchg:
5384 ; GFX10-CU: ; %bb.0: ; %entry
5385 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5386 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5387 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
5388 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
5389 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
5390 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
5391 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
5392 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
5393 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5394 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5395 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5396 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
5397 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
5398 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
5399 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
5400 ; GFX10-CU-NEXT: s_endpgm
5402 ; SKIP-CACHE-INV-LABEL: flat_workgroup_acquire_seq_cst_ret_cmpxchg:
5403 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5404 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5405 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5406 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
5407 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
5408 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
5409 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
5410 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
5411 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
5412 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5413 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5414 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5415 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
5416 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
5417 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
5418 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
5419 ; SKIP-CACHE-INV-NEXT: s_endpgm
5421 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_acquire_seq_cst_ret_cmpxchg:
5422 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5423 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5424 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5425 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
5426 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
5427 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5428 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
5429 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5430 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
5431 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5433 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_acquire_seq_cst_ret_cmpxchg:
5434 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5435 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5436 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5437 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
5438 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
5439 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5440 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
5441 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5442 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
5443 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
5444 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5446 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_acquire_seq_cst_ret_cmpxchg:
5447 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
5448 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5449 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5450 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
5451 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
5452 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5453 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
5454 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5455 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
5456 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
5458 ; GFX940-TGSPLIT-LABEL: flat_workgroup_acquire_seq_cst_ret_cmpxchg:
5459 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
5460 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5461 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5462 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
5463 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
5464 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5465 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
5466 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5467 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
5468 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
5469 ; GFX940-TGSPLIT-NEXT: s_endpgm
5471 ; GFX11-WGP-LABEL: flat_workgroup_acquire_seq_cst_ret_cmpxchg:
5472 ; GFX11-WGP: ; %bb.0: ; %entry
5473 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
5474 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
5475 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
5476 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
5477 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5478 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5479 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
5480 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5481 ; GFX11-WGP-NEXT: buffer_gl0_inv
5482 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
5483 ; GFX11-WGP-NEXT: s_endpgm
5485 ; GFX11-CU-LABEL: flat_workgroup_acquire_seq_cst_ret_cmpxchg:
5486 ; GFX11-CU: ; %bb.0: ; %entry
5487 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
5488 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5489 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
5490 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
5491 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5492 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
5493 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5494 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
5495 ; GFX11-CU-NEXT: s_endpgm
5496 ptr %out, i32 %in, i32 %old) {
5498 %gep = getelementptr i32, ptr %out, i32 4
5499 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup") acquire seq_cst
5500 %val0 = extractvalue { i32, i1 } %val, 0
5501 store i32 %val0, ptr %out, align 4
5505 define amdgpu_kernel void @flat_workgroup_release_seq_cst_ret_cmpxchg(
5506 ; GFX7-LABEL: flat_workgroup_release_seq_cst_ret_cmpxchg:
5507 ; GFX7: ; %bb.0: ; %entry
5508 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5509 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5510 ; GFX7-NEXT: s_add_u32 s4, s0, 16
5511 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
5512 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
5513 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
5514 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
5515 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
5516 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5517 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5518 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5519 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
5520 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
5521 ; GFX7-NEXT: s_waitcnt vmcnt(0)
5522 ; GFX7-NEXT: flat_store_dword v[0:1], v2
5523 ; GFX7-NEXT: s_endpgm
5525 ; GFX10-WGP-LABEL: flat_workgroup_release_seq_cst_ret_cmpxchg:
5526 ; GFX10-WGP: ; %bb.0: ; %entry
5527 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5528 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5529 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
5530 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
5531 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
5532 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
5533 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
5534 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
5535 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5536 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5537 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5538 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5539 ; GFX10-WGP-NEXT: buffer_gl0_inv
5540 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
5541 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
5542 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
5543 ; GFX10-WGP-NEXT: s_endpgm
5545 ; GFX10-CU-LABEL: flat_workgroup_release_seq_cst_ret_cmpxchg:
5546 ; GFX10-CU: ; %bb.0: ; %entry
5547 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5548 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5549 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
5550 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
5551 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
5552 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
5553 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
5554 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
5555 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5556 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5557 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5558 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
5559 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
5560 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
5561 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
5562 ; GFX10-CU-NEXT: s_endpgm
5564 ; SKIP-CACHE-INV-LABEL: flat_workgroup_release_seq_cst_ret_cmpxchg:
5565 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5566 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5567 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5568 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
5569 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
5570 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
5571 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
5572 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
5573 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
5574 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5575 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5576 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5577 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
5578 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
5579 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
5580 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
5581 ; SKIP-CACHE-INV-NEXT: s_endpgm
5583 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_release_seq_cst_ret_cmpxchg:
5584 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5585 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5586 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5587 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
5588 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
5589 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5590 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
5591 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5592 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
5593 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5595 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_release_seq_cst_ret_cmpxchg:
5596 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5597 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5598 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5599 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
5600 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
5601 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5602 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
5603 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5604 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
5605 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
5606 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5608 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_release_seq_cst_ret_cmpxchg:
5609 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
5610 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5611 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5612 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
5613 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
5614 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5615 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
5616 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5617 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
5618 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
5620 ; GFX940-TGSPLIT-LABEL: flat_workgroup_release_seq_cst_ret_cmpxchg:
5621 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
5622 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5623 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5624 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
5625 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
5626 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5627 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
5628 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5629 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
5630 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
5631 ; GFX940-TGSPLIT-NEXT: s_endpgm
5633 ; GFX11-WGP-LABEL: flat_workgroup_release_seq_cst_ret_cmpxchg:
5634 ; GFX11-WGP: ; %bb.0: ; %entry
5635 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
5636 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
5637 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
5638 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
5639 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5640 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5641 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
5642 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5643 ; GFX11-WGP-NEXT: buffer_gl0_inv
5644 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
5645 ; GFX11-WGP-NEXT: s_endpgm
5647 ; GFX11-CU-LABEL: flat_workgroup_release_seq_cst_ret_cmpxchg:
5648 ; GFX11-CU: ; %bb.0: ; %entry
5649 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
5650 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5651 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
5652 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
5653 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5654 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
5655 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5656 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
5657 ; GFX11-CU-NEXT: s_endpgm
5658 ptr %out, i32 %in, i32 %old) {
5660 %gep = getelementptr i32, ptr %out, i32 4
5661 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup") release seq_cst
5662 %val0 = extractvalue { i32, i1 } %val, 0
5663 store i32 %val0, ptr %out, align 4
5667 define amdgpu_kernel void @flat_workgroup_acq_rel_seq_cst_ret_cmpxchg(
5668 ; GFX7-LABEL: flat_workgroup_acq_rel_seq_cst_ret_cmpxchg:
5669 ; GFX7: ; %bb.0: ; %entry
5670 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5671 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5672 ; GFX7-NEXT: s_add_u32 s4, s0, 16
5673 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
5674 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
5675 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
5676 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
5677 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
5678 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5679 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5680 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5681 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
5682 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
5683 ; GFX7-NEXT: s_waitcnt vmcnt(0)
5684 ; GFX7-NEXT: flat_store_dword v[0:1], v2
5685 ; GFX7-NEXT: s_endpgm
5687 ; GFX10-WGP-LABEL: flat_workgroup_acq_rel_seq_cst_ret_cmpxchg:
5688 ; GFX10-WGP: ; %bb.0: ; %entry
5689 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5690 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5691 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
5692 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
5693 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
5694 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
5695 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
5696 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
5697 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5698 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5699 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5700 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5701 ; GFX10-WGP-NEXT: buffer_gl0_inv
5702 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
5703 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
5704 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
5705 ; GFX10-WGP-NEXT: s_endpgm
5707 ; GFX10-CU-LABEL: flat_workgroup_acq_rel_seq_cst_ret_cmpxchg:
5708 ; GFX10-CU: ; %bb.0: ; %entry
5709 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5710 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5711 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
5712 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
5713 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
5714 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
5715 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
5716 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
5717 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5718 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5719 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5720 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
5721 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
5722 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
5723 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
5724 ; GFX10-CU-NEXT: s_endpgm
5726 ; SKIP-CACHE-INV-LABEL: flat_workgroup_acq_rel_seq_cst_ret_cmpxchg:
5727 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5728 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5729 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5730 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
5731 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
5732 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
5733 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
5734 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
5735 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
5736 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5737 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5738 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5739 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
5740 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
5741 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
5742 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
5743 ; SKIP-CACHE-INV-NEXT: s_endpgm
5745 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_acq_rel_seq_cst_ret_cmpxchg:
5746 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5747 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5748 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5749 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
5750 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
5751 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5752 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
5753 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5754 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
5755 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5757 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_acq_rel_seq_cst_ret_cmpxchg:
5758 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5759 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5760 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5761 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
5762 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
5763 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5764 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
5765 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5766 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
5767 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
5768 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5770 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_acq_rel_seq_cst_ret_cmpxchg:
5771 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
5772 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5773 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5774 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
5775 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
5776 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5777 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
5778 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5779 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
5780 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
5782 ; GFX940-TGSPLIT-LABEL: flat_workgroup_acq_rel_seq_cst_ret_cmpxchg:
5783 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
5784 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5785 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5786 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
5787 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
5788 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5789 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
5790 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5791 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
5792 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
5793 ; GFX940-TGSPLIT-NEXT: s_endpgm
5795 ; GFX11-WGP-LABEL: flat_workgroup_acq_rel_seq_cst_ret_cmpxchg:
5796 ; GFX11-WGP: ; %bb.0: ; %entry
5797 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
5798 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
5799 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
5800 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
5801 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5802 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5803 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
5804 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5805 ; GFX11-WGP-NEXT: buffer_gl0_inv
5806 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
5807 ; GFX11-WGP-NEXT: s_endpgm
5809 ; GFX11-CU-LABEL: flat_workgroup_acq_rel_seq_cst_ret_cmpxchg:
5810 ; GFX11-CU: ; %bb.0: ; %entry
5811 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
5812 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5813 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
5814 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
5815 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5816 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
5817 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5818 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
5819 ; GFX11-CU-NEXT: s_endpgm
5820 ptr %out, i32 %in, i32 %old) {
5822 %gep = getelementptr i32, ptr %out, i32 4
5823 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup") acq_rel seq_cst
5824 %val0 = extractvalue { i32, i1 } %val, 0
5825 store i32 %val0, ptr %out, align 4
5829 define amdgpu_kernel void @flat_workgroup_seq_cst_seq_cst_ret_cmpxchg(
5830 ; GFX7-LABEL: flat_workgroup_seq_cst_seq_cst_ret_cmpxchg:
5831 ; GFX7: ; %bb.0: ; %entry
5832 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5833 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5834 ; GFX7-NEXT: s_add_u32 s4, s0, 16
5835 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
5836 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
5837 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
5838 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
5839 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
5840 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5841 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5842 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5843 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
5844 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
5845 ; GFX7-NEXT: s_waitcnt vmcnt(0)
5846 ; GFX7-NEXT: flat_store_dword v[0:1], v2
5847 ; GFX7-NEXT: s_endpgm
5849 ; GFX10-WGP-LABEL: flat_workgroup_seq_cst_seq_cst_ret_cmpxchg:
5850 ; GFX10-WGP: ; %bb.0: ; %entry
5851 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5852 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5853 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
5854 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
5855 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
5856 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
5857 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
5858 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
5859 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5860 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5861 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5862 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5863 ; GFX10-WGP-NEXT: buffer_gl0_inv
5864 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
5865 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
5866 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
5867 ; GFX10-WGP-NEXT: s_endpgm
5869 ; GFX10-CU-LABEL: flat_workgroup_seq_cst_seq_cst_ret_cmpxchg:
5870 ; GFX10-CU: ; %bb.0: ; %entry
5871 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5872 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5873 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
5874 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
5875 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
5876 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
5877 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
5878 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
5879 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5880 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5881 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5882 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
5883 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
5884 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
5885 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
5886 ; GFX10-CU-NEXT: s_endpgm
5888 ; SKIP-CACHE-INV-LABEL: flat_workgroup_seq_cst_seq_cst_ret_cmpxchg:
5889 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5890 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5891 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5892 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
5893 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
5894 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
5895 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
5896 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
5897 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
5898 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5899 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
5900 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5901 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
5902 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
5903 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
5904 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
5905 ; SKIP-CACHE-INV-NEXT: s_endpgm
5907 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_seq_cst_seq_cst_ret_cmpxchg:
5908 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5909 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5910 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5911 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
5912 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
5913 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5914 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
5915 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5916 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
5917 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5919 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_seq_cst_seq_cst_ret_cmpxchg:
5920 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5921 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5922 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5923 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
5924 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
5925 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5926 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
5927 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5928 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
5929 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
5930 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5932 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_seq_cst_seq_cst_ret_cmpxchg:
5933 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
5934 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5935 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5936 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
5937 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
5938 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5939 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
5940 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5941 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
5942 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
5944 ; GFX940-TGSPLIT-LABEL: flat_workgroup_seq_cst_seq_cst_ret_cmpxchg:
5945 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
5946 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
5947 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5948 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
5949 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
5950 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5951 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
5952 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5953 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
5954 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
5955 ; GFX940-TGSPLIT-NEXT: s_endpgm
5957 ; GFX11-WGP-LABEL: flat_workgroup_seq_cst_seq_cst_ret_cmpxchg:
5958 ; GFX11-WGP: ; %bb.0: ; %entry
5959 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
5960 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
5961 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
5962 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
5963 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5964 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5965 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
5966 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5967 ; GFX11-WGP-NEXT: buffer_gl0_inv
5968 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
5969 ; GFX11-WGP-NEXT: s_endpgm
5971 ; GFX11-CU-LABEL: flat_workgroup_seq_cst_seq_cst_ret_cmpxchg:
5972 ; GFX11-CU: ; %bb.0: ; %entry
5973 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
5974 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5975 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
5976 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
5977 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5978 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
5979 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5980 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
5981 ; GFX11-CU-NEXT: s_endpgm
5982 ptr %out, i32 %in, i32 %old) {
5984 %gep = getelementptr i32, ptr %out, i32 4
5985 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup") seq_cst seq_cst
5986 %val0 = extractvalue { i32, i1 } %val, 0
5987 store i32 %val0, ptr %out, align 4
5991 define amdgpu_kernel void @flat_workgroup_one_as_unordered_load(
5992 ; GFX7-LABEL: flat_workgroup_one_as_unordered_load:
5993 ; GFX7: ; %bb.0: ; %entry
5994 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
5995 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5996 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
5997 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
5998 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
5999 ; GFX7-NEXT: v_mov_b32_e32 v0, s2
6000 ; GFX7-NEXT: v_mov_b32_e32 v1, s3
6001 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6002 ; GFX7-NEXT: flat_store_dword v[0:1], v2
6003 ; GFX7-NEXT: s_endpgm
6005 ; GFX10-WGP-LABEL: flat_workgroup_one_as_unordered_load:
6006 ; GFX10-WGP: ; %bb.0: ; %entry
6007 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6008 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6009 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
6010 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
6011 ; GFX10-WGP-NEXT: flat_load_dword v2, v[0:1]
6012 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
6013 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
6014 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6015 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
6016 ; GFX10-WGP-NEXT: s_endpgm
6018 ; GFX10-CU-LABEL: flat_workgroup_one_as_unordered_load:
6019 ; GFX10-CU: ; %bb.0: ; %entry
6020 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6021 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6022 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
6023 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
6024 ; GFX10-CU-NEXT: flat_load_dword v2, v[0:1]
6025 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
6026 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
6027 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6028 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
6029 ; GFX10-CU-NEXT: s_endpgm
6031 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_unordered_load:
6032 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6033 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6034 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6035 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
6036 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
6037 ; SKIP-CACHE-INV-NEXT: flat_load_dword v2, v[0:1]
6038 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
6039 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
6040 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6041 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
6042 ; SKIP-CACHE-INV-NEXT: s_endpgm
6044 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_unordered_load:
6045 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6046 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6047 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6048 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s0
6049 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s1
6050 ; GFX90A-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1]
6051 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
6052 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s3
6053 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6054 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
6055 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6057 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_unordered_load:
6058 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6059 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6060 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6061 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s0
6062 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s1
6063 ; GFX90A-TGSPLIT-NEXT: flat_load_dword v2, v[0:1]
6064 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
6065 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s3
6066 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6067 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
6068 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6070 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_unordered_load:
6071 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
6072 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6073 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6074 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s0
6075 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s1
6076 ; GFX940-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1]
6077 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
6078 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s3
6079 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6080 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
6081 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
6083 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_unordered_load:
6084 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
6085 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6086 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6087 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s0
6088 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s1
6089 ; GFX940-TGSPLIT-NEXT: flat_load_dword v2, v[0:1]
6090 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
6091 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s3
6092 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6093 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
6094 ; GFX940-TGSPLIT-NEXT: s_endpgm
6096 ; GFX11-WGP-LABEL: flat_workgroup_one_as_unordered_load:
6097 ; GFX11-WGP: ; %bb.0: ; %entry
6098 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
6099 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
6100 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
6101 ; GFX11-WGP-NEXT: flat_load_b32 v2, v[0:1]
6102 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
6103 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6104 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
6105 ; GFX11-WGP-NEXT: s_endpgm
6107 ; GFX11-CU-LABEL: flat_workgroup_one_as_unordered_load:
6108 ; GFX11-CU: ; %bb.0: ; %entry
6109 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
6110 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6111 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
6112 ; GFX11-CU-NEXT: flat_load_b32 v2, v[0:1]
6113 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
6114 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6115 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
6116 ; GFX11-CU-NEXT: s_endpgm
6117 ptr %in, ptr %out) {
6119 %val = load atomic i32, ptr %in syncscope("workgroup-one-as") unordered, align 4
6120 store i32 %val, ptr %out
6124 define amdgpu_kernel void @flat_workgroup_one_as_monotonic_load(
6125 ; GFX7-LABEL: flat_workgroup_one_as_monotonic_load:
6126 ; GFX7: ; %bb.0: ; %entry
6127 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6128 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6129 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
6130 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
6131 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
6132 ; GFX7-NEXT: v_mov_b32_e32 v0, s2
6133 ; GFX7-NEXT: v_mov_b32_e32 v1, s3
6134 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6135 ; GFX7-NEXT: flat_store_dword v[0:1], v2
6136 ; GFX7-NEXT: s_endpgm
6138 ; GFX10-WGP-LABEL: flat_workgroup_one_as_monotonic_load:
6139 ; GFX10-WGP: ; %bb.0: ; %entry
6140 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6141 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6142 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
6143 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
6144 ; GFX10-WGP-NEXT: flat_load_dword v2, v[0:1] glc
6145 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
6146 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
6147 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6148 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
6149 ; GFX10-WGP-NEXT: s_endpgm
6151 ; GFX10-CU-LABEL: flat_workgroup_one_as_monotonic_load:
6152 ; GFX10-CU: ; %bb.0: ; %entry
6153 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6154 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6155 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
6156 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
6157 ; GFX10-CU-NEXT: flat_load_dword v2, v[0:1]
6158 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
6159 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
6160 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6161 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
6162 ; GFX10-CU-NEXT: s_endpgm
6164 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_monotonic_load:
6165 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6166 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6167 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6168 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
6169 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
6170 ; SKIP-CACHE-INV-NEXT: flat_load_dword v2, v[0:1]
6171 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
6172 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
6173 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6174 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
6175 ; SKIP-CACHE-INV-NEXT: s_endpgm
6177 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_monotonic_load:
6178 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6179 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6180 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6181 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s0
6182 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s1
6183 ; GFX90A-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1]
6184 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
6185 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s3
6186 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6187 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
6188 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6190 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_monotonic_load:
6191 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6192 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6193 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6194 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s0
6195 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s1
6196 ; GFX90A-TGSPLIT-NEXT: flat_load_dword v2, v[0:1] glc
6197 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
6198 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s3
6199 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6200 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
6201 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6203 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_monotonic_load:
6204 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
6205 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6206 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6207 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s0
6208 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s1
6209 ; GFX940-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1] sc0
6210 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
6211 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s3
6212 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6213 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
6214 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
6216 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_monotonic_load:
6217 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
6218 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6219 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6220 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s0
6221 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s1
6222 ; GFX940-TGSPLIT-NEXT: flat_load_dword v2, v[0:1] sc0
6223 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
6224 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s3
6225 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6226 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
6227 ; GFX940-TGSPLIT-NEXT: s_endpgm
6229 ; GFX11-WGP-LABEL: flat_workgroup_one_as_monotonic_load:
6230 ; GFX11-WGP: ; %bb.0: ; %entry
6231 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
6232 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
6233 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
6234 ; GFX11-WGP-NEXT: flat_load_b32 v2, v[0:1] glc
6235 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
6236 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6237 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
6238 ; GFX11-WGP-NEXT: s_endpgm
6240 ; GFX11-CU-LABEL: flat_workgroup_one_as_monotonic_load:
6241 ; GFX11-CU: ; %bb.0: ; %entry
6242 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
6243 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6244 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
6245 ; GFX11-CU-NEXT: flat_load_b32 v2, v[0:1]
6246 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
6247 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6248 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
6249 ; GFX11-CU-NEXT: s_endpgm
6250 ptr %in, ptr %out) {
6252 %val = load atomic i32, ptr %in syncscope("workgroup-one-as") monotonic, align 4
6253 store i32 %val, ptr %out
6257 define amdgpu_kernel void @flat_workgroup_one_as_acquire_load(
6258 ; GFX7-LABEL: flat_workgroup_one_as_acquire_load:
6259 ; GFX7: ; %bb.0: ; %entry
6260 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6261 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6262 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
6263 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
6264 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
6265 ; GFX7-NEXT: v_mov_b32_e32 v0, s2
6266 ; GFX7-NEXT: v_mov_b32_e32 v1, s3
6267 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6268 ; GFX7-NEXT: flat_store_dword v[0:1], v2
6269 ; GFX7-NEXT: s_endpgm
6271 ; GFX10-WGP-LABEL: flat_workgroup_one_as_acquire_load:
6272 ; GFX10-WGP: ; %bb.0: ; %entry
6273 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6274 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6275 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
6276 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
6277 ; GFX10-WGP-NEXT: flat_load_dword v2, v[0:1] glc
6278 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
6279 ; GFX10-WGP-NEXT: buffer_gl0_inv
6280 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
6281 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
6282 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6283 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
6284 ; GFX10-WGP-NEXT: s_endpgm
6286 ; GFX10-CU-LABEL: flat_workgroup_one_as_acquire_load:
6287 ; GFX10-CU: ; %bb.0: ; %entry
6288 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6289 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6290 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
6291 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
6292 ; GFX10-CU-NEXT: flat_load_dword v2, v[0:1]
6293 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
6294 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
6295 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6296 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
6297 ; GFX10-CU-NEXT: s_endpgm
6299 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_acquire_load:
6300 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6301 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6302 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6303 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
6304 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
6305 ; SKIP-CACHE-INV-NEXT: flat_load_dword v2, v[0:1]
6306 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
6307 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
6308 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6309 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
6310 ; SKIP-CACHE-INV-NEXT: s_endpgm
6312 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acquire_load:
6313 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6314 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6315 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6316 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s0
6317 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s1
6318 ; GFX90A-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1]
6319 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
6320 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s3
6321 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6322 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
6323 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6325 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_acquire_load:
6326 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6327 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6328 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6329 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s0
6330 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s1
6331 ; GFX90A-TGSPLIT-NEXT: flat_load_dword v2, v[0:1] glc
6332 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6333 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
6334 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
6335 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s3
6336 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
6337 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6339 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acquire_load:
6340 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
6341 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6342 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6343 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s0
6344 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s1
6345 ; GFX940-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1] sc0
6346 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
6347 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s3
6348 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6349 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
6350 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
6352 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_acquire_load:
6353 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
6354 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6355 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6356 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s0
6357 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s1
6358 ; GFX940-TGSPLIT-NEXT: flat_load_dword v2, v[0:1] sc0
6359 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6360 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
6361 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
6362 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s3
6363 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
6364 ; GFX940-TGSPLIT-NEXT: s_endpgm
6366 ; GFX11-WGP-LABEL: flat_workgroup_one_as_acquire_load:
6367 ; GFX11-WGP: ; %bb.0: ; %entry
6368 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
6369 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
6370 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
6371 ; GFX11-WGP-NEXT: flat_load_b32 v2, v[0:1] glc
6372 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
6373 ; GFX11-WGP-NEXT: buffer_gl0_inv
6374 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
6375 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
6376 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
6377 ; GFX11-WGP-NEXT: s_endpgm
6379 ; GFX11-CU-LABEL: flat_workgroup_one_as_acquire_load:
6380 ; GFX11-CU: ; %bb.0: ; %entry
6381 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
6382 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6383 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
6384 ; GFX11-CU-NEXT: flat_load_b32 v2, v[0:1]
6385 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
6386 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6387 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
6388 ; GFX11-CU-NEXT: s_endpgm
6389 ptr %in, ptr %out) {
6391 %val = load atomic i32, ptr %in syncscope("workgroup-one-as") acquire, align 4
6392 store i32 %val, ptr %out
6396 define amdgpu_kernel void @flat_workgroup_one_as_seq_cst_load(
6397 ; GFX7-LABEL: flat_workgroup_one_as_seq_cst_load:
6398 ; GFX7: ; %bb.0: ; %entry
6399 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6400 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6401 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
6402 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
6403 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
6404 ; GFX7-NEXT: v_mov_b32_e32 v0, s2
6405 ; GFX7-NEXT: v_mov_b32_e32 v1, s3
6406 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6407 ; GFX7-NEXT: flat_store_dword v[0:1], v2
6408 ; GFX7-NEXT: s_endpgm
6410 ; GFX10-WGP-LABEL: flat_workgroup_one_as_seq_cst_load:
6411 ; GFX10-WGP: ; %bb.0: ; %entry
6412 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6413 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6414 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
6415 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
6416 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
6417 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6418 ; GFX10-WGP-NEXT: flat_load_dword v2, v[0:1] glc
6419 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
6420 ; GFX10-WGP-NEXT: buffer_gl0_inv
6421 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s2
6422 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s3
6423 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6424 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
6425 ; GFX10-WGP-NEXT: s_endpgm
6427 ; GFX10-CU-LABEL: flat_workgroup_one_as_seq_cst_load:
6428 ; GFX10-CU: ; %bb.0: ; %entry
6429 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6430 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6431 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
6432 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
6433 ; GFX10-CU-NEXT: flat_load_dword v2, v[0:1]
6434 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s2
6435 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s3
6436 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6437 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
6438 ; GFX10-CU-NEXT: s_endpgm
6440 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_seq_cst_load:
6441 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6442 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6443 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6444 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
6445 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
6446 ; SKIP-CACHE-INV-NEXT: flat_load_dword v2, v[0:1]
6447 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
6448 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
6449 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6450 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
6451 ; SKIP-CACHE-INV-NEXT: s_endpgm
6453 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_load:
6454 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6455 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6456 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6457 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s0
6458 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s1
6459 ; GFX90A-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1]
6460 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
6461 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s3
6462 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6463 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
6464 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6466 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_load:
6467 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6468 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
6469 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6470 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s0
6471 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s1
6472 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6473 ; GFX90A-TGSPLIT-NEXT: flat_load_dword v2, v[0:1] glc
6474 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6475 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
6476 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
6477 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s3
6478 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
6479 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6481 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_load:
6482 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
6483 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6484 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6485 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s0
6486 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s1
6487 ; GFX940-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1] sc0
6488 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
6489 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s3
6490 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6491 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
6492 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
6494 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_load:
6495 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
6496 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
6497 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6498 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s0
6499 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s1
6500 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6501 ; GFX940-TGSPLIT-NEXT: flat_load_dword v2, v[0:1] sc0
6502 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6503 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
6504 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
6505 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s3
6506 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
6507 ; GFX940-TGSPLIT-NEXT: s_endpgm
6509 ; GFX11-WGP-LABEL: flat_workgroup_one_as_seq_cst_load:
6510 ; GFX11-WGP: ; %bb.0: ; %entry
6511 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
6512 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
6513 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
6514 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
6515 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6516 ; GFX11-WGP-NEXT: flat_load_b32 v2, v[0:1] glc
6517 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
6518 ; GFX11-WGP-NEXT: buffer_gl0_inv
6519 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
6520 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
6521 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
6522 ; GFX11-WGP-NEXT: s_endpgm
6524 ; GFX11-CU-LABEL: flat_workgroup_one_as_seq_cst_load:
6525 ; GFX11-CU: ; %bb.0: ; %entry
6526 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
6527 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6528 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
6529 ; GFX11-CU-NEXT: flat_load_b32 v2, v[0:1]
6530 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
6531 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6532 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
6533 ; GFX11-CU-NEXT: s_endpgm
6534 ptr %in, ptr %out) {
6536 %val = load atomic i32, ptr %in syncscope("workgroup-one-as") seq_cst, align 4
6537 store i32 %val, ptr %out
6541 define amdgpu_kernel void @flat_workgroup_one_as_unordered_store(
6542 ; GFX7-LABEL: flat_workgroup_one_as_unordered_store:
6543 ; GFX7: ; %bb.0: ; %entry
6544 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
6545 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x0
6546 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6547 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
6548 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
6549 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
6550 ; GFX7-NEXT: flat_store_dword v[0:1], v2
6551 ; GFX7-NEXT: s_endpgm
6553 ; GFX10-WGP-LABEL: flat_workgroup_one_as_unordered_store:
6554 ; GFX10-WGP: ; %bb.0: ; %entry
6555 ; GFX10-WGP-NEXT: s_clause 0x1
6556 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6557 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x0
6558 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6559 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
6560 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
6561 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
6562 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
6563 ; GFX10-WGP-NEXT: s_endpgm
6565 ; GFX10-CU-LABEL: flat_workgroup_one_as_unordered_store:
6566 ; GFX10-CU: ; %bb.0: ; %entry
6567 ; GFX10-CU-NEXT: s_clause 0x1
6568 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6569 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x0
6570 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6571 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
6572 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
6573 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
6574 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
6575 ; GFX10-CU-NEXT: s_endpgm
6577 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_unordered_store:
6578 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6579 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x2
6580 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x0
6581 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6582 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
6583 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
6584 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
6585 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
6586 ; SKIP-CACHE-INV-NEXT: s_endpgm
6588 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_unordered_store:
6589 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6590 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6591 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
6592 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6593 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
6594 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
6595 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
6596 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6598 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_unordered_store:
6599 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6600 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6601 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
6602 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6603 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
6604 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
6605 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
6606 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6608 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_unordered_store:
6609 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
6610 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
6611 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
6612 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6613 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
6614 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
6615 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
6616 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
6618 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_unordered_store:
6619 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
6620 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
6621 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
6622 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6623 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
6624 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
6625 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
6626 ; GFX940-TGSPLIT-NEXT: s_endpgm
6628 ; GFX11-WGP-LABEL: flat_workgroup_one_as_unordered_store:
6629 ; GFX11-WGP: ; %bb.0: ; %entry
6630 ; GFX11-WGP-NEXT: s_clause 0x1
6631 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x8
6632 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x0
6633 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
6634 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
6635 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
6636 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
6637 ; GFX11-WGP-NEXT: s_endpgm
6639 ; GFX11-CU-LABEL: flat_workgroup_one_as_unordered_store:
6640 ; GFX11-CU: ; %bb.0: ; %entry
6641 ; GFX11-CU-NEXT: s_clause 0x1
6642 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x8
6643 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x0
6644 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6645 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
6646 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
6647 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
6648 ; GFX11-CU-NEXT: s_endpgm
6649 i32 %in, ptr %out) {
6651 store atomic i32 %in, ptr %out syncscope("workgroup-one-as") unordered, align 4
6655 define amdgpu_kernel void @flat_workgroup_one_as_monotonic_store(
6656 ; GFX7-LABEL: flat_workgroup_one_as_monotonic_store:
6657 ; GFX7: ; %bb.0: ; %entry
6658 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
6659 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x0
6660 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6661 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
6662 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
6663 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
6664 ; GFX7-NEXT: flat_store_dword v[0:1], v2
6665 ; GFX7-NEXT: s_endpgm
6667 ; GFX10-WGP-LABEL: flat_workgroup_one_as_monotonic_store:
6668 ; GFX10-WGP: ; %bb.0: ; %entry
6669 ; GFX10-WGP-NEXT: s_clause 0x1
6670 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6671 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x0
6672 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6673 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
6674 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
6675 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
6676 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
6677 ; GFX10-WGP-NEXT: s_endpgm
6679 ; GFX10-CU-LABEL: flat_workgroup_one_as_monotonic_store:
6680 ; GFX10-CU: ; %bb.0: ; %entry
6681 ; GFX10-CU-NEXT: s_clause 0x1
6682 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6683 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x0
6684 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6685 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
6686 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
6687 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
6688 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
6689 ; GFX10-CU-NEXT: s_endpgm
6691 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_monotonic_store:
6692 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6693 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x2
6694 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x0
6695 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6696 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
6697 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
6698 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
6699 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
6700 ; SKIP-CACHE-INV-NEXT: s_endpgm
6702 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_monotonic_store:
6703 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6704 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6705 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
6706 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6707 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
6708 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
6709 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
6710 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6712 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_monotonic_store:
6713 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6714 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6715 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
6716 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6717 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
6718 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
6719 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
6720 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6722 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_monotonic_store:
6723 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
6724 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
6725 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
6726 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6727 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
6728 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
6729 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
6730 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
6732 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_monotonic_store:
6733 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
6734 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
6735 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
6736 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6737 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
6738 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
6739 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
6740 ; GFX940-TGSPLIT-NEXT: s_endpgm
6742 ; GFX11-WGP-LABEL: flat_workgroup_one_as_monotonic_store:
6743 ; GFX11-WGP: ; %bb.0: ; %entry
6744 ; GFX11-WGP-NEXT: s_clause 0x1
6745 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x8
6746 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x0
6747 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
6748 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
6749 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
6750 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
6751 ; GFX11-WGP-NEXT: s_endpgm
6753 ; GFX11-CU-LABEL: flat_workgroup_one_as_monotonic_store:
6754 ; GFX11-CU: ; %bb.0: ; %entry
6755 ; GFX11-CU-NEXT: s_clause 0x1
6756 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x8
6757 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x0
6758 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6759 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
6760 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
6761 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
6762 ; GFX11-CU-NEXT: s_endpgm
6763 i32 %in, ptr %out) {
6765 store atomic i32 %in, ptr %out syncscope("workgroup-one-as") monotonic, align 4
6769 define amdgpu_kernel void @flat_workgroup_one_as_release_store(
6770 ; GFX7-LABEL: flat_workgroup_one_as_release_store:
6771 ; GFX7: ; %bb.0: ; %entry
6772 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
6773 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x0
6774 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6775 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
6776 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
6777 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
6778 ; GFX7-NEXT: flat_store_dword v[0:1], v2
6779 ; GFX7-NEXT: s_endpgm
6781 ; GFX10-WGP-LABEL: flat_workgroup_one_as_release_store:
6782 ; GFX10-WGP: ; %bb.0: ; %entry
6783 ; GFX10-WGP-NEXT: s_clause 0x1
6784 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6785 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x0
6786 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6787 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
6788 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
6789 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
6790 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
6791 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6792 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
6793 ; GFX10-WGP-NEXT: s_endpgm
6795 ; GFX10-CU-LABEL: flat_workgroup_one_as_release_store:
6796 ; GFX10-CU: ; %bb.0: ; %entry
6797 ; GFX10-CU-NEXT: s_clause 0x1
6798 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6799 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x0
6800 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6801 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
6802 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
6803 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
6804 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
6805 ; GFX10-CU-NEXT: s_endpgm
6807 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_release_store:
6808 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6809 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x2
6810 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x0
6811 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6812 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
6813 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
6814 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
6815 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
6816 ; SKIP-CACHE-INV-NEXT: s_endpgm
6818 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_release_store:
6819 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6820 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6821 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
6822 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6823 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
6824 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
6825 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
6826 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6828 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_release_store:
6829 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6830 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6831 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
6832 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6833 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
6834 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
6835 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6836 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
6837 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6839 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_release_store:
6840 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
6841 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
6842 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
6843 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6844 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
6845 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
6846 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
6847 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
6849 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_release_store:
6850 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
6851 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
6852 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
6853 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6854 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
6855 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
6856 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6857 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
6858 ; GFX940-TGSPLIT-NEXT: s_endpgm
6860 ; GFX11-WGP-LABEL: flat_workgroup_one_as_release_store:
6861 ; GFX11-WGP: ; %bb.0: ; %entry
6862 ; GFX11-WGP-NEXT: s_clause 0x1
6863 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x8
6864 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x0
6865 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
6866 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
6867 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
6868 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
6869 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6870 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
6871 ; GFX11-WGP-NEXT: s_endpgm
6873 ; GFX11-CU-LABEL: flat_workgroup_one_as_release_store:
6874 ; GFX11-CU: ; %bb.0: ; %entry
6875 ; GFX11-CU-NEXT: s_clause 0x1
6876 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x8
6877 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x0
6878 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6879 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
6880 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
6881 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
6882 ; GFX11-CU-NEXT: s_endpgm
6883 i32 %in, ptr %out) {
6885 store atomic i32 %in, ptr %out syncscope("workgroup-one-as") release, align 4
6889 define amdgpu_kernel void @flat_workgroup_one_as_seq_cst_store(
6890 ; GFX7-LABEL: flat_workgroup_one_as_seq_cst_store:
6891 ; GFX7: ; %bb.0: ; %entry
6892 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x2
6893 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x0
6894 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6895 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
6896 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
6897 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
6898 ; GFX7-NEXT: flat_store_dword v[0:1], v2
6899 ; GFX7-NEXT: s_endpgm
6901 ; GFX10-WGP-LABEL: flat_workgroup_one_as_seq_cst_store:
6902 ; GFX10-WGP: ; %bb.0: ; %entry
6903 ; GFX10-WGP-NEXT: s_clause 0x1
6904 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6905 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x0
6906 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6907 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
6908 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
6909 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
6910 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
6911 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6912 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
6913 ; GFX10-WGP-NEXT: s_endpgm
6915 ; GFX10-CU-LABEL: flat_workgroup_one_as_seq_cst_store:
6916 ; GFX10-CU: ; %bb.0: ; %entry
6917 ; GFX10-CU-NEXT: s_clause 0x1
6918 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6919 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x0
6920 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6921 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
6922 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
6923 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
6924 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
6925 ; GFX10-CU-NEXT: s_endpgm
6927 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_seq_cst_store:
6928 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6929 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x2
6930 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x0
6931 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6932 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
6933 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
6934 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
6935 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
6936 ; SKIP-CACHE-INV-NEXT: s_endpgm
6938 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_store:
6939 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6940 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6941 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
6942 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6943 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
6944 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
6945 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
6946 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6948 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_store:
6949 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6950 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
6951 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
6952 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6953 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
6954 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
6955 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6956 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
6957 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6959 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_store:
6960 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
6961 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
6962 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
6963 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6964 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
6965 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
6966 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
6967 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
6969 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_store:
6970 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
6971 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x8
6972 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x0
6973 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6974 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
6975 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
6976 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6977 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
6978 ; GFX940-TGSPLIT-NEXT: s_endpgm
6980 ; GFX11-WGP-LABEL: flat_workgroup_one_as_seq_cst_store:
6981 ; GFX11-WGP: ; %bb.0: ; %entry
6982 ; GFX11-WGP-NEXT: s_clause 0x1
6983 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x8
6984 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x0
6985 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
6986 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
6987 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
6988 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
6989 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6990 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
6991 ; GFX11-WGP-NEXT: s_endpgm
6993 ; GFX11-CU-LABEL: flat_workgroup_one_as_seq_cst_store:
6994 ; GFX11-CU: ; %bb.0: ; %entry
6995 ; GFX11-CU-NEXT: s_clause 0x1
6996 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x8
6997 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x0
6998 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6999 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
7000 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
7001 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
7002 ; GFX11-CU-NEXT: s_endpgm
7003 i32 %in, ptr %out) {
7005 store atomic i32 %in, ptr %out syncscope("workgroup-one-as") seq_cst, align 4
7009 define amdgpu_kernel void @flat_workgroup_one_as_monotonic_atomicrmw(
7010 ; GFX7-LABEL: flat_workgroup_one_as_monotonic_atomicrmw:
7011 ; GFX7: ; %bb.0: ; %entry
7012 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7013 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
7014 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7015 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
7016 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
7017 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
7018 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
7019 ; GFX7-NEXT: s_endpgm
7021 ; GFX10-WGP-LABEL: flat_workgroup_one_as_monotonic_atomicrmw:
7022 ; GFX10-WGP: ; %bb.0: ; %entry
7023 ; GFX10-WGP-NEXT: s_clause 0x1
7024 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7025 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
7026 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7027 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
7028 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
7029 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
7030 ; GFX10-WGP-NEXT: flat_atomic_swap v[0:1], v2
7031 ; GFX10-WGP-NEXT: s_endpgm
7033 ; GFX10-CU-LABEL: flat_workgroup_one_as_monotonic_atomicrmw:
7034 ; GFX10-CU: ; %bb.0: ; %entry
7035 ; GFX10-CU-NEXT: s_clause 0x1
7036 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7037 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
7038 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7039 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
7040 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
7041 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
7042 ; GFX10-CU-NEXT: flat_atomic_swap v[0:1], v2
7043 ; GFX10-CU-NEXT: s_endpgm
7045 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_monotonic_atomicrmw:
7046 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7047 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
7048 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x2
7049 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7050 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
7051 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
7052 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
7053 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v[0:1], v2
7054 ; SKIP-CACHE-INV-NEXT: s_endpgm
7056 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_monotonic_atomicrmw:
7057 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7058 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7059 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
7060 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7061 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
7062 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
7063 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
7064 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7066 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_monotonic_atomicrmw:
7067 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7068 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7069 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
7070 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7071 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
7072 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
7073 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
7074 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7076 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_monotonic_atomicrmw:
7077 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
7078 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
7079 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
7080 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7081 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
7082 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
7083 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
7084 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
7086 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_monotonic_atomicrmw:
7087 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
7088 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
7089 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
7090 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7091 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
7092 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
7093 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
7094 ; GFX940-TGSPLIT-NEXT: s_endpgm
7096 ; GFX11-WGP-LABEL: flat_workgroup_one_as_monotonic_atomicrmw:
7097 ; GFX11-WGP: ; %bb.0: ; %entry
7098 ; GFX11-WGP-NEXT: s_clause 0x1
7099 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
7100 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
7101 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
7102 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
7103 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
7104 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
7105 ; GFX11-WGP-NEXT: s_endpgm
7107 ; GFX11-CU-LABEL: flat_workgroup_one_as_monotonic_atomicrmw:
7108 ; GFX11-CU: ; %bb.0: ; %entry
7109 ; GFX11-CU-NEXT: s_clause 0x1
7110 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
7111 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
7112 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
7113 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
7114 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
7115 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
7116 ; GFX11-CU-NEXT: s_endpgm
7117 ptr %out, i32 %in) {
7119 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("workgroup-one-as") monotonic
7123 define amdgpu_kernel void @flat_workgroup_one_as_acquire_atomicrmw(
7124 ; GFX7-LABEL: flat_workgroup_one_as_acquire_atomicrmw:
7125 ; GFX7: ; %bb.0: ; %entry
7126 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7127 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
7128 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7129 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
7130 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
7131 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
7132 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
7133 ; GFX7-NEXT: s_endpgm
7135 ; GFX10-WGP-LABEL: flat_workgroup_one_as_acquire_atomicrmw:
7136 ; GFX10-WGP: ; %bb.0: ; %entry
7137 ; GFX10-WGP-NEXT: s_clause 0x1
7138 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7139 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
7140 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7141 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
7142 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
7143 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
7144 ; GFX10-WGP-NEXT: flat_atomic_swap v[0:1], v2
7145 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7146 ; GFX10-WGP-NEXT: buffer_gl0_inv
7147 ; GFX10-WGP-NEXT: s_endpgm
7149 ; GFX10-CU-LABEL: flat_workgroup_one_as_acquire_atomicrmw:
7150 ; GFX10-CU: ; %bb.0: ; %entry
7151 ; GFX10-CU-NEXT: s_clause 0x1
7152 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7153 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
7154 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7155 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
7156 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
7157 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
7158 ; GFX10-CU-NEXT: flat_atomic_swap v[0:1], v2
7159 ; GFX10-CU-NEXT: s_endpgm
7161 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_acquire_atomicrmw:
7162 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7163 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
7164 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x2
7165 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7166 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
7167 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
7168 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
7169 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v[0:1], v2
7170 ; SKIP-CACHE-INV-NEXT: s_endpgm
7172 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acquire_atomicrmw:
7173 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7174 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7175 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
7176 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7177 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
7178 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
7179 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
7180 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7182 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_acquire_atomicrmw:
7183 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7184 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7185 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
7186 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7187 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
7188 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
7189 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
7190 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7191 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
7192 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7194 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acquire_atomicrmw:
7195 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
7196 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
7197 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
7198 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7199 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
7200 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
7201 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
7202 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
7204 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_acquire_atomicrmw:
7205 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
7206 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
7207 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
7208 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7209 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
7210 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
7211 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
7212 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7213 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
7214 ; GFX940-TGSPLIT-NEXT: s_endpgm
7216 ; GFX11-WGP-LABEL: flat_workgroup_one_as_acquire_atomicrmw:
7217 ; GFX11-WGP: ; %bb.0: ; %entry
7218 ; GFX11-WGP-NEXT: s_clause 0x1
7219 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
7220 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
7221 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
7222 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
7223 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
7224 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
7225 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7226 ; GFX11-WGP-NEXT: buffer_gl0_inv
7227 ; GFX11-WGP-NEXT: s_endpgm
7229 ; GFX11-CU-LABEL: flat_workgroup_one_as_acquire_atomicrmw:
7230 ; GFX11-CU: ; %bb.0: ; %entry
7231 ; GFX11-CU-NEXT: s_clause 0x1
7232 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
7233 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
7234 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
7235 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
7236 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
7237 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
7238 ; GFX11-CU-NEXT: s_endpgm
7239 ptr %out, i32 %in) {
7241 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("workgroup-one-as") acquire
7245 define amdgpu_kernel void @flat_workgroup_one_as_release_atomicrmw(
7246 ; GFX7-LABEL: flat_workgroup_one_as_release_atomicrmw:
7247 ; GFX7: ; %bb.0: ; %entry
7248 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7249 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
7250 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7251 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
7252 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
7253 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
7254 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
7255 ; GFX7-NEXT: s_endpgm
7257 ; GFX10-WGP-LABEL: flat_workgroup_one_as_release_atomicrmw:
7258 ; GFX10-WGP: ; %bb.0: ; %entry
7259 ; GFX10-WGP-NEXT: s_clause 0x1
7260 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7261 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
7262 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7263 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
7264 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
7265 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
7266 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
7267 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7268 ; GFX10-WGP-NEXT: flat_atomic_swap v[0:1], v2
7269 ; GFX10-WGP-NEXT: s_endpgm
7271 ; GFX10-CU-LABEL: flat_workgroup_one_as_release_atomicrmw:
7272 ; GFX10-CU: ; %bb.0: ; %entry
7273 ; GFX10-CU-NEXT: s_clause 0x1
7274 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7275 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
7276 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7277 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
7278 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
7279 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
7280 ; GFX10-CU-NEXT: flat_atomic_swap v[0:1], v2
7281 ; GFX10-CU-NEXT: s_endpgm
7283 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_release_atomicrmw:
7284 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7285 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
7286 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x2
7287 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7288 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
7289 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
7290 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
7291 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v[0:1], v2
7292 ; SKIP-CACHE-INV-NEXT: s_endpgm
7294 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_release_atomicrmw:
7295 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7296 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7297 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
7298 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7299 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
7300 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
7301 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
7302 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7304 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_release_atomicrmw:
7305 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7306 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7307 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
7308 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7309 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
7310 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
7311 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7312 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
7313 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7315 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_release_atomicrmw:
7316 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
7317 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
7318 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
7319 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7320 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
7321 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
7322 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
7323 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
7325 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_release_atomicrmw:
7326 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
7327 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
7328 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
7329 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7330 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
7331 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
7332 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7333 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
7334 ; GFX940-TGSPLIT-NEXT: s_endpgm
7336 ; GFX11-WGP-LABEL: flat_workgroup_one_as_release_atomicrmw:
7337 ; GFX11-WGP: ; %bb.0: ; %entry
7338 ; GFX11-WGP-NEXT: s_clause 0x1
7339 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
7340 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
7341 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
7342 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
7343 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
7344 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
7345 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7346 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
7347 ; GFX11-WGP-NEXT: s_endpgm
7349 ; GFX11-CU-LABEL: flat_workgroup_one_as_release_atomicrmw:
7350 ; GFX11-CU: ; %bb.0: ; %entry
7351 ; GFX11-CU-NEXT: s_clause 0x1
7352 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
7353 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
7354 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
7355 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
7356 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
7357 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
7358 ; GFX11-CU-NEXT: s_endpgm
7359 ptr %out, i32 %in) {
7361 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("workgroup-one-as") release
7365 define amdgpu_kernel void @flat_workgroup_one_as_acq_rel_atomicrmw(
7366 ; GFX7-LABEL: flat_workgroup_one_as_acq_rel_atomicrmw:
7367 ; GFX7: ; %bb.0: ; %entry
7368 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7369 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
7370 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7371 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
7372 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
7373 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
7374 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
7375 ; GFX7-NEXT: s_endpgm
7377 ; GFX10-WGP-LABEL: flat_workgroup_one_as_acq_rel_atomicrmw:
7378 ; GFX10-WGP: ; %bb.0: ; %entry
7379 ; GFX10-WGP-NEXT: s_clause 0x1
7380 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7381 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
7382 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7383 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
7384 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
7385 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
7386 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
7387 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7388 ; GFX10-WGP-NEXT: flat_atomic_swap v[0:1], v2
7389 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7390 ; GFX10-WGP-NEXT: buffer_gl0_inv
7391 ; GFX10-WGP-NEXT: s_endpgm
7393 ; GFX10-CU-LABEL: flat_workgroup_one_as_acq_rel_atomicrmw:
7394 ; GFX10-CU: ; %bb.0: ; %entry
7395 ; GFX10-CU-NEXT: s_clause 0x1
7396 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7397 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
7398 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7399 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
7400 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
7401 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
7402 ; GFX10-CU-NEXT: flat_atomic_swap v[0:1], v2
7403 ; GFX10-CU-NEXT: s_endpgm
7405 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_acq_rel_atomicrmw:
7406 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7407 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
7408 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x2
7409 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7410 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
7411 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
7412 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
7413 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v[0:1], v2
7414 ; SKIP-CACHE-INV-NEXT: s_endpgm
7416 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_atomicrmw:
7417 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7418 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7419 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
7420 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7421 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
7422 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
7423 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
7424 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7426 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_atomicrmw:
7427 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7428 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7429 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
7430 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7431 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
7432 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
7433 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7434 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
7435 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7436 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
7437 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7439 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_atomicrmw:
7440 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
7441 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
7442 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
7443 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7444 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
7445 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
7446 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
7447 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
7449 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_atomicrmw:
7450 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
7451 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
7452 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
7453 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7454 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
7455 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
7456 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7457 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
7458 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7459 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
7460 ; GFX940-TGSPLIT-NEXT: s_endpgm
7462 ; GFX11-WGP-LABEL: flat_workgroup_one_as_acq_rel_atomicrmw:
7463 ; GFX11-WGP: ; %bb.0: ; %entry
7464 ; GFX11-WGP-NEXT: s_clause 0x1
7465 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
7466 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
7467 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
7468 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
7469 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
7470 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
7471 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7472 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
7473 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7474 ; GFX11-WGP-NEXT: buffer_gl0_inv
7475 ; GFX11-WGP-NEXT: s_endpgm
7477 ; GFX11-CU-LABEL: flat_workgroup_one_as_acq_rel_atomicrmw:
7478 ; GFX11-CU: ; %bb.0: ; %entry
7479 ; GFX11-CU-NEXT: s_clause 0x1
7480 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
7481 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
7482 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
7483 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
7484 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
7485 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
7486 ; GFX11-CU-NEXT: s_endpgm
7487 ptr %out, i32 %in) {
7489 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("workgroup-one-as") acq_rel
7493 define amdgpu_kernel void @flat_workgroup_one_as_seq_cst_atomicrmw(
7494 ; GFX7-LABEL: flat_workgroup_one_as_seq_cst_atomicrmw:
7495 ; GFX7: ; %bb.0: ; %entry
7496 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7497 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
7498 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7499 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
7500 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
7501 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
7502 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
7503 ; GFX7-NEXT: s_endpgm
7505 ; GFX10-WGP-LABEL: flat_workgroup_one_as_seq_cst_atomicrmw:
7506 ; GFX10-WGP: ; %bb.0: ; %entry
7507 ; GFX10-WGP-NEXT: s_clause 0x1
7508 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7509 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
7510 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7511 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
7512 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
7513 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
7514 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
7515 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7516 ; GFX10-WGP-NEXT: flat_atomic_swap v[0:1], v2
7517 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7518 ; GFX10-WGP-NEXT: buffer_gl0_inv
7519 ; GFX10-WGP-NEXT: s_endpgm
7521 ; GFX10-CU-LABEL: flat_workgroup_one_as_seq_cst_atomicrmw:
7522 ; GFX10-CU: ; %bb.0: ; %entry
7523 ; GFX10-CU-NEXT: s_clause 0x1
7524 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7525 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
7526 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7527 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
7528 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
7529 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
7530 ; GFX10-CU-NEXT: flat_atomic_swap v[0:1], v2
7531 ; GFX10-CU-NEXT: s_endpgm
7533 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_seq_cst_atomicrmw:
7534 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7535 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
7536 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x2
7537 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7538 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
7539 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
7540 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
7541 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v[0:1], v2
7542 ; SKIP-CACHE-INV-NEXT: s_endpgm
7544 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_atomicrmw:
7545 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7546 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7547 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
7548 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7549 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
7550 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
7551 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
7552 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7554 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_atomicrmw:
7555 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7556 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7557 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
7558 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7559 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
7560 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
7561 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7562 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
7563 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7564 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
7565 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7567 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_atomicrmw:
7568 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
7569 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
7570 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
7571 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7572 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
7573 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
7574 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
7575 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
7577 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_atomicrmw:
7578 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
7579 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
7580 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
7581 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7582 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
7583 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
7584 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7585 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
7586 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7587 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
7588 ; GFX940-TGSPLIT-NEXT: s_endpgm
7590 ; GFX11-WGP-LABEL: flat_workgroup_one_as_seq_cst_atomicrmw:
7591 ; GFX11-WGP: ; %bb.0: ; %entry
7592 ; GFX11-WGP-NEXT: s_clause 0x1
7593 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
7594 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
7595 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
7596 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
7597 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
7598 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
7599 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7600 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
7601 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7602 ; GFX11-WGP-NEXT: buffer_gl0_inv
7603 ; GFX11-WGP-NEXT: s_endpgm
7605 ; GFX11-CU-LABEL: flat_workgroup_one_as_seq_cst_atomicrmw:
7606 ; GFX11-CU: ; %bb.0: ; %entry
7607 ; GFX11-CU-NEXT: s_clause 0x1
7608 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
7609 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
7610 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
7611 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
7612 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
7613 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
7614 ; GFX11-CU-NEXT: s_endpgm
7615 ptr %out, i32 %in) {
7617 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("workgroup-one-as") seq_cst
7621 define amdgpu_kernel void @flat_workgroup_one_as_acquire_ret_atomicrmw(
7622 ; GFX7-LABEL: flat_workgroup_one_as_acquire_ret_atomicrmw:
7623 ; GFX7: ; %bb.0: ; %entry
7624 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7625 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
7626 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7627 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
7628 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
7629 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
7630 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
7631 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7632 ; GFX7-NEXT: flat_store_dword v[0:1], v2
7633 ; GFX7-NEXT: s_endpgm
7635 ; GFX10-WGP-LABEL: flat_workgroup_one_as_acquire_ret_atomicrmw:
7636 ; GFX10-WGP: ; %bb.0: ; %entry
7637 ; GFX10-WGP-NEXT: s_clause 0x1
7638 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7639 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
7640 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7641 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
7642 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
7643 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
7644 ; GFX10-WGP-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
7645 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
7646 ; GFX10-WGP-NEXT: buffer_gl0_inv
7647 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7648 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
7649 ; GFX10-WGP-NEXT: s_endpgm
7651 ; GFX10-CU-LABEL: flat_workgroup_one_as_acquire_ret_atomicrmw:
7652 ; GFX10-CU: ; %bb.0: ; %entry
7653 ; GFX10-CU-NEXT: s_clause 0x1
7654 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7655 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
7656 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7657 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
7658 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
7659 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
7660 ; GFX10-CU-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
7661 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7662 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
7663 ; GFX10-CU-NEXT: s_endpgm
7665 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_acquire_ret_atomicrmw:
7666 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7667 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
7668 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x2
7669 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7670 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
7671 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
7672 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
7673 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
7674 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7675 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
7676 ; SKIP-CACHE-INV-NEXT: s_endpgm
7678 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acquire_ret_atomicrmw:
7679 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7680 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7681 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
7682 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7683 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
7684 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
7685 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
7686 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7687 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
7688 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7690 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_acquire_ret_atomicrmw:
7691 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7692 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7693 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
7694 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7695 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
7696 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
7697 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
7698 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7699 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
7700 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
7701 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7703 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acquire_ret_atomicrmw:
7704 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
7705 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
7706 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
7707 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7708 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
7709 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
7710 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 sc0
7711 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7712 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
7713 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
7715 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_acquire_ret_atomicrmw:
7716 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
7717 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
7718 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
7719 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7720 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
7721 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
7722 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 sc0
7723 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7724 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
7725 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
7726 ; GFX940-TGSPLIT-NEXT: s_endpgm
7728 ; GFX11-WGP-LABEL: flat_workgroup_one_as_acquire_ret_atomicrmw:
7729 ; GFX11-WGP: ; %bb.0: ; %entry
7730 ; GFX11-WGP-NEXT: s_clause 0x1
7731 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
7732 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
7733 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
7734 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
7735 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
7736 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 glc
7737 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
7738 ; GFX11-WGP-NEXT: buffer_gl0_inv
7739 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
7740 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
7741 ; GFX11-WGP-NEXT: s_endpgm
7743 ; GFX11-CU-LABEL: flat_workgroup_one_as_acquire_ret_atomicrmw:
7744 ; GFX11-CU: ; %bb.0: ; %entry
7745 ; GFX11-CU-NEXT: s_clause 0x1
7746 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
7747 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
7748 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
7749 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
7750 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
7751 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 glc
7752 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7753 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
7754 ; GFX11-CU-NEXT: s_endpgm
7755 ptr %out, i32 %in) {
7757 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("workgroup-one-as") acquire
7758 store i32 %val, ptr %out, align 4
7762 define amdgpu_kernel void @flat_workgroup_one_as_acq_rel_ret_atomicrmw(
7763 ; GFX7-LABEL: flat_workgroup_one_as_acq_rel_ret_atomicrmw:
7764 ; GFX7: ; %bb.0: ; %entry
7765 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7766 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
7767 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7768 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
7769 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
7770 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
7771 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
7772 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7773 ; GFX7-NEXT: flat_store_dword v[0:1], v2
7774 ; GFX7-NEXT: s_endpgm
7776 ; GFX10-WGP-LABEL: flat_workgroup_one_as_acq_rel_ret_atomicrmw:
7777 ; GFX10-WGP: ; %bb.0: ; %entry
7778 ; GFX10-WGP-NEXT: s_clause 0x1
7779 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7780 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
7781 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7782 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
7783 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
7784 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
7785 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
7786 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7787 ; GFX10-WGP-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
7788 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
7789 ; GFX10-WGP-NEXT: buffer_gl0_inv
7790 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7791 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
7792 ; GFX10-WGP-NEXT: s_endpgm
7794 ; GFX10-CU-LABEL: flat_workgroup_one_as_acq_rel_ret_atomicrmw:
7795 ; GFX10-CU: ; %bb.0: ; %entry
7796 ; GFX10-CU-NEXT: s_clause 0x1
7797 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7798 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
7799 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7800 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
7801 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
7802 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
7803 ; GFX10-CU-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
7804 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7805 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
7806 ; GFX10-CU-NEXT: s_endpgm
7808 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_acq_rel_ret_atomicrmw:
7809 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7810 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
7811 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x2
7812 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7813 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
7814 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
7815 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
7816 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
7817 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7818 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
7819 ; SKIP-CACHE-INV-NEXT: s_endpgm
7821 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_ret_atomicrmw:
7822 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7823 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7824 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
7825 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7826 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
7827 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
7828 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
7829 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7830 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
7831 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7833 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_ret_atomicrmw:
7834 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7835 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7836 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
7837 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7838 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
7839 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
7840 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7841 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
7842 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7843 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
7844 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
7845 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7847 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_ret_atomicrmw:
7848 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
7849 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
7850 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
7851 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7852 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
7853 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
7854 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 sc0
7855 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7856 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
7857 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
7859 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_ret_atomicrmw:
7860 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
7861 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
7862 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
7863 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7864 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
7865 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
7866 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7867 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 sc0
7868 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7869 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
7870 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
7871 ; GFX940-TGSPLIT-NEXT: s_endpgm
7873 ; GFX11-WGP-LABEL: flat_workgroup_one_as_acq_rel_ret_atomicrmw:
7874 ; GFX11-WGP: ; %bb.0: ; %entry
7875 ; GFX11-WGP-NEXT: s_clause 0x1
7876 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
7877 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
7878 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
7879 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
7880 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
7881 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
7882 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7883 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 glc
7884 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
7885 ; GFX11-WGP-NEXT: buffer_gl0_inv
7886 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
7887 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
7888 ; GFX11-WGP-NEXT: s_endpgm
7890 ; GFX11-CU-LABEL: flat_workgroup_one_as_acq_rel_ret_atomicrmw:
7891 ; GFX11-CU: ; %bb.0: ; %entry
7892 ; GFX11-CU-NEXT: s_clause 0x1
7893 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
7894 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
7895 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
7896 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
7897 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
7898 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 glc
7899 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7900 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
7901 ; GFX11-CU-NEXT: s_endpgm
7902 ptr %out, i32 %in) {
7904 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("workgroup-one-as") acq_rel
7905 store i32 %val, ptr %out, align 4
7909 define amdgpu_kernel void @flat_workgroup_one_as_seq_cst_ret_atomicrmw(
7910 ; GFX7-LABEL: flat_workgroup_one_as_seq_cst_ret_atomicrmw:
7911 ; GFX7: ; %bb.0: ; %entry
7912 ; GFX7-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7913 ; GFX7-NEXT: s_load_dword s2, s[4:5], 0x2
7914 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7915 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
7916 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
7917 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
7918 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
7919 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7920 ; GFX7-NEXT: flat_store_dword v[0:1], v2
7921 ; GFX7-NEXT: s_endpgm
7923 ; GFX10-WGP-LABEL: flat_workgroup_one_as_seq_cst_ret_atomicrmw:
7924 ; GFX10-WGP: ; %bb.0: ; %entry
7925 ; GFX10-WGP-NEXT: s_clause 0x1
7926 ; GFX10-WGP-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7927 ; GFX10-WGP-NEXT: s_load_dword s2, s[4:5], 0x8
7928 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7929 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
7930 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
7931 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
7932 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
7933 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7934 ; GFX10-WGP-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
7935 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
7936 ; GFX10-WGP-NEXT: buffer_gl0_inv
7937 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7938 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
7939 ; GFX10-WGP-NEXT: s_endpgm
7941 ; GFX10-CU-LABEL: flat_workgroup_one_as_seq_cst_ret_atomicrmw:
7942 ; GFX10-CU: ; %bb.0: ; %entry
7943 ; GFX10-CU-NEXT: s_clause 0x1
7944 ; GFX10-CU-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7945 ; GFX10-CU-NEXT: s_load_dword s2, s[4:5], 0x8
7946 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7947 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
7948 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
7949 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
7950 ; GFX10-CU-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
7951 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7952 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
7953 ; GFX10-CU-NEXT: s_endpgm
7955 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_seq_cst_ret_atomicrmw:
7956 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7957 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
7958 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x2
7959 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7960 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
7961 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
7962 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
7963 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
7964 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7965 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
7966 ; SKIP-CACHE-INV-NEXT: s_endpgm
7968 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_ret_atomicrmw:
7969 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7970 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7971 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
7972 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7973 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
7974 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
7975 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
7976 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7977 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
7978 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7980 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_ret_atomicrmw:
7981 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7982 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7983 ; GFX90A-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
7984 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7985 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
7986 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
7987 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7988 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
7989 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7990 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
7991 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
7992 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7994 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_ret_atomicrmw:
7995 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
7996 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
7997 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
7998 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7999 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
8000 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
8001 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 sc0
8002 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8003 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
8004 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
8006 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_ret_atomicrmw:
8007 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
8008 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
8009 ; GFX940-TGSPLIT-NEXT: s_load_dword s4, s[0:1], 0x8
8010 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8011 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
8012 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
8013 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8014 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 sc0
8015 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8016 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
8017 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
8018 ; GFX940-TGSPLIT-NEXT: s_endpgm
8020 ; GFX11-WGP-LABEL: flat_workgroup_one_as_seq_cst_ret_atomicrmw:
8021 ; GFX11-WGP: ; %bb.0: ; %entry
8022 ; GFX11-WGP-NEXT: s_clause 0x1
8023 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
8024 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
8025 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
8026 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
8027 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
8028 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
8029 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8030 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 glc
8031 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
8032 ; GFX11-WGP-NEXT: buffer_gl0_inv
8033 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
8034 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
8035 ; GFX11-WGP-NEXT: s_endpgm
8037 ; GFX11-CU-LABEL: flat_workgroup_one_as_seq_cst_ret_atomicrmw:
8038 ; GFX11-CU: ; %bb.0: ; %entry
8039 ; GFX11-CU-NEXT: s_clause 0x1
8040 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
8041 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
8042 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
8043 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s2 :: v_dual_mov_b32 v1, s3
8044 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
8045 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 glc
8046 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8047 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
8048 ; GFX11-CU-NEXT: s_endpgm
8049 ptr %out, i32 %in) {
8051 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("workgroup-one-as") seq_cst
8052 store i32 %val, ptr %out, align 4
8056 define amdgpu_kernel void @flat_workgroup_one_as_monotonic_monotonic_cmpxchg(
8057 ; GFX7-LABEL: flat_workgroup_one_as_monotonic_monotonic_cmpxchg:
8058 ; GFX7: ; %bb.0: ; %entry
8059 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8060 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8061 ; GFX7-NEXT: s_add_u32 s0, s0, 16
8062 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
8063 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
8064 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
8065 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
8066 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
8067 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8068 ; GFX7-NEXT: s_endpgm
8070 ; GFX10-WGP-LABEL: flat_workgroup_one_as_monotonic_monotonic_cmpxchg:
8071 ; GFX10-WGP: ; %bb.0: ; %entry
8072 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8073 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8074 ; GFX10-WGP-NEXT: s_add_u32 s0, s0, 16
8075 ; GFX10-WGP-NEXT: s_addc_u32 s1, s1, 0
8076 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
8077 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
8078 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
8079 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
8080 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8081 ; GFX10-WGP-NEXT: s_endpgm
8083 ; GFX10-CU-LABEL: flat_workgroup_one_as_monotonic_monotonic_cmpxchg:
8084 ; GFX10-CU: ; %bb.0: ; %entry
8085 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8086 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8087 ; GFX10-CU-NEXT: s_add_u32 s0, s0, 16
8088 ; GFX10-CU-NEXT: s_addc_u32 s1, s1, 0
8089 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
8090 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
8091 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
8092 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
8093 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8094 ; GFX10-CU-NEXT: s_endpgm
8096 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_monotonic_monotonic_cmpxchg:
8097 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8098 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
8099 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8100 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, 16
8101 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s1, s1, 0
8102 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
8103 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
8104 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
8105 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
8106 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8107 ; SKIP-CACHE-INV-NEXT: s_endpgm
8109 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_monotonic_monotonic_cmpxchg:
8110 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8111 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8112 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8113 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
8114 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
8115 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8116 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8118 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_monotonic_monotonic_cmpxchg:
8119 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8120 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8121 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8122 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
8123 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
8124 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8125 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8127 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_monotonic_monotonic_cmpxchg:
8128 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
8129 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
8130 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8131 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8132 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
8133 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8134 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
8136 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_monotonic_monotonic_cmpxchg:
8137 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
8138 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
8139 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8140 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8141 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
8142 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8143 ; GFX940-TGSPLIT-NEXT: s_endpgm
8145 ; GFX11-WGP-LABEL: flat_workgroup_one_as_monotonic_monotonic_cmpxchg:
8146 ; GFX11-WGP: ; %bb.0: ; %entry
8147 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
8148 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
8149 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
8150 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
8151 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
8152 ; GFX11-WGP-NEXT: s_endpgm
8154 ; GFX11-CU-LABEL: flat_workgroup_one_as_monotonic_monotonic_cmpxchg:
8155 ; GFX11-CU: ; %bb.0: ; %entry
8156 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
8157 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
8158 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
8159 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
8160 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
8161 ; GFX11-CU-NEXT: s_endpgm
8162 ptr %out, i32 %in, i32 %old) {
8164 %gep = getelementptr i32, ptr %out, i32 4
8165 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") monotonic monotonic
8169 define amdgpu_kernel void @flat_workgroup_one_as_acquire_monotonic_cmpxchg(
8170 ; GFX7-LABEL: flat_workgroup_one_as_acquire_monotonic_cmpxchg:
8171 ; GFX7: ; %bb.0: ; %entry
8172 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8173 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8174 ; GFX7-NEXT: s_add_u32 s0, s0, 16
8175 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
8176 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
8177 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
8178 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
8179 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
8180 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8181 ; GFX7-NEXT: s_endpgm
8183 ; GFX10-WGP-LABEL: flat_workgroup_one_as_acquire_monotonic_cmpxchg:
8184 ; GFX10-WGP: ; %bb.0: ; %entry
8185 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8186 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8187 ; GFX10-WGP-NEXT: s_add_u32 s0, s0, 16
8188 ; GFX10-WGP-NEXT: s_addc_u32 s1, s1, 0
8189 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
8190 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
8191 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
8192 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
8193 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8194 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8195 ; GFX10-WGP-NEXT: buffer_gl0_inv
8196 ; GFX10-WGP-NEXT: s_endpgm
8198 ; GFX10-CU-LABEL: flat_workgroup_one_as_acquire_monotonic_cmpxchg:
8199 ; GFX10-CU: ; %bb.0: ; %entry
8200 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8201 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8202 ; GFX10-CU-NEXT: s_add_u32 s0, s0, 16
8203 ; GFX10-CU-NEXT: s_addc_u32 s1, s1, 0
8204 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
8205 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
8206 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
8207 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
8208 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8209 ; GFX10-CU-NEXT: s_endpgm
8211 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_acquire_monotonic_cmpxchg:
8212 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8213 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
8214 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8215 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, 16
8216 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s1, s1, 0
8217 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
8218 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
8219 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
8220 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
8221 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8222 ; SKIP-CACHE-INV-NEXT: s_endpgm
8224 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acquire_monotonic_cmpxchg:
8225 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8226 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8227 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8228 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
8229 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
8230 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8231 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8233 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_acquire_monotonic_cmpxchg:
8234 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8235 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8236 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8237 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
8238 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
8239 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8240 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8241 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
8242 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8244 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acquire_monotonic_cmpxchg:
8245 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
8246 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
8247 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8248 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8249 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
8250 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8251 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
8253 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_acquire_monotonic_cmpxchg:
8254 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
8255 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
8256 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8257 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8258 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
8259 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8260 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8261 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
8262 ; GFX940-TGSPLIT-NEXT: s_endpgm
8264 ; GFX11-WGP-LABEL: flat_workgroup_one_as_acquire_monotonic_cmpxchg:
8265 ; GFX11-WGP: ; %bb.0: ; %entry
8266 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
8267 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
8268 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
8269 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
8270 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
8271 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8272 ; GFX11-WGP-NEXT: buffer_gl0_inv
8273 ; GFX11-WGP-NEXT: s_endpgm
8275 ; GFX11-CU-LABEL: flat_workgroup_one_as_acquire_monotonic_cmpxchg:
8276 ; GFX11-CU: ; %bb.0: ; %entry
8277 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
8278 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
8279 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
8280 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
8281 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
8282 ; GFX11-CU-NEXT: s_endpgm
8283 ptr %out, i32 %in, i32 %old) {
8285 %gep = getelementptr i32, ptr %out, i32 4
8286 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acquire monotonic
8290 define amdgpu_kernel void @flat_workgroup_one_as_release_monotonic_cmpxchg(
8291 ; GFX7-LABEL: flat_workgroup_one_as_release_monotonic_cmpxchg:
8292 ; GFX7: ; %bb.0: ; %entry
8293 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8294 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8295 ; GFX7-NEXT: s_add_u32 s0, s0, 16
8296 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
8297 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
8298 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
8299 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
8300 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
8301 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8302 ; GFX7-NEXT: s_endpgm
8304 ; GFX10-WGP-LABEL: flat_workgroup_one_as_release_monotonic_cmpxchg:
8305 ; GFX10-WGP: ; %bb.0: ; %entry
8306 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8307 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8308 ; GFX10-WGP-NEXT: s_add_u32 s0, s0, 16
8309 ; GFX10-WGP-NEXT: s_addc_u32 s1, s1, 0
8310 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
8311 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
8312 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
8313 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
8314 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8315 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8316 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8317 ; GFX10-WGP-NEXT: s_endpgm
8319 ; GFX10-CU-LABEL: flat_workgroup_one_as_release_monotonic_cmpxchg:
8320 ; GFX10-CU: ; %bb.0: ; %entry
8321 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8322 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8323 ; GFX10-CU-NEXT: s_add_u32 s0, s0, 16
8324 ; GFX10-CU-NEXT: s_addc_u32 s1, s1, 0
8325 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
8326 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
8327 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
8328 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
8329 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8330 ; GFX10-CU-NEXT: s_endpgm
8332 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_release_monotonic_cmpxchg:
8333 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8334 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
8335 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8336 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, 16
8337 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s1, s1, 0
8338 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
8339 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
8340 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
8341 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
8342 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8343 ; SKIP-CACHE-INV-NEXT: s_endpgm
8345 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_release_monotonic_cmpxchg:
8346 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8347 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8348 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8349 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
8350 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
8351 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8352 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8354 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_release_monotonic_cmpxchg:
8355 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8356 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8357 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8358 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
8359 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
8360 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8361 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8362 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8364 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_release_monotonic_cmpxchg:
8365 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
8366 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
8367 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8368 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8369 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
8370 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8371 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
8373 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_release_monotonic_cmpxchg:
8374 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
8375 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
8376 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8377 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8378 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
8379 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8380 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8381 ; GFX940-TGSPLIT-NEXT: s_endpgm
8383 ; GFX11-WGP-LABEL: flat_workgroup_one_as_release_monotonic_cmpxchg:
8384 ; GFX11-WGP: ; %bb.0: ; %entry
8385 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
8386 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
8387 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
8388 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
8389 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
8390 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8391 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
8392 ; GFX11-WGP-NEXT: s_endpgm
8394 ; GFX11-CU-LABEL: flat_workgroup_one_as_release_monotonic_cmpxchg:
8395 ; GFX11-CU: ; %bb.0: ; %entry
8396 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
8397 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
8398 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
8399 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
8400 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
8401 ; GFX11-CU-NEXT: s_endpgm
8402 ptr %out, i32 %in, i32 %old) {
8404 %gep = getelementptr i32, ptr %out, i32 4
8405 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") release monotonic
8409 define amdgpu_kernel void @flat_workgroup_one_as_acq_rel_monotonic_cmpxchg(
8410 ; GFX7-LABEL: flat_workgroup_one_as_acq_rel_monotonic_cmpxchg:
8411 ; GFX7: ; %bb.0: ; %entry
8412 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8413 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8414 ; GFX7-NEXT: s_add_u32 s0, s0, 16
8415 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
8416 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
8417 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
8418 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
8419 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
8420 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8421 ; GFX7-NEXT: s_endpgm
8423 ; GFX10-WGP-LABEL: flat_workgroup_one_as_acq_rel_monotonic_cmpxchg:
8424 ; GFX10-WGP: ; %bb.0: ; %entry
8425 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8426 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8427 ; GFX10-WGP-NEXT: s_add_u32 s0, s0, 16
8428 ; GFX10-WGP-NEXT: s_addc_u32 s1, s1, 0
8429 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
8430 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
8431 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
8432 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
8433 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8434 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8435 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8436 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8437 ; GFX10-WGP-NEXT: buffer_gl0_inv
8438 ; GFX10-WGP-NEXT: s_endpgm
8440 ; GFX10-CU-LABEL: flat_workgroup_one_as_acq_rel_monotonic_cmpxchg:
8441 ; GFX10-CU: ; %bb.0: ; %entry
8442 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8443 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8444 ; GFX10-CU-NEXT: s_add_u32 s0, s0, 16
8445 ; GFX10-CU-NEXT: s_addc_u32 s1, s1, 0
8446 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
8447 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
8448 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
8449 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
8450 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8451 ; GFX10-CU-NEXT: s_endpgm
8453 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_acq_rel_monotonic_cmpxchg:
8454 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8455 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
8456 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8457 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, 16
8458 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s1, s1, 0
8459 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
8460 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
8461 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
8462 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
8463 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8464 ; SKIP-CACHE-INV-NEXT: s_endpgm
8466 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_monotonic_cmpxchg:
8467 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8468 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8469 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8470 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
8471 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
8472 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8473 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8475 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_monotonic_cmpxchg:
8476 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8477 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8478 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8479 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
8480 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
8481 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8482 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8483 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8484 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
8485 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8487 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_monotonic_cmpxchg:
8488 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
8489 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
8490 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8491 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8492 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
8493 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8494 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
8496 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_monotonic_cmpxchg:
8497 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
8498 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
8499 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8500 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8501 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
8502 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8503 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8504 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8505 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
8506 ; GFX940-TGSPLIT-NEXT: s_endpgm
8508 ; GFX11-WGP-LABEL: flat_workgroup_one_as_acq_rel_monotonic_cmpxchg:
8509 ; GFX11-WGP: ; %bb.0: ; %entry
8510 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
8511 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
8512 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
8513 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
8514 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
8515 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8516 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
8517 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8518 ; GFX11-WGP-NEXT: buffer_gl0_inv
8519 ; GFX11-WGP-NEXT: s_endpgm
8521 ; GFX11-CU-LABEL: flat_workgroup_one_as_acq_rel_monotonic_cmpxchg:
8522 ; GFX11-CU: ; %bb.0: ; %entry
8523 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
8524 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
8525 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
8526 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
8527 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
8528 ; GFX11-CU-NEXT: s_endpgm
8529 ptr %out, i32 %in, i32 %old) {
8531 %gep = getelementptr i32, ptr %out, i32 4
8532 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acq_rel monotonic
8536 define amdgpu_kernel void @flat_workgroup_one_as_seq_cst_monotonic_cmpxchg(
8537 ; GFX7-LABEL: flat_workgroup_one_as_seq_cst_monotonic_cmpxchg:
8538 ; GFX7: ; %bb.0: ; %entry
8539 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8540 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8541 ; GFX7-NEXT: s_add_u32 s0, s0, 16
8542 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
8543 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
8544 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
8545 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
8546 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
8547 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8548 ; GFX7-NEXT: s_endpgm
8550 ; GFX10-WGP-LABEL: flat_workgroup_one_as_seq_cst_monotonic_cmpxchg:
8551 ; GFX10-WGP: ; %bb.0: ; %entry
8552 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8553 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8554 ; GFX10-WGP-NEXT: s_add_u32 s0, s0, 16
8555 ; GFX10-WGP-NEXT: s_addc_u32 s1, s1, 0
8556 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
8557 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
8558 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
8559 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
8560 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8561 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8562 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8563 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8564 ; GFX10-WGP-NEXT: buffer_gl0_inv
8565 ; GFX10-WGP-NEXT: s_endpgm
8567 ; GFX10-CU-LABEL: flat_workgroup_one_as_seq_cst_monotonic_cmpxchg:
8568 ; GFX10-CU: ; %bb.0: ; %entry
8569 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8570 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8571 ; GFX10-CU-NEXT: s_add_u32 s0, s0, 16
8572 ; GFX10-CU-NEXT: s_addc_u32 s1, s1, 0
8573 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
8574 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
8575 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
8576 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
8577 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8578 ; GFX10-CU-NEXT: s_endpgm
8580 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_seq_cst_monotonic_cmpxchg:
8581 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8582 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
8583 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8584 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, 16
8585 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s1, s1, 0
8586 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
8587 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
8588 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
8589 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
8590 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8591 ; SKIP-CACHE-INV-NEXT: s_endpgm
8593 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_monotonic_cmpxchg:
8594 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8595 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8596 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8597 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
8598 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
8599 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8600 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8602 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_monotonic_cmpxchg:
8603 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8604 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8605 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8606 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
8607 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
8608 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8609 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8610 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8611 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
8612 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8614 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_monotonic_cmpxchg:
8615 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
8616 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
8617 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8618 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8619 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
8620 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8621 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
8623 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_monotonic_cmpxchg:
8624 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
8625 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
8626 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8627 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8628 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
8629 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8630 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8631 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8632 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
8633 ; GFX940-TGSPLIT-NEXT: s_endpgm
8635 ; GFX11-WGP-LABEL: flat_workgroup_one_as_seq_cst_monotonic_cmpxchg:
8636 ; GFX11-WGP: ; %bb.0: ; %entry
8637 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
8638 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
8639 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
8640 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
8641 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
8642 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8643 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
8644 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8645 ; GFX11-WGP-NEXT: buffer_gl0_inv
8646 ; GFX11-WGP-NEXT: s_endpgm
8648 ; GFX11-CU-LABEL: flat_workgroup_one_as_seq_cst_monotonic_cmpxchg:
8649 ; GFX11-CU: ; %bb.0: ; %entry
8650 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
8651 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
8652 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
8653 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
8654 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
8655 ; GFX11-CU-NEXT: s_endpgm
8656 ptr %out, i32 %in, i32 %old) {
8658 %gep = getelementptr i32, ptr %out, i32 4
8659 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") seq_cst monotonic
8663 define amdgpu_kernel void @flat_workgroup_one_as_monotonic_acquire_cmpxchg(
8664 ; GFX7-LABEL: flat_workgroup_one_as_monotonic_acquire_cmpxchg:
8665 ; GFX7: ; %bb.0: ; %entry
8666 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8667 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8668 ; GFX7-NEXT: s_add_u32 s0, s0, 16
8669 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
8670 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
8671 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
8672 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
8673 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
8674 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8675 ; GFX7-NEXT: s_endpgm
8677 ; GFX10-WGP-LABEL: flat_workgroup_one_as_monotonic_acquire_cmpxchg:
8678 ; GFX10-WGP: ; %bb.0: ; %entry
8679 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8680 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8681 ; GFX10-WGP-NEXT: s_add_u32 s0, s0, 16
8682 ; GFX10-WGP-NEXT: s_addc_u32 s1, s1, 0
8683 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
8684 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
8685 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
8686 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
8687 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8688 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8689 ; GFX10-WGP-NEXT: buffer_gl0_inv
8690 ; GFX10-WGP-NEXT: s_endpgm
8692 ; GFX10-CU-LABEL: flat_workgroup_one_as_monotonic_acquire_cmpxchg:
8693 ; GFX10-CU: ; %bb.0: ; %entry
8694 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8695 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8696 ; GFX10-CU-NEXT: s_add_u32 s0, s0, 16
8697 ; GFX10-CU-NEXT: s_addc_u32 s1, s1, 0
8698 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
8699 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
8700 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
8701 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
8702 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8703 ; GFX10-CU-NEXT: s_endpgm
8705 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_monotonic_acquire_cmpxchg:
8706 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8707 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
8708 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8709 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, 16
8710 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s1, s1, 0
8711 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
8712 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
8713 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
8714 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
8715 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8716 ; SKIP-CACHE-INV-NEXT: s_endpgm
8718 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_monotonic_acquire_cmpxchg:
8719 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8720 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8721 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8722 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
8723 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
8724 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8725 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8727 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_monotonic_acquire_cmpxchg:
8728 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8729 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8730 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8731 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
8732 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
8733 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8734 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8735 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
8736 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8738 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_monotonic_acquire_cmpxchg:
8739 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
8740 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
8741 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8742 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8743 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
8744 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8745 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
8747 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_monotonic_acquire_cmpxchg:
8748 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
8749 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
8750 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8751 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8752 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
8753 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8754 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8755 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
8756 ; GFX940-TGSPLIT-NEXT: s_endpgm
8758 ; GFX11-WGP-LABEL: flat_workgroup_one_as_monotonic_acquire_cmpxchg:
8759 ; GFX11-WGP: ; %bb.0: ; %entry
8760 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
8761 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
8762 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
8763 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
8764 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
8765 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8766 ; GFX11-WGP-NEXT: buffer_gl0_inv
8767 ; GFX11-WGP-NEXT: s_endpgm
8769 ; GFX11-CU-LABEL: flat_workgroup_one_as_monotonic_acquire_cmpxchg:
8770 ; GFX11-CU: ; %bb.0: ; %entry
8771 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
8772 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
8773 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
8774 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
8775 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
8776 ; GFX11-CU-NEXT: s_endpgm
8777 ptr %out, i32 %in, i32 %old) {
8779 %gep = getelementptr i32, ptr %out, i32 4
8780 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") monotonic acquire
8784 define amdgpu_kernel void @flat_workgroup_one_as_acquire_acquire_cmpxchg(
8785 ; GFX7-LABEL: flat_workgroup_one_as_acquire_acquire_cmpxchg:
8786 ; GFX7: ; %bb.0: ; %entry
8787 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8788 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8789 ; GFX7-NEXT: s_add_u32 s0, s0, 16
8790 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
8791 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
8792 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
8793 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
8794 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
8795 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8796 ; GFX7-NEXT: s_endpgm
8798 ; GFX10-WGP-LABEL: flat_workgroup_one_as_acquire_acquire_cmpxchg:
8799 ; GFX10-WGP: ; %bb.0: ; %entry
8800 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8801 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8802 ; GFX10-WGP-NEXT: s_add_u32 s0, s0, 16
8803 ; GFX10-WGP-NEXT: s_addc_u32 s1, s1, 0
8804 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
8805 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
8806 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
8807 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
8808 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8809 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8810 ; GFX10-WGP-NEXT: buffer_gl0_inv
8811 ; GFX10-WGP-NEXT: s_endpgm
8813 ; GFX10-CU-LABEL: flat_workgroup_one_as_acquire_acquire_cmpxchg:
8814 ; GFX10-CU: ; %bb.0: ; %entry
8815 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8816 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8817 ; GFX10-CU-NEXT: s_add_u32 s0, s0, 16
8818 ; GFX10-CU-NEXT: s_addc_u32 s1, s1, 0
8819 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
8820 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
8821 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
8822 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
8823 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8824 ; GFX10-CU-NEXT: s_endpgm
8826 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_acquire_acquire_cmpxchg:
8827 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8828 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
8829 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8830 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, 16
8831 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s1, s1, 0
8832 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
8833 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
8834 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
8835 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
8836 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8837 ; SKIP-CACHE-INV-NEXT: s_endpgm
8839 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acquire_acquire_cmpxchg:
8840 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8841 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8842 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8843 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
8844 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
8845 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8846 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8848 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_acquire_acquire_cmpxchg:
8849 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8850 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8851 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8852 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
8853 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
8854 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8855 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8856 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
8857 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8859 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acquire_acquire_cmpxchg:
8860 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
8861 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
8862 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8863 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8864 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
8865 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8866 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
8868 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_acquire_acquire_cmpxchg:
8869 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
8870 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
8871 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8872 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8873 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
8874 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8875 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8876 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
8877 ; GFX940-TGSPLIT-NEXT: s_endpgm
8879 ; GFX11-WGP-LABEL: flat_workgroup_one_as_acquire_acquire_cmpxchg:
8880 ; GFX11-WGP: ; %bb.0: ; %entry
8881 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
8882 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
8883 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
8884 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
8885 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
8886 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8887 ; GFX11-WGP-NEXT: buffer_gl0_inv
8888 ; GFX11-WGP-NEXT: s_endpgm
8890 ; GFX11-CU-LABEL: flat_workgroup_one_as_acquire_acquire_cmpxchg:
8891 ; GFX11-CU: ; %bb.0: ; %entry
8892 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
8893 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
8894 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
8895 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
8896 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
8897 ; GFX11-CU-NEXT: s_endpgm
8898 ptr %out, i32 %in, i32 %old) {
8900 %gep = getelementptr i32, ptr %out, i32 4
8901 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acquire acquire
8905 define amdgpu_kernel void @flat_workgroup_one_as_release_acquire_cmpxchg(
8906 ; GFX7-LABEL: flat_workgroup_one_as_release_acquire_cmpxchg:
8907 ; GFX7: ; %bb.0: ; %entry
8908 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8909 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8910 ; GFX7-NEXT: s_add_u32 s0, s0, 16
8911 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
8912 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
8913 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
8914 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
8915 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
8916 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8917 ; GFX7-NEXT: s_endpgm
8919 ; GFX10-WGP-LABEL: flat_workgroup_one_as_release_acquire_cmpxchg:
8920 ; GFX10-WGP: ; %bb.0: ; %entry
8921 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8922 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8923 ; GFX10-WGP-NEXT: s_add_u32 s0, s0, 16
8924 ; GFX10-WGP-NEXT: s_addc_u32 s1, s1, 0
8925 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
8926 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
8927 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
8928 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
8929 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8930 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8931 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8932 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8933 ; GFX10-WGP-NEXT: buffer_gl0_inv
8934 ; GFX10-WGP-NEXT: s_endpgm
8936 ; GFX10-CU-LABEL: flat_workgroup_one_as_release_acquire_cmpxchg:
8937 ; GFX10-CU: ; %bb.0: ; %entry
8938 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8939 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8940 ; GFX10-CU-NEXT: s_add_u32 s0, s0, 16
8941 ; GFX10-CU-NEXT: s_addc_u32 s1, s1, 0
8942 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
8943 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
8944 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
8945 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
8946 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8947 ; GFX10-CU-NEXT: s_endpgm
8949 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_release_acquire_cmpxchg:
8950 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8951 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
8952 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8953 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, 16
8954 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s1, s1, 0
8955 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
8956 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
8957 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
8958 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
8959 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
8960 ; SKIP-CACHE-INV-NEXT: s_endpgm
8962 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_release_acquire_cmpxchg:
8963 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8964 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8965 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8966 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
8967 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
8968 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8969 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8971 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_release_acquire_cmpxchg:
8972 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8973 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
8974 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8975 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
8976 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
8977 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8978 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8979 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8980 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
8981 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8983 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_release_acquire_cmpxchg:
8984 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
8985 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
8986 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8987 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8988 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
8989 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
8990 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
8992 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_release_acquire_cmpxchg:
8993 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
8994 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
8995 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8996 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8997 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
8998 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8999 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9000 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9001 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
9002 ; GFX940-TGSPLIT-NEXT: s_endpgm
9004 ; GFX11-WGP-LABEL: flat_workgroup_one_as_release_acquire_cmpxchg:
9005 ; GFX11-WGP: ; %bb.0: ; %entry
9006 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9007 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
9008 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
9009 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
9010 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
9011 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9012 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
9013 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9014 ; GFX11-WGP-NEXT: buffer_gl0_inv
9015 ; GFX11-WGP-NEXT: s_endpgm
9017 ; GFX11-CU-LABEL: flat_workgroup_one_as_release_acquire_cmpxchg:
9018 ; GFX11-CU: ; %bb.0: ; %entry
9019 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9020 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
9021 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
9022 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
9023 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
9024 ; GFX11-CU-NEXT: s_endpgm
9025 ptr %out, i32 %in, i32 %old) {
9027 %gep = getelementptr i32, ptr %out, i32 4
9028 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") release acquire
9032 define amdgpu_kernel void @flat_workgroup_one_as_acq_rel_acquire_cmpxchg(
9033 ; GFX7-LABEL: flat_workgroup_one_as_acq_rel_acquire_cmpxchg:
9034 ; GFX7: ; %bb.0: ; %entry
9035 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9036 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
9037 ; GFX7-NEXT: s_add_u32 s0, s0, 16
9038 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
9039 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
9040 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
9041 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
9042 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
9043 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9044 ; GFX7-NEXT: s_endpgm
9046 ; GFX10-WGP-LABEL: flat_workgroup_one_as_acq_rel_acquire_cmpxchg:
9047 ; GFX10-WGP: ; %bb.0: ; %entry
9048 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9049 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
9050 ; GFX10-WGP-NEXT: s_add_u32 s0, s0, 16
9051 ; GFX10-WGP-NEXT: s_addc_u32 s1, s1, 0
9052 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
9053 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
9054 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
9055 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
9056 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
9057 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9058 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9059 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9060 ; GFX10-WGP-NEXT: buffer_gl0_inv
9061 ; GFX10-WGP-NEXT: s_endpgm
9063 ; GFX10-CU-LABEL: flat_workgroup_one_as_acq_rel_acquire_cmpxchg:
9064 ; GFX10-CU: ; %bb.0: ; %entry
9065 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9066 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9067 ; GFX10-CU-NEXT: s_add_u32 s0, s0, 16
9068 ; GFX10-CU-NEXT: s_addc_u32 s1, s1, 0
9069 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
9070 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
9071 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
9072 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
9073 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9074 ; GFX10-CU-NEXT: s_endpgm
9076 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_acq_rel_acquire_cmpxchg:
9077 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
9078 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9079 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9080 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, 16
9081 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s1, s1, 0
9082 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
9083 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
9084 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
9085 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
9086 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9087 ; SKIP-CACHE-INV-NEXT: s_endpgm
9089 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_acquire_cmpxchg:
9090 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
9091 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9092 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9093 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
9094 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
9095 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9096 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
9098 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_acquire_cmpxchg:
9099 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
9100 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9101 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9102 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
9103 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
9104 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9105 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9106 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9107 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
9108 ; GFX90A-TGSPLIT-NEXT: s_endpgm
9110 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_acquire_cmpxchg:
9111 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
9112 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9113 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9114 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
9115 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
9116 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9117 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
9119 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_acquire_cmpxchg:
9120 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
9121 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9122 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9123 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
9124 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
9125 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9126 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9127 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9128 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
9129 ; GFX940-TGSPLIT-NEXT: s_endpgm
9131 ; GFX11-WGP-LABEL: flat_workgroup_one_as_acq_rel_acquire_cmpxchg:
9132 ; GFX11-WGP: ; %bb.0: ; %entry
9133 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9134 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
9135 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
9136 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
9137 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
9138 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9139 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
9140 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9141 ; GFX11-WGP-NEXT: buffer_gl0_inv
9142 ; GFX11-WGP-NEXT: s_endpgm
9144 ; GFX11-CU-LABEL: flat_workgroup_one_as_acq_rel_acquire_cmpxchg:
9145 ; GFX11-CU: ; %bb.0: ; %entry
9146 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9147 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
9148 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
9149 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
9150 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
9151 ; GFX11-CU-NEXT: s_endpgm
9152 ptr %out, i32 %in, i32 %old) {
9154 %gep = getelementptr i32, ptr %out, i32 4
9155 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acq_rel acquire
9159 define amdgpu_kernel void @flat_workgroup_one_as_seq_cst_acquire_cmpxchg(
9160 ; GFX7-LABEL: flat_workgroup_one_as_seq_cst_acquire_cmpxchg:
9161 ; GFX7: ; %bb.0: ; %entry
9162 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9163 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
9164 ; GFX7-NEXT: s_add_u32 s0, s0, 16
9165 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
9166 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
9167 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
9168 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
9169 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
9170 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9171 ; GFX7-NEXT: s_endpgm
9173 ; GFX10-WGP-LABEL: flat_workgroup_one_as_seq_cst_acquire_cmpxchg:
9174 ; GFX10-WGP: ; %bb.0: ; %entry
9175 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9176 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
9177 ; GFX10-WGP-NEXT: s_add_u32 s0, s0, 16
9178 ; GFX10-WGP-NEXT: s_addc_u32 s1, s1, 0
9179 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
9180 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
9181 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
9182 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
9183 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
9184 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9185 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9186 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9187 ; GFX10-WGP-NEXT: buffer_gl0_inv
9188 ; GFX10-WGP-NEXT: s_endpgm
9190 ; GFX10-CU-LABEL: flat_workgroup_one_as_seq_cst_acquire_cmpxchg:
9191 ; GFX10-CU: ; %bb.0: ; %entry
9192 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9193 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9194 ; GFX10-CU-NEXT: s_add_u32 s0, s0, 16
9195 ; GFX10-CU-NEXT: s_addc_u32 s1, s1, 0
9196 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
9197 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
9198 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
9199 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
9200 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9201 ; GFX10-CU-NEXT: s_endpgm
9203 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_seq_cst_acquire_cmpxchg:
9204 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
9205 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9206 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9207 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, 16
9208 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s1, s1, 0
9209 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
9210 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
9211 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
9212 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
9213 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9214 ; SKIP-CACHE-INV-NEXT: s_endpgm
9216 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_acquire_cmpxchg:
9217 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
9218 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9219 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9220 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
9221 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
9222 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9223 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
9225 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_acquire_cmpxchg:
9226 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
9227 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9228 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9229 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
9230 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
9231 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9232 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9233 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9234 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
9235 ; GFX90A-TGSPLIT-NEXT: s_endpgm
9237 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_acquire_cmpxchg:
9238 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
9239 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9240 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9241 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
9242 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
9243 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9244 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
9246 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_acquire_cmpxchg:
9247 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
9248 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9249 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9250 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
9251 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
9252 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9253 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9254 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9255 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
9256 ; GFX940-TGSPLIT-NEXT: s_endpgm
9258 ; GFX11-WGP-LABEL: flat_workgroup_one_as_seq_cst_acquire_cmpxchg:
9259 ; GFX11-WGP: ; %bb.0: ; %entry
9260 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9261 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
9262 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
9263 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
9264 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
9265 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9266 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
9267 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9268 ; GFX11-WGP-NEXT: buffer_gl0_inv
9269 ; GFX11-WGP-NEXT: s_endpgm
9271 ; GFX11-CU-LABEL: flat_workgroup_one_as_seq_cst_acquire_cmpxchg:
9272 ; GFX11-CU: ; %bb.0: ; %entry
9273 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9274 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
9275 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
9276 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
9277 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
9278 ; GFX11-CU-NEXT: s_endpgm
9279 ptr %out, i32 %in, i32 %old) {
9281 %gep = getelementptr i32, ptr %out, i32 4
9282 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") seq_cst acquire
9286 define amdgpu_kernel void @flat_workgroup_one_as_monotonic_seq_cst_cmpxchg(
9287 ; GFX7-LABEL: flat_workgroup_one_as_monotonic_seq_cst_cmpxchg:
9288 ; GFX7: ; %bb.0: ; %entry
9289 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9290 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
9291 ; GFX7-NEXT: s_add_u32 s0, s0, 16
9292 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
9293 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
9294 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
9295 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
9296 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
9297 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9298 ; GFX7-NEXT: s_endpgm
9300 ; GFX10-WGP-LABEL: flat_workgroup_one_as_monotonic_seq_cst_cmpxchg:
9301 ; GFX10-WGP: ; %bb.0: ; %entry
9302 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9303 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
9304 ; GFX10-WGP-NEXT: s_add_u32 s0, s0, 16
9305 ; GFX10-WGP-NEXT: s_addc_u32 s1, s1, 0
9306 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
9307 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
9308 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
9309 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
9310 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
9311 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9312 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9313 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9314 ; GFX10-WGP-NEXT: buffer_gl0_inv
9315 ; GFX10-WGP-NEXT: s_endpgm
9317 ; GFX10-CU-LABEL: flat_workgroup_one_as_monotonic_seq_cst_cmpxchg:
9318 ; GFX10-CU: ; %bb.0: ; %entry
9319 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9320 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9321 ; GFX10-CU-NEXT: s_add_u32 s0, s0, 16
9322 ; GFX10-CU-NEXT: s_addc_u32 s1, s1, 0
9323 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
9324 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
9325 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
9326 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
9327 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9328 ; GFX10-CU-NEXT: s_endpgm
9330 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_monotonic_seq_cst_cmpxchg:
9331 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
9332 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9333 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9334 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, 16
9335 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s1, s1, 0
9336 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
9337 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
9338 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
9339 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
9340 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9341 ; SKIP-CACHE-INV-NEXT: s_endpgm
9343 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_monotonic_seq_cst_cmpxchg:
9344 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
9345 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9346 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9347 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
9348 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
9349 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9350 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
9352 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_monotonic_seq_cst_cmpxchg:
9353 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
9354 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9355 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9356 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
9357 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
9358 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9359 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9360 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9361 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
9362 ; GFX90A-TGSPLIT-NEXT: s_endpgm
9364 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_monotonic_seq_cst_cmpxchg:
9365 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
9366 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9367 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9368 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
9369 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
9370 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9371 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
9373 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_monotonic_seq_cst_cmpxchg:
9374 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
9375 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9376 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9377 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
9378 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
9379 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9380 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9381 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9382 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
9383 ; GFX940-TGSPLIT-NEXT: s_endpgm
9385 ; GFX11-WGP-LABEL: flat_workgroup_one_as_monotonic_seq_cst_cmpxchg:
9386 ; GFX11-WGP: ; %bb.0: ; %entry
9387 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9388 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
9389 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
9390 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
9391 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
9392 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9393 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
9394 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9395 ; GFX11-WGP-NEXT: buffer_gl0_inv
9396 ; GFX11-WGP-NEXT: s_endpgm
9398 ; GFX11-CU-LABEL: flat_workgroup_one_as_monotonic_seq_cst_cmpxchg:
9399 ; GFX11-CU: ; %bb.0: ; %entry
9400 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9401 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
9402 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
9403 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
9404 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
9405 ; GFX11-CU-NEXT: s_endpgm
9406 ptr %out, i32 %in, i32 %old) {
9408 %gep = getelementptr i32, ptr %out, i32 4
9409 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") monotonic seq_cst
9413 define amdgpu_kernel void @flat_workgroup_one_as_acquire_seq_cst_cmpxchg(
9414 ; GFX7-LABEL: flat_workgroup_one_as_acquire_seq_cst_cmpxchg:
9415 ; GFX7: ; %bb.0: ; %entry
9416 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9417 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
9418 ; GFX7-NEXT: s_add_u32 s0, s0, 16
9419 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
9420 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
9421 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
9422 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
9423 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
9424 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9425 ; GFX7-NEXT: s_endpgm
9427 ; GFX10-WGP-LABEL: flat_workgroup_one_as_acquire_seq_cst_cmpxchg:
9428 ; GFX10-WGP: ; %bb.0: ; %entry
9429 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9430 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
9431 ; GFX10-WGP-NEXT: s_add_u32 s0, s0, 16
9432 ; GFX10-WGP-NEXT: s_addc_u32 s1, s1, 0
9433 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
9434 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
9435 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
9436 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
9437 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
9438 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9439 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9440 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9441 ; GFX10-WGP-NEXT: buffer_gl0_inv
9442 ; GFX10-WGP-NEXT: s_endpgm
9444 ; GFX10-CU-LABEL: flat_workgroup_one_as_acquire_seq_cst_cmpxchg:
9445 ; GFX10-CU: ; %bb.0: ; %entry
9446 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9447 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9448 ; GFX10-CU-NEXT: s_add_u32 s0, s0, 16
9449 ; GFX10-CU-NEXT: s_addc_u32 s1, s1, 0
9450 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
9451 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
9452 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
9453 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
9454 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9455 ; GFX10-CU-NEXT: s_endpgm
9457 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_acquire_seq_cst_cmpxchg:
9458 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
9459 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9460 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9461 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, 16
9462 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s1, s1, 0
9463 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
9464 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
9465 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
9466 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
9467 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9468 ; SKIP-CACHE-INV-NEXT: s_endpgm
9470 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acquire_seq_cst_cmpxchg:
9471 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
9472 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9473 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9474 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
9475 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
9476 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9477 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
9479 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_acquire_seq_cst_cmpxchg:
9480 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
9481 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9482 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9483 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
9484 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
9485 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9486 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9487 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9488 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
9489 ; GFX90A-TGSPLIT-NEXT: s_endpgm
9491 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acquire_seq_cst_cmpxchg:
9492 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
9493 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9494 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9495 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
9496 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
9497 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9498 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
9500 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_acquire_seq_cst_cmpxchg:
9501 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
9502 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9503 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9504 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
9505 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
9506 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9507 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9508 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9509 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
9510 ; GFX940-TGSPLIT-NEXT: s_endpgm
9512 ; GFX11-WGP-LABEL: flat_workgroup_one_as_acquire_seq_cst_cmpxchg:
9513 ; GFX11-WGP: ; %bb.0: ; %entry
9514 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9515 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
9516 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
9517 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
9518 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
9519 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9520 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
9521 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9522 ; GFX11-WGP-NEXT: buffer_gl0_inv
9523 ; GFX11-WGP-NEXT: s_endpgm
9525 ; GFX11-CU-LABEL: flat_workgroup_one_as_acquire_seq_cst_cmpxchg:
9526 ; GFX11-CU: ; %bb.0: ; %entry
9527 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9528 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
9529 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
9530 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
9531 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
9532 ; GFX11-CU-NEXT: s_endpgm
9533 ptr %out, i32 %in, i32 %old) {
9535 %gep = getelementptr i32, ptr %out, i32 4
9536 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acquire seq_cst
9540 define amdgpu_kernel void @flat_workgroup_one_as_release_seq_cst_cmpxchg(
9541 ; GFX7-LABEL: flat_workgroup_one_as_release_seq_cst_cmpxchg:
9542 ; GFX7: ; %bb.0: ; %entry
9543 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9544 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
9545 ; GFX7-NEXT: s_add_u32 s0, s0, 16
9546 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
9547 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
9548 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
9549 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
9550 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
9551 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9552 ; GFX7-NEXT: s_endpgm
9554 ; GFX10-WGP-LABEL: flat_workgroup_one_as_release_seq_cst_cmpxchg:
9555 ; GFX10-WGP: ; %bb.0: ; %entry
9556 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9557 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
9558 ; GFX10-WGP-NEXT: s_add_u32 s0, s0, 16
9559 ; GFX10-WGP-NEXT: s_addc_u32 s1, s1, 0
9560 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
9561 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
9562 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
9563 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
9564 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
9565 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9566 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9567 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9568 ; GFX10-WGP-NEXT: buffer_gl0_inv
9569 ; GFX10-WGP-NEXT: s_endpgm
9571 ; GFX10-CU-LABEL: flat_workgroup_one_as_release_seq_cst_cmpxchg:
9572 ; GFX10-CU: ; %bb.0: ; %entry
9573 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9574 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9575 ; GFX10-CU-NEXT: s_add_u32 s0, s0, 16
9576 ; GFX10-CU-NEXT: s_addc_u32 s1, s1, 0
9577 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
9578 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
9579 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
9580 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
9581 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9582 ; GFX10-CU-NEXT: s_endpgm
9584 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_release_seq_cst_cmpxchg:
9585 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
9586 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9587 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9588 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, 16
9589 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s1, s1, 0
9590 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
9591 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
9592 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
9593 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
9594 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9595 ; SKIP-CACHE-INV-NEXT: s_endpgm
9597 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_release_seq_cst_cmpxchg:
9598 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
9599 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9600 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9601 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
9602 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
9603 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9604 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
9606 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_release_seq_cst_cmpxchg:
9607 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
9608 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9609 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9610 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
9611 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
9612 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9613 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9614 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9615 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
9616 ; GFX90A-TGSPLIT-NEXT: s_endpgm
9618 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_release_seq_cst_cmpxchg:
9619 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
9620 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9621 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9622 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
9623 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
9624 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9625 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
9627 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_release_seq_cst_cmpxchg:
9628 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
9629 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9630 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9631 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
9632 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
9633 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9634 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9635 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9636 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
9637 ; GFX940-TGSPLIT-NEXT: s_endpgm
9639 ; GFX11-WGP-LABEL: flat_workgroup_one_as_release_seq_cst_cmpxchg:
9640 ; GFX11-WGP: ; %bb.0: ; %entry
9641 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9642 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
9643 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
9644 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
9645 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
9646 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9647 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
9648 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9649 ; GFX11-WGP-NEXT: buffer_gl0_inv
9650 ; GFX11-WGP-NEXT: s_endpgm
9652 ; GFX11-CU-LABEL: flat_workgroup_one_as_release_seq_cst_cmpxchg:
9653 ; GFX11-CU: ; %bb.0: ; %entry
9654 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9655 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
9656 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
9657 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
9658 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
9659 ; GFX11-CU-NEXT: s_endpgm
9660 ptr %out, i32 %in, i32 %old) {
9662 %gep = getelementptr i32, ptr %out, i32 4
9663 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") release seq_cst
9667 define amdgpu_kernel void @flat_workgroup_one_as_acq_rel_seq_cst_cmpxchg(
9668 ; GFX7-LABEL: flat_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
9669 ; GFX7: ; %bb.0: ; %entry
9670 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9671 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
9672 ; GFX7-NEXT: s_add_u32 s0, s0, 16
9673 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
9674 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
9675 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
9676 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
9677 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
9678 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9679 ; GFX7-NEXT: s_endpgm
9681 ; GFX10-WGP-LABEL: flat_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
9682 ; GFX10-WGP: ; %bb.0: ; %entry
9683 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9684 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
9685 ; GFX10-WGP-NEXT: s_add_u32 s0, s0, 16
9686 ; GFX10-WGP-NEXT: s_addc_u32 s1, s1, 0
9687 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
9688 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
9689 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
9690 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
9691 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
9692 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9693 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9694 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9695 ; GFX10-WGP-NEXT: buffer_gl0_inv
9696 ; GFX10-WGP-NEXT: s_endpgm
9698 ; GFX10-CU-LABEL: flat_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
9699 ; GFX10-CU: ; %bb.0: ; %entry
9700 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9701 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9702 ; GFX10-CU-NEXT: s_add_u32 s0, s0, 16
9703 ; GFX10-CU-NEXT: s_addc_u32 s1, s1, 0
9704 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
9705 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
9706 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
9707 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
9708 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9709 ; GFX10-CU-NEXT: s_endpgm
9711 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
9712 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
9713 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9714 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9715 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, 16
9716 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s1, s1, 0
9717 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
9718 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
9719 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
9720 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
9721 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9722 ; SKIP-CACHE-INV-NEXT: s_endpgm
9724 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
9725 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
9726 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9727 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9728 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
9729 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
9730 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9731 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
9733 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
9734 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
9735 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9736 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9737 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
9738 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
9739 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9740 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9741 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9742 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
9743 ; GFX90A-TGSPLIT-NEXT: s_endpgm
9745 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
9746 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
9747 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9748 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9749 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
9750 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
9751 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9752 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
9754 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
9755 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
9756 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9757 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9758 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
9759 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
9760 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9761 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9762 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9763 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
9764 ; GFX940-TGSPLIT-NEXT: s_endpgm
9766 ; GFX11-WGP-LABEL: flat_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
9767 ; GFX11-WGP: ; %bb.0: ; %entry
9768 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9769 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
9770 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
9771 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
9772 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
9773 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9774 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
9775 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9776 ; GFX11-WGP-NEXT: buffer_gl0_inv
9777 ; GFX11-WGP-NEXT: s_endpgm
9779 ; GFX11-CU-LABEL: flat_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
9780 ; GFX11-CU: ; %bb.0: ; %entry
9781 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9782 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
9783 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
9784 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
9785 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
9786 ; GFX11-CU-NEXT: s_endpgm
9787 ptr %out, i32 %in, i32 %old) {
9789 %gep = getelementptr i32, ptr %out, i32 4
9790 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acq_rel seq_cst
9794 define amdgpu_kernel void @flat_workgroup_one_as_seq_cst_seq_cst_cmpxchg(
9795 ; GFX7-LABEL: flat_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
9796 ; GFX7: ; %bb.0: ; %entry
9797 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9798 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
9799 ; GFX7-NEXT: s_add_u32 s0, s0, 16
9800 ; GFX7-NEXT: s_addc_u32 s1, s1, 0
9801 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
9802 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
9803 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
9804 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
9805 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9806 ; GFX7-NEXT: s_endpgm
9808 ; GFX10-WGP-LABEL: flat_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
9809 ; GFX10-WGP: ; %bb.0: ; %entry
9810 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9811 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
9812 ; GFX10-WGP-NEXT: s_add_u32 s0, s0, 16
9813 ; GFX10-WGP-NEXT: s_addc_u32 s1, s1, 0
9814 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
9815 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
9816 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
9817 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
9818 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
9819 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9820 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9821 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9822 ; GFX10-WGP-NEXT: buffer_gl0_inv
9823 ; GFX10-WGP-NEXT: s_endpgm
9825 ; GFX10-CU-LABEL: flat_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
9826 ; GFX10-CU: ; %bb.0: ; %entry
9827 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9828 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9829 ; GFX10-CU-NEXT: s_add_u32 s0, s0, 16
9830 ; GFX10-CU-NEXT: s_addc_u32 s1, s1, 0
9831 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
9832 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
9833 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
9834 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
9835 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9836 ; GFX10-CU-NEXT: s_endpgm
9838 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
9839 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
9840 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9841 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9842 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, 16
9843 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s1, s1, 0
9844 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
9845 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
9846 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
9847 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
9848 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
9849 ; SKIP-CACHE-INV-NEXT: s_endpgm
9851 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
9852 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
9853 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9854 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9855 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
9856 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
9857 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9858 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
9860 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
9861 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
9862 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9863 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9864 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
9865 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
9866 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9867 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9868 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9869 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
9870 ; GFX90A-TGSPLIT-NEXT: s_endpgm
9872 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
9873 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
9874 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9875 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9876 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
9877 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
9878 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9879 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
9881 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
9882 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
9883 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9884 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9885 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
9886 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
9887 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9888 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
9889 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9890 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
9891 ; GFX940-TGSPLIT-NEXT: s_endpgm
9893 ; GFX11-WGP-LABEL: flat_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
9894 ; GFX11-WGP: ; %bb.0: ; %entry
9895 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9896 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
9897 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
9898 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
9899 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
9900 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9901 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
9902 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9903 ; GFX11-WGP-NEXT: buffer_gl0_inv
9904 ; GFX11-WGP-NEXT: s_endpgm
9906 ; GFX11-CU-LABEL: flat_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
9907 ; GFX11-CU: ; %bb.0: ; %entry
9908 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
9909 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
9910 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
9911 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
9912 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
9913 ; GFX11-CU-NEXT: s_endpgm
9914 ptr %out, i32 %in, i32 %old) {
9916 %gep = getelementptr i32, ptr %out, i32 4
9917 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") seq_cst seq_cst
9921 define amdgpu_kernel void @flat_workgroup_one_as_monotonicmonotonic_ret_cmpxchg(
9922 ; GFX7-LABEL: flat_workgroup_one_as_monotonicmonotonic_ret_cmpxchg:
9923 ; GFX7: ; %bb.0: ; %entry
9924 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9925 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
9926 ; GFX7-NEXT: s_add_u32 s4, s0, 16
9927 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
9928 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
9929 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
9930 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
9931 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
9932 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9933 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
9934 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
9935 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9936 ; GFX7-NEXT: flat_store_dword v[0:1], v2
9937 ; GFX7-NEXT: s_endpgm
9939 ; GFX10-WGP-LABEL: flat_workgroup_one_as_monotonicmonotonic_ret_cmpxchg:
9940 ; GFX10-WGP: ; %bb.0: ; %entry
9941 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9942 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
9943 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
9944 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
9945 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
9946 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
9947 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
9948 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
9949 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9950 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
9951 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
9952 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9953 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
9954 ; GFX10-WGP-NEXT: s_endpgm
9956 ; GFX10-CU-LABEL: flat_workgroup_one_as_monotonicmonotonic_ret_cmpxchg:
9957 ; GFX10-CU: ; %bb.0: ; %entry
9958 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9959 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9960 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
9961 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
9962 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
9963 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
9964 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
9965 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
9966 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9967 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
9968 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
9969 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9970 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
9971 ; GFX10-CU-NEXT: s_endpgm
9973 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_monotonicmonotonic_ret_cmpxchg:
9974 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
9975 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
9976 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9977 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
9978 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
9979 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
9980 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
9981 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
9982 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
9983 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9984 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
9985 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
9986 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9987 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
9988 ; SKIP-CACHE-INV-NEXT: s_endpgm
9990 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_monotonicmonotonic_ret_cmpxchg:
9991 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
9992 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
9993 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9994 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
9995 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
9996 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
9997 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9998 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
9999 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
10001 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_monotonicmonotonic_ret_cmpxchg:
10002 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
10003 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10004 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10005 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
10006 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
10007 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
10008 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10009 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
10010 ; GFX90A-TGSPLIT-NEXT: s_endpgm
10012 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_monotonicmonotonic_ret_cmpxchg:
10013 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
10014 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10015 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10016 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
10017 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
10018 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
10019 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10020 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
10021 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
10023 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_monotonicmonotonic_ret_cmpxchg:
10024 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
10025 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10026 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10027 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
10028 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
10029 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
10030 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10031 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
10032 ; GFX940-TGSPLIT-NEXT: s_endpgm
10034 ; GFX11-WGP-LABEL: flat_workgroup_one_as_monotonicmonotonic_ret_cmpxchg:
10035 ; GFX11-WGP: ; %bb.0: ; %entry
10036 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10037 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10038 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
10039 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
10040 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
10041 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10042 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
10043 ; GFX11-WGP-NEXT: s_endpgm
10045 ; GFX11-CU-LABEL: flat_workgroup_one_as_monotonicmonotonic_ret_cmpxchg:
10046 ; GFX11-CU: ; %bb.0: ; %entry
10047 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10048 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
10049 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
10050 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
10051 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
10052 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10053 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
10054 ; GFX11-CU-NEXT: s_endpgm
10055 ptr %out, i32 %in, i32 %old) {
10057 %gep = getelementptr i32, ptr %out, i32 4
10058 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") monotonic monotonic
10059 %val0 = extractvalue { i32, i1 } %val, 0
10060 store i32 %val0, ptr %out, align 4
10064 define amdgpu_kernel void @flat_workgroup_one_as_acquire_monotonic_ret_cmpxchg(
10065 ; GFX7-LABEL: flat_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
10066 ; GFX7: ; %bb.0: ; %entry
10067 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10068 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
10069 ; GFX7-NEXT: s_add_u32 s4, s0, 16
10070 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
10071 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
10072 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
10073 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
10074 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
10075 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
10076 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
10077 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
10078 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10079 ; GFX7-NEXT: flat_store_dword v[0:1], v2
10080 ; GFX7-NEXT: s_endpgm
10082 ; GFX10-WGP-LABEL: flat_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
10083 ; GFX10-WGP: ; %bb.0: ; %entry
10084 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10085 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
10086 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
10087 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
10088 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
10089 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
10090 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
10091 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
10092 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
10093 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
10094 ; GFX10-WGP-NEXT: buffer_gl0_inv
10095 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
10096 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
10097 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
10098 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
10099 ; GFX10-WGP-NEXT: s_endpgm
10101 ; GFX10-CU-LABEL: flat_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
10102 ; GFX10-CU: ; %bb.0: ; %entry
10103 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10104 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
10105 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
10106 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
10107 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
10108 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
10109 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
10110 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
10111 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
10112 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
10113 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
10114 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10115 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
10116 ; GFX10-CU-NEXT: s_endpgm
10118 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
10119 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
10120 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10121 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
10122 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
10123 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
10124 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
10125 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
10126 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
10127 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
10128 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
10129 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
10130 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
10131 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10132 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
10133 ; SKIP-CACHE-INV-NEXT: s_endpgm
10135 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
10136 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
10137 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10138 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10139 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
10140 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
10141 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
10142 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10143 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
10144 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
10146 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
10147 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
10148 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10149 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10150 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
10151 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
10152 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
10153 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10154 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
10155 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
10156 ; GFX90A-TGSPLIT-NEXT: s_endpgm
10158 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
10159 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
10160 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10161 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10162 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
10163 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
10164 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
10165 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10166 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
10167 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
10169 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
10170 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
10171 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10172 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10173 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
10174 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
10175 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
10176 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10177 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
10178 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
10179 ; GFX940-TGSPLIT-NEXT: s_endpgm
10181 ; GFX11-WGP-LABEL: flat_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
10182 ; GFX11-WGP: ; %bb.0: ; %entry
10183 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10184 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10185 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
10186 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
10187 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
10188 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
10189 ; GFX11-WGP-NEXT: buffer_gl0_inv
10190 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10191 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
10192 ; GFX11-WGP-NEXT: s_endpgm
10194 ; GFX11-CU-LABEL: flat_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
10195 ; GFX11-CU: ; %bb.0: ; %entry
10196 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10197 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
10198 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
10199 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
10200 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
10201 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10202 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
10203 ; GFX11-CU-NEXT: s_endpgm
10204 ptr %out, i32 %in, i32 %old) {
10206 %gep = getelementptr i32, ptr %out, i32 4
10207 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acquire monotonic
10208 %val0 = extractvalue { i32, i1 } %val, 0
10209 store i32 %val0, ptr %out, align 4
10213 define amdgpu_kernel void @flat_workgroup_one_as_release_monotonic_ret_cmpxchg(
10214 ; GFX7-LABEL: flat_workgroup_one_as_release_monotonic_ret_cmpxchg:
10215 ; GFX7: ; %bb.0: ; %entry
10216 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10217 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
10218 ; GFX7-NEXT: s_add_u32 s4, s0, 16
10219 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
10220 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
10221 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
10222 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
10223 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
10224 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
10225 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
10226 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
10227 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10228 ; GFX7-NEXT: flat_store_dword v[0:1], v2
10229 ; GFX7-NEXT: s_endpgm
10231 ; GFX10-WGP-LABEL: flat_workgroup_one_as_release_monotonic_ret_cmpxchg:
10232 ; GFX10-WGP: ; %bb.0: ; %entry
10233 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10234 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
10235 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
10236 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
10237 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
10238 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
10239 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
10240 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
10241 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
10242 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10243 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
10244 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
10245 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
10246 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10247 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
10248 ; GFX10-WGP-NEXT: s_endpgm
10250 ; GFX10-CU-LABEL: flat_workgroup_one_as_release_monotonic_ret_cmpxchg:
10251 ; GFX10-CU: ; %bb.0: ; %entry
10252 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10253 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
10254 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
10255 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
10256 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
10257 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
10258 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
10259 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
10260 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
10261 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
10262 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
10263 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10264 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
10265 ; GFX10-CU-NEXT: s_endpgm
10267 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_release_monotonic_ret_cmpxchg:
10268 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
10269 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10270 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
10271 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
10272 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
10273 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
10274 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
10275 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
10276 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
10277 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
10278 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
10279 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
10280 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10281 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
10282 ; SKIP-CACHE-INV-NEXT: s_endpgm
10284 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_release_monotonic_ret_cmpxchg:
10285 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
10286 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10287 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10288 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
10289 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
10290 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
10291 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10292 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
10293 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
10295 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_release_monotonic_ret_cmpxchg:
10296 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
10297 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10298 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10299 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
10300 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
10301 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10302 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
10303 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10304 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
10305 ; GFX90A-TGSPLIT-NEXT: s_endpgm
10307 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_release_monotonic_ret_cmpxchg:
10308 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
10309 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10310 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10311 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
10312 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
10313 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
10314 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10315 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
10316 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
10318 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_release_monotonic_ret_cmpxchg:
10319 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
10320 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10321 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10322 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
10323 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
10324 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10325 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
10326 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10327 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
10328 ; GFX940-TGSPLIT-NEXT: s_endpgm
10330 ; GFX11-WGP-LABEL: flat_workgroup_one_as_release_monotonic_ret_cmpxchg:
10331 ; GFX11-WGP: ; %bb.0: ; %entry
10332 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10333 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10334 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
10335 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
10336 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
10337 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10338 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
10339 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10340 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
10341 ; GFX11-WGP-NEXT: s_endpgm
10343 ; GFX11-CU-LABEL: flat_workgroup_one_as_release_monotonic_ret_cmpxchg:
10344 ; GFX11-CU: ; %bb.0: ; %entry
10345 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10346 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
10347 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
10348 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
10349 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
10350 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10351 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
10352 ; GFX11-CU-NEXT: s_endpgm
10353 ptr %out, i32 %in, i32 %old) {
10355 %gep = getelementptr i32, ptr %out, i32 4
10356 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") release monotonic
10357 %val0 = extractvalue { i32, i1 } %val, 0
10358 store i32 %val0, ptr %out, align 4
10362 define amdgpu_kernel void @flat_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg(
10363 ; GFX7-LABEL: flat_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
10364 ; GFX7: ; %bb.0: ; %entry
10365 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10366 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
10367 ; GFX7-NEXT: s_add_u32 s4, s0, 16
10368 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
10369 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
10370 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
10371 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
10372 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
10373 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
10374 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
10375 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
10376 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10377 ; GFX7-NEXT: flat_store_dword v[0:1], v2
10378 ; GFX7-NEXT: s_endpgm
10380 ; GFX10-WGP-LABEL: flat_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
10381 ; GFX10-WGP: ; %bb.0: ; %entry
10382 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10383 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
10384 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
10385 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
10386 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
10387 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
10388 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
10389 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
10390 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
10391 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10392 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
10393 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
10394 ; GFX10-WGP-NEXT: buffer_gl0_inv
10395 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
10396 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
10397 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
10398 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
10399 ; GFX10-WGP-NEXT: s_endpgm
10401 ; GFX10-CU-LABEL: flat_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
10402 ; GFX10-CU: ; %bb.0: ; %entry
10403 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10404 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
10405 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
10406 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
10407 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
10408 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
10409 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
10410 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
10411 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
10412 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
10413 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
10414 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10415 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
10416 ; GFX10-CU-NEXT: s_endpgm
10418 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
10419 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
10420 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10421 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
10422 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
10423 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
10424 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
10425 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
10426 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
10427 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
10428 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
10429 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
10430 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
10431 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10432 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
10433 ; SKIP-CACHE-INV-NEXT: s_endpgm
10435 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
10436 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
10437 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10438 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10439 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
10440 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
10441 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
10442 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10443 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
10444 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
10446 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
10447 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
10448 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10449 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10450 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
10451 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
10452 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10453 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
10454 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10455 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
10456 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
10457 ; GFX90A-TGSPLIT-NEXT: s_endpgm
10459 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
10460 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
10461 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10462 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10463 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
10464 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
10465 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
10466 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10467 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
10468 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
10470 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
10471 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
10472 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10473 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10474 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
10475 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
10476 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10477 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
10478 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10479 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
10480 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
10481 ; GFX940-TGSPLIT-NEXT: s_endpgm
10483 ; GFX11-WGP-LABEL: flat_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
10484 ; GFX11-WGP: ; %bb.0: ; %entry
10485 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10486 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10487 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
10488 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
10489 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
10490 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10491 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
10492 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
10493 ; GFX11-WGP-NEXT: buffer_gl0_inv
10494 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10495 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
10496 ; GFX11-WGP-NEXT: s_endpgm
10498 ; GFX11-CU-LABEL: flat_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
10499 ; GFX11-CU: ; %bb.0: ; %entry
10500 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10501 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
10502 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
10503 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
10504 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
10505 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10506 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
10507 ; GFX11-CU-NEXT: s_endpgm
10508 ptr %out, i32 %in, i32 %old) {
10510 %gep = getelementptr i32, ptr %out, i32 4
10511 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acq_rel monotonic
10512 %val0 = extractvalue { i32, i1 } %val, 0
10513 store i32 %val0, ptr %out, align 4
10517 define amdgpu_kernel void @flat_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg(
10518 ; GFX7-LABEL: flat_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
10519 ; GFX7: ; %bb.0: ; %entry
10520 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10521 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
10522 ; GFX7-NEXT: s_add_u32 s4, s0, 16
10523 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
10524 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
10525 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
10526 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
10527 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
10528 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
10529 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
10530 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
10531 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10532 ; GFX7-NEXT: flat_store_dword v[0:1], v2
10533 ; GFX7-NEXT: s_endpgm
10535 ; GFX10-WGP-LABEL: flat_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
10536 ; GFX10-WGP: ; %bb.0: ; %entry
10537 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10538 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
10539 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
10540 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
10541 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
10542 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
10543 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
10544 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
10545 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
10546 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10547 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
10548 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
10549 ; GFX10-WGP-NEXT: buffer_gl0_inv
10550 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
10551 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
10552 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
10553 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
10554 ; GFX10-WGP-NEXT: s_endpgm
10556 ; GFX10-CU-LABEL: flat_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
10557 ; GFX10-CU: ; %bb.0: ; %entry
10558 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10559 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
10560 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
10561 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
10562 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
10563 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
10564 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
10565 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
10566 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
10567 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
10568 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
10569 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10570 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
10571 ; GFX10-CU-NEXT: s_endpgm
10573 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
10574 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
10575 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10576 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
10577 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
10578 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
10579 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
10580 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
10581 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
10582 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
10583 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
10584 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
10585 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
10586 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10587 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
10588 ; SKIP-CACHE-INV-NEXT: s_endpgm
10590 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
10591 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
10592 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10593 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10594 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
10595 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
10596 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
10597 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10598 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
10599 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
10601 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
10602 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
10603 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10604 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10605 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
10606 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
10607 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10608 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
10609 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10610 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
10611 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
10612 ; GFX90A-TGSPLIT-NEXT: s_endpgm
10614 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
10615 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
10616 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10617 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10618 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
10619 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
10620 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
10621 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10622 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
10623 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
10625 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
10626 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
10627 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10628 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10629 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
10630 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
10631 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10632 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
10633 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10634 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
10635 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
10636 ; GFX940-TGSPLIT-NEXT: s_endpgm
10638 ; GFX11-WGP-LABEL: flat_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
10639 ; GFX11-WGP: ; %bb.0: ; %entry
10640 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10641 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10642 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
10643 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
10644 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
10645 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10646 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
10647 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
10648 ; GFX11-WGP-NEXT: buffer_gl0_inv
10649 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10650 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
10651 ; GFX11-WGP-NEXT: s_endpgm
10653 ; GFX11-CU-LABEL: flat_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
10654 ; GFX11-CU: ; %bb.0: ; %entry
10655 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10656 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
10657 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
10658 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
10659 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
10660 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10661 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
10662 ; GFX11-CU-NEXT: s_endpgm
10663 ptr %out, i32 %in, i32 %old) {
10665 %gep = getelementptr i32, ptr %out, i32 4
10666 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") seq_cst monotonic
10667 %val0 = extractvalue { i32, i1 } %val, 0
10668 store i32 %val0, ptr %out, align 4
10672 define amdgpu_kernel void @flat_workgroup_one_as_monotonic_acquire_ret_cmpxchg(
10673 ; GFX7-LABEL: flat_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
10674 ; GFX7: ; %bb.0: ; %entry
10675 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10676 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
10677 ; GFX7-NEXT: s_add_u32 s4, s0, 16
10678 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
10679 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
10680 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
10681 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
10682 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
10683 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
10684 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
10685 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
10686 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10687 ; GFX7-NEXT: flat_store_dword v[0:1], v2
10688 ; GFX7-NEXT: s_endpgm
10690 ; GFX10-WGP-LABEL: flat_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
10691 ; GFX10-WGP: ; %bb.0: ; %entry
10692 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10693 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
10694 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
10695 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
10696 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
10697 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
10698 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
10699 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
10700 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
10701 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
10702 ; GFX10-WGP-NEXT: buffer_gl0_inv
10703 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
10704 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
10705 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
10706 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
10707 ; GFX10-WGP-NEXT: s_endpgm
10709 ; GFX10-CU-LABEL: flat_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
10710 ; GFX10-CU: ; %bb.0: ; %entry
10711 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10712 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
10713 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
10714 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
10715 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
10716 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
10717 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
10718 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
10719 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
10720 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
10721 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
10722 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10723 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
10724 ; GFX10-CU-NEXT: s_endpgm
10726 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
10727 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
10728 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10729 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
10730 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
10731 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
10732 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
10733 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
10734 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
10735 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
10736 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
10737 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
10738 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
10739 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10740 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
10741 ; SKIP-CACHE-INV-NEXT: s_endpgm
10743 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
10744 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
10745 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10746 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10747 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
10748 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
10749 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
10750 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10751 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
10752 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
10754 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
10755 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
10756 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10757 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10758 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
10759 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
10760 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
10761 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10762 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
10763 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
10764 ; GFX90A-TGSPLIT-NEXT: s_endpgm
10766 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
10767 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
10768 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10769 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10770 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
10771 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
10772 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
10773 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10774 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
10775 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
10777 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
10778 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
10779 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10780 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10781 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
10782 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
10783 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
10784 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10785 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
10786 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
10787 ; GFX940-TGSPLIT-NEXT: s_endpgm
10789 ; GFX11-WGP-LABEL: flat_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
10790 ; GFX11-WGP: ; %bb.0: ; %entry
10791 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10792 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10793 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
10794 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
10795 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
10796 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
10797 ; GFX11-WGP-NEXT: buffer_gl0_inv
10798 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10799 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
10800 ; GFX11-WGP-NEXT: s_endpgm
10802 ; GFX11-CU-LABEL: flat_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
10803 ; GFX11-CU: ; %bb.0: ; %entry
10804 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10805 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
10806 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
10807 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
10808 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
10809 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10810 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
10811 ; GFX11-CU-NEXT: s_endpgm
10812 ptr %out, i32 %in, i32 %old) {
10814 %gep = getelementptr i32, ptr %out, i32 4
10815 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") monotonic acquire
10816 %val0 = extractvalue { i32, i1 } %val, 0
10817 store i32 %val0, ptr %out, align 4
10821 define amdgpu_kernel void @flat_workgroup_one_as_acquire_acquire_ret_cmpxchg(
10822 ; GFX7-LABEL: flat_workgroup_one_as_acquire_acquire_ret_cmpxchg:
10823 ; GFX7: ; %bb.0: ; %entry
10824 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10825 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
10826 ; GFX7-NEXT: s_add_u32 s4, s0, 16
10827 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
10828 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
10829 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
10830 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
10831 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
10832 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
10833 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
10834 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
10835 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10836 ; GFX7-NEXT: flat_store_dword v[0:1], v2
10837 ; GFX7-NEXT: s_endpgm
10839 ; GFX10-WGP-LABEL: flat_workgroup_one_as_acquire_acquire_ret_cmpxchg:
10840 ; GFX10-WGP: ; %bb.0: ; %entry
10841 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10842 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
10843 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
10844 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
10845 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
10846 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
10847 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
10848 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
10849 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
10850 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
10851 ; GFX10-WGP-NEXT: buffer_gl0_inv
10852 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
10853 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
10854 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
10855 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
10856 ; GFX10-WGP-NEXT: s_endpgm
10858 ; GFX10-CU-LABEL: flat_workgroup_one_as_acquire_acquire_ret_cmpxchg:
10859 ; GFX10-CU: ; %bb.0: ; %entry
10860 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10861 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
10862 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
10863 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
10864 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
10865 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
10866 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
10867 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
10868 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
10869 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
10870 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
10871 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10872 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
10873 ; GFX10-CU-NEXT: s_endpgm
10875 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_acquire_acquire_ret_cmpxchg:
10876 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
10877 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10878 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
10879 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
10880 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
10881 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
10882 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
10883 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
10884 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
10885 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
10886 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
10887 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
10888 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10889 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
10890 ; SKIP-CACHE-INV-NEXT: s_endpgm
10892 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acquire_acquire_ret_cmpxchg:
10893 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
10894 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10895 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10896 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
10897 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
10898 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
10899 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10900 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
10901 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
10903 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_acquire_acquire_ret_cmpxchg:
10904 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
10905 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10906 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10907 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
10908 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
10909 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
10910 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10911 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
10912 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
10913 ; GFX90A-TGSPLIT-NEXT: s_endpgm
10915 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acquire_acquire_ret_cmpxchg:
10916 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
10917 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10918 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10919 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
10920 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
10921 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
10922 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10923 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
10924 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
10926 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_acquire_acquire_ret_cmpxchg:
10927 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
10928 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
10929 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10930 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
10931 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
10932 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
10933 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10934 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
10935 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
10936 ; GFX940-TGSPLIT-NEXT: s_endpgm
10938 ; GFX11-WGP-LABEL: flat_workgroup_one_as_acquire_acquire_ret_cmpxchg:
10939 ; GFX11-WGP: ; %bb.0: ; %entry
10940 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10941 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10942 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
10943 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
10944 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
10945 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
10946 ; GFX11-WGP-NEXT: buffer_gl0_inv
10947 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10948 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
10949 ; GFX11-WGP-NEXT: s_endpgm
10951 ; GFX11-CU-LABEL: flat_workgroup_one_as_acquire_acquire_ret_cmpxchg:
10952 ; GFX11-CU: ; %bb.0: ; %entry
10953 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
10954 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
10955 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
10956 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
10957 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
10958 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10959 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
10960 ; GFX11-CU-NEXT: s_endpgm
10961 ptr %out, i32 %in, i32 %old) {
10963 %gep = getelementptr i32, ptr %out, i32 4
10964 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acquire acquire
10965 %val0 = extractvalue { i32, i1 } %val, 0
10966 store i32 %val0, ptr %out, align 4
10970 define amdgpu_kernel void @flat_workgroup_one_as_release_acquire_ret_cmpxchg(
10971 ; GFX7-LABEL: flat_workgroup_one_as_release_acquire_ret_cmpxchg:
10972 ; GFX7: ; %bb.0: ; %entry
10973 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10974 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
10975 ; GFX7-NEXT: s_add_u32 s4, s0, 16
10976 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
10977 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
10978 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
10979 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
10980 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
10981 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
10982 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
10983 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
10984 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10985 ; GFX7-NEXT: flat_store_dword v[0:1], v2
10986 ; GFX7-NEXT: s_endpgm
10988 ; GFX10-WGP-LABEL: flat_workgroup_one_as_release_acquire_ret_cmpxchg:
10989 ; GFX10-WGP: ; %bb.0: ; %entry
10990 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
10991 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
10992 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
10993 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
10994 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
10995 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
10996 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
10997 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
10998 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
10999 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
11000 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11001 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
11002 ; GFX10-WGP-NEXT: buffer_gl0_inv
11003 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
11004 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
11005 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11006 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
11007 ; GFX10-WGP-NEXT: s_endpgm
11009 ; GFX10-CU-LABEL: flat_workgroup_one_as_release_acquire_ret_cmpxchg:
11010 ; GFX10-CU: ; %bb.0: ; %entry
11011 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11012 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
11013 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
11014 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
11015 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
11016 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
11017 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
11018 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
11019 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11020 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
11021 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
11022 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11023 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
11024 ; GFX10-CU-NEXT: s_endpgm
11026 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_release_acquire_ret_cmpxchg:
11027 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
11028 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11029 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
11030 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
11031 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
11032 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
11033 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
11034 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
11035 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
11036 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11037 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
11038 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
11039 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11040 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
11041 ; SKIP-CACHE-INV-NEXT: s_endpgm
11043 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_release_acquire_ret_cmpxchg:
11044 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
11045 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11046 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11047 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
11048 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
11049 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
11050 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11051 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
11052 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
11054 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_release_acquire_ret_cmpxchg:
11055 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
11056 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11057 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11058 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
11059 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
11060 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11061 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
11062 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11063 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
11064 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
11065 ; GFX90A-TGSPLIT-NEXT: s_endpgm
11067 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_release_acquire_ret_cmpxchg:
11068 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
11069 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11070 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11071 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
11072 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
11073 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
11074 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11075 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
11076 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
11078 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_release_acquire_ret_cmpxchg:
11079 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
11080 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11081 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11082 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
11083 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
11084 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11085 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
11086 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11087 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
11088 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
11089 ; GFX940-TGSPLIT-NEXT: s_endpgm
11091 ; GFX11-WGP-LABEL: flat_workgroup_one_as_release_acquire_ret_cmpxchg:
11092 ; GFX11-WGP: ; %bb.0: ; %entry
11093 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
11094 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11095 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
11096 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
11097 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
11098 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
11099 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
11100 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
11101 ; GFX11-WGP-NEXT: buffer_gl0_inv
11102 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11103 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
11104 ; GFX11-WGP-NEXT: s_endpgm
11106 ; GFX11-CU-LABEL: flat_workgroup_one_as_release_acquire_ret_cmpxchg:
11107 ; GFX11-CU: ; %bb.0: ; %entry
11108 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
11109 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
11110 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
11111 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
11112 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
11113 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11114 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
11115 ; GFX11-CU-NEXT: s_endpgm
11116 ptr %out, i32 %in, i32 %old) {
11118 %gep = getelementptr i32, ptr %out, i32 4
11119 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") release acquire
11120 %val0 = extractvalue { i32, i1 } %val, 0
11121 store i32 %val0, ptr %out, align 4
11125 define amdgpu_kernel void @flat_workgroup_one_as_acq_rel_acquire_ret_cmpxchg(
11126 ; GFX7-LABEL: flat_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
11127 ; GFX7: ; %bb.0: ; %entry
11128 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11129 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
11130 ; GFX7-NEXT: s_add_u32 s4, s0, 16
11131 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
11132 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
11133 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
11134 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
11135 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
11136 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11137 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
11138 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
11139 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11140 ; GFX7-NEXT: flat_store_dword v[0:1], v2
11141 ; GFX7-NEXT: s_endpgm
11143 ; GFX10-WGP-LABEL: flat_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
11144 ; GFX10-WGP: ; %bb.0: ; %entry
11145 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11146 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11147 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
11148 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
11149 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
11150 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
11151 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
11152 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
11153 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
11154 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
11155 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11156 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
11157 ; GFX10-WGP-NEXT: buffer_gl0_inv
11158 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
11159 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
11160 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11161 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
11162 ; GFX10-WGP-NEXT: s_endpgm
11164 ; GFX10-CU-LABEL: flat_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
11165 ; GFX10-CU: ; %bb.0: ; %entry
11166 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11167 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
11168 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
11169 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
11170 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
11171 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
11172 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
11173 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
11174 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11175 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
11176 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
11177 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11178 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
11179 ; GFX10-CU-NEXT: s_endpgm
11181 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
11182 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
11183 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11184 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
11185 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
11186 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
11187 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
11188 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
11189 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
11190 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
11191 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11192 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
11193 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
11194 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11195 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
11196 ; SKIP-CACHE-INV-NEXT: s_endpgm
11198 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
11199 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
11200 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11201 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11202 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
11203 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
11204 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
11205 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11206 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
11207 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
11209 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
11210 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
11211 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11212 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11213 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
11214 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
11215 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11216 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
11217 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11218 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
11219 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
11220 ; GFX90A-TGSPLIT-NEXT: s_endpgm
11222 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
11223 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
11224 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11225 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11226 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
11227 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
11228 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
11229 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11230 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
11231 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
11233 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
11234 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
11235 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11236 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11237 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
11238 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
11239 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11240 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
11241 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11242 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
11243 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
11244 ; GFX940-TGSPLIT-NEXT: s_endpgm
11246 ; GFX11-WGP-LABEL: flat_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
11247 ; GFX11-WGP: ; %bb.0: ; %entry
11248 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
11249 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11250 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
11251 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
11252 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
11253 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
11254 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
11255 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
11256 ; GFX11-WGP-NEXT: buffer_gl0_inv
11257 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11258 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
11259 ; GFX11-WGP-NEXT: s_endpgm
11261 ; GFX11-CU-LABEL: flat_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
11262 ; GFX11-CU: ; %bb.0: ; %entry
11263 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
11264 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
11265 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
11266 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
11267 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
11268 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11269 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
11270 ; GFX11-CU-NEXT: s_endpgm
11271 ptr %out, i32 %in, i32 %old) {
11273 %gep = getelementptr i32, ptr %out, i32 4
11274 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acq_rel acquire
11275 %val0 = extractvalue { i32, i1 } %val, 0
11276 store i32 %val0, ptr %out, align 4
11280 define amdgpu_kernel void @flat_workgroup_one_as_seq_cst_acquire_ret_cmpxchg(
11281 ; GFX7-LABEL: flat_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
11282 ; GFX7: ; %bb.0: ; %entry
11283 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11284 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
11285 ; GFX7-NEXT: s_add_u32 s4, s0, 16
11286 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
11287 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
11288 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
11289 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
11290 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
11291 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11292 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
11293 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
11294 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11295 ; GFX7-NEXT: flat_store_dword v[0:1], v2
11296 ; GFX7-NEXT: s_endpgm
11298 ; GFX10-WGP-LABEL: flat_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
11299 ; GFX10-WGP: ; %bb.0: ; %entry
11300 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11301 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11302 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
11303 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
11304 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
11305 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
11306 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
11307 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
11308 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
11309 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
11310 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11311 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
11312 ; GFX10-WGP-NEXT: buffer_gl0_inv
11313 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
11314 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
11315 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11316 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
11317 ; GFX10-WGP-NEXT: s_endpgm
11319 ; GFX10-CU-LABEL: flat_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
11320 ; GFX10-CU: ; %bb.0: ; %entry
11321 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11322 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
11323 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
11324 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
11325 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
11326 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
11327 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
11328 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
11329 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11330 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
11331 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
11332 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11333 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
11334 ; GFX10-CU-NEXT: s_endpgm
11336 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
11337 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
11338 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11339 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
11340 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
11341 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
11342 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
11343 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
11344 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
11345 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
11346 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11347 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
11348 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
11349 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11350 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
11351 ; SKIP-CACHE-INV-NEXT: s_endpgm
11353 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
11354 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
11355 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11356 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11357 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
11358 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
11359 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
11360 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11361 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
11362 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
11364 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
11365 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
11366 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11367 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11368 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
11369 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
11370 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11371 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
11372 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11373 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
11374 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
11375 ; GFX90A-TGSPLIT-NEXT: s_endpgm
11377 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
11378 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
11379 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11380 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11381 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
11382 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
11383 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
11384 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11385 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
11386 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
11388 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
11389 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
11390 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11391 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11392 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
11393 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
11394 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11395 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
11396 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11397 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
11398 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
11399 ; GFX940-TGSPLIT-NEXT: s_endpgm
11401 ; GFX11-WGP-LABEL: flat_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
11402 ; GFX11-WGP: ; %bb.0: ; %entry
11403 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
11404 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11405 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
11406 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
11407 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
11408 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
11409 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
11410 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
11411 ; GFX11-WGP-NEXT: buffer_gl0_inv
11412 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11413 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
11414 ; GFX11-WGP-NEXT: s_endpgm
11416 ; GFX11-CU-LABEL: flat_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
11417 ; GFX11-CU: ; %bb.0: ; %entry
11418 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
11419 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
11420 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
11421 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
11422 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
11423 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11424 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
11425 ; GFX11-CU-NEXT: s_endpgm
11426 ptr %out, i32 %in, i32 %old) {
11428 %gep = getelementptr i32, ptr %out, i32 4
11429 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") seq_cst acquire
11430 %val0 = extractvalue { i32, i1 } %val, 0
11431 store i32 %val0, ptr %out, align 4
11435 define amdgpu_kernel void @flat_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg(
11436 ; GFX7-LABEL: flat_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
11437 ; GFX7: ; %bb.0: ; %entry
11438 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11439 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
11440 ; GFX7-NEXT: s_add_u32 s4, s0, 16
11441 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
11442 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
11443 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
11444 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
11445 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
11446 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11447 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
11448 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
11449 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11450 ; GFX7-NEXT: flat_store_dword v[0:1], v2
11451 ; GFX7-NEXT: s_endpgm
11453 ; GFX10-WGP-LABEL: flat_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
11454 ; GFX10-WGP: ; %bb.0: ; %entry
11455 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11456 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11457 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
11458 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
11459 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
11460 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
11461 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
11462 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
11463 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
11464 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
11465 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11466 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
11467 ; GFX10-WGP-NEXT: buffer_gl0_inv
11468 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
11469 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
11470 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11471 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
11472 ; GFX10-WGP-NEXT: s_endpgm
11474 ; GFX10-CU-LABEL: flat_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
11475 ; GFX10-CU: ; %bb.0: ; %entry
11476 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11477 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
11478 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
11479 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
11480 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
11481 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
11482 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
11483 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
11484 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11485 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
11486 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
11487 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11488 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
11489 ; GFX10-CU-NEXT: s_endpgm
11491 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
11492 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
11493 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11494 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
11495 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
11496 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
11497 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
11498 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
11499 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
11500 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
11501 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11502 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
11503 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
11504 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11505 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
11506 ; SKIP-CACHE-INV-NEXT: s_endpgm
11508 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
11509 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
11510 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11511 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11512 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
11513 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
11514 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
11515 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11516 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
11517 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
11519 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
11520 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
11521 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11522 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11523 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
11524 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
11525 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11526 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
11527 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11528 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
11529 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
11530 ; GFX90A-TGSPLIT-NEXT: s_endpgm
11532 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
11533 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
11534 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11535 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11536 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
11537 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
11538 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
11539 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11540 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
11541 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
11543 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
11544 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
11545 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11546 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11547 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
11548 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
11549 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11550 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
11551 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11552 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
11553 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
11554 ; GFX940-TGSPLIT-NEXT: s_endpgm
11556 ; GFX11-WGP-LABEL: flat_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
11557 ; GFX11-WGP: ; %bb.0: ; %entry
11558 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
11559 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11560 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
11561 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
11562 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
11563 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
11564 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
11565 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
11566 ; GFX11-WGP-NEXT: buffer_gl0_inv
11567 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11568 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
11569 ; GFX11-WGP-NEXT: s_endpgm
11571 ; GFX11-CU-LABEL: flat_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
11572 ; GFX11-CU: ; %bb.0: ; %entry
11573 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
11574 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
11575 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
11576 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
11577 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
11578 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11579 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
11580 ; GFX11-CU-NEXT: s_endpgm
11581 ptr %out, i32 %in, i32 %old) {
11583 %gep = getelementptr i32, ptr %out, i32 4
11584 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") monotonic seq_cst
11585 %val0 = extractvalue { i32, i1 } %val, 0
11586 store i32 %val0, ptr %out, align 4
11590 define amdgpu_kernel void @flat_workgroup_one_as_acquire_seq_cst_ret_cmpxchg(
11591 ; GFX7-LABEL: flat_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
11592 ; GFX7: ; %bb.0: ; %entry
11593 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11594 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
11595 ; GFX7-NEXT: s_add_u32 s4, s0, 16
11596 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
11597 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
11598 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
11599 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
11600 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
11601 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11602 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
11603 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
11604 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11605 ; GFX7-NEXT: flat_store_dword v[0:1], v2
11606 ; GFX7-NEXT: s_endpgm
11608 ; GFX10-WGP-LABEL: flat_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
11609 ; GFX10-WGP: ; %bb.0: ; %entry
11610 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11611 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11612 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
11613 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
11614 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
11615 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
11616 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
11617 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
11618 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
11619 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
11620 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11621 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
11622 ; GFX10-WGP-NEXT: buffer_gl0_inv
11623 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
11624 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
11625 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11626 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
11627 ; GFX10-WGP-NEXT: s_endpgm
11629 ; GFX10-CU-LABEL: flat_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
11630 ; GFX10-CU: ; %bb.0: ; %entry
11631 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11632 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
11633 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
11634 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
11635 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
11636 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
11637 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
11638 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
11639 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11640 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
11641 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
11642 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11643 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
11644 ; GFX10-CU-NEXT: s_endpgm
11646 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
11647 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
11648 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11649 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
11650 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
11651 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
11652 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
11653 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
11654 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
11655 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
11656 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11657 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
11658 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
11659 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11660 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
11661 ; SKIP-CACHE-INV-NEXT: s_endpgm
11663 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
11664 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
11665 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11666 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11667 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
11668 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
11669 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
11670 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11671 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
11672 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
11674 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
11675 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
11676 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11677 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11678 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
11679 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
11680 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11681 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
11682 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11683 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
11684 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
11685 ; GFX90A-TGSPLIT-NEXT: s_endpgm
11687 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
11688 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
11689 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11690 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11691 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
11692 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
11693 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
11694 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11695 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
11696 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
11698 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
11699 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
11700 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11701 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11702 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
11703 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
11704 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11705 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
11706 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11707 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
11708 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
11709 ; GFX940-TGSPLIT-NEXT: s_endpgm
11711 ; GFX11-WGP-LABEL: flat_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
11712 ; GFX11-WGP: ; %bb.0: ; %entry
11713 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
11714 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11715 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
11716 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
11717 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
11718 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
11719 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
11720 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
11721 ; GFX11-WGP-NEXT: buffer_gl0_inv
11722 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11723 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
11724 ; GFX11-WGP-NEXT: s_endpgm
11726 ; GFX11-CU-LABEL: flat_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
11727 ; GFX11-CU: ; %bb.0: ; %entry
11728 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
11729 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
11730 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
11731 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
11732 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
11733 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11734 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
11735 ; GFX11-CU-NEXT: s_endpgm
11736 ptr %out, i32 %in, i32 %old) {
11738 %gep = getelementptr i32, ptr %out, i32 4
11739 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acquire seq_cst
11740 %val0 = extractvalue { i32, i1 } %val, 0
11741 store i32 %val0, ptr %out, align 4
11745 define amdgpu_kernel void @flat_workgroup_one_as_release_seq_cst_ret_cmpxchg(
11746 ; GFX7-LABEL: flat_workgroup_one_as_release_seq_cst_ret_cmpxchg:
11747 ; GFX7: ; %bb.0: ; %entry
11748 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11749 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
11750 ; GFX7-NEXT: s_add_u32 s4, s0, 16
11751 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
11752 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
11753 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
11754 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
11755 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
11756 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11757 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
11758 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
11759 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11760 ; GFX7-NEXT: flat_store_dword v[0:1], v2
11761 ; GFX7-NEXT: s_endpgm
11763 ; GFX10-WGP-LABEL: flat_workgroup_one_as_release_seq_cst_ret_cmpxchg:
11764 ; GFX10-WGP: ; %bb.0: ; %entry
11765 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11766 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11767 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
11768 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
11769 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
11770 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
11771 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
11772 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
11773 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
11774 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
11775 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11776 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
11777 ; GFX10-WGP-NEXT: buffer_gl0_inv
11778 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
11779 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
11780 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11781 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
11782 ; GFX10-WGP-NEXT: s_endpgm
11784 ; GFX10-CU-LABEL: flat_workgroup_one_as_release_seq_cst_ret_cmpxchg:
11785 ; GFX10-CU: ; %bb.0: ; %entry
11786 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11787 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
11788 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
11789 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
11790 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
11791 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
11792 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
11793 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
11794 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11795 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
11796 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
11797 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11798 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
11799 ; GFX10-CU-NEXT: s_endpgm
11801 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_release_seq_cst_ret_cmpxchg:
11802 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
11803 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11804 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
11805 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
11806 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
11807 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
11808 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
11809 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
11810 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
11811 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11812 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
11813 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
11814 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11815 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
11816 ; SKIP-CACHE-INV-NEXT: s_endpgm
11818 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_release_seq_cst_ret_cmpxchg:
11819 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
11820 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11821 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11822 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
11823 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
11824 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
11825 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11826 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
11827 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
11829 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_release_seq_cst_ret_cmpxchg:
11830 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
11831 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11832 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11833 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
11834 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
11835 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11836 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
11837 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11838 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
11839 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
11840 ; GFX90A-TGSPLIT-NEXT: s_endpgm
11842 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_release_seq_cst_ret_cmpxchg:
11843 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
11844 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11845 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11846 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
11847 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
11848 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
11849 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11850 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
11851 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
11853 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_release_seq_cst_ret_cmpxchg:
11854 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
11855 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11856 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11857 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
11858 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
11859 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11860 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
11861 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11862 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
11863 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
11864 ; GFX940-TGSPLIT-NEXT: s_endpgm
11866 ; GFX11-WGP-LABEL: flat_workgroup_one_as_release_seq_cst_ret_cmpxchg:
11867 ; GFX11-WGP: ; %bb.0: ; %entry
11868 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
11869 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11870 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
11871 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
11872 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
11873 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
11874 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
11875 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
11876 ; GFX11-WGP-NEXT: buffer_gl0_inv
11877 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11878 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
11879 ; GFX11-WGP-NEXT: s_endpgm
11881 ; GFX11-CU-LABEL: flat_workgroup_one_as_release_seq_cst_ret_cmpxchg:
11882 ; GFX11-CU: ; %bb.0: ; %entry
11883 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
11884 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
11885 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
11886 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
11887 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
11888 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11889 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
11890 ; GFX11-CU-NEXT: s_endpgm
11891 ptr %out, i32 %in, i32 %old) {
11893 %gep = getelementptr i32, ptr %out, i32 4
11894 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") release seq_cst
11895 %val0 = extractvalue { i32, i1 } %val, 0
11896 store i32 %val0, ptr %out, align 4
11900 define amdgpu_kernel void @flat_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg(
11901 ; GFX7-LABEL: flat_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
11902 ; GFX7: ; %bb.0: ; %entry
11903 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11904 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
11905 ; GFX7-NEXT: s_add_u32 s4, s0, 16
11906 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
11907 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
11908 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
11909 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
11910 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
11911 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11912 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
11913 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
11914 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11915 ; GFX7-NEXT: flat_store_dword v[0:1], v2
11916 ; GFX7-NEXT: s_endpgm
11918 ; GFX10-WGP-LABEL: flat_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
11919 ; GFX10-WGP: ; %bb.0: ; %entry
11920 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11921 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11922 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
11923 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
11924 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
11925 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
11926 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
11927 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
11928 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
11929 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
11930 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11931 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
11932 ; GFX10-WGP-NEXT: buffer_gl0_inv
11933 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
11934 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
11935 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11936 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
11937 ; GFX10-WGP-NEXT: s_endpgm
11939 ; GFX10-CU-LABEL: flat_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
11940 ; GFX10-CU: ; %bb.0: ; %entry
11941 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11942 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
11943 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
11944 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
11945 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
11946 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
11947 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
11948 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
11949 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11950 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
11951 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
11952 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11953 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
11954 ; GFX10-CU-NEXT: s_endpgm
11956 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
11957 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
11958 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
11959 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
11960 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
11961 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
11962 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
11963 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
11964 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
11965 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
11966 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
11967 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
11968 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
11969 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11970 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
11971 ; SKIP-CACHE-INV-NEXT: s_endpgm
11973 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
11974 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
11975 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11976 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11977 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
11978 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
11979 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
11980 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11981 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
11982 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
11984 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
11985 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
11986 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
11987 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11988 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
11989 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
11990 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11991 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
11992 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11993 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
11994 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
11995 ; GFX90A-TGSPLIT-NEXT: s_endpgm
11997 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
11998 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
11999 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
12000 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12001 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
12002 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
12003 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
12004 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12005 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
12006 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
12008 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
12009 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
12010 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
12011 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12012 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
12013 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
12014 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12015 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
12016 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12017 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
12018 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
12019 ; GFX940-TGSPLIT-NEXT: s_endpgm
12021 ; GFX11-WGP-LABEL: flat_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
12022 ; GFX11-WGP: ; %bb.0: ; %entry
12023 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
12024 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
12025 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
12026 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
12027 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
12028 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
12029 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
12030 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
12031 ; GFX11-WGP-NEXT: buffer_gl0_inv
12032 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
12033 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
12034 ; GFX11-WGP-NEXT: s_endpgm
12036 ; GFX11-CU-LABEL: flat_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
12037 ; GFX11-CU: ; %bb.0: ; %entry
12038 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
12039 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
12040 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
12041 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
12042 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
12043 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12044 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
12045 ; GFX11-CU-NEXT: s_endpgm
12046 ptr %out, i32 %in, i32 %old) {
12048 %gep = getelementptr i32, ptr %out, i32 4
12049 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acq_rel seq_cst
12050 %val0 = extractvalue { i32, i1 } %val, 0
12051 store i32 %val0, ptr %out, align 4
12055 define amdgpu_kernel void @flat_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg(
12056 ; GFX7-LABEL: flat_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
12057 ; GFX7: ; %bb.0: ; %entry
12058 ; GFX7-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12059 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
12060 ; GFX7-NEXT: s_add_u32 s4, s0, 16
12061 ; GFX7-NEXT: s_addc_u32 s5, s1, 0
12062 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
12063 ; GFX7-NEXT: v_mov_b32_e32 v2, s2
12064 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
12065 ; GFX7-NEXT: v_mov_b32_e32 v3, s3
12066 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
12067 ; GFX7-NEXT: v_mov_b32_e32 v0, s0
12068 ; GFX7-NEXT: v_mov_b32_e32 v1, s1
12069 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12070 ; GFX7-NEXT: flat_store_dword v[0:1], v2
12071 ; GFX7-NEXT: s_endpgm
12073 ; GFX10-WGP-LABEL: flat_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
12074 ; GFX10-WGP: ; %bb.0: ; %entry
12075 ; GFX10-WGP-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12076 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
12077 ; GFX10-WGP-NEXT: s_add_u32 s4, s0, 16
12078 ; GFX10-WGP-NEXT: s_addc_u32 s5, s1, 0
12079 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
12080 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s2
12081 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
12082 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s3
12083 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
12084 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
12085 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
12086 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
12087 ; GFX10-WGP-NEXT: buffer_gl0_inv
12088 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s0
12089 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s1
12090 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
12091 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
12092 ; GFX10-WGP-NEXT: s_endpgm
12094 ; GFX10-CU-LABEL: flat_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
12095 ; GFX10-CU: ; %bb.0: ; %entry
12096 ; GFX10-CU-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12097 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
12098 ; GFX10-CU-NEXT: s_add_u32 s4, s0, 16
12099 ; GFX10-CU-NEXT: s_addc_u32 s5, s1, 0
12100 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
12101 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s2
12102 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
12103 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s3
12104 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
12105 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s0
12106 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s1
12107 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12108 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
12109 ; GFX10-CU-NEXT: s_endpgm
12111 ; SKIP-CACHE-INV-LABEL: flat_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
12112 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
12113 ; SKIP-CACHE-INV-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
12114 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
12115 ; SKIP-CACHE-INV-NEXT: s_add_u32 s4, s0, 16
12116 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s5, s1, 0
12117 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
12118 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
12119 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s5
12120 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, s3
12121 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
12122 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
12123 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
12124 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12125 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
12126 ; SKIP-CACHE-INV-NEXT: s_endpgm
12128 ; GFX90A-NOTTGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
12129 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
12130 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12131 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12132 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
12133 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
12134 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
12135 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12136 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
12137 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
12139 ; GFX90A-TGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
12140 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
12141 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[4:5], 0x0
12142 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12143 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[0:1], s[0:1] op_sel:[0,1]
12144 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[2:3], s[2:3], s[2:3] op_sel:[0,1]
12145 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12146 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
12147 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12148 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
12149 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
12150 ; GFX90A-TGSPLIT-NEXT: s_endpgm
12152 ; GFX940-NOTTGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
12153 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
12154 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
12155 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12156 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
12157 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
12158 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
12159 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12160 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
12161 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
12163 ; GFX940-TGSPLIT-LABEL: flat_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
12164 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
12165 ; GFX940-TGSPLIT-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
12166 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12167 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
12168 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[2:3], s[2:3]
12169 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12170 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
12171 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12172 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
12173 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
12174 ; GFX940-TGSPLIT-NEXT: s_endpgm
12176 ; GFX11-WGP-LABEL: flat_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
12177 ; GFX11-WGP: ; %bb.0: ; %entry
12178 ; GFX11-WGP-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
12179 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
12180 ; GFX11-WGP-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
12181 ; GFX11-WGP-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
12182 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
12183 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
12184 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
12185 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
12186 ; GFX11-WGP-NEXT: buffer_gl0_inv
12187 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
12188 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
12189 ; GFX11-WGP-NEXT: s_endpgm
12191 ; GFX11-CU-LABEL: flat_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
12192 ; GFX11-CU: ; %bb.0: ; %entry
12193 ; GFX11-CU-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
12194 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
12195 ; GFX11-CU-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
12196 ; GFX11-CU-NEXT: v_dual_mov_b32 v2, s2 :: v_dual_mov_b32 v3, s3
12197 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
12198 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12199 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
12200 ; GFX11-CU-NEXT: s_endpgm
12201 ptr %out, i32 %in, i32 %old) {
12203 %gep = getelementptr i32, ptr %out, i32 4
12204 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("workgroup-one-as") seq_cst seq_cst
12205 %val0 = extractvalue { i32, i1 } %val, 0
12206 store i32 %val0, ptr %out, align 4