1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -O0 -mcpu=gfx700 < %s | FileCheck --check-prefixes=GFX7 %s
3 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -O0 -mcpu=gfx1010 < %s | FileCheck --check-prefixes=GFX10-WGP %s
4 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -O0 -mcpu=gfx1010 -mattr=+cumode < %s | FileCheck --check-prefixes=GFX10-CU %s
5 ; RUN: llc -mtriple=amdgcn-amd-amdpal -O0 -mcpu=gfx700 -amdgcn-skip-cache-invalidations < %s | FileCheck --check-prefixes=SKIP-CACHE-INV %s
6 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -O0 -mcpu=gfx90a < %s | FileCheck -check-prefixes=GFX90A-NOTTGSPLIT %s
7 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -O0 -mcpu=gfx90a -mattr=+tgsplit < %s | FileCheck -check-prefixes=GFX90A-TGSPLIT %s
8 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -O0 -mcpu=gfx940 < %s | FileCheck -check-prefixes=GFX940-NOTTGSPLIT %s
9 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -O0 -mcpu=gfx940 -mattr=+tgsplit < %s | FileCheck -check-prefixes=GFX940-TGSPLIT %s
10 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -O0 -mcpu=gfx1100 < %s | FileCheck --check-prefixes=GFX11-WGP %s
11 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -O0 -mcpu=gfx1100 -mattr=+cumode < %s | FileCheck --check-prefixes=GFX11-CU %s
12 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -O0 -mcpu=gfx1200 < %s | FileCheck --check-prefixes=GFX12-WGP %s
13 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -O0 -mcpu=gfx1200 -mattr=+cumode < %s | FileCheck --check-prefixes=GFX12-CU %s
15 define amdgpu_kernel void @flat_singlethread_unordered_load(
16 ; GFX7-LABEL: flat_singlethread_unordered_load:
17 ; GFX7: ; %bb.0: ; %entry
18 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
19 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
20 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
21 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
22 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
23 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
24 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
25 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
26 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
27 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
28 ; GFX7-NEXT: flat_store_dword v[0:1], v2
31 ; GFX10-WGP-LABEL: flat_singlethread_unordered_load:
32 ; GFX10-WGP: ; %bb.0: ; %entry
33 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
34 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
35 ; GFX10-WGP-NEXT: s_nop 0
36 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
37 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
38 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
39 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
40 ; GFX10-WGP-NEXT: flat_load_dword v2, v[0:1]
41 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
42 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
43 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
44 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
45 ; GFX10-WGP-NEXT: s_endpgm
47 ; GFX10-CU-LABEL: flat_singlethread_unordered_load:
48 ; GFX10-CU: ; %bb.0: ; %entry
49 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
50 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
51 ; GFX10-CU-NEXT: s_nop 0
52 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
53 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
54 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
55 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
56 ; GFX10-CU-NEXT: flat_load_dword v2, v[0:1]
57 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
58 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
59 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
60 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
61 ; GFX10-CU-NEXT: s_endpgm
63 ; SKIP-CACHE-INV-LABEL: flat_singlethread_unordered_load:
64 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
65 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
66 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
67 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
68 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
69 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
70 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
71 ; SKIP-CACHE-INV-NEXT: flat_load_dword v2, v[0:1]
72 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
73 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
74 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
75 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
76 ; SKIP-CACHE-INV-NEXT: s_endpgm
78 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_unordered_load:
79 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
80 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
81 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
82 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
83 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
84 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
85 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
86 ; GFX90A-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1]
87 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
88 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
89 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
90 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
92 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_unordered_load:
93 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
94 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
95 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
96 ; GFX90A-TGSPLIT-NEXT: s_nop 0
97 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
98 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
99 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
100 ; GFX90A-TGSPLIT-NEXT: flat_load_dword v2, v[0:1]
101 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
102 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
103 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
104 ; GFX90A-TGSPLIT-NEXT: s_endpgm
106 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_unordered_load:
107 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
108 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
109 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
110 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
111 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x8
112 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
113 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
114 ; GFX940-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1]
115 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
116 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
117 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
118 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
120 ; GFX940-TGSPLIT-LABEL: flat_singlethread_unordered_load:
121 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
122 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
123 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
124 ; GFX940-TGSPLIT-NEXT: s_nop 0
125 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x8
126 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
127 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
128 ; GFX940-TGSPLIT-NEXT: flat_load_dword v2, v[0:1]
129 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
130 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
131 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
132 ; GFX940-TGSPLIT-NEXT: s_endpgm
134 ; GFX11-WGP-LABEL: flat_singlethread_unordered_load:
135 ; GFX11-WGP: ; %bb.0: ; %entry
136 ; GFX11-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
137 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
138 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
139 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
140 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
141 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
142 ; GFX11-WGP-NEXT: flat_load_b32 v2, v[0:1]
143 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
144 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
145 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
146 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
147 ; GFX11-WGP-NEXT: s_endpgm
149 ; GFX11-CU-LABEL: flat_singlethread_unordered_load:
150 ; GFX11-CU: ; %bb.0: ; %entry
151 ; GFX11-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
152 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
153 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
154 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
155 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
156 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
157 ; GFX11-CU-NEXT: flat_load_b32 v2, v[0:1]
158 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
159 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
160 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
161 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
162 ; GFX11-CU-NEXT: s_endpgm
164 ; GFX12-WGP-LABEL: flat_singlethread_unordered_load:
165 ; GFX12-WGP: ; %bb.0: ; %entry
166 ; GFX12-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
167 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
168 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
169 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
170 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
171 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
172 ; GFX12-WGP-NEXT: flat_load_b32 v2, v[0:1]
173 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
174 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
175 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
176 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
177 ; GFX12-WGP-NEXT: s_endpgm
179 ; GFX12-CU-LABEL: flat_singlethread_unordered_load:
180 ; GFX12-CU: ; %bb.0: ; %entry
181 ; GFX12-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
182 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
183 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
184 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
185 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
186 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
187 ; GFX12-CU-NEXT: flat_load_b32 v2, v[0:1]
188 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
189 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
190 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
191 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
192 ; GFX12-CU-NEXT: s_endpgm
195 %val = load atomic i32, ptr %in syncscope("singlethread") unordered, align 4
196 store i32 %val, ptr %out
200 define amdgpu_kernel void @flat_singlethread_monotonic_load(
201 ; GFX7-LABEL: flat_singlethread_monotonic_load:
202 ; GFX7: ; %bb.0: ; %entry
203 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
204 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
205 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
206 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
207 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
208 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
209 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
210 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
211 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
212 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
213 ; GFX7-NEXT: flat_store_dword v[0:1], v2
214 ; GFX7-NEXT: s_endpgm
216 ; GFX10-WGP-LABEL: flat_singlethread_monotonic_load:
217 ; GFX10-WGP: ; %bb.0: ; %entry
218 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
219 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
220 ; GFX10-WGP-NEXT: s_nop 0
221 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
222 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
223 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
224 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
225 ; GFX10-WGP-NEXT: flat_load_dword v2, v[0:1]
226 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
227 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
228 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
229 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
230 ; GFX10-WGP-NEXT: s_endpgm
232 ; GFX10-CU-LABEL: flat_singlethread_monotonic_load:
233 ; GFX10-CU: ; %bb.0: ; %entry
234 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
235 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
236 ; GFX10-CU-NEXT: s_nop 0
237 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
238 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
239 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
240 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
241 ; GFX10-CU-NEXT: flat_load_dword v2, v[0:1]
242 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
243 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
244 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
245 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
246 ; GFX10-CU-NEXT: s_endpgm
248 ; SKIP-CACHE-INV-LABEL: flat_singlethread_monotonic_load:
249 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
250 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
251 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
252 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
253 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
254 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
255 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
256 ; SKIP-CACHE-INV-NEXT: flat_load_dword v2, v[0:1]
257 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
258 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
259 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
260 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
261 ; SKIP-CACHE-INV-NEXT: s_endpgm
263 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_monotonic_load:
264 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
265 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
266 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
267 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
268 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
269 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
270 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
271 ; GFX90A-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1]
272 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
273 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
274 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
275 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
277 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_monotonic_load:
278 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
279 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
280 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
281 ; GFX90A-TGSPLIT-NEXT: s_nop 0
282 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
283 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
284 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
285 ; GFX90A-TGSPLIT-NEXT: flat_load_dword v2, v[0:1]
286 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
287 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
288 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
289 ; GFX90A-TGSPLIT-NEXT: s_endpgm
291 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_monotonic_load:
292 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
293 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
294 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
295 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
296 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x8
297 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
298 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
299 ; GFX940-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1]
300 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
301 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
302 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
303 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
305 ; GFX940-TGSPLIT-LABEL: flat_singlethread_monotonic_load:
306 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
307 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
308 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
309 ; GFX940-TGSPLIT-NEXT: s_nop 0
310 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x8
311 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
312 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
313 ; GFX940-TGSPLIT-NEXT: flat_load_dword v2, v[0:1]
314 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
315 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
316 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
317 ; GFX940-TGSPLIT-NEXT: s_endpgm
319 ; GFX11-WGP-LABEL: flat_singlethread_monotonic_load:
320 ; GFX11-WGP: ; %bb.0: ; %entry
321 ; GFX11-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
322 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
323 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
324 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
325 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
326 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
327 ; GFX11-WGP-NEXT: flat_load_b32 v2, v[0:1]
328 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
329 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
330 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
331 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
332 ; GFX11-WGP-NEXT: s_endpgm
334 ; GFX11-CU-LABEL: flat_singlethread_monotonic_load:
335 ; GFX11-CU: ; %bb.0: ; %entry
336 ; GFX11-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
337 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
338 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
339 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
340 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
341 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
342 ; GFX11-CU-NEXT: flat_load_b32 v2, v[0:1]
343 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
344 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
345 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
346 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
347 ; GFX11-CU-NEXT: s_endpgm
349 ; GFX12-WGP-LABEL: flat_singlethread_monotonic_load:
350 ; GFX12-WGP: ; %bb.0: ; %entry
351 ; GFX12-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
352 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
353 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
354 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
355 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
356 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
357 ; GFX12-WGP-NEXT: flat_load_b32 v2, v[0:1]
358 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
359 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
360 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
361 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
362 ; GFX12-WGP-NEXT: s_endpgm
364 ; GFX12-CU-LABEL: flat_singlethread_monotonic_load:
365 ; GFX12-CU: ; %bb.0: ; %entry
366 ; GFX12-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
367 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
368 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
369 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
370 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
371 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
372 ; GFX12-CU-NEXT: flat_load_b32 v2, v[0:1]
373 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
374 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
375 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
376 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
377 ; GFX12-CU-NEXT: s_endpgm
380 %val = load atomic i32, ptr %in syncscope("singlethread") monotonic, align 4
381 store i32 %val, ptr %out
385 define amdgpu_kernel void @flat_singlethread_acquire_load(
386 ; GFX7-LABEL: flat_singlethread_acquire_load:
387 ; GFX7: ; %bb.0: ; %entry
388 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
389 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
390 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
391 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
392 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
393 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
394 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
395 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
396 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
397 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
398 ; GFX7-NEXT: flat_store_dword v[0:1], v2
399 ; GFX7-NEXT: s_endpgm
401 ; GFX10-WGP-LABEL: flat_singlethread_acquire_load:
402 ; GFX10-WGP: ; %bb.0: ; %entry
403 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
404 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
405 ; GFX10-WGP-NEXT: s_nop 0
406 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
407 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
408 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
409 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
410 ; GFX10-WGP-NEXT: flat_load_dword v2, v[0:1]
411 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
412 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
413 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
414 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
415 ; GFX10-WGP-NEXT: s_endpgm
417 ; GFX10-CU-LABEL: flat_singlethread_acquire_load:
418 ; GFX10-CU: ; %bb.0: ; %entry
419 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
420 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
421 ; GFX10-CU-NEXT: s_nop 0
422 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
423 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
424 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
425 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
426 ; GFX10-CU-NEXT: flat_load_dword v2, v[0:1]
427 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
428 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
429 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
430 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
431 ; GFX10-CU-NEXT: s_endpgm
433 ; SKIP-CACHE-INV-LABEL: flat_singlethread_acquire_load:
434 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
435 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
436 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
437 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
438 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
439 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
440 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
441 ; SKIP-CACHE-INV-NEXT: flat_load_dword v2, v[0:1]
442 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
443 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
444 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
445 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
446 ; SKIP-CACHE-INV-NEXT: s_endpgm
448 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_acquire_load:
449 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
450 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
451 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
452 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
453 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
454 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
455 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
456 ; GFX90A-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1]
457 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
458 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
459 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
460 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
462 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_acquire_load:
463 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
464 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
465 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
466 ; GFX90A-TGSPLIT-NEXT: s_nop 0
467 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
468 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
469 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
470 ; GFX90A-TGSPLIT-NEXT: flat_load_dword v2, v[0:1]
471 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
472 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
473 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
474 ; GFX90A-TGSPLIT-NEXT: s_endpgm
476 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_acquire_load:
477 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
478 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
479 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
480 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
481 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x8
482 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
483 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
484 ; GFX940-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1]
485 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
486 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
487 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
488 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
490 ; GFX940-TGSPLIT-LABEL: flat_singlethread_acquire_load:
491 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
492 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
493 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
494 ; GFX940-TGSPLIT-NEXT: s_nop 0
495 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x8
496 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
497 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
498 ; GFX940-TGSPLIT-NEXT: flat_load_dword v2, v[0:1]
499 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
500 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
501 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
502 ; GFX940-TGSPLIT-NEXT: s_endpgm
504 ; GFX11-WGP-LABEL: flat_singlethread_acquire_load:
505 ; GFX11-WGP: ; %bb.0: ; %entry
506 ; GFX11-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
507 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
508 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
509 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
510 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
511 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
512 ; GFX11-WGP-NEXT: flat_load_b32 v2, v[0:1]
513 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
514 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
515 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
516 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
517 ; GFX11-WGP-NEXT: s_endpgm
519 ; GFX11-CU-LABEL: flat_singlethread_acquire_load:
520 ; GFX11-CU: ; %bb.0: ; %entry
521 ; GFX11-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
522 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
523 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
524 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
525 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
526 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
527 ; GFX11-CU-NEXT: flat_load_b32 v2, v[0:1]
528 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
529 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
530 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
531 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
532 ; GFX11-CU-NEXT: s_endpgm
534 ; GFX12-WGP-LABEL: flat_singlethread_acquire_load:
535 ; GFX12-WGP: ; %bb.0: ; %entry
536 ; GFX12-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
537 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
538 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
539 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
540 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
541 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
542 ; GFX12-WGP-NEXT: flat_load_b32 v2, v[0:1]
543 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
544 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
545 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
546 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
547 ; GFX12-WGP-NEXT: s_endpgm
549 ; GFX12-CU-LABEL: flat_singlethread_acquire_load:
550 ; GFX12-CU: ; %bb.0: ; %entry
551 ; GFX12-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
552 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
553 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
554 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
555 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
556 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
557 ; GFX12-CU-NEXT: flat_load_b32 v2, v[0:1]
558 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
559 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
560 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
561 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
562 ; GFX12-CU-NEXT: s_endpgm
565 %val = load atomic i32, ptr %in syncscope("singlethread") acquire, align 4
566 store i32 %val, ptr %out
570 define amdgpu_kernel void @flat_singlethread_seq_cst_load(
571 ; GFX7-LABEL: flat_singlethread_seq_cst_load:
572 ; GFX7: ; %bb.0: ; %entry
573 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
574 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
575 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
576 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
577 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
578 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
579 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
580 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
581 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
582 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
583 ; GFX7-NEXT: flat_store_dword v[0:1], v2
584 ; GFX7-NEXT: s_endpgm
586 ; GFX10-WGP-LABEL: flat_singlethread_seq_cst_load:
587 ; GFX10-WGP: ; %bb.0: ; %entry
588 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
589 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
590 ; GFX10-WGP-NEXT: s_nop 0
591 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
592 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
593 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
594 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
595 ; GFX10-WGP-NEXT: flat_load_dword v2, v[0:1]
596 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
597 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
598 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
599 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
600 ; GFX10-WGP-NEXT: s_endpgm
602 ; GFX10-CU-LABEL: flat_singlethread_seq_cst_load:
603 ; GFX10-CU: ; %bb.0: ; %entry
604 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
605 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
606 ; GFX10-CU-NEXT: s_nop 0
607 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
608 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
609 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
610 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
611 ; GFX10-CU-NEXT: flat_load_dword v2, v[0:1]
612 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
613 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
614 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
615 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
616 ; GFX10-CU-NEXT: s_endpgm
618 ; SKIP-CACHE-INV-LABEL: flat_singlethread_seq_cst_load:
619 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
620 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
621 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
622 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
623 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
624 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
625 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
626 ; SKIP-CACHE-INV-NEXT: flat_load_dword v2, v[0:1]
627 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
628 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
629 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
630 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
631 ; SKIP-CACHE-INV-NEXT: s_endpgm
633 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_seq_cst_load:
634 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
635 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
636 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
637 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
638 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
639 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
640 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
641 ; GFX90A-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1]
642 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
643 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
644 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
645 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
647 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_seq_cst_load:
648 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
649 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
650 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
651 ; GFX90A-TGSPLIT-NEXT: s_nop 0
652 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
653 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
654 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
655 ; GFX90A-TGSPLIT-NEXT: flat_load_dword v2, v[0:1]
656 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
657 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
658 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
659 ; GFX90A-TGSPLIT-NEXT: s_endpgm
661 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_seq_cst_load:
662 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
663 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
664 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
665 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
666 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x8
667 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
668 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
669 ; GFX940-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1]
670 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
671 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
672 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
673 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
675 ; GFX940-TGSPLIT-LABEL: flat_singlethread_seq_cst_load:
676 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
677 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
678 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
679 ; GFX940-TGSPLIT-NEXT: s_nop 0
680 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x8
681 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
682 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
683 ; GFX940-TGSPLIT-NEXT: flat_load_dword v2, v[0:1]
684 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
685 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
686 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
687 ; GFX940-TGSPLIT-NEXT: s_endpgm
689 ; GFX11-WGP-LABEL: flat_singlethread_seq_cst_load:
690 ; GFX11-WGP: ; %bb.0: ; %entry
691 ; GFX11-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
692 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
693 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
694 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
695 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
696 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
697 ; GFX11-WGP-NEXT: flat_load_b32 v2, v[0:1]
698 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
699 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
700 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
701 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
702 ; GFX11-WGP-NEXT: s_endpgm
704 ; GFX11-CU-LABEL: flat_singlethread_seq_cst_load:
705 ; GFX11-CU: ; %bb.0: ; %entry
706 ; GFX11-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
707 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
708 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
709 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
710 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
711 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
712 ; GFX11-CU-NEXT: flat_load_b32 v2, v[0:1]
713 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
714 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
715 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
716 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
717 ; GFX11-CU-NEXT: s_endpgm
719 ; GFX12-WGP-LABEL: flat_singlethread_seq_cst_load:
720 ; GFX12-WGP: ; %bb.0: ; %entry
721 ; GFX12-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
722 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
723 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
724 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
725 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
726 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
727 ; GFX12-WGP-NEXT: flat_load_b32 v2, v[0:1]
728 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
729 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
730 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
731 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
732 ; GFX12-WGP-NEXT: s_endpgm
734 ; GFX12-CU-LABEL: flat_singlethread_seq_cst_load:
735 ; GFX12-CU: ; %bb.0: ; %entry
736 ; GFX12-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
737 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
738 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
739 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
740 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
741 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
742 ; GFX12-CU-NEXT: flat_load_b32 v2, v[0:1]
743 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
744 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
745 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
746 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
747 ; GFX12-CU-NEXT: s_endpgm
750 %val = load atomic i32, ptr %in syncscope("singlethread") seq_cst, align 4
751 store i32 %val, ptr %out
755 define amdgpu_kernel void @flat_singlethread_unordered_store(
756 ; GFX7-LABEL: flat_singlethread_unordered_store:
757 ; GFX7: ; %bb.0: ; %entry
758 ; GFX7-NEXT: s_load_dword s4, s[6:7], 0x0
759 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x2
760 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
761 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
762 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
763 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
764 ; GFX7-NEXT: flat_store_dword v[0:1], v2
765 ; GFX7-NEXT: s_endpgm
767 ; GFX10-WGP-LABEL: flat_singlethread_unordered_store:
768 ; GFX10-WGP: ; %bb.0: ; %entry
769 ; GFX10-WGP-NEXT: s_load_dword s4, s[6:7], 0x0
770 ; GFX10-WGP-NEXT: s_nop 0
771 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
772 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
773 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
774 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
775 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s4
776 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
777 ; GFX10-WGP-NEXT: s_endpgm
779 ; GFX10-CU-LABEL: flat_singlethread_unordered_store:
780 ; GFX10-CU: ; %bb.0: ; %entry
781 ; GFX10-CU-NEXT: s_load_dword s4, s[6:7], 0x0
782 ; GFX10-CU-NEXT: s_nop 0
783 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
784 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
785 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
786 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
787 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s4
788 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
789 ; GFX10-CU-NEXT: s_endpgm
791 ; SKIP-CACHE-INV-LABEL: flat_singlethread_unordered_store:
792 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
793 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[2:3], 0x0
794 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[2:3], 0x2
795 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
796 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
797 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
798 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
799 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
800 ; SKIP-CACHE-INV-NEXT: s_endpgm
802 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_unordered_store:
803 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
804 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s4, s[6:7], 0x0
805 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
806 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
807 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
808 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
809 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
810 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
811 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
813 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_unordered_store:
814 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
815 ; GFX90A-TGSPLIT-NEXT: s_load_dword s4, s[6:7], 0x0
816 ; GFX90A-TGSPLIT-NEXT: s_nop 0
817 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
818 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
819 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
820 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
821 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
822 ; GFX90A-TGSPLIT-NEXT: s_endpgm
824 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_unordered_store:
825 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
826 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s0, s[2:3], 0x0
827 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
828 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[2:3], 0x8
829 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
830 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
831 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s0
832 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
833 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
835 ; GFX940-TGSPLIT-LABEL: flat_singlethread_unordered_store:
836 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
837 ; GFX940-TGSPLIT-NEXT: s_load_dword s0, s[2:3], 0x0
838 ; GFX940-TGSPLIT-NEXT: s_nop 0
839 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[2:3], 0x8
840 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
841 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
842 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s0
843 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
844 ; GFX940-TGSPLIT-NEXT: s_endpgm
846 ; GFX11-WGP-LABEL: flat_singlethread_unordered_store:
847 ; GFX11-WGP: ; %bb.0: ; %entry
848 ; GFX11-WGP-NEXT: s_load_b32 s0, s[2:3], 0x0
849 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
850 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
851 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
852 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
853 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
854 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
855 ; GFX11-WGP-NEXT: s_endpgm
857 ; GFX11-CU-LABEL: flat_singlethread_unordered_store:
858 ; GFX11-CU: ; %bb.0: ; %entry
859 ; GFX11-CU-NEXT: s_load_b32 s0, s[2:3], 0x0
860 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
861 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
862 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
863 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
864 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
865 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
866 ; GFX11-CU-NEXT: s_endpgm
868 ; GFX12-WGP-LABEL: flat_singlethread_unordered_store:
869 ; GFX12-WGP: ; %bb.0: ; %entry
870 ; GFX12-WGP-NEXT: s_load_b32 s0, s[2:3], 0x0
871 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
872 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
873 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
874 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
875 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s0
876 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
877 ; GFX12-WGP-NEXT: s_endpgm
879 ; GFX12-CU-LABEL: flat_singlethread_unordered_store:
880 ; GFX12-CU: ; %bb.0: ; %entry
881 ; GFX12-CU-NEXT: s_load_b32 s0, s[2:3], 0x0
882 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
883 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
884 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
885 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
886 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s0
887 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
888 ; GFX12-CU-NEXT: s_endpgm
891 store atomic i32 %in, ptr %out syncscope("singlethread") unordered, align 4
895 define amdgpu_kernel void @flat_singlethread_monotonic_store(
896 ; GFX7-LABEL: flat_singlethread_monotonic_store:
897 ; GFX7: ; %bb.0: ; %entry
898 ; GFX7-NEXT: s_load_dword s4, s[6:7], 0x0
899 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x2
900 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
901 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
902 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
903 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
904 ; GFX7-NEXT: flat_store_dword v[0:1], v2
905 ; GFX7-NEXT: s_endpgm
907 ; GFX10-WGP-LABEL: flat_singlethread_monotonic_store:
908 ; GFX10-WGP: ; %bb.0: ; %entry
909 ; GFX10-WGP-NEXT: s_load_dword s4, s[6:7], 0x0
910 ; GFX10-WGP-NEXT: s_nop 0
911 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
912 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
913 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
914 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
915 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s4
916 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
917 ; GFX10-WGP-NEXT: s_endpgm
919 ; GFX10-CU-LABEL: flat_singlethread_monotonic_store:
920 ; GFX10-CU: ; %bb.0: ; %entry
921 ; GFX10-CU-NEXT: s_load_dword s4, s[6:7], 0x0
922 ; GFX10-CU-NEXT: s_nop 0
923 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
924 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
925 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
926 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
927 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s4
928 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
929 ; GFX10-CU-NEXT: s_endpgm
931 ; SKIP-CACHE-INV-LABEL: flat_singlethread_monotonic_store:
932 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
933 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[2:3], 0x0
934 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[2:3], 0x2
935 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
936 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
937 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
938 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
939 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
940 ; SKIP-CACHE-INV-NEXT: s_endpgm
942 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_monotonic_store:
943 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
944 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s4, s[6:7], 0x0
945 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
946 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
947 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
948 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
949 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
950 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
951 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
953 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_monotonic_store:
954 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
955 ; GFX90A-TGSPLIT-NEXT: s_load_dword s4, s[6:7], 0x0
956 ; GFX90A-TGSPLIT-NEXT: s_nop 0
957 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
958 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
959 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
960 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
961 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
962 ; GFX90A-TGSPLIT-NEXT: s_endpgm
964 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_monotonic_store:
965 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
966 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s0, s[2:3], 0x0
967 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
968 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[2:3], 0x8
969 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
970 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
971 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s0
972 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
973 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
975 ; GFX940-TGSPLIT-LABEL: flat_singlethread_monotonic_store:
976 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
977 ; GFX940-TGSPLIT-NEXT: s_load_dword s0, s[2:3], 0x0
978 ; GFX940-TGSPLIT-NEXT: s_nop 0
979 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[2:3], 0x8
980 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
981 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
982 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s0
983 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
984 ; GFX940-TGSPLIT-NEXT: s_endpgm
986 ; GFX11-WGP-LABEL: flat_singlethread_monotonic_store:
987 ; GFX11-WGP: ; %bb.0: ; %entry
988 ; GFX11-WGP-NEXT: s_load_b32 s0, s[2:3], 0x0
989 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
990 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
991 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
992 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
993 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
994 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
995 ; GFX11-WGP-NEXT: s_endpgm
997 ; GFX11-CU-LABEL: flat_singlethread_monotonic_store:
998 ; GFX11-CU: ; %bb.0: ; %entry
999 ; GFX11-CU-NEXT: s_load_b32 s0, s[2:3], 0x0
1000 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
1001 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1002 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
1003 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
1004 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
1005 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
1006 ; GFX11-CU-NEXT: s_endpgm
1008 ; GFX12-WGP-LABEL: flat_singlethread_monotonic_store:
1009 ; GFX12-WGP: ; %bb.0: ; %entry
1010 ; GFX12-WGP-NEXT: s_load_b32 s0, s[2:3], 0x0
1011 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
1012 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
1013 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
1014 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
1015 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s0
1016 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
1017 ; GFX12-WGP-NEXT: s_endpgm
1019 ; GFX12-CU-LABEL: flat_singlethread_monotonic_store:
1020 ; GFX12-CU: ; %bb.0: ; %entry
1021 ; GFX12-CU-NEXT: s_load_b32 s0, s[2:3], 0x0
1022 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
1023 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
1024 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
1025 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
1026 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s0
1027 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
1028 ; GFX12-CU-NEXT: s_endpgm
1029 i32 %in, ptr %out) {
1031 store atomic i32 %in, ptr %out syncscope("singlethread") monotonic, align 4
1035 define amdgpu_kernel void @flat_singlethread_release_store(
1036 ; GFX7-LABEL: flat_singlethread_release_store:
1037 ; GFX7: ; %bb.0: ; %entry
1038 ; GFX7-NEXT: s_load_dword s4, s[6:7], 0x0
1039 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x2
1040 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1041 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
1042 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
1043 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
1044 ; GFX7-NEXT: flat_store_dword v[0:1], v2
1045 ; GFX7-NEXT: s_endpgm
1047 ; GFX10-WGP-LABEL: flat_singlethread_release_store:
1048 ; GFX10-WGP: ; %bb.0: ; %entry
1049 ; GFX10-WGP-NEXT: s_load_dword s4, s[6:7], 0x0
1050 ; GFX10-WGP-NEXT: s_nop 0
1051 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
1052 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1053 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
1054 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
1055 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s4
1056 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
1057 ; GFX10-WGP-NEXT: s_endpgm
1059 ; GFX10-CU-LABEL: flat_singlethread_release_store:
1060 ; GFX10-CU: ; %bb.0: ; %entry
1061 ; GFX10-CU-NEXT: s_load_dword s4, s[6:7], 0x0
1062 ; GFX10-CU-NEXT: s_nop 0
1063 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
1064 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1065 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
1066 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
1067 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s4
1068 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
1069 ; GFX10-CU-NEXT: s_endpgm
1071 ; SKIP-CACHE-INV-LABEL: flat_singlethread_release_store:
1072 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1073 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[2:3], 0x0
1074 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[2:3], 0x2
1075 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1076 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
1077 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
1078 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
1079 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
1080 ; SKIP-CACHE-INV-NEXT: s_endpgm
1082 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_release_store:
1083 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1084 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s4, s[6:7], 0x0
1085 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
1086 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
1087 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1088 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
1089 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1090 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
1091 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1093 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_release_store:
1094 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1095 ; GFX90A-TGSPLIT-NEXT: s_load_dword s4, s[6:7], 0x0
1096 ; GFX90A-TGSPLIT-NEXT: s_nop 0
1097 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
1098 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1099 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
1100 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1101 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
1102 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1104 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_release_store:
1105 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
1106 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s0, s[2:3], 0x0
1107 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
1108 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[2:3], 0x8
1109 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1110 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
1111 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s0
1112 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
1113 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
1115 ; GFX940-TGSPLIT-LABEL: flat_singlethread_release_store:
1116 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
1117 ; GFX940-TGSPLIT-NEXT: s_load_dword s0, s[2:3], 0x0
1118 ; GFX940-TGSPLIT-NEXT: s_nop 0
1119 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[2:3], 0x8
1120 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1121 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
1122 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s0
1123 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
1124 ; GFX940-TGSPLIT-NEXT: s_endpgm
1126 ; GFX11-WGP-LABEL: flat_singlethread_release_store:
1127 ; GFX11-WGP: ; %bb.0: ; %entry
1128 ; GFX11-WGP-NEXT: s_load_b32 s0, s[2:3], 0x0
1129 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
1130 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1131 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
1132 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
1133 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
1134 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
1135 ; GFX11-WGP-NEXT: s_endpgm
1137 ; GFX11-CU-LABEL: flat_singlethread_release_store:
1138 ; GFX11-CU: ; %bb.0: ; %entry
1139 ; GFX11-CU-NEXT: s_load_b32 s0, s[2:3], 0x0
1140 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
1141 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1142 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
1143 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
1144 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
1145 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
1146 ; GFX11-CU-NEXT: s_endpgm
1148 ; GFX12-WGP-LABEL: flat_singlethread_release_store:
1149 ; GFX12-WGP: ; %bb.0: ; %entry
1150 ; GFX12-WGP-NEXT: s_load_b32 s0, s[2:3], 0x0
1151 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
1152 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
1153 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
1154 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
1155 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s0
1156 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
1157 ; GFX12-WGP-NEXT: s_endpgm
1159 ; GFX12-CU-LABEL: flat_singlethread_release_store:
1160 ; GFX12-CU: ; %bb.0: ; %entry
1161 ; GFX12-CU-NEXT: s_load_b32 s0, s[2:3], 0x0
1162 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
1163 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
1164 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
1165 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
1166 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s0
1167 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
1168 ; GFX12-CU-NEXT: s_endpgm
1169 i32 %in, ptr %out) {
1171 store atomic i32 %in, ptr %out syncscope("singlethread") release, align 4
1175 define amdgpu_kernel void @flat_singlethread_seq_cst_store(
1176 ; GFX7-LABEL: flat_singlethread_seq_cst_store:
1177 ; GFX7: ; %bb.0: ; %entry
1178 ; GFX7-NEXT: s_load_dword s4, s[6:7], 0x0
1179 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x2
1180 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1181 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
1182 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
1183 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
1184 ; GFX7-NEXT: flat_store_dword v[0:1], v2
1185 ; GFX7-NEXT: s_endpgm
1187 ; GFX10-WGP-LABEL: flat_singlethread_seq_cst_store:
1188 ; GFX10-WGP: ; %bb.0: ; %entry
1189 ; GFX10-WGP-NEXT: s_load_dword s4, s[6:7], 0x0
1190 ; GFX10-WGP-NEXT: s_nop 0
1191 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
1192 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1193 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
1194 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
1195 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s4
1196 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
1197 ; GFX10-WGP-NEXT: s_endpgm
1199 ; GFX10-CU-LABEL: flat_singlethread_seq_cst_store:
1200 ; GFX10-CU: ; %bb.0: ; %entry
1201 ; GFX10-CU-NEXT: s_load_dword s4, s[6:7], 0x0
1202 ; GFX10-CU-NEXT: s_nop 0
1203 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
1204 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1205 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
1206 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
1207 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s4
1208 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
1209 ; GFX10-CU-NEXT: s_endpgm
1211 ; SKIP-CACHE-INV-LABEL: flat_singlethread_seq_cst_store:
1212 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1213 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[2:3], 0x0
1214 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[2:3], 0x2
1215 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1216 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
1217 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
1218 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
1219 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
1220 ; SKIP-CACHE-INV-NEXT: s_endpgm
1222 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_seq_cst_store:
1223 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1224 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s4, s[6:7], 0x0
1225 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
1226 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
1227 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1228 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
1229 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1230 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
1231 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1233 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_seq_cst_store:
1234 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1235 ; GFX90A-TGSPLIT-NEXT: s_load_dword s4, s[6:7], 0x0
1236 ; GFX90A-TGSPLIT-NEXT: s_nop 0
1237 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
1238 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1239 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
1240 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1241 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
1242 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1244 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_seq_cst_store:
1245 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
1246 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s0, s[2:3], 0x0
1247 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
1248 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[2:3], 0x8
1249 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1250 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
1251 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s0
1252 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
1253 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
1255 ; GFX940-TGSPLIT-LABEL: flat_singlethread_seq_cst_store:
1256 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
1257 ; GFX940-TGSPLIT-NEXT: s_load_dword s0, s[2:3], 0x0
1258 ; GFX940-TGSPLIT-NEXT: s_nop 0
1259 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[2:3], 0x8
1260 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1261 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
1262 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s0
1263 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
1264 ; GFX940-TGSPLIT-NEXT: s_endpgm
1266 ; GFX11-WGP-LABEL: flat_singlethread_seq_cst_store:
1267 ; GFX11-WGP: ; %bb.0: ; %entry
1268 ; GFX11-WGP-NEXT: s_load_b32 s0, s[2:3], 0x0
1269 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
1270 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1271 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
1272 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
1273 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
1274 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
1275 ; GFX11-WGP-NEXT: s_endpgm
1277 ; GFX11-CU-LABEL: flat_singlethread_seq_cst_store:
1278 ; GFX11-CU: ; %bb.0: ; %entry
1279 ; GFX11-CU-NEXT: s_load_b32 s0, s[2:3], 0x0
1280 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
1281 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1282 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
1283 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
1284 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
1285 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
1286 ; GFX11-CU-NEXT: s_endpgm
1288 ; GFX12-WGP-LABEL: flat_singlethread_seq_cst_store:
1289 ; GFX12-WGP: ; %bb.0: ; %entry
1290 ; GFX12-WGP-NEXT: s_load_b32 s0, s[2:3], 0x0
1291 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
1292 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
1293 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
1294 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
1295 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s0
1296 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
1297 ; GFX12-WGP-NEXT: s_endpgm
1299 ; GFX12-CU-LABEL: flat_singlethread_seq_cst_store:
1300 ; GFX12-CU: ; %bb.0: ; %entry
1301 ; GFX12-CU-NEXT: s_load_b32 s0, s[2:3], 0x0
1302 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
1303 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
1304 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
1305 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
1306 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s0
1307 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
1308 ; GFX12-CU-NEXT: s_endpgm
1309 i32 %in, ptr %out) {
1311 store atomic i32 %in, ptr %out syncscope("singlethread") seq_cst, align 4
1315 define amdgpu_kernel void @flat_singlethread_monotonic_atomicrmw(
1316 ; GFX7-LABEL: flat_singlethread_monotonic_atomicrmw:
1317 ; GFX7: ; %bb.0: ; %entry
1318 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
1319 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
1320 ; GFX7-NEXT: s_load_dword s4, s[4:5], 0x2
1321 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1322 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
1323 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
1324 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
1325 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
1326 ; GFX7-NEXT: s_endpgm
1328 ; GFX10-WGP-LABEL: flat_singlethread_monotonic_atomicrmw:
1329 ; GFX10-WGP: ; %bb.0: ; %entry
1330 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
1331 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
1332 ; GFX10-WGP-NEXT: s_nop 0
1333 ; GFX10-WGP-NEXT: s_load_dword s4, s[4:5], 0x8
1334 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1335 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
1336 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
1337 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s4
1338 ; GFX10-WGP-NEXT: flat_atomic_swap v[0:1], v2
1339 ; GFX10-WGP-NEXT: s_endpgm
1341 ; GFX10-CU-LABEL: flat_singlethread_monotonic_atomicrmw:
1342 ; GFX10-CU: ; %bb.0: ; %entry
1343 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
1344 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
1345 ; GFX10-CU-NEXT: s_nop 0
1346 ; GFX10-CU-NEXT: s_load_dword s4, s[4:5], 0x8
1347 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1348 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
1349 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
1350 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s4
1351 ; GFX10-CU-NEXT: flat_atomic_swap v[0:1], v2
1352 ; GFX10-CU-NEXT: s_endpgm
1354 ; SKIP-CACHE-INV-LABEL: flat_singlethread_monotonic_atomicrmw:
1355 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1356 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
1357 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1358 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x2
1359 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1360 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
1361 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
1362 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
1363 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v[0:1], v2
1364 ; SKIP-CACHE-INV-NEXT: s_endpgm
1366 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_monotonic_atomicrmw:
1367 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1368 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
1369 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
1370 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
1371 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s4, s[4:5], 0x8
1372 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1373 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
1374 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1375 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1376 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1378 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_monotonic_atomicrmw:
1379 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1380 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
1381 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
1382 ; GFX90A-TGSPLIT-NEXT: s_nop 0
1383 ; GFX90A-TGSPLIT-NEXT: s_load_dword s4, s[4:5], 0x8
1384 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1385 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
1386 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1387 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1388 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1390 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_monotonic_atomicrmw:
1391 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
1392 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
1393 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1394 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
1395 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s0, s[0:1], 0x8
1396 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1397 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
1398 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s0
1399 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1400 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
1402 ; GFX940-TGSPLIT-LABEL: flat_singlethread_monotonic_atomicrmw:
1403 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
1404 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
1405 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1406 ; GFX940-TGSPLIT-NEXT: s_nop 0
1407 ; GFX940-TGSPLIT-NEXT: s_load_dword s0, s[0:1], 0x8
1408 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1409 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
1410 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s0
1411 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1412 ; GFX940-TGSPLIT-NEXT: s_endpgm
1414 ; GFX11-WGP-LABEL: flat_singlethread_monotonic_atomicrmw:
1415 ; GFX11-WGP: ; %bb.0: ; %entry
1416 ; GFX11-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
1417 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1418 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
1419 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1420 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
1421 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
1422 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
1423 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
1424 ; GFX11-WGP-NEXT: s_endpgm
1426 ; GFX11-CU-LABEL: flat_singlethread_monotonic_atomicrmw:
1427 ; GFX11-CU: ; %bb.0: ; %entry
1428 ; GFX11-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
1429 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1430 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
1431 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1432 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
1433 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
1434 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
1435 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
1436 ; GFX11-CU-NEXT: s_endpgm
1438 ; GFX12-WGP-LABEL: flat_singlethread_monotonic_atomicrmw:
1439 ; GFX12-WGP: ; %bb.0: ; %entry
1440 ; GFX12-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
1441 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1442 ; GFX12-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
1443 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
1444 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
1445 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
1446 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s0
1447 ; GFX12-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
1448 ; GFX12-WGP-NEXT: s_endpgm
1450 ; GFX12-CU-LABEL: flat_singlethread_monotonic_atomicrmw:
1451 ; GFX12-CU: ; %bb.0: ; %entry
1452 ; GFX12-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
1453 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1454 ; GFX12-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
1455 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
1456 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
1457 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
1458 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s0
1459 ; GFX12-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
1460 ; GFX12-CU-NEXT: s_endpgm
1461 ptr %out, i32 %in) {
1463 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("singlethread") monotonic
1467 define amdgpu_kernel void @flat_singlethread_acquire_atomicrmw(
1468 ; GFX7-LABEL: flat_singlethread_acquire_atomicrmw:
1469 ; GFX7: ; %bb.0: ; %entry
1470 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
1471 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
1472 ; GFX7-NEXT: s_load_dword s4, s[4:5], 0x2
1473 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1474 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
1475 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
1476 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
1477 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
1478 ; GFX7-NEXT: s_endpgm
1480 ; GFX10-WGP-LABEL: flat_singlethread_acquire_atomicrmw:
1481 ; GFX10-WGP: ; %bb.0: ; %entry
1482 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
1483 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
1484 ; GFX10-WGP-NEXT: s_nop 0
1485 ; GFX10-WGP-NEXT: s_load_dword s4, s[4:5], 0x8
1486 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1487 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
1488 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
1489 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s4
1490 ; GFX10-WGP-NEXT: flat_atomic_swap v[0:1], v2
1491 ; GFX10-WGP-NEXT: s_endpgm
1493 ; GFX10-CU-LABEL: flat_singlethread_acquire_atomicrmw:
1494 ; GFX10-CU: ; %bb.0: ; %entry
1495 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
1496 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
1497 ; GFX10-CU-NEXT: s_nop 0
1498 ; GFX10-CU-NEXT: s_load_dword s4, s[4:5], 0x8
1499 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1500 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
1501 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
1502 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s4
1503 ; GFX10-CU-NEXT: flat_atomic_swap v[0:1], v2
1504 ; GFX10-CU-NEXT: s_endpgm
1506 ; SKIP-CACHE-INV-LABEL: flat_singlethread_acquire_atomicrmw:
1507 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1508 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
1509 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1510 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x2
1511 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1512 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
1513 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
1514 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
1515 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v[0:1], v2
1516 ; SKIP-CACHE-INV-NEXT: s_endpgm
1518 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_acquire_atomicrmw:
1519 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1520 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
1521 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
1522 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
1523 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s4, s[4:5], 0x8
1524 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1525 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
1526 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1527 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1528 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1530 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_acquire_atomicrmw:
1531 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1532 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
1533 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
1534 ; GFX90A-TGSPLIT-NEXT: s_nop 0
1535 ; GFX90A-TGSPLIT-NEXT: s_load_dword s4, s[4:5], 0x8
1536 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1537 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
1538 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1539 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1540 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1542 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_acquire_atomicrmw:
1543 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
1544 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
1545 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1546 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
1547 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s0, s[0:1], 0x8
1548 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1549 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
1550 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s0
1551 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1552 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
1554 ; GFX940-TGSPLIT-LABEL: flat_singlethread_acquire_atomicrmw:
1555 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
1556 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
1557 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1558 ; GFX940-TGSPLIT-NEXT: s_nop 0
1559 ; GFX940-TGSPLIT-NEXT: s_load_dword s0, s[0:1], 0x8
1560 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1561 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
1562 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s0
1563 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1564 ; GFX940-TGSPLIT-NEXT: s_endpgm
1566 ; GFX11-WGP-LABEL: flat_singlethread_acquire_atomicrmw:
1567 ; GFX11-WGP: ; %bb.0: ; %entry
1568 ; GFX11-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
1569 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1570 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
1571 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1572 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
1573 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
1574 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
1575 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
1576 ; GFX11-WGP-NEXT: s_endpgm
1578 ; GFX11-CU-LABEL: flat_singlethread_acquire_atomicrmw:
1579 ; GFX11-CU: ; %bb.0: ; %entry
1580 ; GFX11-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
1581 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1582 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
1583 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1584 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
1585 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
1586 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
1587 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
1588 ; GFX11-CU-NEXT: s_endpgm
1590 ; GFX12-WGP-LABEL: flat_singlethread_acquire_atomicrmw:
1591 ; GFX12-WGP: ; %bb.0: ; %entry
1592 ; GFX12-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
1593 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1594 ; GFX12-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
1595 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
1596 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
1597 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
1598 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s0
1599 ; GFX12-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
1600 ; GFX12-WGP-NEXT: s_endpgm
1602 ; GFX12-CU-LABEL: flat_singlethread_acquire_atomicrmw:
1603 ; GFX12-CU: ; %bb.0: ; %entry
1604 ; GFX12-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
1605 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1606 ; GFX12-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
1607 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
1608 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
1609 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
1610 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s0
1611 ; GFX12-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
1612 ; GFX12-CU-NEXT: s_endpgm
1613 ptr %out, i32 %in) {
1615 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("singlethread") acquire
1619 define amdgpu_kernel void @flat_singlethread_release_atomicrmw(
1620 ; GFX7-LABEL: flat_singlethread_release_atomicrmw:
1621 ; GFX7: ; %bb.0: ; %entry
1622 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
1623 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
1624 ; GFX7-NEXT: s_load_dword s4, s[4:5], 0x2
1625 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1626 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
1627 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
1628 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
1629 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
1630 ; GFX7-NEXT: s_endpgm
1632 ; GFX10-WGP-LABEL: flat_singlethread_release_atomicrmw:
1633 ; GFX10-WGP: ; %bb.0: ; %entry
1634 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
1635 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
1636 ; GFX10-WGP-NEXT: s_nop 0
1637 ; GFX10-WGP-NEXT: s_load_dword s4, s[4:5], 0x8
1638 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1639 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
1640 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
1641 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s4
1642 ; GFX10-WGP-NEXT: flat_atomic_swap v[0:1], v2
1643 ; GFX10-WGP-NEXT: s_endpgm
1645 ; GFX10-CU-LABEL: flat_singlethread_release_atomicrmw:
1646 ; GFX10-CU: ; %bb.0: ; %entry
1647 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
1648 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
1649 ; GFX10-CU-NEXT: s_nop 0
1650 ; GFX10-CU-NEXT: s_load_dword s4, s[4:5], 0x8
1651 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1652 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
1653 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
1654 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s4
1655 ; GFX10-CU-NEXT: flat_atomic_swap v[0:1], v2
1656 ; GFX10-CU-NEXT: s_endpgm
1658 ; SKIP-CACHE-INV-LABEL: flat_singlethread_release_atomicrmw:
1659 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1660 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
1661 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1662 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x2
1663 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1664 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
1665 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
1666 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
1667 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v[0:1], v2
1668 ; SKIP-CACHE-INV-NEXT: s_endpgm
1670 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_release_atomicrmw:
1671 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1672 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
1673 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
1674 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
1675 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s4, s[4:5], 0x8
1676 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1677 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
1678 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1679 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1680 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1682 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_release_atomicrmw:
1683 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1684 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
1685 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
1686 ; GFX90A-TGSPLIT-NEXT: s_nop 0
1687 ; GFX90A-TGSPLIT-NEXT: s_load_dword s4, s[4:5], 0x8
1688 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1689 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
1690 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1691 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1692 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1694 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_release_atomicrmw:
1695 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
1696 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
1697 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1698 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
1699 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s0, s[0:1], 0x8
1700 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1701 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
1702 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s0
1703 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1704 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
1706 ; GFX940-TGSPLIT-LABEL: flat_singlethread_release_atomicrmw:
1707 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
1708 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
1709 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1710 ; GFX940-TGSPLIT-NEXT: s_nop 0
1711 ; GFX940-TGSPLIT-NEXT: s_load_dword s0, s[0:1], 0x8
1712 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1713 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
1714 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s0
1715 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1716 ; GFX940-TGSPLIT-NEXT: s_endpgm
1718 ; GFX11-WGP-LABEL: flat_singlethread_release_atomicrmw:
1719 ; GFX11-WGP: ; %bb.0: ; %entry
1720 ; GFX11-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
1721 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1722 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
1723 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1724 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
1725 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
1726 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
1727 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
1728 ; GFX11-WGP-NEXT: s_endpgm
1730 ; GFX11-CU-LABEL: flat_singlethread_release_atomicrmw:
1731 ; GFX11-CU: ; %bb.0: ; %entry
1732 ; GFX11-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
1733 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1734 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
1735 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1736 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
1737 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
1738 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
1739 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
1740 ; GFX11-CU-NEXT: s_endpgm
1742 ; GFX12-WGP-LABEL: flat_singlethread_release_atomicrmw:
1743 ; GFX12-WGP: ; %bb.0: ; %entry
1744 ; GFX12-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
1745 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1746 ; GFX12-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
1747 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
1748 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
1749 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
1750 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s0
1751 ; GFX12-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
1752 ; GFX12-WGP-NEXT: s_endpgm
1754 ; GFX12-CU-LABEL: flat_singlethread_release_atomicrmw:
1755 ; GFX12-CU: ; %bb.0: ; %entry
1756 ; GFX12-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
1757 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1758 ; GFX12-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
1759 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
1760 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
1761 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
1762 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s0
1763 ; GFX12-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
1764 ; GFX12-CU-NEXT: s_endpgm
1765 ptr %out, i32 %in) {
1767 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("singlethread") release
1771 define amdgpu_kernel void @flat_singlethread_acq_rel_atomicrmw(
1772 ; GFX7-LABEL: flat_singlethread_acq_rel_atomicrmw:
1773 ; GFX7: ; %bb.0: ; %entry
1774 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
1775 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
1776 ; GFX7-NEXT: s_load_dword s4, s[4:5], 0x2
1777 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1778 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
1779 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
1780 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
1781 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
1782 ; GFX7-NEXT: s_endpgm
1784 ; GFX10-WGP-LABEL: flat_singlethread_acq_rel_atomicrmw:
1785 ; GFX10-WGP: ; %bb.0: ; %entry
1786 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
1787 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
1788 ; GFX10-WGP-NEXT: s_nop 0
1789 ; GFX10-WGP-NEXT: s_load_dword s4, s[4:5], 0x8
1790 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1791 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
1792 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
1793 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s4
1794 ; GFX10-WGP-NEXT: flat_atomic_swap v[0:1], v2
1795 ; GFX10-WGP-NEXT: s_endpgm
1797 ; GFX10-CU-LABEL: flat_singlethread_acq_rel_atomicrmw:
1798 ; GFX10-CU: ; %bb.0: ; %entry
1799 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
1800 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
1801 ; GFX10-CU-NEXT: s_nop 0
1802 ; GFX10-CU-NEXT: s_load_dword s4, s[4:5], 0x8
1803 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1804 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
1805 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
1806 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s4
1807 ; GFX10-CU-NEXT: flat_atomic_swap v[0:1], v2
1808 ; GFX10-CU-NEXT: s_endpgm
1810 ; SKIP-CACHE-INV-LABEL: flat_singlethread_acq_rel_atomicrmw:
1811 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1812 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
1813 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1814 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x2
1815 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1816 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
1817 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
1818 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
1819 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v[0:1], v2
1820 ; SKIP-CACHE-INV-NEXT: s_endpgm
1822 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_acq_rel_atomicrmw:
1823 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1824 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
1825 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
1826 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
1827 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s4, s[4:5], 0x8
1828 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1829 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
1830 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1831 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1832 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1834 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_acq_rel_atomicrmw:
1835 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1836 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
1837 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
1838 ; GFX90A-TGSPLIT-NEXT: s_nop 0
1839 ; GFX90A-TGSPLIT-NEXT: s_load_dword s4, s[4:5], 0x8
1840 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1841 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
1842 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1843 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1844 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1846 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_acq_rel_atomicrmw:
1847 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
1848 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
1849 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1850 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
1851 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s0, s[0:1], 0x8
1852 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1853 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
1854 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s0
1855 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1856 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
1858 ; GFX940-TGSPLIT-LABEL: flat_singlethread_acq_rel_atomicrmw:
1859 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
1860 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
1861 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1862 ; GFX940-TGSPLIT-NEXT: s_nop 0
1863 ; GFX940-TGSPLIT-NEXT: s_load_dword s0, s[0:1], 0x8
1864 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1865 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
1866 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s0
1867 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1868 ; GFX940-TGSPLIT-NEXT: s_endpgm
1870 ; GFX11-WGP-LABEL: flat_singlethread_acq_rel_atomicrmw:
1871 ; GFX11-WGP: ; %bb.0: ; %entry
1872 ; GFX11-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
1873 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1874 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
1875 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1876 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
1877 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
1878 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
1879 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
1880 ; GFX11-WGP-NEXT: s_endpgm
1882 ; GFX11-CU-LABEL: flat_singlethread_acq_rel_atomicrmw:
1883 ; GFX11-CU: ; %bb.0: ; %entry
1884 ; GFX11-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
1885 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1886 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
1887 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1888 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
1889 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
1890 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
1891 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
1892 ; GFX11-CU-NEXT: s_endpgm
1894 ; GFX12-WGP-LABEL: flat_singlethread_acq_rel_atomicrmw:
1895 ; GFX12-WGP: ; %bb.0: ; %entry
1896 ; GFX12-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
1897 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1898 ; GFX12-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
1899 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
1900 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
1901 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
1902 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s0
1903 ; GFX12-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
1904 ; GFX12-WGP-NEXT: s_endpgm
1906 ; GFX12-CU-LABEL: flat_singlethread_acq_rel_atomicrmw:
1907 ; GFX12-CU: ; %bb.0: ; %entry
1908 ; GFX12-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
1909 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
1910 ; GFX12-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
1911 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
1912 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
1913 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
1914 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s0
1915 ; GFX12-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
1916 ; GFX12-CU-NEXT: s_endpgm
1917 ptr %out, i32 %in) {
1919 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("singlethread") acq_rel
1923 define amdgpu_kernel void @flat_singlethread_seq_cst_atomicrmw(
1924 ; GFX7-LABEL: flat_singlethread_seq_cst_atomicrmw:
1925 ; GFX7: ; %bb.0: ; %entry
1926 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
1927 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
1928 ; GFX7-NEXT: s_load_dword s4, s[4:5], 0x2
1929 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1930 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
1931 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
1932 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
1933 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
1934 ; GFX7-NEXT: s_endpgm
1936 ; GFX10-WGP-LABEL: flat_singlethread_seq_cst_atomicrmw:
1937 ; GFX10-WGP: ; %bb.0: ; %entry
1938 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
1939 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
1940 ; GFX10-WGP-NEXT: s_nop 0
1941 ; GFX10-WGP-NEXT: s_load_dword s4, s[4:5], 0x8
1942 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1943 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
1944 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
1945 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s4
1946 ; GFX10-WGP-NEXT: flat_atomic_swap v[0:1], v2
1947 ; GFX10-WGP-NEXT: s_endpgm
1949 ; GFX10-CU-LABEL: flat_singlethread_seq_cst_atomicrmw:
1950 ; GFX10-CU: ; %bb.0: ; %entry
1951 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
1952 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
1953 ; GFX10-CU-NEXT: s_nop 0
1954 ; GFX10-CU-NEXT: s_load_dword s4, s[4:5], 0x8
1955 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1956 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
1957 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
1958 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s4
1959 ; GFX10-CU-NEXT: flat_atomic_swap v[0:1], v2
1960 ; GFX10-CU-NEXT: s_endpgm
1962 ; SKIP-CACHE-INV-LABEL: flat_singlethread_seq_cst_atomicrmw:
1963 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1964 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
1965 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
1966 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x2
1967 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1968 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
1969 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
1970 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
1971 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v[0:1], v2
1972 ; SKIP-CACHE-INV-NEXT: s_endpgm
1974 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_seq_cst_atomicrmw:
1975 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1976 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
1977 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
1978 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
1979 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s4, s[4:5], 0x8
1980 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1981 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
1982 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1983 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1984 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1986 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_seq_cst_atomicrmw:
1987 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1988 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
1989 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
1990 ; GFX90A-TGSPLIT-NEXT: s_nop 0
1991 ; GFX90A-TGSPLIT-NEXT: s_load_dword s4, s[4:5], 0x8
1992 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1993 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
1994 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
1995 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
1996 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1998 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_seq_cst_atomicrmw:
1999 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
2000 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
2001 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
2002 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
2003 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s0, s[0:1], 0x8
2004 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2005 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
2006 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s0
2007 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
2008 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
2010 ; GFX940-TGSPLIT-LABEL: flat_singlethread_seq_cst_atomicrmw:
2011 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
2012 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
2013 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
2014 ; GFX940-TGSPLIT-NEXT: s_nop 0
2015 ; GFX940-TGSPLIT-NEXT: s_load_dword s0, s[0:1], 0x8
2016 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2017 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
2018 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s0
2019 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
2020 ; GFX940-TGSPLIT-NEXT: s_endpgm
2022 ; GFX11-WGP-LABEL: flat_singlethread_seq_cst_atomicrmw:
2023 ; GFX11-WGP: ; %bb.0: ; %entry
2024 ; GFX11-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
2025 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
2026 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
2027 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
2028 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
2029 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
2030 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
2031 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
2032 ; GFX11-WGP-NEXT: s_endpgm
2034 ; GFX11-CU-LABEL: flat_singlethread_seq_cst_atomicrmw:
2035 ; GFX11-CU: ; %bb.0: ; %entry
2036 ; GFX11-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
2037 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
2038 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
2039 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2040 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
2041 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
2042 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
2043 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
2044 ; GFX11-CU-NEXT: s_endpgm
2046 ; GFX12-WGP-LABEL: flat_singlethread_seq_cst_atomicrmw:
2047 ; GFX12-WGP: ; %bb.0: ; %entry
2048 ; GFX12-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
2049 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
2050 ; GFX12-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
2051 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
2052 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
2053 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
2054 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s0
2055 ; GFX12-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
2056 ; GFX12-WGP-NEXT: s_endpgm
2058 ; GFX12-CU-LABEL: flat_singlethread_seq_cst_atomicrmw:
2059 ; GFX12-CU: ; %bb.0: ; %entry
2060 ; GFX12-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
2061 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
2062 ; GFX12-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
2063 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
2064 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
2065 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
2066 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s0
2067 ; GFX12-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
2068 ; GFX12-CU-NEXT: s_endpgm
2069 ptr %out, i32 %in) {
2071 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("singlethread") seq_cst
2075 define amdgpu_kernel void @flat_singlethread_acquire_ret_atomicrmw(
2076 ; GFX7-LABEL: flat_singlethread_acquire_ret_atomicrmw:
2077 ; GFX7: ; %bb.0: ; %entry
2078 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
2079 ; GFX7-NEXT: s_load_dword s6, s[6:7], 0x2
2080 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2081 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
2082 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
2083 ; GFX7-NEXT: v_mov_b32_e32 v2, s6
2084 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
2085 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
2086 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
2087 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2088 ; GFX7-NEXT: flat_store_dword v[0:1], v2
2089 ; GFX7-NEXT: s_endpgm
2091 ; GFX10-WGP-LABEL: flat_singlethread_acquire_ret_atomicrmw:
2092 ; GFX10-WGP: ; %bb.0: ; %entry
2093 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
2094 ; GFX10-WGP-NEXT: s_nop 0
2095 ; GFX10-WGP-NEXT: s_load_dword s6, s[6:7], 0x8
2096 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2097 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
2098 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
2099 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s6
2100 ; GFX10-WGP-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
2101 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
2102 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
2103 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2104 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
2105 ; GFX10-WGP-NEXT: s_endpgm
2107 ; GFX10-CU-LABEL: flat_singlethread_acquire_ret_atomicrmw:
2108 ; GFX10-CU: ; %bb.0: ; %entry
2109 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
2110 ; GFX10-CU-NEXT: s_nop 0
2111 ; GFX10-CU-NEXT: s_load_dword s6, s[6:7], 0x8
2112 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2113 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
2114 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
2115 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s6
2116 ; GFX10-CU-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
2117 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
2118 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
2119 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2120 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
2121 ; GFX10-CU-NEXT: s_endpgm
2123 ; SKIP-CACHE-INV-LABEL: flat_singlethread_acquire_ret_atomicrmw:
2124 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2125 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
2126 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[2:3], 0x2
2127 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2128 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
2129 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
2130 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
2131 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
2132 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
2133 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
2134 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2135 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
2136 ; SKIP-CACHE-INV-NEXT: s_endpgm
2138 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_acquire_ret_atomicrmw:
2139 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2140 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
2141 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
2142 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[6:7], 0x8
2143 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2144 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
2145 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s6
2146 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
2147 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
2148 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2149 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
2150 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2152 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_acquire_ret_atomicrmw:
2153 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2154 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
2155 ; GFX90A-TGSPLIT-NEXT: s_nop 0
2156 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[6:7], 0x8
2157 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2158 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
2159 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s6
2160 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
2161 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
2162 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2163 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
2164 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2166 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_acquire_ret_atomicrmw:
2167 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
2168 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
2169 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
2170 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[2:3], 0x8
2171 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2172 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
2173 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
2174 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 sc0
2175 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
2176 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2177 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
2178 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
2180 ; GFX940-TGSPLIT-LABEL: flat_singlethread_acquire_ret_atomicrmw:
2181 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
2182 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
2183 ; GFX940-TGSPLIT-NEXT: s_nop 0
2184 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[2:3], 0x8
2185 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2186 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
2187 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
2188 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 sc0
2189 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
2190 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2191 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
2192 ; GFX940-TGSPLIT-NEXT: s_endpgm
2194 ; GFX11-WGP-LABEL: flat_singlethread_acquire_ret_atomicrmw:
2195 ; GFX11-WGP: ; %bb.0: ; %entry
2196 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
2197 ; GFX11-WGP-NEXT: s_load_b32 s2, s[2:3], 0x8
2198 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
2199 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
2200 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
2201 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s2
2202 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 glc
2203 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
2204 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
2205 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2206 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
2207 ; GFX11-WGP-NEXT: s_endpgm
2209 ; GFX11-CU-LABEL: flat_singlethread_acquire_ret_atomicrmw:
2210 ; GFX11-CU: ; %bb.0: ; %entry
2211 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
2212 ; GFX11-CU-NEXT: s_load_b32 s2, s[2:3], 0x8
2213 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2214 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
2215 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
2216 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s2
2217 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 glc
2218 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
2219 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
2220 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2221 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
2222 ; GFX11-CU-NEXT: s_endpgm
2224 ; GFX12-WGP-LABEL: flat_singlethread_acquire_ret_atomicrmw:
2225 ; GFX12-WGP: ; %bb.0: ; %entry
2226 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
2227 ; GFX12-WGP-NEXT: s_load_b32 s2, s[2:3], 0x8
2228 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
2229 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
2230 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
2231 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s2
2232 ; GFX12-WGP-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 th:TH_ATOMIC_RETURN
2233 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
2234 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
2235 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
2236 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
2237 ; GFX12-WGP-NEXT: s_endpgm
2239 ; GFX12-CU-LABEL: flat_singlethread_acquire_ret_atomicrmw:
2240 ; GFX12-CU: ; %bb.0: ; %entry
2241 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
2242 ; GFX12-CU-NEXT: s_load_b32 s2, s[2:3], 0x8
2243 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
2244 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
2245 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
2246 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s2
2247 ; GFX12-CU-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 th:TH_ATOMIC_RETURN
2248 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
2249 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
2250 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
2251 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
2252 ; GFX12-CU-NEXT: s_endpgm
2253 ptr %out, i32 %in) {
2255 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("singlethread") acquire
2256 store i32 %val, ptr %out, align 4
2260 define amdgpu_kernel void @flat_singlethread_acq_rel_ret_atomicrmw(
2261 ; GFX7-LABEL: flat_singlethread_acq_rel_ret_atomicrmw:
2262 ; GFX7: ; %bb.0: ; %entry
2263 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
2264 ; GFX7-NEXT: s_load_dword s6, s[6:7], 0x2
2265 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2266 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
2267 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
2268 ; GFX7-NEXT: v_mov_b32_e32 v2, s6
2269 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
2270 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
2271 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
2272 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2273 ; GFX7-NEXT: flat_store_dword v[0:1], v2
2274 ; GFX7-NEXT: s_endpgm
2276 ; GFX10-WGP-LABEL: flat_singlethread_acq_rel_ret_atomicrmw:
2277 ; GFX10-WGP: ; %bb.0: ; %entry
2278 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
2279 ; GFX10-WGP-NEXT: s_nop 0
2280 ; GFX10-WGP-NEXT: s_load_dword s6, s[6:7], 0x8
2281 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2282 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
2283 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
2284 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s6
2285 ; GFX10-WGP-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
2286 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
2287 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
2288 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2289 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
2290 ; GFX10-WGP-NEXT: s_endpgm
2292 ; GFX10-CU-LABEL: flat_singlethread_acq_rel_ret_atomicrmw:
2293 ; GFX10-CU: ; %bb.0: ; %entry
2294 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
2295 ; GFX10-CU-NEXT: s_nop 0
2296 ; GFX10-CU-NEXT: s_load_dword s6, s[6:7], 0x8
2297 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2298 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
2299 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
2300 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s6
2301 ; GFX10-CU-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
2302 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
2303 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
2304 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2305 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
2306 ; GFX10-CU-NEXT: s_endpgm
2308 ; SKIP-CACHE-INV-LABEL: flat_singlethread_acq_rel_ret_atomicrmw:
2309 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2310 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
2311 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[2:3], 0x2
2312 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2313 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
2314 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
2315 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
2316 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
2317 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
2318 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
2319 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2320 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
2321 ; SKIP-CACHE-INV-NEXT: s_endpgm
2323 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_acq_rel_ret_atomicrmw:
2324 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2325 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
2326 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
2327 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[6:7], 0x8
2328 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2329 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
2330 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s6
2331 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
2332 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
2333 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2334 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
2335 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2337 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_acq_rel_ret_atomicrmw:
2338 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2339 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
2340 ; GFX90A-TGSPLIT-NEXT: s_nop 0
2341 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[6:7], 0x8
2342 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2343 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
2344 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s6
2345 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
2346 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
2347 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2348 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
2349 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2351 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_acq_rel_ret_atomicrmw:
2352 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
2353 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
2354 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
2355 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[2:3], 0x8
2356 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2357 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
2358 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
2359 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 sc0
2360 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
2361 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2362 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
2363 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
2365 ; GFX940-TGSPLIT-LABEL: flat_singlethread_acq_rel_ret_atomicrmw:
2366 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
2367 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
2368 ; GFX940-TGSPLIT-NEXT: s_nop 0
2369 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[2:3], 0x8
2370 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2371 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
2372 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
2373 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 sc0
2374 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
2375 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2376 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
2377 ; GFX940-TGSPLIT-NEXT: s_endpgm
2379 ; GFX11-WGP-LABEL: flat_singlethread_acq_rel_ret_atomicrmw:
2380 ; GFX11-WGP: ; %bb.0: ; %entry
2381 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
2382 ; GFX11-WGP-NEXT: s_load_b32 s2, s[2:3], 0x8
2383 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
2384 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
2385 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
2386 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s2
2387 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 glc
2388 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
2389 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
2390 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2391 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
2392 ; GFX11-WGP-NEXT: s_endpgm
2394 ; GFX11-CU-LABEL: flat_singlethread_acq_rel_ret_atomicrmw:
2395 ; GFX11-CU: ; %bb.0: ; %entry
2396 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
2397 ; GFX11-CU-NEXT: s_load_b32 s2, s[2:3], 0x8
2398 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2399 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
2400 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
2401 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s2
2402 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 glc
2403 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
2404 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
2405 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2406 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
2407 ; GFX11-CU-NEXT: s_endpgm
2409 ; GFX12-WGP-LABEL: flat_singlethread_acq_rel_ret_atomicrmw:
2410 ; GFX12-WGP: ; %bb.0: ; %entry
2411 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
2412 ; GFX12-WGP-NEXT: s_load_b32 s2, s[2:3], 0x8
2413 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
2414 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
2415 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
2416 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s2
2417 ; GFX12-WGP-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 th:TH_ATOMIC_RETURN
2418 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
2419 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
2420 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
2421 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
2422 ; GFX12-WGP-NEXT: s_endpgm
2424 ; GFX12-CU-LABEL: flat_singlethread_acq_rel_ret_atomicrmw:
2425 ; GFX12-CU: ; %bb.0: ; %entry
2426 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
2427 ; GFX12-CU-NEXT: s_load_b32 s2, s[2:3], 0x8
2428 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
2429 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
2430 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
2431 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s2
2432 ; GFX12-CU-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 th:TH_ATOMIC_RETURN
2433 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
2434 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
2435 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
2436 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
2437 ; GFX12-CU-NEXT: s_endpgm
2438 ptr %out, i32 %in) {
2440 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("singlethread") acq_rel
2441 store i32 %val, ptr %out, align 4
2445 define amdgpu_kernel void @flat_singlethread_seq_cst_ret_atomicrmw(
2446 ; GFX7-LABEL: flat_singlethread_seq_cst_ret_atomicrmw:
2447 ; GFX7: ; %bb.0: ; %entry
2448 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
2449 ; GFX7-NEXT: s_load_dword s6, s[6:7], 0x2
2450 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2451 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
2452 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
2453 ; GFX7-NEXT: v_mov_b32_e32 v2, s6
2454 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
2455 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
2456 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
2457 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2458 ; GFX7-NEXT: flat_store_dword v[0:1], v2
2459 ; GFX7-NEXT: s_endpgm
2461 ; GFX10-WGP-LABEL: flat_singlethread_seq_cst_ret_atomicrmw:
2462 ; GFX10-WGP: ; %bb.0: ; %entry
2463 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
2464 ; GFX10-WGP-NEXT: s_nop 0
2465 ; GFX10-WGP-NEXT: s_load_dword s6, s[6:7], 0x8
2466 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2467 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
2468 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
2469 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s6
2470 ; GFX10-WGP-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
2471 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
2472 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
2473 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2474 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
2475 ; GFX10-WGP-NEXT: s_endpgm
2477 ; GFX10-CU-LABEL: flat_singlethread_seq_cst_ret_atomicrmw:
2478 ; GFX10-CU: ; %bb.0: ; %entry
2479 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
2480 ; GFX10-CU-NEXT: s_nop 0
2481 ; GFX10-CU-NEXT: s_load_dword s6, s[6:7], 0x8
2482 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2483 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
2484 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
2485 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s6
2486 ; GFX10-CU-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
2487 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
2488 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
2489 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2490 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
2491 ; GFX10-CU-NEXT: s_endpgm
2493 ; SKIP-CACHE-INV-LABEL: flat_singlethread_seq_cst_ret_atomicrmw:
2494 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2495 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
2496 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[2:3], 0x2
2497 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2498 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
2499 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
2500 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
2501 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
2502 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
2503 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
2504 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2505 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
2506 ; SKIP-CACHE-INV-NEXT: s_endpgm
2508 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_seq_cst_ret_atomicrmw:
2509 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2510 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
2511 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
2512 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[6:7], 0x8
2513 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2514 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
2515 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s6
2516 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
2517 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
2518 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2519 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
2520 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2522 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_seq_cst_ret_atomicrmw:
2523 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2524 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
2525 ; GFX90A-TGSPLIT-NEXT: s_nop 0
2526 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[6:7], 0x8
2527 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2528 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
2529 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s6
2530 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
2531 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
2532 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2533 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
2534 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2536 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_seq_cst_ret_atomicrmw:
2537 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
2538 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
2539 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
2540 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[2:3], 0x8
2541 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2542 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
2543 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
2544 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 sc0
2545 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
2546 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2547 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
2548 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
2550 ; GFX940-TGSPLIT-LABEL: flat_singlethread_seq_cst_ret_atomicrmw:
2551 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
2552 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
2553 ; GFX940-TGSPLIT-NEXT: s_nop 0
2554 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[2:3], 0x8
2555 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2556 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
2557 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
2558 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 sc0
2559 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
2560 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2561 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
2562 ; GFX940-TGSPLIT-NEXT: s_endpgm
2564 ; GFX11-WGP-LABEL: flat_singlethread_seq_cst_ret_atomicrmw:
2565 ; GFX11-WGP: ; %bb.0: ; %entry
2566 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
2567 ; GFX11-WGP-NEXT: s_load_b32 s2, s[2:3], 0x8
2568 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
2569 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
2570 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
2571 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s2
2572 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 glc
2573 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
2574 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
2575 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2576 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
2577 ; GFX11-WGP-NEXT: s_endpgm
2579 ; GFX11-CU-LABEL: flat_singlethread_seq_cst_ret_atomicrmw:
2580 ; GFX11-CU: ; %bb.0: ; %entry
2581 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
2582 ; GFX11-CU-NEXT: s_load_b32 s2, s[2:3], 0x8
2583 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2584 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
2585 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
2586 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s2
2587 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 glc
2588 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
2589 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
2590 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2591 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
2592 ; GFX11-CU-NEXT: s_endpgm
2594 ; GFX12-WGP-LABEL: flat_singlethread_seq_cst_ret_atomicrmw:
2595 ; GFX12-WGP: ; %bb.0: ; %entry
2596 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
2597 ; GFX12-WGP-NEXT: s_load_b32 s2, s[2:3], 0x8
2598 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
2599 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
2600 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
2601 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s2
2602 ; GFX12-WGP-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 th:TH_ATOMIC_RETURN
2603 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
2604 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
2605 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
2606 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
2607 ; GFX12-WGP-NEXT: s_endpgm
2609 ; GFX12-CU-LABEL: flat_singlethread_seq_cst_ret_atomicrmw:
2610 ; GFX12-CU: ; %bb.0: ; %entry
2611 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
2612 ; GFX12-CU-NEXT: s_load_b32 s2, s[2:3], 0x8
2613 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
2614 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
2615 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
2616 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s2
2617 ; GFX12-CU-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 th:TH_ATOMIC_RETURN
2618 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
2619 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
2620 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
2621 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
2622 ; GFX12-CU-NEXT: s_endpgm
2623 ptr %out, i32 %in) {
2625 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("singlethread") seq_cst
2626 store i32 %val, ptr %out, align 4
2630 define amdgpu_kernel void @flat_singlethread_monotonic_monotonic_cmpxchg(
2631 ; GFX7-LABEL: flat_singlethread_monotonic_monotonic_cmpxchg:
2632 ; GFX7: ; %bb.0: ; %entry
2633 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
2634 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
2635 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
2636 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
2637 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
2638 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2639 ; GFX7-NEXT: s_mov_b32 s4, s8
2640 ; GFX7-NEXT: s_mov_b32 s5, s9
2641 ; GFX7-NEXT: s_mov_b32 s9, s10
2642 ; GFX7-NEXT: s_mov_b32 s8, s11
2643 ; GFX7-NEXT: s_add_u32 s4, s4, s9
2644 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
2645 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
2646 ; GFX7-NEXT: s_mov_b32 s5, s8
2647 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
2648 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
2649 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
2650 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
2651 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
2652 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
2653 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2654 ; GFX7-NEXT: s_endpgm
2656 ; GFX10-WGP-LABEL: flat_singlethread_monotonic_monotonic_cmpxchg:
2657 ; GFX10-WGP: ; %bb.0: ; %entry
2658 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
2659 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
2660 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
2661 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
2662 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
2663 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2664 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
2665 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
2666 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
2667 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
2668 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
2669 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
2670 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
2671 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
2672 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
2673 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
2674 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
2675 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
2676 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
2677 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
2678 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2679 ; GFX10-WGP-NEXT: s_endpgm
2681 ; GFX10-CU-LABEL: flat_singlethread_monotonic_monotonic_cmpxchg:
2682 ; GFX10-CU: ; %bb.0: ; %entry
2683 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
2684 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
2685 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
2686 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
2687 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
2688 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2689 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
2690 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
2691 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
2692 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
2693 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
2694 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
2695 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
2696 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
2697 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
2698 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
2699 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
2700 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
2701 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
2702 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
2703 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2704 ; GFX10-CU-NEXT: s_endpgm
2706 ; SKIP-CACHE-INV-LABEL: flat_singlethread_monotonic_monotonic_cmpxchg:
2707 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2708 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
2709 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
2710 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
2711 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
2712 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
2713 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2714 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
2715 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
2716 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
2717 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
2718 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
2719 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
2720 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
2721 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
2722 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
2723 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
2724 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
2725 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
2726 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
2727 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
2728 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2729 ; SKIP-CACHE-INV-NEXT: s_endpgm
2731 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_monotonic_monotonic_cmpxchg:
2732 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2733 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
2734 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2735 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
2736 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
2737 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2738 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
2739 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
2740 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
2741 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
2742 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
2743 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2744 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2746 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_monotonic_monotonic_cmpxchg:
2747 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2748 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
2749 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2750 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
2751 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
2752 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2753 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
2754 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
2755 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
2756 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
2757 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
2758 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2759 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2761 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_monotonic_monotonic_cmpxchg:
2762 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
2763 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
2764 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2765 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
2766 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
2767 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2768 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
2769 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
2770 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
2771 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
2772 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
2773 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2774 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
2776 ; GFX940-TGSPLIT-LABEL: flat_singlethread_monotonic_monotonic_cmpxchg:
2777 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
2778 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
2779 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2780 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
2781 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
2782 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2783 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
2784 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
2785 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
2786 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
2787 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
2788 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2789 ; GFX940-TGSPLIT-NEXT: s_endpgm
2791 ; GFX11-WGP-LABEL: flat_singlethread_monotonic_monotonic_cmpxchg:
2792 ; GFX11-WGP: ; %bb.0: ; %entry
2793 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
2794 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
2795 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
2796 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
2797 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
2798 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
2799 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
2800 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
2801 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
2802 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
2803 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
2804 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
2805 ; GFX11-WGP-NEXT: s_endpgm
2807 ; GFX11-CU-LABEL: flat_singlethread_monotonic_monotonic_cmpxchg:
2808 ; GFX11-CU: ; %bb.0: ; %entry
2809 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
2810 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
2811 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
2812 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
2813 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2814 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
2815 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
2816 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
2817 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
2818 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
2819 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
2820 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
2821 ; GFX11-CU-NEXT: s_endpgm
2823 ; GFX12-WGP-LABEL: flat_singlethread_monotonic_monotonic_cmpxchg:
2824 ; GFX12-WGP: ; %bb.0: ; %entry
2825 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
2826 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
2827 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
2828 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
2829 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
2830 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
2831 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
2832 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
2833 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
2834 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
2835 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
2836 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
2837 ; GFX12-WGP-NEXT: s_endpgm
2839 ; GFX12-CU-LABEL: flat_singlethread_monotonic_monotonic_cmpxchg:
2840 ; GFX12-CU: ; %bb.0: ; %entry
2841 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
2842 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
2843 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
2844 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
2845 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
2846 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
2847 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
2848 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
2849 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
2850 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
2851 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
2852 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
2853 ; GFX12-CU-NEXT: s_endpgm
2854 ptr %out, i32 %in, i32 %old) {
2856 %gep = getelementptr i32, ptr %out, i32 4
2857 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") monotonic monotonic
2861 define amdgpu_kernel void @flat_singlethread_acquire_monotonic_cmpxchg(
2862 ; GFX7-LABEL: flat_singlethread_acquire_monotonic_cmpxchg:
2863 ; GFX7: ; %bb.0: ; %entry
2864 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
2865 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
2866 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
2867 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
2868 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
2869 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2870 ; GFX7-NEXT: s_mov_b32 s4, s8
2871 ; GFX7-NEXT: s_mov_b32 s5, s9
2872 ; GFX7-NEXT: s_mov_b32 s9, s10
2873 ; GFX7-NEXT: s_mov_b32 s8, s11
2874 ; GFX7-NEXT: s_add_u32 s4, s4, s9
2875 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
2876 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
2877 ; GFX7-NEXT: s_mov_b32 s5, s8
2878 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
2879 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
2880 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
2881 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
2882 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
2883 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
2884 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2885 ; GFX7-NEXT: s_endpgm
2887 ; GFX10-WGP-LABEL: flat_singlethread_acquire_monotonic_cmpxchg:
2888 ; GFX10-WGP: ; %bb.0: ; %entry
2889 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
2890 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
2891 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
2892 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
2893 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
2894 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2895 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
2896 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
2897 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
2898 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
2899 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
2900 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
2901 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
2902 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
2903 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
2904 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
2905 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
2906 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
2907 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
2908 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
2909 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2910 ; GFX10-WGP-NEXT: s_endpgm
2912 ; GFX10-CU-LABEL: flat_singlethread_acquire_monotonic_cmpxchg:
2913 ; GFX10-CU: ; %bb.0: ; %entry
2914 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
2915 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
2916 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
2917 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
2918 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
2919 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2920 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
2921 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
2922 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
2923 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
2924 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
2925 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
2926 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
2927 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
2928 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
2929 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
2930 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
2931 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
2932 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
2933 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
2934 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2935 ; GFX10-CU-NEXT: s_endpgm
2937 ; SKIP-CACHE-INV-LABEL: flat_singlethread_acquire_monotonic_cmpxchg:
2938 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2939 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
2940 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
2941 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
2942 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
2943 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
2944 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2945 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
2946 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
2947 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
2948 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
2949 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
2950 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
2951 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
2952 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
2953 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
2954 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
2955 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
2956 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
2957 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
2958 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
2959 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2960 ; SKIP-CACHE-INV-NEXT: s_endpgm
2962 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_acquire_monotonic_cmpxchg:
2963 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2964 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
2965 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2966 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
2967 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
2968 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2969 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
2970 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
2971 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
2972 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
2973 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
2974 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2975 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2977 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_acquire_monotonic_cmpxchg:
2978 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2979 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
2980 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2981 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
2982 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
2983 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2984 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
2985 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
2986 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
2987 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
2988 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
2989 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
2990 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2992 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_acquire_monotonic_cmpxchg:
2993 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
2994 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
2995 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2996 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
2997 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
2998 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2999 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
3000 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
3001 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3002 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
3003 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
3004 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3005 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
3007 ; GFX940-TGSPLIT-LABEL: flat_singlethread_acquire_monotonic_cmpxchg:
3008 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
3009 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
3010 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3011 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
3012 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
3013 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3014 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
3015 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
3016 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3017 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
3018 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
3019 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3020 ; GFX940-TGSPLIT-NEXT: s_endpgm
3022 ; GFX11-WGP-LABEL: flat_singlethread_acquire_monotonic_cmpxchg:
3023 ; GFX11-WGP: ; %bb.0: ; %entry
3024 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
3025 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3026 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
3027 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
3028 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3029 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
3030 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
3031 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3032 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
3033 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
3034 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
3035 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3036 ; GFX11-WGP-NEXT: s_endpgm
3038 ; GFX11-CU-LABEL: flat_singlethread_acquire_monotonic_cmpxchg:
3039 ; GFX11-CU: ; %bb.0: ; %entry
3040 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
3041 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3042 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
3043 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
3044 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3045 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
3046 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
3047 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3048 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
3049 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
3050 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
3051 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3052 ; GFX11-CU-NEXT: s_endpgm
3054 ; GFX12-WGP-LABEL: flat_singlethread_acquire_monotonic_cmpxchg:
3055 ; GFX12-WGP: ; %bb.0: ; %entry
3056 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
3057 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3058 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
3059 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
3060 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
3061 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
3062 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
3063 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3064 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
3065 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
3066 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
3067 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3068 ; GFX12-WGP-NEXT: s_endpgm
3070 ; GFX12-CU-LABEL: flat_singlethread_acquire_monotonic_cmpxchg:
3071 ; GFX12-CU: ; %bb.0: ; %entry
3072 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
3073 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3074 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
3075 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
3076 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
3077 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
3078 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
3079 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3080 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
3081 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
3082 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
3083 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3084 ; GFX12-CU-NEXT: s_endpgm
3085 ptr %out, i32 %in, i32 %old) {
3087 %gep = getelementptr i32, ptr %out, i32 4
3088 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") acquire monotonic
3092 define amdgpu_kernel void @flat_singlethread_release_monotonic_cmpxchg(
3093 ; GFX7-LABEL: flat_singlethread_release_monotonic_cmpxchg:
3094 ; GFX7: ; %bb.0: ; %entry
3095 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
3096 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
3097 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
3098 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
3099 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
3100 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3101 ; GFX7-NEXT: s_mov_b32 s4, s8
3102 ; GFX7-NEXT: s_mov_b32 s5, s9
3103 ; GFX7-NEXT: s_mov_b32 s9, s10
3104 ; GFX7-NEXT: s_mov_b32 s8, s11
3105 ; GFX7-NEXT: s_add_u32 s4, s4, s9
3106 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
3107 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
3108 ; GFX7-NEXT: s_mov_b32 s5, s8
3109 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
3110 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
3111 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3112 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
3113 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
3114 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
3115 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3116 ; GFX7-NEXT: s_endpgm
3118 ; GFX10-WGP-LABEL: flat_singlethread_release_monotonic_cmpxchg:
3119 ; GFX10-WGP: ; %bb.0: ; %entry
3120 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
3121 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
3122 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
3123 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
3124 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
3125 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3126 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
3127 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
3128 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
3129 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
3130 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
3131 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
3132 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
3133 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
3134 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
3135 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
3136 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3137 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
3138 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
3139 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
3140 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3141 ; GFX10-WGP-NEXT: s_endpgm
3143 ; GFX10-CU-LABEL: flat_singlethread_release_monotonic_cmpxchg:
3144 ; GFX10-CU: ; %bb.0: ; %entry
3145 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
3146 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
3147 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
3148 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
3149 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
3150 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3151 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
3152 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
3153 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
3154 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
3155 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
3156 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
3157 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
3158 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
3159 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
3160 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
3161 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3162 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
3163 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
3164 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
3165 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3166 ; GFX10-CU-NEXT: s_endpgm
3168 ; SKIP-CACHE-INV-LABEL: flat_singlethread_release_monotonic_cmpxchg:
3169 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3170 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
3171 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
3172 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
3173 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
3174 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
3175 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3176 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
3177 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
3178 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
3179 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
3180 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
3181 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
3182 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
3183 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
3184 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
3185 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
3186 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3187 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
3188 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
3189 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
3190 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3191 ; SKIP-CACHE-INV-NEXT: s_endpgm
3193 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_release_monotonic_cmpxchg:
3194 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3195 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
3196 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
3197 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
3198 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
3199 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3200 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
3201 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
3202 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3203 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
3204 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
3205 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3206 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3208 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_release_monotonic_cmpxchg:
3209 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3210 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
3211 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
3212 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
3213 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
3214 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3215 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
3216 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
3217 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3218 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
3219 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
3220 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3221 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3223 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_release_monotonic_cmpxchg:
3224 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
3225 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
3226 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3227 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
3228 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
3229 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3230 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
3231 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
3232 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3233 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
3234 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
3235 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3236 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
3238 ; GFX940-TGSPLIT-LABEL: flat_singlethread_release_monotonic_cmpxchg:
3239 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
3240 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
3241 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3242 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
3243 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
3244 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3245 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
3246 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
3247 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3248 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
3249 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
3250 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3251 ; GFX940-TGSPLIT-NEXT: s_endpgm
3253 ; GFX11-WGP-LABEL: flat_singlethread_release_monotonic_cmpxchg:
3254 ; GFX11-WGP: ; %bb.0: ; %entry
3255 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
3256 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3257 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
3258 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
3259 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3260 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
3261 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
3262 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3263 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
3264 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
3265 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
3266 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3267 ; GFX11-WGP-NEXT: s_endpgm
3269 ; GFX11-CU-LABEL: flat_singlethread_release_monotonic_cmpxchg:
3270 ; GFX11-CU: ; %bb.0: ; %entry
3271 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
3272 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3273 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
3274 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
3275 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3276 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
3277 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
3278 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3279 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
3280 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
3281 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
3282 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3283 ; GFX11-CU-NEXT: s_endpgm
3285 ; GFX12-WGP-LABEL: flat_singlethread_release_monotonic_cmpxchg:
3286 ; GFX12-WGP: ; %bb.0: ; %entry
3287 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
3288 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3289 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
3290 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
3291 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
3292 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
3293 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
3294 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3295 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
3296 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
3297 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
3298 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3299 ; GFX12-WGP-NEXT: s_endpgm
3301 ; GFX12-CU-LABEL: flat_singlethread_release_monotonic_cmpxchg:
3302 ; GFX12-CU: ; %bb.0: ; %entry
3303 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
3304 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3305 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
3306 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
3307 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
3308 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
3309 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
3310 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3311 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
3312 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
3313 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
3314 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3315 ; GFX12-CU-NEXT: s_endpgm
3316 ptr %out, i32 %in, i32 %old) {
3318 %gep = getelementptr i32, ptr %out, i32 4
3319 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") release monotonic
3323 define amdgpu_kernel void @flat_singlethread_acq_rel_monotonic_cmpxchg(
3324 ; GFX7-LABEL: flat_singlethread_acq_rel_monotonic_cmpxchg:
3325 ; GFX7: ; %bb.0: ; %entry
3326 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
3327 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
3328 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
3329 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
3330 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
3331 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3332 ; GFX7-NEXT: s_mov_b32 s4, s8
3333 ; GFX7-NEXT: s_mov_b32 s5, s9
3334 ; GFX7-NEXT: s_mov_b32 s9, s10
3335 ; GFX7-NEXT: s_mov_b32 s8, s11
3336 ; GFX7-NEXT: s_add_u32 s4, s4, s9
3337 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
3338 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
3339 ; GFX7-NEXT: s_mov_b32 s5, s8
3340 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
3341 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
3342 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3343 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
3344 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
3345 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
3346 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3347 ; GFX7-NEXT: s_endpgm
3349 ; GFX10-WGP-LABEL: flat_singlethread_acq_rel_monotonic_cmpxchg:
3350 ; GFX10-WGP: ; %bb.0: ; %entry
3351 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
3352 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
3353 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
3354 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
3355 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
3356 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3357 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
3358 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
3359 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
3360 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
3361 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
3362 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
3363 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
3364 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
3365 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
3366 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
3367 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3368 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
3369 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
3370 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
3371 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3372 ; GFX10-WGP-NEXT: s_endpgm
3374 ; GFX10-CU-LABEL: flat_singlethread_acq_rel_monotonic_cmpxchg:
3375 ; GFX10-CU: ; %bb.0: ; %entry
3376 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
3377 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
3378 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
3379 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
3380 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
3381 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3382 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
3383 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
3384 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
3385 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
3386 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
3387 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
3388 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
3389 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
3390 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
3391 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
3392 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3393 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
3394 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
3395 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
3396 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3397 ; GFX10-CU-NEXT: s_endpgm
3399 ; SKIP-CACHE-INV-LABEL: flat_singlethread_acq_rel_monotonic_cmpxchg:
3400 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3401 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
3402 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
3403 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
3404 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
3405 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
3406 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3407 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
3408 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
3409 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
3410 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
3411 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
3412 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
3413 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
3414 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
3415 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
3416 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
3417 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3418 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
3419 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
3420 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
3421 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3422 ; SKIP-CACHE-INV-NEXT: s_endpgm
3424 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_acq_rel_monotonic_cmpxchg:
3425 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3426 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
3427 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
3428 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
3429 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
3430 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3431 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
3432 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
3433 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3434 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
3435 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
3436 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3437 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3439 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_acq_rel_monotonic_cmpxchg:
3440 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3441 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
3442 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
3443 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
3444 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
3445 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3446 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
3447 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
3448 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3449 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
3450 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
3451 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3452 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3454 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_acq_rel_monotonic_cmpxchg:
3455 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
3456 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
3457 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3458 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
3459 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
3460 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3461 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
3462 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
3463 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3464 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
3465 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
3466 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3467 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
3469 ; GFX940-TGSPLIT-LABEL: flat_singlethread_acq_rel_monotonic_cmpxchg:
3470 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
3471 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
3472 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3473 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
3474 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
3475 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3476 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
3477 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
3478 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3479 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
3480 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
3481 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3482 ; GFX940-TGSPLIT-NEXT: s_endpgm
3484 ; GFX11-WGP-LABEL: flat_singlethread_acq_rel_monotonic_cmpxchg:
3485 ; GFX11-WGP: ; %bb.0: ; %entry
3486 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
3487 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3488 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
3489 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
3490 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3491 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
3492 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
3493 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3494 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
3495 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
3496 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
3497 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3498 ; GFX11-WGP-NEXT: s_endpgm
3500 ; GFX11-CU-LABEL: flat_singlethread_acq_rel_monotonic_cmpxchg:
3501 ; GFX11-CU: ; %bb.0: ; %entry
3502 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
3503 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3504 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
3505 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
3506 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3507 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
3508 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
3509 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3510 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
3511 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
3512 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
3513 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3514 ; GFX11-CU-NEXT: s_endpgm
3516 ; GFX12-WGP-LABEL: flat_singlethread_acq_rel_monotonic_cmpxchg:
3517 ; GFX12-WGP: ; %bb.0: ; %entry
3518 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
3519 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3520 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
3521 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
3522 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
3523 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
3524 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
3525 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3526 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
3527 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
3528 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
3529 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3530 ; GFX12-WGP-NEXT: s_endpgm
3532 ; GFX12-CU-LABEL: flat_singlethread_acq_rel_monotonic_cmpxchg:
3533 ; GFX12-CU: ; %bb.0: ; %entry
3534 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
3535 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3536 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
3537 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
3538 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
3539 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
3540 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
3541 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3542 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
3543 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
3544 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
3545 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3546 ; GFX12-CU-NEXT: s_endpgm
3547 ptr %out, i32 %in, i32 %old) {
3549 %gep = getelementptr i32, ptr %out, i32 4
3550 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") acq_rel monotonic
3554 define amdgpu_kernel void @flat_singlethread_seq_cst_monotonic_cmpxchg(
3555 ; GFX7-LABEL: flat_singlethread_seq_cst_monotonic_cmpxchg:
3556 ; GFX7: ; %bb.0: ; %entry
3557 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
3558 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
3559 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
3560 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
3561 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
3562 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3563 ; GFX7-NEXT: s_mov_b32 s4, s8
3564 ; GFX7-NEXT: s_mov_b32 s5, s9
3565 ; GFX7-NEXT: s_mov_b32 s9, s10
3566 ; GFX7-NEXT: s_mov_b32 s8, s11
3567 ; GFX7-NEXT: s_add_u32 s4, s4, s9
3568 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
3569 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
3570 ; GFX7-NEXT: s_mov_b32 s5, s8
3571 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
3572 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
3573 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3574 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
3575 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
3576 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
3577 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3578 ; GFX7-NEXT: s_endpgm
3580 ; GFX10-WGP-LABEL: flat_singlethread_seq_cst_monotonic_cmpxchg:
3581 ; GFX10-WGP: ; %bb.0: ; %entry
3582 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
3583 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
3584 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
3585 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
3586 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
3587 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3588 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
3589 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
3590 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
3591 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
3592 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
3593 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
3594 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
3595 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
3596 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
3597 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
3598 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3599 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
3600 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
3601 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
3602 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3603 ; GFX10-WGP-NEXT: s_endpgm
3605 ; GFX10-CU-LABEL: flat_singlethread_seq_cst_monotonic_cmpxchg:
3606 ; GFX10-CU: ; %bb.0: ; %entry
3607 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
3608 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
3609 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
3610 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
3611 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
3612 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3613 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
3614 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
3615 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
3616 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
3617 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
3618 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
3619 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
3620 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
3621 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
3622 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
3623 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3624 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
3625 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
3626 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
3627 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3628 ; GFX10-CU-NEXT: s_endpgm
3630 ; SKIP-CACHE-INV-LABEL: flat_singlethread_seq_cst_monotonic_cmpxchg:
3631 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3632 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
3633 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
3634 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
3635 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
3636 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
3637 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3638 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
3639 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
3640 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
3641 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
3642 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
3643 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
3644 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
3645 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
3646 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
3647 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
3648 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3649 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
3650 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
3651 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
3652 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3653 ; SKIP-CACHE-INV-NEXT: s_endpgm
3655 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_seq_cst_monotonic_cmpxchg:
3656 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3657 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
3658 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
3659 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
3660 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
3661 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3662 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
3663 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
3664 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3665 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
3666 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
3667 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3668 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3670 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_seq_cst_monotonic_cmpxchg:
3671 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3672 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
3673 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
3674 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
3675 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
3676 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3677 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
3678 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
3679 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3680 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
3681 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
3682 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3683 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3685 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_seq_cst_monotonic_cmpxchg:
3686 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
3687 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
3688 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3689 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
3690 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
3691 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3692 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
3693 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
3694 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3695 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
3696 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
3697 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3698 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
3700 ; GFX940-TGSPLIT-LABEL: flat_singlethread_seq_cst_monotonic_cmpxchg:
3701 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
3702 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
3703 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3704 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
3705 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
3706 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3707 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
3708 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
3709 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3710 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
3711 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
3712 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3713 ; GFX940-TGSPLIT-NEXT: s_endpgm
3715 ; GFX11-WGP-LABEL: flat_singlethread_seq_cst_monotonic_cmpxchg:
3716 ; GFX11-WGP: ; %bb.0: ; %entry
3717 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
3718 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3719 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
3720 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
3721 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3722 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
3723 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
3724 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3725 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
3726 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
3727 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
3728 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3729 ; GFX11-WGP-NEXT: s_endpgm
3731 ; GFX11-CU-LABEL: flat_singlethread_seq_cst_monotonic_cmpxchg:
3732 ; GFX11-CU: ; %bb.0: ; %entry
3733 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
3734 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3735 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
3736 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
3737 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3738 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
3739 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
3740 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3741 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
3742 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
3743 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
3744 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3745 ; GFX11-CU-NEXT: s_endpgm
3747 ; GFX12-WGP-LABEL: flat_singlethread_seq_cst_monotonic_cmpxchg:
3748 ; GFX12-WGP: ; %bb.0: ; %entry
3749 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
3750 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3751 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
3752 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
3753 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
3754 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
3755 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
3756 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3757 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
3758 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
3759 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
3760 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3761 ; GFX12-WGP-NEXT: s_endpgm
3763 ; GFX12-CU-LABEL: flat_singlethread_seq_cst_monotonic_cmpxchg:
3764 ; GFX12-CU: ; %bb.0: ; %entry
3765 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
3766 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3767 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
3768 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
3769 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
3770 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
3771 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
3772 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3773 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
3774 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
3775 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
3776 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3777 ; GFX12-CU-NEXT: s_endpgm
3778 ptr %out, i32 %in, i32 %old) {
3780 %gep = getelementptr i32, ptr %out, i32 4
3781 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") seq_cst monotonic
3785 define amdgpu_kernel void @flat_singlethread_monotonic_acquire_cmpxchg(
3786 ; GFX7-LABEL: flat_singlethread_monotonic_acquire_cmpxchg:
3787 ; GFX7: ; %bb.0: ; %entry
3788 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
3789 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
3790 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
3791 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
3792 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
3793 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3794 ; GFX7-NEXT: s_mov_b32 s4, s8
3795 ; GFX7-NEXT: s_mov_b32 s5, s9
3796 ; GFX7-NEXT: s_mov_b32 s9, s10
3797 ; GFX7-NEXT: s_mov_b32 s8, s11
3798 ; GFX7-NEXT: s_add_u32 s4, s4, s9
3799 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
3800 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
3801 ; GFX7-NEXT: s_mov_b32 s5, s8
3802 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
3803 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
3804 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3805 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
3806 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
3807 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
3808 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3809 ; GFX7-NEXT: s_endpgm
3811 ; GFX10-WGP-LABEL: flat_singlethread_monotonic_acquire_cmpxchg:
3812 ; GFX10-WGP: ; %bb.0: ; %entry
3813 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
3814 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
3815 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
3816 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
3817 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
3818 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3819 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
3820 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
3821 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
3822 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
3823 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
3824 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
3825 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
3826 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
3827 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
3828 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
3829 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3830 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
3831 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
3832 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
3833 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3834 ; GFX10-WGP-NEXT: s_endpgm
3836 ; GFX10-CU-LABEL: flat_singlethread_monotonic_acquire_cmpxchg:
3837 ; GFX10-CU: ; %bb.0: ; %entry
3838 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
3839 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
3840 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
3841 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
3842 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
3843 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3844 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
3845 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
3846 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
3847 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
3848 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
3849 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
3850 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
3851 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
3852 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
3853 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
3854 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3855 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
3856 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
3857 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
3858 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3859 ; GFX10-CU-NEXT: s_endpgm
3861 ; SKIP-CACHE-INV-LABEL: flat_singlethread_monotonic_acquire_cmpxchg:
3862 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3863 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
3864 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
3865 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
3866 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
3867 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
3868 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3869 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
3870 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
3871 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
3872 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
3873 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
3874 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
3875 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
3876 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
3877 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
3878 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
3879 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3880 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
3881 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
3882 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
3883 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3884 ; SKIP-CACHE-INV-NEXT: s_endpgm
3886 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_monotonic_acquire_cmpxchg:
3887 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3888 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
3889 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
3890 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
3891 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
3892 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3893 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
3894 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
3895 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3896 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
3897 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
3898 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3899 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3901 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_monotonic_acquire_cmpxchg:
3902 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3903 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
3904 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
3905 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
3906 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
3907 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3908 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
3909 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
3910 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3911 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
3912 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
3913 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3914 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3916 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_monotonic_acquire_cmpxchg:
3917 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
3918 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
3919 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3920 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
3921 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
3922 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3923 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
3924 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
3925 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3926 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
3927 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
3928 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3929 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
3931 ; GFX940-TGSPLIT-LABEL: flat_singlethread_monotonic_acquire_cmpxchg:
3932 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
3933 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
3934 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3935 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
3936 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
3937 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3938 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
3939 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
3940 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3941 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
3942 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
3943 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
3944 ; GFX940-TGSPLIT-NEXT: s_endpgm
3946 ; GFX11-WGP-LABEL: flat_singlethread_monotonic_acquire_cmpxchg:
3947 ; GFX11-WGP: ; %bb.0: ; %entry
3948 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
3949 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3950 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
3951 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
3952 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3953 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
3954 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
3955 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3956 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
3957 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
3958 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
3959 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3960 ; GFX11-WGP-NEXT: s_endpgm
3962 ; GFX11-CU-LABEL: flat_singlethread_monotonic_acquire_cmpxchg:
3963 ; GFX11-CU: ; %bb.0: ; %entry
3964 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
3965 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3966 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
3967 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
3968 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3969 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
3970 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
3971 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3972 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
3973 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
3974 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
3975 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3976 ; GFX11-CU-NEXT: s_endpgm
3978 ; GFX12-WGP-LABEL: flat_singlethread_monotonic_acquire_cmpxchg:
3979 ; GFX12-WGP: ; %bb.0: ; %entry
3980 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
3981 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3982 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
3983 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
3984 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
3985 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
3986 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
3987 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3988 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
3989 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
3990 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
3991 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
3992 ; GFX12-WGP-NEXT: s_endpgm
3994 ; GFX12-CU-LABEL: flat_singlethread_monotonic_acquire_cmpxchg:
3995 ; GFX12-CU: ; %bb.0: ; %entry
3996 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
3997 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3998 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
3999 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
4000 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
4001 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
4002 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
4003 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4004 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
4005 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
4006 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
4007 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
4008 ; GFX12-CU-NEXT: s_endpgm
4009 ptr %out, i32 %in, i32 %old) {
4011 %gep = getelementptr i32, ptr %out, i32 4
4012 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") monotonic acquire
4016 define amdgpu_kernel void @flat_singlethread_acquire_acquire_cmpxchg(
4017 ; GFX7-LABEL: flat_singlethread_acquire_acquire_cmpxchg:
4018 ; GFX7: ; %bb.0: ; %entry
4019 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
4020 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
4021 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
4022 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
4023 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
4024 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4025 ; GFX7-NEXT: s_mov_b32 s4, s8
4026 ; GFX7-NEXT: s_mov_b32 s5, s9
4027 ; GFX7-NEXT: s_mov_b32 s9, s10
4028 ; GFX7-NEXT: s_mov_b32 s8, s11
4029 ; GFX7-NEXT: s_add_u32 s4, s4, s9
4030 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
4031 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
4032 ; GFX7-NEXT: s_mov_b32 s5, s8
4033 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
4034 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
4035 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4036 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
4037 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
4038 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
4039 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4040 ; GFX7-NEXT: s_endpgm
4042 ; GFX10-WGP-LABEL: flat_singlethread_acquire_acquire_cmpxchg:
4043 ; GFX10-WGP: ; %bb.0: ; %entry
4044 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
4045 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
4046 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
4047 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
4048 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
4049 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4050 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
4051 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
4052 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
4053 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
4054 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
4055 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
4056 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
4057 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
4058 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
4059 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
4060 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4061 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
4062 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
4063 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
4064 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4065 ; GFX10-WGP-NEXT: s_endpgm
4067 ; GFX10-CU-LABEL: flat_singlethread_acquire_acquire_cmpxchg:
4068 ; GFX10-CU: ; %bb.0: ; %entry
4069 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
4070 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
4071 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
4072 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
4073 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
4074 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4075 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
4076 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
4077 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
4078 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
4079 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
4080 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
4081 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
4082 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
4083 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
4084 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
4085 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4086 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
4087 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
4088 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
4089 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4090 ; GFX10-CU-NEXT: s_endpgm
4092 ; SKIP-CACHE-INV-LABEL: flat_singlethread_acquire_acquire_cmpxchg:
4093 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4094 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
4095 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
4096 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
4097 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
4098 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
4099 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4100 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
4101 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
4102 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
4103 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
4104 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
4105 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
4106 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
4107 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
4108 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
4109 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
4110 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4111 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
4112 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
4113 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
4114 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4115 ; SKIP-CACHE-INV-NEXT: s_endpgm
4117 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_acquire_acquire_cmpxchg:
4118 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4119 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
4120 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
4121 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
4122 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
4123 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4124 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
4125 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
4126 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4127 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
4128 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
4129 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
4130 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4132 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_acquire_acquire_cmpxchg:
4133 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4134 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
4135 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
4136 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
4137 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
4138 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4139 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
4140 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
4141 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4142 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
4143 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
4144 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
4145 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4147 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_acquire_acquire_cmpxchg:
4148 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
4149 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
4150 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4151 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
4152 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
4153 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4154 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
4155 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
4156 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4157 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
4158 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
4159 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
4160 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
4162 ; GFX940-TGSPLIT-LABEL: flat_singlethread_acquire_acquire_cmpxchg:
4163 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
4164 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
4165 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4166 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
4167 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
4168 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4169 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
4170 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
4171 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4172 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
4173 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
4174 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
4175 ; GFX940-TGSPLIT-NEXT: s_endpgm
4177 ; GFX11-WGP-LABEL: flat_singlethread_acquire_acquire_cmpxchg:
4178 ; GFX11-WGP: ; %bb.0: ; %entry
4179 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
4180 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4181 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
4182 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
4183 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
4184 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
4185 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
4186 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4187 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
4188 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
4189 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
4190 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
4191 ; GFX11-WGP-NEXT: s_endpgm
4193 ; GFX11-CU-LABEL: flat_singlethread_acquire_acquire_cmpxchg:
4194 ; GFX11-CU: ; %bb.0: ; %entry
4195 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
4196 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4197 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
4198 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
4199 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4200 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
4201 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
4202 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4203 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
4204 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
4205 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
4206 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
4207 ; GFX11-CU-NEXT: s_endpgm
4209 ; GFX12-WGP-LABEL: flat_singlethread_acquire_acquire_cmpxchg:
4210 ; GFX12-WGP: ; %bb.0: ; %entry
4211 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
4212 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4213 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
4214 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
4215 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
4216 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
4217 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
4218 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4219 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
4220 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
4221 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
4222 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
4223 ; GFX12-WGP-NEXT: s_endpgm
4225 ; GFX12-CU-LABEL: flat_singlethread_acquire_acquire_cmpxchg:
4226 ; GFX12-CU: ; %bb.0: ; %entry
4227 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
4228 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4229 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
4230 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
4231 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
4232 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
4233 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
4234 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4235 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
4236 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
4237 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
4238 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
4239 ; GFX12-CU-NEXT: s_endpgm
4240 ptr %out, i32 %in, i32 %old) {
4242 %gep = getelementptr i32, ptr %out, i32 4
4243 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") acquire acquire
4247 define amdgpu_kernel void @flat_singlethread_release_acquire_cmpxchg(
4248 ; GFX7-LABEL: flat_singlethread_release_acquire_cmpxchg:
4249 ; GFX7: ; %bb.0: ; %entry
4250 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
4251 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
4252 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
4253 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
4254 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
4255 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4256 ; GFX7-NEXT: s_mov_b32 s4, s8
4257 ; GFX7-NEXT: s_mov_b32 s5, s9
4258 ; GFX7-NEXT: s_mov_b32 s9, s10
4259 ; GFX7-NEXT: s_mov_b32 s8, s11
4260 ; GFX7-NEXT: s_add_u32 s4, s4, s9
4261 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
4262 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
4263 ; GFX7-NEXT: s_mov_b32 s5, s8
4264 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
4265 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
4266 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4267 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
4268 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
4269 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
4270 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4271 ; GFX7-NEXT: s_endpgm
4273 ; GFX10-WGP-LABEL: flat_singlethread_release_acquire_cmpxchg:
4274 ; GFX10-WGP: ; %bb.0: ; %entry
4275 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
4276 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
4277 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
4278 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
4279 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
4280 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4281 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
4282 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
4283 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
4284 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
4285 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
4286 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
4287 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
4288 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
4289 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
4290 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
4291 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4292 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
4293 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
4294 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
4295 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4296 ; GFX10-WGP-NEXT: s_endpgm
4298 ; GFX10-CU-LABEL: flat_singlethread_release_acquire_cmpxchg:
4299 ; GFX10-CU: ; %bb.0: ; %entry
4300 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
4301 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
4302 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
4303 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
4304 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
4305 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4306 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
4307 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
4308 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
4309 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
4310 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
4311 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
4312 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
4313 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
4314 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
4315 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
4316 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4317 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
4318 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
4319 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
4320 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4321 ; GFX10-CU-NEXT: s_endpgm
4323 ; SKIP-CACHE-INV-LABEL: flat_singlethread_release_acquire_cmpxchg:
4324 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4325 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
4326 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
4327 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
4328 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
4329 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
4330 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4331 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
4332 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
4333 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
4334 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
4335 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
4336 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
4337 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
4338 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
4339 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
4340 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
4341 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4342 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
4343 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
4344 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
4345 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4346 ; SKIP-CACHE-INV-NEXT: s_endpgm
4348 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_release_acquire_cmpxchg:
4349 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4350 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
4351 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
4352 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
4353 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
4354 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4355 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
4356 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
4357 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4358 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
4359 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
4360 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
4361 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4363 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_release_acquire_cmpxchg:
4364 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4365 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
4366 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
4367 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
4368 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
4369 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4370 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
4371 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
4372 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4373 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
4374 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
4375 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
4376 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4378 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_release_acquire_cmpxchg:
4379 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
4380 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
4381 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4382 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
4383 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
4384 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4385 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
4386 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
4387 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4388 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
4389 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
4390 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
4391 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
4393 ; GFX940-TGSPLIT-LABEL: flat_singlethread_release_acquire_cmpxchg:
4394 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
4395 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
4396 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4397 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
4398 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
4399 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4400 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
4401 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
4402 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4403 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
4404 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
4405 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
4406 ; GFX940-TGSPLIT-NEXT: s_endpgm
4408 ; GFX11-WGP-LABEL: flat_singlethread_release_acquire_cmpxchg:
4409 ; GFX11-WGP: ; %bb.0: ; %entry
4410 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
4411 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4412 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
4413 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
4414 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
4415 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
4416 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
4417 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4418 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
4419 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
4420 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
4421 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
4422 ; GFX11-WGP-NEXT: s_endpgm
4424 ; GFX11-CU-LABEL: flat_singlethread_release_acquire_cmpxchg:
4425 ; GFX11-CU: ; %bb.0: ; %entry
4426 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
4427 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4428 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
4429 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
4430 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4431 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
4432 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
4433 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4434 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
4435 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
4436 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
4437 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
4438 ; GFX11-CU-NEXT: s_endpgm
4440 ; GFX12-WGP-LABEL: flat_singlethread_release_acquire_cmpxchg:
4441 ; GFX12-WGP: ; %bb.0: ; %entry
4442 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
4443 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4444 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
4445 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
4446 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
4447 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
4448 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
4449 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4450 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
4451 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
4452 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
4453 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
4454 ; GFX12-WGP-NEXT: s_endpgm
4456 ; GFX12-CU-LABEL: flat_singlethread_release_acquire_cmpxchg:
4457 ; GFX12-CU: ; %bb.0: ; %entry
4458 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
4459 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4460 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
4461 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
4462 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
4463 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
4464 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
4465 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4466 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
4467 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
4468 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
4469 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
4470 ; GFX12-CU-NEXT: s_endpgm
4471 ptr %out, i32 %in, i32 %old) {
4473 %gep = getelementptr i32, ptr %out, i32 4
4474 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") release acquire
4478 define amdgpu_kernel void @flat_singlethread_acq_rel_acquire_cmpxchg(
4479 ; GFX7-LABEL: flat_singlethread_acq_rel_acquire_cmpxchg:
4480 ; GFX7: ; %bb.0: ; %entry
4481 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
4482 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
4483 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
4484 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
4485 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
4486 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4487 ; GFX7-NEXT: s_mov_b32 s4, s8
4488 ; GFX7-NEXT: s_mov_b32 s5, s9
4489 ; GFX7-NEXT: s_mov_b32 s9, s10
4490 ; GFX7-NEXT: s_mov_b32 s8, s11
4491 ; GFX7-NEXT: s_add_u32 s4, s4, s9
4492 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
4493 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
4494 ; GFX7-NEXT: s_mov_b32 s5, s8
4495 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
4496 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
4497 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4498 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
4499 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
4500 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
4501 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4502 ; GFX7-NEXT: s_endpgm
4504 ; GFX10-WGP-LABEL: flat_singlethread_acq_rel_acquire_cmpxchg:
4505 ; GFX10-WGP: ; %bb.0: ; %entry
4506 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
4507 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
4508 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
4509 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
4510 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
4511 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4512 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
4513 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
4514 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
4515 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
4516 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
4517 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
4518 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
4519 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
4520 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
4521 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
4522 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4523 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
4524 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
4525 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
4526 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4527 ; GFX10-WGP-NEXT: s_endpgm
4529 ; GFX10-CU-LABEL: flat_singlethread_acq_rel_acquire_cmpxchg:
4530 ; GFX10-CU: ; %bb.0: ; %entry
4531 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
4532 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
4533 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
4534 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
4535 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
4536 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4537 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
4538 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
4539 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
4540 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
4541 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
4542 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
4543 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
4544 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
4545 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
4546 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
4547 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4548 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
4549 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
4550 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
4551 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4552 ; GFX10-CU-NEXT: s_endpgm
4554 ; SKIP-CACHE-INV-LABEL: flat_singlethread_acq_rel_acquire_cmpxchg:
4555 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4556 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
4557 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
4558 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
4559 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
4560 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
4561 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4562 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
4563 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
4564 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
4565 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
4566 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
4567 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
4568 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
4569 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
4570 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
4571 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
4572 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4573 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
4574 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
4575 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
4576 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4577 ; SKIP-CACHE-INV-NEXT: s_endpgm
4579 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_acq_rel_acquire_cmpxchg:
4580 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4581 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
4582 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
4583 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
4584 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
4585 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4586 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
4587 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
4588 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4589 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
4590 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
4591 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
4592 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4594 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_acq_rel_acquire_cmpxchg:
4595 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4596 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
4597 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
4598 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
4599 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
4600 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4601 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
4602 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
4603 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4604 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
4605 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
4606 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
4607 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4609 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_acq_rel_acquire_cmpxchg:
4610 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
4611 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
4612 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4613 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
4614 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
4615 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4616 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
4617 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
4618 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4619 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
4620 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
4621 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
4622 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
4624 ; GFX940-TGSPLIT-LABEL: flat_singlethread_acq_rel_acquire_cmpxchg:
4625 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
4626 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
4627 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4628 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
4629 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
4630 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4631 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
4632 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
4633 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4634 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
4635 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
4636 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
4637 ; GFX940-TGSPLIT-NEXT: s_endpgm
4639 ; GFX11-WGP-LABEL: flat_singlethread_acq_rel_acquire_cmpxchg:
4640 ; GFX11-WGP: ; %bb.0: ; %entry
4641 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
4642 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4643 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
4644 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
4645 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
4646 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
4647 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
4648 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4649 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
4650 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
4651 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
4652 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
4653 ; GFX11-WGP-NEXT: s_endpgm
4655 ; GFX11-CU-LABEL: flat_singlethread_acq_rel_acquire_cmpxchg:
4656 ; GFX11-CU: ; %bb.0: ; %entry
4657 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
4658 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4659 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
4660 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
4661 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4662 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
4663 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
4664 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4665 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
4666 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
4667 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
4668 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
4669 ; GFX11-CU-NEXT: s_endpgm
4671 ; GFX12-WGP-LABEL: flat_singlethread_acq_rel_acquire_cmpxchg:
4672 ; GFX12-WGP: ; %bb.0: ; %entry
4673 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
4674 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4675 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
4676 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
4677 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
4678 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
4679 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
4680 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4681 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
4682 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
4683 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
4684 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
4685 ; GFX12-WGP-NEXT: s_endpgm
4687 ; GFX12-CU-LABEL: flat_singlethread_acq_rel_acquire_cmpxchg:
4688 ; GFX12-CU: ; %bb.0: ; %entry
4689 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
4690 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4691 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
4692 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
4693 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
4694 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
4695 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
4696 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4697 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
4698 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
4699 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
4700 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
4701 ; GFX12-CU-NEXT: s_endpgm
4702 ptr %out, i32 %in, i32 %old) {
4704 %gep = getelementptr i32, ptr %out, i32 4
4705 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") acq_rel acquire
4709 define amdgpu_kernel void @flat_singlethread_seq_cst_acquire_cmpxchg(
4710 ; GFX7-LABEL: flat_singlethread_seq_cst_acquire_cmpxchg:
4711 ; GFX7: ; %bb.0: ; %entry
4712 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
4713 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
4714 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
4715 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
4716 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
4717 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4718 ; GFX7-NEXT: s_mov_b32 s4, s8
4719 ; GFX7-NEXT: s_mov_b32 s5, s9
4720 ; GFX7-NEXT: s_mov_b32 s9, s10
4721 ; GFX7-NEXT: s_mov_b32 s8, s11
4722 ; GFX7-NEXT: s_add_u32 s4, s4, s9
4723 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
4724 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
4725 ; GFX7-NEXT: s_mov_b32 s5, s8
4726 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
4727 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
4728 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4729 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
4730 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
4731 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
4732 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4733 ; GFX7-NEXT: s_endpgm
4735 ; GFX10-WGP-LABEL: flat_singlethread_seq_cst_acquire_cmpxchg:
4736 ; GFX10-WGP: ; %bb.0: ; %entry
4737 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
4738 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
4739 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
4740 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
4741 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
4742 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4743 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
4744 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
4745 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
4746 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
4747 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
4748 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
4749 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
4750 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
4751 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
4752 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
4753 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4754 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
4755 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
4756 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
4757 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4758 ; GFX10-WGP-NEXT: s_endpgm
4760 ; GFX10-CU-LABEL: flat_singlethread_seq_cst_acquire_cmpxchg:
4761 ; GFX10-CU: ; %bb.0: ; %entry
4762 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
4763 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
4764 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
4765 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
4766 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
4767 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4768 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
4769 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
4770 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
4771 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
4772 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
4773 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
4774 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
4775 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
4776 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
4777 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
4778 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4779 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
4780 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
4781 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
4782 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4783 ; GFX10-CU-NEXT: s_endpgm
4785 ; SKIP-CACHE-INV-LABEL: flat_singlethread_seq_cst_acquire_cmpxchg:
4786 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4787 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
4788 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
4789 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
4790 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
4791 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
4792 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4793 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
4794 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
4795 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
4796 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
4797 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
4798 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
4799 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
4800 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
4801 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
4802 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
4803 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4804 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
4805 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
4806 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
4807 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4808 ; SKIP-CACHE-INV-NEXT: s_endpgm
4810 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_seq_cst_acquire_cmpxchg:
4811 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4812 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
4813 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
4814 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
4815 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
4816 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4817 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
4818 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
4819 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4820 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
4821 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
4822 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
4823 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4825 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_seq_cst_acquire_cmpxchg:
4826 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4827 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
4828 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
4829 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
4830 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
4831 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4832 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
4833 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
4834 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4835 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
4836 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
4837 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
4838 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4840 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_seq_cst_acquire_cmpxchg:
4841 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
4842 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
4843 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4844 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
4845 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
4846 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4847 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
4848 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
4849 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4850 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
4851 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
4852 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
4853 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
4855 ; GFX940-TGSPLIT-LABEL: flat_singlethread_seq_cst_acquire_cmpxchg:
4856 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
4857 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
4858 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4859 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
4860 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
4861 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4862 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
4863 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
4864 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4865 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
4866 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
4867 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
4868 ; GFX940-TGSPLIT-NEXT: s_endpgm
4870 ; GFX11-WGP-LABEL: flat_singlethread_seq_cst_acquire_cmpxchg:
4871 ; GFX11-WGP: ; %bb.0: ; %entry
4872 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
4873 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4874 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
4875 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
4876 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
4877 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
4878 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
4879 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4880 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
4881 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
4882 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
4883 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
4884 ; GFX11-WGP-NEXT: s_endpgm
4886 ; GFX11-CU-LABEL: flat_singlethread_seq_cst_acquire_cmpxchg:
4887 ; GFX11-CU: ; %bb.0: ; %entry
4888 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
4889 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4890 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
4891 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
4892 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4893 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
4894 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
4895 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4896 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
4897 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
4898 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
4899 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
4900 ; GFX11-CU-NEXT: s_endpgm
4902 ; GFX12-WGP-LABEL: flat_singlethread_seq_cst_acquire_cmpxchg:
4903 ; GFX12-WGP: ; %bb.0: ; %entry
4904 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
4905 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4906 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
4907 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
4908 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
4909 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
4910 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
4911 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4912 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
4913 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
4914 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
4915 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
4916 ; GFX12-WGP-NEXT: s_endpgm
4918 ; GFX12-CU-LABEL: flat_singlethread_seq_cst_acquire_cmpxchg:
4919 ; GFX12-CU: ; %bb.0: ; %entry
4920 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
4921 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4922 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
4923 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
4924 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
4925 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
4926 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
4927 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4928 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
4929 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
4930 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
4931 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
4932 ; GFX12-CU-NEXT: s_endpgm
4933 ptr %out, i32 %in, i32 %old) {
4935 %gep = getelementptr i32, ptr %out, i32 4
4936 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") seq_cst acquire
4940 define amdgpu_kernel void @flat_singlethread_monotonic_seq_cst_cmpxchg(
4941 ; GFX7-LABEL: flat_singlethread_monotonic_seq_cst_cmpxchg:
4942 ; GFX7: ; %bb.0: ; %entry
4943 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
4944 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
4945 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
4946 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
4947 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
4948 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4949 ; GFX7-NEXT: s_mov_b32 s4, s8
4950 ; GFX7-NEXT: s_mov_b32 s5, s9
4951 ; GFX7-NEXT: s_mov_b32 s9, s10
4952 ; GFX7-NEXT: s_mov_b32 s8, s11
4953 ; GFX7-NEXT: s_add_u32 s4, s4, s9
4954 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
4955 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
4956 ; GFX7-NEXT: s_mov_b32 s5, s8
4957 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
4958 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
4959 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4960 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
4961 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
4962 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
4963 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4964 ; GFX7-NEXT: s_endpgm
4966 ; GFX10-WGP-LABEL: flat_singlethread_monotonic_seq_cst_cmpxchg:
4967 ; GFX10-WGP: ; %bb.0: ; %entry
4968 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
4969 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
4970 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
4971 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
4972 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
4973 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4974 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
4975 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
4976 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
4977 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
4978 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
4979 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
4980 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
4981 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
4982 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
4983 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
4984 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4985 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
4986 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
4987 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
4988 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4989 ; GFX10-WGP-NEXT: s_endpgm
4991 ; GFX10-CU-LABEL: flat_singlethread_monotonic_seq_cst_cmpxchg:
4992 ; GFX10-CU: ; %bb.0: ; %entry
4993 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
4994 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
4995 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
4996 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
4997 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
4998 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4999 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
5000 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
5001 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
5002 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
5003 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
5004 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
5005 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
5006 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
5007 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
5008 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
5009 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5010 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
5011 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
5012 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
5013 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
5014 ; GFX10-CU-NEXT: s_endpgm
5016 ; SKIP-CACHE-INV-LABEL: flat_singlethread_monotonic_seq_cst_cmpxchg:
5017 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5018 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
5019 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
5020 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
5021 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
5022 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
5023 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5024 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
5025 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
5026 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
5027 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
5028 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
5029 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
5030 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
5031 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
5032 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
5033 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
5034 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5035 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
5036 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
5037 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
5038 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
5039 ; SKIP-CACHE-INV-NEXT: s_endpgm
5041 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_monotonic_seq_cst_cmpxchg:
5042 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5043 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
5044 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
5045 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
5046 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
5047 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5048 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
5049 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
5050 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5051 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
5052 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
5053 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
5054 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5056 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_monotonic_seq_cst_cmpxchg:
5057 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5058 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
5059 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
5060 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
5061 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
5062 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5063 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
5064 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
5065 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5066 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
5067 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
5068 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
5069 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5071 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_monotonic_seq_cst_cmpxchg:
5072 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
5073 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
5074 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5075 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
5076 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
5077 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5078 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
5079 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
5080 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5081 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
5082 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
5083 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
5084 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
5086 ; GFX940-TGSPLIT-LABEL: flat_singlethread_monotonic_seq_cst_cmpxchg:
5087 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
5088 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
5089 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5090 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
5091 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
5092 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5093 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
5094 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
5095 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5096 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
5097 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
5098 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
5099 ; GFX940-TGSPLIT-NEXT: s_endpgm
5101 ; GFX11-WGP-LABEL: flat_singlethread_monotonic_seq_cst_cmpxchg:
5102 ; GFX11-WGP: ; %bb.0: ; %entry
5103 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
5104 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5105 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
5106 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
5107 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
5108 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
5109 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
5110 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5111 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
5112 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
5113 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
5114 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
5115 ; GFX11-WGP-NEXT: s_endpgm
5117 ; GFX11-CU-LABEL: flat_singlethread_monotonic_seq_cst_cmpxchg:
5118 ; GFX11-CU: ; %bb.0: ; %entry
5119 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
5120 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5121 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
5122 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
5123 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5124 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
5125 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
5126 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5127 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
5128 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
5129 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
5130 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
5131 ; GFX11-CU-NEXT: s_endpgm
5133 ; GFX12-WGP-LABEL: flat_singlethread_monotonic_seq_cst_cmpxchg:
5134 ; GFX12-WGP: ; %bb.0: ; %entry
5135 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
5136 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5137 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
5138 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
5139 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
5140 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
5141 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
5142 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5143 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
5144 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
5145 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
5146 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
5147 ; GFX12-WGP-NEXT: s_endpgm
5149 ; GFX12-CU-LABEL: flat_singlethread_monotonic_seq_cst_cmpxchg:
5150 ; GFX12-CU: ; %bb.0: ; %entry
5151 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
5152 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5153 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
5154 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
5155 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
5156 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
5157 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
5158 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5159 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
5160 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
5161 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
5162 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
5163 ; GFX12-CU-NEXT: s_endpgm
5164 ptr %out, i32 %in, i32 %old) {
5166 %gep = getelementptr i32, ptr %out, i32 4
5167 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") monotonic seq_cst
5171 define amdgpu_kernel void @flat_singlethread_acquire_seq_cst_cmpxchg(
5172 ; GFX7-LABEL: flat_singlethread_acquire_seq_cst_cmpxchg:
5173 ; GFX7: ; %bb.0: ; %entry
5174 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
5175 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
5176 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
5177 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
5178 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
5179 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5180 ; GFX7-NEXT: s_mov_b32 s4, s8
5181 ; GFX7-NEXT: s_mov_b32 s5, s9
5182 ; GFX7-NEXT: s_mov_b32 s9, s10
5183 ; GFX7-NEXT: s_mov_b32 s8, s11
5184 ; GFX7-NEXT: s_add_u32 s4, s4, s9
5185 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
5186 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
5187 ; GFX7-NEXT: s_mov_b32 s5, s8
5188 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
5189 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
5190 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5191 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
5192 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
5193 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
5194 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
5195 ; GFX7-NEXT: s_endpgm
5197 ; GFX10-WGP-LABEL: flat_singlethread_acquire_seq_cst_cmpxchg:
5198 ; GFX10-WGP: ; %bb.0: ; %entry
5199 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
5200 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
5201 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
5202 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
5203 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
5204 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5205 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
5206 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
5207 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
5208 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
5209 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
5210 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
5211 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
5212 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
5213 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
5214 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
5215 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5216 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
5217 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
5218 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
5219 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
5220 ; GFX10-WGP-NEXT: s_endpgm
5222 ; GFX10-CU-LABEL: flat_singlethread_acquire_seq_cst_cmpxchg:
5223 ; GFX10-CU: ; %bb.0: ; %entry
5224 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
5225 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
5226 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
5227 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
5228 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
5229 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5230 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
5231 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
5232 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
5233 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
5234 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
5235 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
5236 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
5237 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
5238 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
5239 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
5240 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5241 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
5242 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
5243 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
5244 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
5245 ; GFX10-CU-NEXT: s_endpgm
5247 ; SKIP-CACHE-INV-LABEL: flat_singlethread_acquire_seq_cst_cmpxchg:
5248 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5249 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
5250 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
5251 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
5252 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
5253 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
5254 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5255 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
5256 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
5257 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
5258 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
5259 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
5260 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
5261 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
5262 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
5263 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
5264 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
5265 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5266 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
5267 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
5268 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
5269 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
5270 ; SKIP-CACHE-INV-NEXT: s_endpgm
5272 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_acquire_seq_cst_cmpxchg:
5273 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5274 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
5275 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
5276 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
5277 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
5278 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5279 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
5280 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
5281 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5282 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
5283 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
5284 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
5285 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5287 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_acquire_seq_cst_cmpxchg:
5288 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5289 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
5290 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
5291 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
5292 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
5293 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5294 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
5295 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
5296 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5297 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
5298 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
5299 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
5300 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5302 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_acquire_seq_cst_cmpxchg:
5303 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
5304 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
5305 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5306 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
5307 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
5308 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5309 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
5310 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
5311 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5312 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
5313 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
5314 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
5315 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
5317 ; GFX940-TGSPLIT-LABEL: flat_singlethread_acquire_seq_cst_cmpxchg:
5318 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
5319 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
5320 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5321 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
5322 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
5323 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5324 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
5325 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
5326 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5327 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
5328 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
5329 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
5330 ; GFX940-TGSPLIT-NEXT: s_endpgm
5332 ; GFX11-WGP-LABEL: flat_singlethread_acquire_seq_cst_cmpxchg:
5333 ; GFX11-WGP: ; %bb.0: ; %entry
5334 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
5335 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5336 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
5337 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
5338 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
5339 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
5340 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
5341 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5342 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
5343 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
5344 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
5345 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
5346 ; GFX11-WGP-NEXT: s_endpgm
5348 ; GFX11-CU-LABEL: flat_singlethread_acquire_seq_cst_cmpxchg:
5349 ; GFX11-CU: ; %bb.0: ; %entry
5350 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
5351 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5352 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
5353 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
5354 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5355 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
5356 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
5357 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5358 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
5359 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
5360 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
5361 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
5362 ; GFX11-CU-NEXT: s_endpgm
5364 ; GFX12-WGP-LABEL: flat_singlethread_acquire_seq_cst_cmpxchg:
5365 ; GFX12-WGP: ; %bb.0: ; %entry
5366 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
5367 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5368 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
5369 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
5370 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
5371 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
5372 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
5373 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5374 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
5375 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
5376 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
5377 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
5378 ; GFX12-WGP-NEXT: s_endpgm
5380 ; GFX12-CU-LABEL: flat_singlethread_acquire_seq_cst_cmpxchg:
5381 ; GFX12-CU: ; %bb.0: ; %entry
5382 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
5383 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5384 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
5385 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
5386 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
5387 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
5388 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
5389 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5390 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
5391 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
5392 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
5393 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
5394 ; GFX12-CU-NEXT: s_endpgm
5395 ptr %out, i32 %in, i32 %old) {
5397 %gep = getelementptr i32, ptr %out, i32 4
5398 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") acquire seq_cst
5402 define amdgpu_kernel void @flat_singlethread_release_seq_cst_cmpxchg(
5403 ; GFX7-LABEL: flat_singlethread_release_seq_cst_cmpxchg:
5404 ; GFX7: ; %bb.0: ; %entry
5405 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
5406 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
5407 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
5408 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
5409 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
5410 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5411 ; GFX7-NEXT: s_mov_b32 s4, s8
5412 ; GFX7-NEXT: s_mov_b32 s5, s9
5413 ; GFX7-NEXT: s_mov_b32 s9, s10
5414 ; GFX7-NEXT: s_mov_b32 s8, s11
5415 ; GFX7-NEXT: s_add_u32 s4, s4, s9
5416 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
5417 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
5418 ; GFX7-NEXT: s_mov_b32 s5, s8
5419 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
5420 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
5421 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5422 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
5423 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
5424 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
5425 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
5426 ; GFX7-NEXT: s_endpgm
5428 ; GFX10-WGP-LABEL: flat_singlethread_release_seq_cst_cmpxchg:
5429 ; GFX10-WGP: ; %bb.0: ; %entry
5430 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
5431 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
5432 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
5433 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
5434 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
5435 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5436 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
5437 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
5438 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
5439 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
5440 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
5441 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
5442 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
5443 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
5444 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
5445 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
5446 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5447 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
5448 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
5449 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
5450 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
5451 ; GFX10-WGP-NEXT: s_endpgm
5453 ; GFX10-CU-LABEL: flat_singlethread_release_seq_cst_cmpxchg:
5454 ; GFX10-CU: ; %bb.0: ; %entry
5455 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
5456 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
5457 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
5458 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
5459 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
5460 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5461 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
5462 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
5463 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
5464 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
5465 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
5466 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
5467 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
5468 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
5469 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
5470 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
5471 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5472 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
5473 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
5474 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
5475 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
5476 ; GFX10-CU-NEXT: s_endpgm
5478 ; SKIP-CACHE-INV-LABEL: flat_singlethread_release_seq_cst_cmpxchg:
5479 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5480 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
5481 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
5482 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
5483 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
5484 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
5485 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5486 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
5487 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
5488 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
5489 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
5490 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
5491 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
5492 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
5493 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
5494 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
5495 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
5496 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5497 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
5498 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
5499 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
5500 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
5501 ; SKIP-CACHE-INV-NEXT: s_endpgm
5503 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_release_seq_cst_cmpxchg:
5504 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5505 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
5506 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
5507 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
5508 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
5509 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5510 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
5511 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
5512 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5513 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
5514 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
5515 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
5516 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5518 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_release_seq_cst_cmpxchg:
5519 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5520 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
5521 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
5522 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
5523 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
5524 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5525 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
5526 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
5527 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5528 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
5529 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
5530 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
5531 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5533 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_release_seq_cst_cmpxchg:
5534 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
5535 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
5536 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5537 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
5538 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
5539 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5540 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
5541 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
5542 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5543 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
5544 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
5545 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
5546 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
5548 ; GFX940-TGSPLIT-LABEL: flat_singlethread_release_seq_cst_cmpxchg:
5549 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
5550 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
5551 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5552 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
5553 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
5554 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5555 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
5556 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
5557 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5558 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
5559 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
5560 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
5561 ; GFX940-TGSPLIT-NEXT: s_endpgm
5563 ; GFX11-WGP-LABEL: flat_singlethread_release_seq_cst_cmpxchg:
5564 ; GFX11-WGP: ; %bb.0: ; %entry
5565 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
5566 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5567 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
5568 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
5569 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
5570 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
5571 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
5572 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5573 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
5574 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
5575 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
5576 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
5577 ; GFX11-WGP-NEXT: s_endpgm
5579 ; GFX11-CU-LABEL: flat_singlethread_release_seq_cst_cmpxchg:
5580 ; GFX11-CU: ; %bb.0: ; %entry
5581 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
5582 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5583 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
5584 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
5585 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5586 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
5587 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
5588 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5589 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
5590 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
5591 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
5592 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
5593 ; GFX11-CU-NEXT: s_endpgm
5595 ; GFX12-WGP-LABEL: flat_singlethread_release_seq_cst_cmpxchg:
5596 ; GFX12-WGP: ; %bb.0: ; %entry
5597 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
5598 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5599 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
5600 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
5601 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
5602 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
5603 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
5604 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5605 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
5606 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
5607 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
5608 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
5609 ; GFX12-WGP-NEXT: s_endpgm
5611 ; GFX12-CU-LABEL: flat_singlethread_release_seq_cst_cmpxchg:
5612 ; GFX12-CU: ; %bb.0: ; %entry
5613 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
5614 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5615 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
5616 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
5617 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
5618 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
5619 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
5620 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5621 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
5622 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
5623 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
5624 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
5625 ; GFX12-CU-NEXT: s_endpgm
5626 ptr %out, i32 %in, i32 %old) {
5628 %gep = getelementptr i32, ptr %out, i32 4
5629 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") release seq_cst
5633 define amdgpu_kernel void @flat_singlethread_acq_rel_seq_cst_cmpxchg(
5634 ; GFX7-LABEL: flat_singlethread_acq_rel_seq_cst_cmpxchg:
5635 ; GFX7: ; %bb.0: ; %entry
5636 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
5637 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
5638 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
5639 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
5640 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
5641 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5642 ; GFX7-NEXT: s_mov_b32 s4, s8
5643 ; GFX7-NEXT: s_mov_b32 s5, s9
5644 ; GFX7-NEXT: s_mov_b32 s9, s10
5645 ; GFX7-NEXT: s_mov_b32 s8, s11
5646 ; GFX7-NEXT: s_add_u32 s4, s4, s9
5647 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
5648 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
5649 ; GFX7-NEXT: s_mov_b32 s5, s8
5650 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
5651 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
5652 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5653 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
5654 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
5655 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
5656 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
5657 ; GFX7-NEXT: s_endpgm
5659 ; GFX10-WGP-LABEL: flat_singlethread_acq_rel_seq_cst_cmpxchg:
5660 ; GFX10-WGP: ; %bb.0: ; %entry
5661 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
5662 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
5663 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
5664 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
5665 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
5666 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5667 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
5668 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
5669 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
5670 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
5671 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
5672 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
5673 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
5674 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
5675 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
5676 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
5677 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5678 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
5679 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
5680 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
5681 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
5682 ; GFX10-WGP-NEXT: s_endpgm
5684 ; GFX10-CU-LABEL: flat_singlethread_acq_rel_seq_cst_cmpxchg:
5685 ; GFX10-CU: ; %bb.0: ; %entry
5686 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
5687 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
5688 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
5689 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
5690 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
5691 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5692 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
5693 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
5694 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
5695 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
5696 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
5697 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
5698 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
5699 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
5700 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
5701 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
5702 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5703 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
5704 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
5705 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
5706 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
5707 ; GFX10-CU-NEXT: s_endpgm
5709 ; SKIP-CACHE-INV-LABEL: flat_singlethread_acq_rel_seq_cst_cmpxchg:
5710 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5711 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
5712 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
5713 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
5714 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
5715 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
5716 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5717 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
5718 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
5719 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
5720 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
5721 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
5722 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
5723 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
5724 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
5725 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
5726 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
5727 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5728 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
5729 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
5730 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
5731 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
5732 ; SKIP-CACHE-INV-NEXT: s_endpgm
5734 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_acq_rel_seq_cst_cmpxchg:
5735 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5736 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
5737 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
5738 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
5739 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
5740 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5741 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
5742 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
5743 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5744 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
5745 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
5746 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
5747 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5749 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_acq_rel_seq_cst_cmpxchg:
5750 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5751 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
5752 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
5753 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
5754 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
5755 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5756 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
5757 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
5758 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5759 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
5760 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
5761 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
5762 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5764 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_acq_rel_seq_cst_cmpxchg:
5765 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
5766 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
5767 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5768 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
5769 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
5770 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5771 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
5772 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
5773 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5774 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
5775 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
5776 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
5777 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
5779 ; GFX940-TGSPLIT-LABEL: flat_singlethread_acq_rel_seq_cst_cmpxchg:
5780 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
5781 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
5782 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5783 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
5784 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
5785 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5786 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
5787 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
5788 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5789 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
5790 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
5791 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
5792 ; GFX940-TGSPLIT-NEXT: s_endpgm
5794 ; GFX11-WGP-LABEL: flat_singlethread_acq_rel_seq_cst_cmpxchg:
5795 ; GFX11-WGP: ; %bb.0: ; %entry
5796 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
5797 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5798 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
5799 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
5800 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
5801 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
5802 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
5803 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5804 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
5805 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
5806 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
5807 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
5808 ; GFX11-WGP-NEXT: s_endpgm
5810 ; GFX11-CU-LABEL: flat_singlethread_acq_rel_seq_cst_cmpxchg:
5811 ; GFX11-CU: ; %bb.0: ; %entry
5812 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
5813 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5814 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
5815 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
5816 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5817 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
5818 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
5819 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5820 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
5821 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
5822 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
5823 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
5824 ; GFX11-CU-NEXT: s_endpgm
5826 ; GFX12-WGP-LABEL: flat_singlethread_acq_rel_seq_cst_cmpxchg:
5827 ; GFX12-WGP: ; %bb.0: ; %entry
5828 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
5829 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5830 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
5831 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
5832 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
5833 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
5834 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
5835 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5836 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
5837 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
5838 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
5839 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
5840 ; GFX12-WGP-NEXT: s_endpgm
5842 ; GFX12-CU-LABEL: flat_singlethread_acq_rel_seq_cst_cmpxchg:
5843 ; GFX12-CU: ; %bb.0: ; %entry
5844 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
5845 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5846 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
5847 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
5848 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
5849 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
5850 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
5851 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5852 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
5853 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
5854 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
5855 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
5856 ; GFX12-CU-NEXT: s_endpgm
5857 ptr %out, i32 %in, i32 %old) {
5859 %gep = getelementptr i32, ptr %out, i32 4
5860 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") acq_rel seq_cst
5864 define amdgpu_kernel void @flat_singlethread_seq_cst_seq_cst_cmpxchg(
5865 ; GFX7-LABEL: flat_singlethread_seq_cst_seq_cst_cmpxchg:
5866 ; GFX7: ; %bb.0: ; %entry
5867 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
5868 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
5869 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
5870 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
5871 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
5872 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5873 ; GFX7-NEXT: s_mov_b32 s4, s8
5874 ; GFX7-NEXT: s_mov_b32 s5, s9
5875 ; GFX7-NEXT: s_mov_b32 s9, s10
5876 ; GFX7-NEXT: s_mov_b32 s8, s11
5877 ; GFX7-NEXT: s_add_u32 s4, s4, s9
5878 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
5879 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
5880 ; GFX7-NEXT: s_mov_b32 s5, s8
5881 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
5882 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
5883 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5884 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
5885 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
5886 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
5887 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
5888 ; GFX7-NEXT: s_endpgm
5890 ; GFX10-WGP-LABEL: flat_singlethread_seq_cst_seq_cst_cmpxchg:
5891 ; GFX10-WGP: ; %bb.0: ; %entry
5892 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
5893 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
5894 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
5895 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
5896 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
5897 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5898 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
5899 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
5900 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
5901 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
5902 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
5903 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
5904 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
5905 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
5906 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
5907 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
5908 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5909 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
5910 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
5911 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
5912 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
5913 ; GFX10-WGP-NEXT: s_endpgm
5915 ; GFX10-CU-LABEL: flat_singlethread_seq_cst_seq_cst_cmpxchg:
5916 ; GFX10-CU: ; %bb.0: ; %entry
5917 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
5918 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
5919 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
5920 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
5921 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
5922 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5923 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
5924 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
5925 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
5926 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
5927 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
5928 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
5929 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
5930 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
5931 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
5932 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
5933 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5934 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
5935 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
5936 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
5937 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
5938 ; GFX10-CU-NEXT: s_endpgm
5940 ; SKIP-CACHE-INV-LABEL: flat_singlethread_seq_cst_seq_cst_cmpxchg:
5941 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5942 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
5943 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
5944 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
5945 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
5946 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
5947 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5948 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
5949 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
5950 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
5951 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
5952 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
5953 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
5954 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
5955 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
5956 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
5957 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
5958 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5959 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
5960 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
5961 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
5962 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
5963 ; SKIP-CACHE-INV-NEXT: s_endpgm
5965 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_seq_cst_seq_cst_cmpxchg:
5966 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5967 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
5968 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
5969 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
5970 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
5971 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5972 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
5973 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
5974 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5975 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
5976 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
5977 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
5978 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5980 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_seq_cst_seq_cst_cmpxchg:
5981 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5982 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
5983 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
5984 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
5985 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
5986 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5987 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
5988 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
5989 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5990 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
5991 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
5992 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
5993 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5995 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_seq_cst_seq_cst_cmpxchg:
5996 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
5997 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
5998 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5999 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
6000 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
6001 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6002 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
6003 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
6004 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6005 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
6006 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
6007 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
6008 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
6010 ; GFX940-TGSPLIT-LABEL: flat_singlethread_seq_cst_seq_cst_cmpxchg:
6011 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
6012 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
6013 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6014 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
6015 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
6016 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6017 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
6018 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
6019 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6020 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
6021 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
6022 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
6023 ; GFX940-TGSPLIT-NEXT: s_endpgm
6025 ; GFX11-WGP-LABEL: flat_singlethread_seq_cst_seq_cst_cmpxchg:
6026 ; GFX11-WGP: ; %bb.0: ; %entry
6027 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
6028 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6029 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
6030 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
6031 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
6032 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
6033 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
6034 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6035 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
6036 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
6037 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
6038 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
6039 ; GFX11-WGP-NEXT: s_endpgm
6041 ; GFX11-CU-LABEL: flat_singlethread_seq_cst_seq_cst_cmpxchg:
6042 ; GFX11-CU: ; %bb.0: ; %entry
6043 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
6044 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6045 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
6046 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
6047 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6048 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
6049 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
6050 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6051 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
6052 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
6053 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
6054 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
6055 ; GFX11-CU-NEXT: s_endpgm
6057 ; GFX12-WGP-LABEL: flat_singlethread_seq_cst_seq_cst_cmpxchg:
6058 ; GFX12-WGP: ; %bb.0: ; %entry
6059 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
6060 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6061 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
6062 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
6063 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
6064 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
6065 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
6066 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6067 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
6068 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
6069 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
6070 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
6071 ; GFX12-WGP-NEXT: s_endpgm
6073 ; GFX12-CU-LABEL: flat_singlethread_seq_cst_seq_cst_cmpxchg:
6074 ; GFX12-CU: ; %bb.0: ; %entry
6075 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
6076 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6077 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
6078 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
6079 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
6080 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
6081 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
6082 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6083 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
6084 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
6085 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
6086 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
6087 ; GFX12-CU-NEXT: s_endpgm
6088 ptr %out, i32 %in, i32 %old) {
6090 %gep = getelementptr i32, ptr %out, i32 4
6091 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") seq_cst seq_cst
6095 define amdgpu_kernel void @flat_singlethread_monotonic_monotonic_ret_cmpxchg(
6096 ; GFX7-LABEL: flat_singlethread_monotonic_monotonic_ret_cmpxchg:
6097 ; GFX7: ; %bb.0: ; %entry
6098 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
6099 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
6100 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
6101 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
6102 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6103 ; GFX7-NEXT: s_mov_b32 s6, s4
6104 ; GFX7-NEXT: s_mov_b32 s7, s5
6105 ; GFX7-NEXT: s_mov_b32 s11, s12
6106 ; GFX7-NEXT: s_mov_b32 s10, s13
6107 ; GFX7-NEXT: s_add_u32 s6, s6, s11
6108 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
6109 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
6110 ; GFX7-NEXT: s_mov_b32 s7, s10
6111 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
6112 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
6113 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6114 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
6115 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
6116 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
6117 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
6118 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
6119 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
6120 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6121 ; GFX7-NEXT: flat_store_dword v[0:1], v2
6122 ; GFX7-NEXT: s_endpgm
6124 ; GFX10-WGP-LABEL: flat_singlethread_monotonic_monotonic_ret_cmpxchg:
6125 ; GFX10-WGP: ; %bb.0: ; %entry
6126 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
6127 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
6128 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
6129 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
6130 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6131 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
6132 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
6133 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
6134 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
6135 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
6136 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
6137 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
6138 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
6139 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
6140 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
6141 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6142 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
6143 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
6144 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
6145 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
6146 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
6147 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
6148 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6149 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
6150 ; GFX10-WGP-NEXT: s_endpgm
6152 ; GFX10-CU-LABEL: flat_singlethread_monotonic_monotonic_ret_cmpxchg:
6153 ; GFX10-CU: ; %bb.0: ; %entry
6154 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
6155 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
6156 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
6157 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
6158 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6159 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
6160 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
6161 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
6162 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
6163 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
6164 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
6165 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
6166 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
6167 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
6168 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
6169 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6170 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
6171 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
6172 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
6173 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
6174 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
6175 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
6176 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6177 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
6178 ; GFX10-CU-NEXT: s_endpgm
6180 ; SKIP-CACHE-INV-LABEL: flat_singlethread_monotonic_monotonic_ret_cmpxchg:
6181 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6182 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
6183 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
6184 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
6185 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
6186 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6187 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
6188 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
6189 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
6190 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
6191 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
6192 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
6193 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
6194 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
6195 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
6196 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
6197 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6198 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
6199 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
6200 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
6201 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
6202 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
6203 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
6204 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6205 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
6206 ; SKIP-CACHE-INV-NEXT: s_endpgm
6208 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_monotonic_monotonic_ret_cmpxchg:
6209 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6210 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
6211 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
6212 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
6213 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
6214 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6215 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
6216 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
6217 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6218 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
6219 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
6220 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
6221 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
6222 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6223 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
6224 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6226 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_monotonic_monotonic_ret_cmpxchg:
6227 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6228 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
6229 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
6230 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
6231 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
6232 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6233 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
6234 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
6235 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6236 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
6237 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
6238 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
6239 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
6240 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6241 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
6242 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6244 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_monotonic_monotonic_ret_cmpxchg:
6245 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
6246 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
6247 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6248 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
6249 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
6250 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6251 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
6252 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
6253 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6254 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
6255 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
6256 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
6257 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
6258 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6259 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
6260 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
6262 ; GFX940-TGSPLIT-LABEL: flat_singlethread_monotonic_monotonic_ret_cmpxchg:
6263 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
6264 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
6265 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6266 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
6267 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
6268 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6269 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
6270 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
6271 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6272 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
6273 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
6274 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
6275 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
6276 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6277 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
6278 ; GFX940-TGSPLIT-NEXT: s_endpgm
6280 ; GFX11-WGP-LABEL: flat_singlethread_monotonic_monotonic_ret_cmpxchg:
6281 ; GFX11-WGP: ; %bb.0: ; %entry
6282 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
6283 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6284 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
6285 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
6286 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
6287 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
6288 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
6289 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6290 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
6291 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
6292 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
6293 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
6294 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
6295 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
6296 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6297 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
6298 ; GFX11-WGP-NEXT: s_endpgm
6300 ; GFX11-CU-LABEL: flat_singlethread_monotonic_monotonic_ret_cmpxchg:
6301 ; GFX11-CU: ; %bb.0: ; %entry
6302 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
6303 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6304 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
6305 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
6306 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6307 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
6308 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
6309 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6310 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
6311 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
6312 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
6313 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
6314 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
6315 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
6316 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6317 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
6318 ; GFX11-CU-NEXT: s_endpgm
6320 ; GFX12-WGP-LABEL: flat_singlethread_monotonic_monotonic_ret_cmpxchg:
6321 ; GFX12-WGP: ; %bb.0: ; %entry
6322 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
6323 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6324 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
6325 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
6326 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
6327 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
6328 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
6329 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6330 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
6331 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
6332 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
6333 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
6334 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
6335 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
6336 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
6337 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
6338 ; GFX12-WGP-NEXT: s_endpgm
6340 ; GFX12-CU-LABEL: flat_singlethread_monotonic_monotonic_ret_cmpxchg:
6341 ; GFX12-CU: ; %bb.0: ; %entry
6342 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
6343 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6344 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
6345 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
6346 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
6347 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
6348 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
6349 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6350 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
6351 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
6352 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
6353 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
6354 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
6355 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
6356 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
6357 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
6358 ; GFX12-CU-NEXT: s_endpgm
6359 ptr %out, i32 %in, i32 %old) {
6361 %gep = getelementptr i32, ptr %out, i32 4
6362 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") monotonic monotonic
6363 %val0 = extractvalue { i32, i1 } %val, 0
6364 store i32 %val0, ptr %out, align 4
6368 define amdgpu_kernel void @flat_singlethread_acquire_monotonic_ret_cmpxchg(
6369 ; GFX7-LABEL: flat_singlethread_acquire_monotonic_ret_cmpxchg:
6370 ; GFX7: ; %bb.0: ; %entry
6371 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
6372 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
6373 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
6374 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
6375 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6376 ; GFX7-NEXT: s_mov_b32 s6, s4
6377 ; GFX7-NEXT: s_mov_b32 s7, s5
6378 ; GFX7-NEXT: s_mov_b32 s11, s12
6379 ; GFX7-NEXT: s_mov_b32 s10, s13
6380 ; GFX7-NEXT: s_add_u32 s6, s6, s11
6381 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
6382 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
6383 ; GFX7-NEXT: s_mov_b32 s7, s10
6384 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
6385 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
6386 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6387 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
6388 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
6389 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
6390 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
6391 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
6392 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
6393 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6394 ; GFX7-NEXT: flat_store_dword v[0:1], v2
6395 ; GFX7-NEXT: s_endpgm
6397 ; GFX10-WGP-LABEL: flat_singlethread_acquire_monotonic_ret_cmpxchg:
6398 ; GFX10-WGP: ; %bb.0: ; %entry
6399 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
6400 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
6401 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
6402 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
6403 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6404 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
6405 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
6406 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
6407 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
6408 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
6409 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
6410 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
6411 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
6412 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
6413 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
6414 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6415 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
6416 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
6417 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
6418 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
6419 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
6420 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
6421 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6422 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
6423 ; GFX10-WGP-NEXT: s_endpgm
6425 ; GFX10-CU-LABEL: flat_singlethread_acquire_monotonic_ret_cmpxchg:
6426 ; GFX10-CU: ; %bb.0: ; %entry
6427 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
6428 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
6429 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
6430 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
6431 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6432 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
6433 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
6434 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
6435 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
6436 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
6437 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
6438 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
6439 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
6440 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
6441 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
6442 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6443 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
6444 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
6445 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
6446 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
6447 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
6448 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
6449 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6450 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
6451 ; GFX10-CU-NEXT: s_endpgm
6453 ; SKIP-CACHE-INV-LABEL: flat_singlethread_acquire_monotonic_ret_cmpxchg:
6454 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6455 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
6456 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
6457 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
6458 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
6459 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6460 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
6461 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
6462 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
6463 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
6464 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
6465 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
6466 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
6467 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
6468 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
6469 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
6470 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6471 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
6472 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
6473 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
6474 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
6475 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
6476 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
6477 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6478 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
6479 ; SKIP-CACHE-INV-NEXT: s_endpgm
6481 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_acquire_monotonic_ret_cmpxchg:
6482 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6483 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
6484 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
6485 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
6486 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
6487 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6488 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
6489 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
6490 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6491 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
6492 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
6493 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
6494 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
6495 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6496 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
6497 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6499 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_acquire_monotonic_ret_cmpxchg:
6500 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6501 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
6502 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
6503 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
6504 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
6505 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6506 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
6507 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
6508 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6509 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
6510 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
6511 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
6512 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
6513 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6514 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
6515 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6517 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_acquire_monotonic_ret_cmpxchg:
6518 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
6519 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
6520 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6521 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
6522 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
6523 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6524 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
6525 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
6526 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6527 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
6528 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
6529 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
6530 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
6531 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6532 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
6533 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
6535 ; GFX940-TGSPLIT-LABEL: flat_singlethread_acquire_monotonic_ret_cmpxchg:
6536 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
6537 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
6538 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6539 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
6540 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
6541 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6542 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
6543 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
6544 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6545 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
6546 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
6547 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
6548 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
6549 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6550 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
6551 ; GFX940-TGSPLIT-NEXT: s_endpgm
6553 ; GFX11-WGP-LABEL: flat_singlethread_acquire_monotonic_ret_cmpxchg:
6554 ; GFX11-WGP: ; %bb.0: ; %entry
6555 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
6556 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6557 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
6558 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
6559 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
6560 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
6561 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
6562 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6563 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
6564 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
6565 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
6566 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
6567 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
6568 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
6569 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6570 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
6571 ; GFX11-WGP-NEXT: s_endpgm
6573 ; GFX11-CU-LABEL: flat_singlethread_acquire_monotonic_ret_cmpxchg:
6574 ; GFX11-CU: ; %bb.0: ; %entry
6575 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
6576 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6577 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
6578 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
6579 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6580 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
6581 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
6582 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6583 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
6584 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
6585 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
6586 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
6587 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
6588 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
6589 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6590 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
6591 ; GFX11-CU-NEXT: s_endpgm
6593 ; GFX12-WGP-LABEL: flat_singlethread_acquire_monotonic_ret_cmpxchg:
6594 ; GFX12-WGP: ; %bb.0: ; %entry
6595 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
6596 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6597 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
6598 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
6599 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
6600 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
6601 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
6602 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6603 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
6604 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
6605 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
6606 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
6607 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
6608 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
6609 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
6610 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
6611 ; GFX12-WGP-NEXT: s_endpgm
6613 ; GFX12-CU-LABEL: flat_singlethread_acquire_monotonic_ret_cmpxchg:
6614 ; GFX12-CU: ; %bb.0: ; %entry
6615 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
6616 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6617 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
6618 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
6619 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
6620 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
6621 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
6622 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6623 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
6624 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
6625 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
6626 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
6627 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
6628 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
6629 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
6630 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
6631 ; GFX12-CU-NEXT: s_endpgm
6632 ptr %out, i32 %in, i32 %old) {
6634 %gep = getelementptr i32, ptr %out, i32 4
6635 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") acquire monotonic
6636 %val0 = extractvalue { i32, i1 } %val, 0
6637 store i32 %val0, ptr %out, align 4
6641 define amdgpu_kernel void @flat_singlethread_release_monotonic_ret_cmpxchg(
6642 ; GFX7-LABEL: flat_singlethread_release_monotonic_ret_cmpxchg:
6643 ; GFX7: ; %bb.0: ; %entry
6644 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
6645 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
6646 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
6647 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
6648 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6649 ; GFX7-NEXT: s_mov_b32 s6, s4
6650 ; GFX7-NEXT: s_mov_b32 s7, s5
6651 ; GFX7-NEXT: s_mov_b32 s11, s12
6652 ; GFX7-NEXT: s_mov_b32 s10, s13
6653 ; GFX7-NEXT: s_add_u32 s6, s6, s11
6654 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
6655 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
6656 ; GFX7-NEXT: s_mov_b32 s7, s10
6657 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
6658 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
6659 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6660 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
6661 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
6662 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
6663 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
6664 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
6665 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
6666 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6667 ; GFX7-NEXT: flat_store_dword v[0:1], v2
6668 ; GFX7-NEXT: s_endpgm
6670 ; GFX10-WGP-LABEL: flat_singlethread_release_monotonic_ret_cmpxchg:
6671 ; GFX10-WGP: ; %bb.0: ; %entry
6672 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
6673 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
6674 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
6675 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
6676 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6677 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
6678 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
6679 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
6680 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
6681 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
6682 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
6683 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
6684 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
6685 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
6686 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
6687 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6688 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
6689 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
6690 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
6691 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
6692 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
6693 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
6694 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6695 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
6696 ; GFX10-WGP-NEXT: s_endpgm
6698 ; GFX10-CU-LABEL: flat_singlethread_release_monotonic_ret_cmpxchg:
6699 ; GFX10-CU: ; %bb.0: ; %entry
6700 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
6701 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
6702 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
6703 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
6704 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6705 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
6706 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
6707 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
6708 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
6709 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
6710 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
6711 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
6712 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
6713 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
6714 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
6715 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6716 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
6717 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
6718 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
6719 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
6720 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
6721 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
6722 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6723 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
6724 ; GFX10-CU-NEXT: s_endpgm
6726 ; SKIP-CACHE-INV-LABEL: flat_singlethread_release_monotonic_ret_cmpxchg:
6727 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6728 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
6729 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
6730 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
6731 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
6732 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6733 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
6734 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
6735 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
6736 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
6737 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
6738 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
6739 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
6740 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
6741 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
6742 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
6743 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6744 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
6745 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
6746 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
6747 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
6748 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
6749 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
6750 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6751 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
6752 ; SKIP-CACHE-INV-NEXT: s_endpgm
6754 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_release_monotonic_ret_cmpxchg:
6755 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6756 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
6757 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
6758 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
6759 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
6760 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6761 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
6762 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
6763 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6764 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
6765 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
6766 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
6767 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
6768 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6769 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
6770 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6772 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_release_monotonic_ret_cmpxchg:
6773 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6774 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
6775 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
6776 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
6777 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
6778 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6779 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
6780 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
6781 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6782 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
6783 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
6784 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
6785 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
6786 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6787 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
6788 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6790 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_release_monotonic_ret_cmpxchg:
6791 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
6792 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
6793 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6794 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
6795 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
6796 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6797 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
6798 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
6799 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6800 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
6801 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
6802 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
6803 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
6804 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6805 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
6806 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
6808 ; GFX940-TGSPLIT-LABEL: flat_singlethread_release_monotonic_ret_cmpxchg:
6809 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
6810 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
6811 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6812 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
6813 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
6814 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6815 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
6816 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
6817 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6818 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
6819 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
6820 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
6821 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
6822 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6823 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
6824 ; GFX940-TGSPLIT-NEXT: s_endpgm
6826 ; GFX11-WGP-LABEL: flat_singlethread_release_monotonic_ret_cmpxchg:
6827 ; GFX11-WGP: ; %bb.0: ; %entry
6828 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
6829 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6830 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
6831 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
6832 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
6833 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
6834 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
6835 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6836 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
6837 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
6838 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
6839 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
6840 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
6841 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
6842 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6843 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
6844 ; GFX11-WGP-NEXT: s_endpgm
6846 ; GFX11-CU-LABEL: flat_singlethread_release_monotonic_ret_cmpxchg:
6847 ; GFX11-CU: ; %bb.0: ; %entry
6848 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
6849 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6850 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
6851 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
6852 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6853 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
6854 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
6855 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6856 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
6857 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
6858 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
6859 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
6860 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
6861 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
6862 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6863 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
6864 ; GFX11-CU-NEXT: s_endpgm
6866 ; GFX12-WGP-LABEL: flat_singlethread_release_monotonic_ret_cmpxchg:
6867 ; GFX12-WGP: ; %bb.0: ; %entry
6868 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
6869 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6870 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
6871 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
6872 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
6873 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
6874 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
6875 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6876 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
6877 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
6878 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
6879 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
6880 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
6881 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
6882 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
6883 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
6884 ; GFX12-WGP-NEXT: s_endpgm
6886 ; GFX12-CU-LABEL: flat_singlethread_release_monotonic_ret_cmpxchg:
6887 ; GFX12-CU: ; %bb.0: ; %entry
6888 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
6889 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6890 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
6891 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
6892 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
6893 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
6894 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
6895 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6896 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
6897 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
6898 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
6899 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
6900 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
6901 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
6902 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
6903 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
6904 ; GFX12-CU-NEXT: s_endpgm
6905 ptr %out, i32 %in, i32 %old) {
6907 %gep = getelementptr i32, ptr %out, i32 4
6908 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") release monotonic
6909 %val0 = extractvalue { i32, i1 } %val, 0
6910 store i32 %val0, ptr %out, align 4
6914 define amdgpu_kernel void @flat_singlethread_acq_rel_monotonic_ret_cmpxchg(
6915 ; GFX7-LABEL: flat_singlethread_acq_rel_monotonic_ret_cmpxchg:
6916 ; GFX7: ; %bb.0: ; %entry
6917 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
6918 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
6919 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
6920 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
6921 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6922 ; GFX7-NEXT: s_mov_b32 s6, s4
6923 ; GFX7-NEXT: s_mov_b32 s7, s5
6924 ; GFX7-NEXT: s_mov_b32 s11, s12
6925 ; GFX7-NEXT: s_mov_b32 s10, s13
6926 ; GFX7-NEXT: s_add_u32 s6, s6, s11
6927 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
6928 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
6929 ; GFX7-NEXT: s_mov_b32 s7, s10
6930 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
6931 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
6932 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6933 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
6934 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
6935 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
6936 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
6937 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
6938 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
6939 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6940 ; GFX7-NEXT: flat_store_dword v[0:1], v2
6941 ; GFX7-NEXT: s_endpgm
6943 ; GFX10-WGP-LABEL: flat_singlethread_acq_rel_monotonic_ret_cmpxchg:
6944 ; GFX10-WGP: ; %bb.0: ; %entry
6945 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
6946 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
6947 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
6948 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
6949 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6950 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
6951 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
6952 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
6953 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
6954 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
6955 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
6956 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
6957 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
6958 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
6959 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
6960 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6961 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
6962 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
6963 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
6964 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
6965 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
6966 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
6967 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6968 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
6969 ; GFX10-WGP-NEXT: s_endpgm
6971 ; GFX10-CU-LABEL: flat_singlethread_acq_rel_monotonic_ret_cmpxchg:
6972 ; GFX10-CU: ; %bb.0: ; %entry
6973 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
6974 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
6975 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
6976 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
6977 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6978 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
6979 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
6980 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
6981 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
6982 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
6983 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
6984 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
6985 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
6986 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
6987 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
6988 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6989 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
6990 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
6991 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
6992 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
6993 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
6994 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
6995 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6996 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
6997 ; GFX10-CU-NEXT: s_endpgm
6999 ; SKIP-CACHE-INV-LABEL: flat_singlethread_acq_rel_monotonic_ret_cmpxchg:
7000 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7001 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
7002 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
7003 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
7004 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
7005 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7006 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
7007 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
7008 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
7009 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
7010 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
7011 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
7012 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
7013 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
7014 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
7015 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
7016 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7017 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
7018 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
7019 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
7020 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
7021 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
7022 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
7023 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7024 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
7025 ; SKIP-CACHE-INV-NEXT: s_endpgm
7027 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_acq_rel_monotonic_ret_cmpxchg:
7028 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7029 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
7030 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
7031 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
7032 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
7033 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7034 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
7035 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
7036 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7037 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
7038 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
7039 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
7040 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
7041 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7042 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
7043 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7045 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_acq_rel_monotonic_ret_cmpxchg:
7046 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7047 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
7048 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
7049 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
7050 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
7051 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7052 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
7053 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
7054 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7055 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
7056 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
7057 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
7058 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
7059 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7060 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
7061 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7063 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_acq_rel_monotonic_ret_cmpxchg:
7064 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
7065 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
7066 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7067 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
7068 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
7069 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7070 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
7071 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
7072 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7073 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
7074 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
7075 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
7076 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
7077 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7078 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
7079 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
7081 ; GFX940-TGSPLIT-LABEL: flat_singlethread_acq_rel_monotonic_ret_cmpxchg:
7082 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
7083 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
7084 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7085 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
7086 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
7087 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7088 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
7089 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
7090 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7091 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
7092 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
7093 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
7094 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
7095 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7096 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
7097 ; GFX940-TGSPLIT-NEXT: s_endpgm
7099 ; GFX11-WGP-LABEL: flat_singlethread_acq_rel_monotonic_ret_cmpxchg:
7100 ; GFX11-WGP: ; %bb.0: ; %entry
7101 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
7102 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7103 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
7104 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
7105 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
7106 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
7107 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
7108 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7109 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
7110 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
7111 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
7112 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
7113 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
7114 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
7115 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7116 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
7117 ; GFX11-WGP-NEXT: s_endpgm
7119 ; GFX11-CU-LABEL: flat_singlethread_acq_rel_monotonic_ret_cmpxchg:
7120 ; GFX11-CU: ; %bb.0: ; %entry
7121 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
7122 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7123 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
7124 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
7125 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
7126 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
7127 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
7128 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7129 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
7130 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
7131 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
7132 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
7133 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
7134 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
7135 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7136 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
7137 ; GFX11-CU-NEXT: s_endpgm
7139 ; GFX12-WGP-LABEL: flat_singlethread_acq_rel_monotonic_ret_cmpxchg:
7140 ; GFX12-WGP: ; %bb.0: ; %entry
7141 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
7142 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7143 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
7144 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
7145 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
7146 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
7147 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
7148 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7149 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
7150 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
7151 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
7152 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
7153 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
7154 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
7155 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
7156 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
7157 ; GFX12-WGP-NEXT: s_endpgm
7159 ; GFX12-CU-LABEL: flat_singlethread_acq_rel_monotonic_ret_cmpxchg:
7160 ; GFX12-CU: ; %bb.0: ; %entry
7161 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
7162 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7163 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
7164 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
7165 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
7166 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
7167 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
7168 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7169 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
7170 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
7171 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
7172 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
7173 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
7174 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
7175 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
7176 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
7177 ; GFX12-CU-NEXT: s_endpgm
7178 ptr %out, i32 %in, i32 %old) {
7180 %gep = getelementptr i32, ptr %out, i32 4
7181 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") acq_rel monotonic
7182 %val0 = extractvalue { i32, i1 } %val, 0
7183 store i32 %val0, ptr %out, align 4
7187 define amdgpu_kernel void @flat_singlethread_seq_cst_monotonic_ret_cmpxchg(
7188 ; GFX7-LABEL: flat_singlethread_seq_cst_monotonic_ret_cmpxchg:
7189 ; GFX7: ; %bb.0: ; %entry
7190 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
7191 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
7192 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
7193 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
7194 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7195 ; GFX7-NEXT: s_mov_b32 s6, s4
7196 ; GFX7-NEXT: s_mov_b32 s7, s5
7197 ; GFX7-NEXT: s_mov_b32 s11, s12
7198 ; GFX7-NEXT: s_mov_b32 s10, s13
7199 ; GFX7-NEXT: s_add_u32 s6, s6, s11
7200 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
7201 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
7202 ; GFX7-NEXT: s_mov_b32 s7, s10
7203 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
7204 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
7205 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7206 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
7207 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
7208 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
7209 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
7210 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
7211 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
7212 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7213 ; GFX7-NEXT: flat_store_dword v[0:1], v2
7214 ; GFX7-NEXT: s_endpgm
7216 ; GFX10-WGP-LABEL: flat_singlethread_seq_cst_monotonic_ret_cmpxchg:
7217 ; GFX10-WGP: ; %bb.0: ; %entry
7218 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
7219 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
7220 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
7221 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
7222 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7223 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
7224 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
7225 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
7226 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
7227 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
7228 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
7229 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
7230 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
7231 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
7232 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
7233 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7234 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
7235 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
7236 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
7237 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
7238 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
7239 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
7240 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7241 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
7242 ; GFX10-WGP-NEXT: s_endpgm
7244 ; GFX10-CU-LABEL: flat_singlethread_seq_cst_monotonic_ret_cmpxchg:
7245 ; GFX10-CU: ; %bb.0: ; %entry
7246 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
7247 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
7248 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
7249 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
7250 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7251 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
7252 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
7253 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
7254 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
7255 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
7256 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
7257 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
7258 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
7259 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
7260 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
7261 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7262 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
7263 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
7264 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
7265 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
7266 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
7267 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
7268 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7269 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
7270 ; GFX10-CU-NEXT: s_endpgm
7272 ; SKIP-CACHE-INV-LABEL: flat_singlethread_seq_cst_monotonic_ret_cmpxchg:
7273 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7274 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
7275 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
7276 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
7277 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
7278 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7279 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
7280 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
7281 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
7282 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
7283 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
7284 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
7285 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
7286 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
7287 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
7288 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
7289 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7290 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
7291 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
7292 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
7293 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
7294 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
7295 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
7296 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7297 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
7298 ; SKIP-CACHE-INV-NEXT: s_endpgm
7300 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_seq_cst_monotonic_ret_cmpxchg:
7301 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7302 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
7303 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
7304 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
7305 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
7306 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7307 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
7308 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
7309 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7310 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
7311 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
7312 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
7313 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
7314 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7315 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
7316 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7318 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_seq_cst_monotonic_ret_cmpxchg:
7319 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7320 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
7321 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
7322 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
7323 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
7324 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7325 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
7326 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
7327 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7328 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
7329 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
7330 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
7331 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
7332 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7333 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
7334 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7336 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_seq_cst_monotonic_ret_cmpxchg:
7337 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
7338 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
7339 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7340 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
7341 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
7342 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7343 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
7344 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
7345 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7346 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
7347 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
7348 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
7349 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
7350 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7351 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
7352 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
7354 ; GFX940-TGSPLIT-LABEL: flat_singlethread_seq_cst_monotonic_ret_cmpxchg:
7355 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
7356 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
7357 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7358 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
7359 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
7360 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7361 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
7362 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
7363 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7364 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
7365 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
7366 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
7367 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
7368 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7369 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
7370 ; GFX940-TGSPLIT-NEXT: s_endpgm
7372 ; GFX11-WGP-LABEL: flat_singlethread_seq_cst_monotonic_ret_cmpxchg:
7373 ; GFX11-WGP: ; %bb.0: ; %entry
7374 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
7375 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7376 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
7377 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
7378 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
7379 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
7380 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
7381 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7382 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
7383 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
7384 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
7385 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
7386 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
7387 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
7388 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7389 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
7390 ; GFX11-WGP-NEXT: s_endpgm
7392 ; GFX11-CU-LABEL: flat_singlethread_seq_cst_monotonic_ret_cmpxchg:
7393 ; GFX11-CU: ; %bb.0: ; %entry
7394 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
7395 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7396 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
7397 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
7398 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
7399 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
7400 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
7401 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7402 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
7403 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
7404 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
7405 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
7406 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
7407 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
7408 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7409 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
7410 ; GFX11-CU-NEXT: s_endpgm
7412 ; GFX12-WGP-LABEL: flat_singlethread_seq_cst_monotonic_ret_cmpxchg:
7413 ; GFX12-WGP: ; %bb.0: ; %entry
7414 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
7415 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7416 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
7417 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
7418 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
7419 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
7420 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
7421 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7422 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
7423 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
7424 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
7425 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
7426 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
7427 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
7428 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
7429 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
7430 ; GFX12-WGP-NEXT: s_endpgm
7432 ; GFX12-CU-LABEL: flat_singlethread_seq_cst_monotonic_ret_cmpxchg:
7433 ; GFX12-CU: ; %bb.0: ; %entry
7434 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
7435 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7436 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
7437 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
7438 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
7439 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
7440 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
7441 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7442 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
7443 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
7444 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
7445 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
7446 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
7447 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
7448 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
7449 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
7450 ; GFX12-CU-NEXT: s_endpgm
7451 ptr %out, i32 %in, i32 %old) {
7453 %gep = getelementptr i32, ptr %out, i32 4
7454 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") seq_cst monotonic
7455 %val0 = extractvalue { i32, i1 } %val, 0
7456 store i32 %val0, ptr %out, align 4
7460 define amdgpu_kernel void @flat_singlethread_monotonic_acquire_ret_cmpxchg(
7461 ; GFX7-LABEL: flat_singlethread_monotonic_acquire_ret_cmpxchg:
7462 ; GFX7: ; %bb.0: ; %entry
7463 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
7464 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
7465 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
7466 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
7467 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7468 ; GFX7-NEXT: s_mov_b32 s6, s4
7469 ; GFX7-NEXT: s_mov_b32 s7, s5
7470 ; GFX7-NEXT: s_mov_b32 s11, s12
7471 ; GFX7-NEXT: s_mov_b32 s10, s13
7472 ; GFX7-NEXT: s_add_u32 s6, s6, s11
7473 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
7474 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
7475 ; GFX7-NEXT: s_mov_b32 s7, s10
7476 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
7477 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
7478 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7479 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
7480 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
7481 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
7482 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
7483 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
7484 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
7485 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7486 ; GFX7-NEXT: flat_store_dword v[0:1], v2
7487 ; GFX7-NEXT: s_endpgm
7489 ; GFX10-WGP-LABEL: flat_singlethread_monotonic_acquire_ret_cmpxchg:
7490 ; GFX10-WGP: ; %bb.0: ; %entry
7491 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
7492 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
7493 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
7494 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
7495 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7496 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
7497 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
7498 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
7499 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
7500 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
7501 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
7502 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
7503 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
7504 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
7505 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
7506 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7507 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
7508 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
7509 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
7510 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
7511 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
7512 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
7513 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7514 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
7515 ; GFX10-WGP-NEXT: s_endpgm
7517 ; GFX10-CU-LABEL: flat_singlethread_monotonic_acquire_ret_cmpxchg:
7518 ; GFX10-CU: ; %bb.0: ; %entry
7519 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
7520 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
7521 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
7522 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
7523 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7524 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
7525 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
7526 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
7527 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
7528 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
7529 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
7530 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
7531 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
7532 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
7533 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
7534 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7535 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
7536 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
7537 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
7538 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
7539 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
7540 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
7541 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7542 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
7543 ; GFX10-CU-NEXT: s_endpgm
7545 ; SKIP-CACHE-INV-LABEL: flat_singlethread_monotonic_acquire_ret_cmpxchg:
7546 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7547 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
7548 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
7549 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
7550 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
7551 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7552 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
7553 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
7554 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
7555 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
7556 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
7557 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
7558 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
7559 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
7560 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
7561 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
7562 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7563 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
7564 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
7565 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
7566 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
7567 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
7568 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
7569 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7570 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
7571 ; SKIP-CACHE-INV-NEXT: s_endpgm
7573 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_monotonic_acquire_ret_cmpxchg:
7574 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7575 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
7576 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
7577 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
7578 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
7579 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7580 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
7581 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
7582 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7583 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
7584 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
7585 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
7586 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
7587 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7588 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
7589 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7591 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_monotonic_acquire_ret_cmpxchg:
7592 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7593 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
7594 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
7595 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
7596 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
7597 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7598 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
7599 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
7600 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7601 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
7602 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
7603 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
7604 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
7605 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7606 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
7607 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7609 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_monotonic_acquire_ret_cmpxchg:
7610 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
7611 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
7612 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7613 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
7614 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
7615 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7616 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
7617 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
7618 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7619 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
7620 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
7621 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
7622 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
7623 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7624 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
7625 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
7627 ; GFX940-TGSPLIT-LABEL: flat_singlethread_monotonic_acquire_ret_cmpxchg:
7628 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
7629 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
7630 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7631 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
7632 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
7633 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7634 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
7635 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
7636 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7637 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
7638 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
7639 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
7640 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
7641 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7642 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
7643 ; GFX940-TGSPLIT-NEXT: s_endpgm
7645 ; GFX11-WGP-LABEL: flat_singlethread_monotonic_acquire_ret_cmpxchg:
7646 ; GFX11-WGP: ; %bb.0: ; %entry
7647 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
7648 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7649 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
7650 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
7651 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
7652 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
7653 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
7654 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7655 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
7656 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
7657 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
7658 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
7659 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
7660 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
7661 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7662 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
7663 ; GFX11-WGP-NEXT: s_endpgm
7665 ; GFX11-CU-LABEL: flat_singlethread_monotonic_acquire_ret_cmpxchg:
7666 ; GFX11-CU: ; %bb.0: ; %entry
7667 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
7668 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7669 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
7670 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
7671 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
7672 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
7673 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
7674 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7675 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
7676 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
7677 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
7678 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
7679 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
7680 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
7681 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7682 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
7683 ; GFX11-CU-NEXT: s_endpgm
7685 ; GFX12-WGP-LABEL: flat_singlethread_monotonic_acquire_ret_cmpxchg:
7686 ; GFX12-WGP: ; %bb.0: ; %entry
7687 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
7688 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7689 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
7690 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
7691 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
7692 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
7693 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
7694 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7695 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
7696 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
7697 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
7698 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
7699 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
7700 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
7701 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
7702 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
7703 ; GFX12-WGP-NEXT: s_endpgm
7705 ; GFX12-CU-LABEL: flat_singlethread_monotonic_acquire_ret_cmpxchg:
7706 ; GFX12-CU: ; %bb.0: ; %entry
7707 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
7708 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7709 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
7710 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
7711 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
7712 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
7713 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
7714 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7715 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
7716 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
7717 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
7718 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
7719 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
7720 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
7721 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
7722 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
7723 ; GFX12-CU-NEXT: s_endpgm
7724 ptr %out, i32 %in, i32 %old) {
7726 %gep = getelementptr i32, ptr %out, i32 4
7727 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") monotonic acquire
7728 %val0 = extractvalue { i32, i1 } %val, 0
7729 store i32 %val0, ptr %out, align 4
7733 define amdgpu_kernel void @flat_singlethread_acquire_acquire_ret_cmpxchg(
7734 ; GFX7-LABEL: flat_singlethread_acquire_acquire_ret_cmpxchg:
7735 ; GFX7: ; %bb.0: ; %entry
7736 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
7737 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
7738 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
7739 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
7740 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7741 ; GFX7-NEXT: s_mov_b32 s6, s4
7742 ; GFX7-NEXT: s_mov_b32 s7, s5
7743 ; GFX7-NEXT: s_mov_b32 s11, s12
7744 ; GFX7-NEXT: s_mov_b32 s10, s13
7745 ; GFX7-NEXT: s_add_u32 s6, s6, s11
7746 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
7747 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
7748 ; GFX7-NEXT: s_mov_b32 s7, s10
7749 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
7750 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
7751 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7752 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
7753 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
7754 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
7755 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
7756 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
7757 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
7758 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7759 ; GFX7-NEXT: flat_store_dword v[0:1], v2
7760 ; GFX7-NEXT: s_endpgm
7762 ; GFX10-WGP-LABEL: flat_singlethread_acquire_acquire_ret_cmpxchg:
7763 ; GFX10-WGP: ; %bb.0: ; %entry
7764 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
7765 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
7766 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
7767 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
7768 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7769 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
7770 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
7771 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
7772 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
7773 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
7774 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
7775 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
7776 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
7777 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
7778 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
7779 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7780 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
7781 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
7782 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
7783 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
7784 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
7785 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
7786 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7787 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
7788 ; GFX10-WGP-NEXT: s_endpgm
7790 ; GFX10-CU-LABEL: flat_singlethread_acquire_acquire_ret_cmpxchg:
7791 ; GFX10-CU: ; %bb.0: ; %entry
7792 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
7793 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
7794 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
7795 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
7796 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7797 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
7798 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
7799 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
7800 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
7801 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
7802 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
7803 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
7804 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
7805 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
7806 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
7807 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7808 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
7809 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
7810 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
7811 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
7812 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
7813 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
7814 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7815 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
7816 ; GFX10-CU-NEXT: s_endpgm
7818 ; SKIP-CACHE-INV-LABEL: flat_singlethread_acquire_acquire_ret_cmpxchg:
7819 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7820 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
7821 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
7822 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
7823 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
7824 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7825 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
7826 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
7827 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
7828 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
7829 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
7830 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
7831 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
7832 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
7833 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
7834 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
7835 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7836 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
7837 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
7838 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
7839 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
7840 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
7841 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
7842 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7843 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
7844 ; SKIP-CACHE-INV-NEXT: s_endpgm
7846 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_acquire_acquire_ret_cmpxchg:
7847 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7848 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
7849 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
7850 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
7851 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
7852 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7853 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
7854 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
7855 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7856 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
7857 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
7858 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
7859 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
7860 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7861 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
7862 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7864 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_acquire_acquire_ret_cmpxchg:
7865 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7866 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
7867 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
7868 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
7869 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
7870 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7871 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
7872 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
7873 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7874 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
7875 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
7876 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
7877 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
7878 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7879 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
7880 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7882 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_acquire_acquire_ret_cmpxchg:
7883 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
7884 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
7885 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7886 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
7887 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
7888 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7889 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
7890 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
7891 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7892 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
7893 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
7894 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
7895 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
7896 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7897 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
7898 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
7900 ; GFX940-TGSPLIT-LABEL: flat_singlethread_acquire_acquire_ret_cmpxchg:
7901 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
7902 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
7903 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7904 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
7905 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
7906 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7907 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
7908 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
7909 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7910 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
7911 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
7912 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
7913 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
7914 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7915 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
7916 ; GFX940-TGSPLIT-NEXT: s_endpgm
7918 ; GFX11-WGP-LABEL: flat_singlethread_acquire_acquire_ret_cmpxchg:
7919 ; GFX11-WGP: ; %bb.0: ; %entry
7920 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
7921 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7922 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
7923 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
7924 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
7925 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
7926 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
7927 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7928 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
7929 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
7930 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
7931 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
7932 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
7933 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
7934 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7935 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
7936 ; GFX11-WGP-NEXT: s_endpgm
7938 ; GFX11-CU-LABEL: flat_singlethread_acquire_acquire_ret_cmpxchg:
7939 ; GFX11-CU: ; %bb.0: ; %entry
7940 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
7941 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7942 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
7943 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
7944 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
7945 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
7946 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
7947 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7948 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
7949 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
7950 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
7951 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
7952 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
7953 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
7954 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7955 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
7956 ; GFX11-CU-NEXT: s_endpgm
7958 ; GFX12-WGP-LABEL: flat_singlethread_acquire_acquire_ret_cmpxchg:
7959 ; GFX12-WGP: ; %bb.0: ; %entry
7960 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
7961 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7962 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
7963 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
7964 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
7965 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
7966 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
7967 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7968 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
7969 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
7970 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
7971 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
7972 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
7973 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
7974 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
7975 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
7976 ; GFX12-WGP-NEXT: s_endpgm
7978 ; GFX12-CU-LABEL: flat_singlethread_acquire_acquire_ret_cmpxchg:
7979 ; GFX12-CU: ; %bb.0: ; %entry
7980 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
7981 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7982 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
7983 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
7984 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
7985 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
7986 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
7987 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7988 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
7989 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
7990 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
7991 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
7992 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
7993 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
7994 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
7995 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
7996 ; GFX12-CU-NEXT: s_endpgm
7997 ptr %out, i32 %in, i32 %old) {
7999 %gep = getelementptr i32, ptr %out, i32 4
8000 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") acquire acquire
8001 %val0 = extractvalue { i32, i1 } %val, 0
8002 store i32 %val0, ptr %out, align 4
8006 define amdgpu_kernel void @flat_singlethread_release_acquire_ret_cmpxchg(
8007 ; GFX7-LABEL: flat_singlethread_release_acquire_ret_cmpxchg:
8008 ; GFX7: ; %bb.0: ; %entry
8009 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
8010 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
8011 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
8012 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
8013 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8014 ; GFX7-NEXT: s_mov_b32 s6, s4
8015 ; GFX7-NEXT: s_mov_b32 s7, s5
8016 ; GFX7-NEXT: s_mov_b32 s11, s12
8017 ; GFX7-NEXT: s_mov_b32 s10, s13
8018 ; GFX7-NEXT: s_add_u32 s6, s6, s11
8019 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
8020 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
8021 ; GFX7-NEXT: s_mov_b32 s7, s10
8022 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
8023 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
8024 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8025 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
8026 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
8027 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
8028 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8029 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
8030 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
8031 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8032 ; GFX7-NEXT: flat_store_dword v[0:1], v2
8033 ; GFX7-NEXT: s_endpgm
8035 ; GFX10-WGP-LABEL: flat_singlethread_release_acquire_ret_cmpxchg:
8036 ; GFX10-WGP: ; %bb.0: ; %entry
8037 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
8038 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
8039 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
8040 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
8041 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8042 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
8043 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
8044 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
8045 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
8046 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
8047 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
8048 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
8049 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
8050 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
8051 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
8052 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8053 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
8054 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
8055 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
8056 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8057 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
8058 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
8059 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8060 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
8061 ; GFX10-WGP-NEXT: s_endpgm
8063 ; GFX10-CU-LABEL: flat_singlethread_release_acquire_ret_cmpxchg:
8064 ; GFX10-CU: ; %bb.0: ; %entry
8065 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
8066 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
8067 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
8068 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
8069 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8070 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
8071 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
8072 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
8073 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
8074 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
8075 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
8076 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
8077 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
8078 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
8079 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
8080 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8081 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
8082 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
8083 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
8084 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8085 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
8086 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
8087 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8088 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
8089 ; GFX10-CU-NEXT: s_endpgm
8091 ; SKIP-CACHE-INV-LABEL: flat_singlethread_release_acquire_ret_cmpxchg:
8092 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8093 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
8094 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
8095 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
8096 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
8097 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8098 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
8099 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
8100 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
8101 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
8102 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
8103 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
8104 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
8105 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
8106 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
8107 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
8108 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8109 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
8110 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
8111 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
8112 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8113 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
8114 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
8115 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8116 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
8117 ; SKIP-CACHE-INV-NEXT: s_endpgm
8119 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_release_acquire_ret_cmpxchg:
8120 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8121 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
8122 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
8123 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
8124 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
8125 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8126 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
8127 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
8128 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8129 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
8130 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
8131 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
8132 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
8133 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8134 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
8135 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8137 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_release_acquire_ret_cmpxchg:
8138 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8139 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
8140 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
8141 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
8142 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
8143 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8144 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
8145 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
8146 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8147 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
8148 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
8149 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
8150 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
8151 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8152 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
8153 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8155 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_release_acquire_ret_cmpxchg:
8156 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
8157 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
8158 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8159 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
8160 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
8161 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8162 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
8163 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
8164 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8165 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
8166 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8167 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
8168 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8169 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8170 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
8171 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
8173 ; GFX940-TGSPLIT-LABEL: flat_singlethread_release_acquire_ret_cmpxchg:
8174 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
8175 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
8176 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8177 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
8178 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
8179 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8180 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
8181 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
8182 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8183 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
8184 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8185 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
8186 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8187 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8188 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
8189 ; GFX940-TGSPLIT-NEXT: s_endpgm
8191 ; GFX11-WGP-LABEL: flat_singlethread_release_acquire_ret_cmpxchg:
8192 ; GFX11-WGP: ; %bb.0: ; %entry
8193 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
8194 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
8195 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
8196 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
8197 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
8198 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
8199 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
8200 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8201 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
8202 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
8203 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
8204 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
8205 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
8206 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
8207 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8208 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
8209 ; GFX11-WGP-NEXT: s_endpgm
8211 ; GFX11-CU-LABEL: flat_singlethread_release_acquire_ret_cmpxchg:
8212 ; GFX11-CU: ; %bb.0: ; %entry
8213 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
8214 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
8215 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
8216 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
8217 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
8218 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
8219 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
8220 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8221 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
8222 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
8223 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
8224 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
8225 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
8226 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
8227 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8228 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
8229 ; GFX11-CU-NEXT: s_endpgm
8231 ; GFX12-WGP-LABEL: flat_singlethread_release_acquire_ret_cmpxchg:
8232 ; GFX12-WGP: ; %bb.0: ; %entry
8233 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
8234 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
8235 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
8236 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
8237 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
8238 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
8239 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
8240 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8241 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
8242 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
8243 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
8244 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
8245 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
8246 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
8247 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
8248 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
8249 ; GFX12-WGP-NEXT: s_endpgm
8251 ; GFX12-CU-LABEL: flat_singlethread_release_acquire_ret_cmpxchg:
8252 ; GFX12-CU: ; %bb.0: ; %entry
8253 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
8254 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
8255 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
8256 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
8257 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
8258 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
8259 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
8260 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8261 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
8262 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
8263 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
8264 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
8265 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
8266 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
8267 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
8268 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
8269 ; GFX12-CU-NEXT: s_endpgm
8270 ptr %out, i32 %in, i32 %old) {
8272 %gep = getelementptr i32, ptr %out, i32 4
8273 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") release acquire
8274 %val0 = extractvalue { i32, i1 } %val, 0
8275 store i32 %val0, ptr %out, align 4
8279 define amdgpu_kernel void @flat_singlethread_acq_rel_acquire_ret_cmpxchg(
8280 ; GFX7-LABEL: flat_singlethread_acq_rel_acquire_ret_cmpxchg:
8281 ; GFX7: ; %bb.0: ; %entry
8282 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
8283 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
8284 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
8285 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
8286 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8287 ; GFX7-NEXT: s_mov_b32 s6, s4
8288 ; GFX7-NEXT: s_mov_b32 s7, s5
8289 ; GFX7-NEXT: s_mov_b32 s11, s12
8290 ; GFX7-NEXT: s_mov_b32 s10, s13
8291 ; GFX7-NEXT: s_add_u32 s6, s6, s11
8292 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
8293 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
8294 ; GFX7-NEXT: s_mov_b32 s7, s10
8295 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
8296 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
8297 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8298 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
8299 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
8300 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
8301 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8302 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
8303 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
8304 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8305 ; GFX7-NEXT: flat_store_dword v[0:1], v2
8306 ; GFX7-NEXT: s_endpgm
8308 ; GFX10-WGP-LABEL: flat_singlethread_acq_rel_acquire_ret_cmpxchg:
8309 ; GFX10-WGP: ; %bb.0: ; %entry
8310 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
8311 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
8312 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
8313 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
8314 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8315 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
8316 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
8317 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
8318 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
8319 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
8320 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
8321 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
8322 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
8323 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
8324 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
8325 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8326 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
8327 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
8328 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
8329 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8330 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
8331 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
8332 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8333 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
8334 ; GFX10-WGP-NEXT: s_endpgm
8336 ; GFX10-CU-LABEL: flat_singlethread_acq_rel_acquire_ret_cmpxchg:
8337 ; GFX10-CU: ; %bb.0: ; %entry
8338 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
8339 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
8340 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
8341 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
8342 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8343 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
8344 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
8345 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
8346 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
8347 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
8348 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
8349 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
8350 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
8351 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
8352 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
8353 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8354 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
8355 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
8356 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
8357 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8358 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
8359 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
8360 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8361 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
8362 ; GFX10-CU-NEXT: s_endpgm
8364 ; SKIP-CACHE-INV-LABEL: flat_singlethread_acq_rel_acquire_ret_cmpxchg:
8365 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8366 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
8367 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
8368 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
8369 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
8370 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8371 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
8372 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
8373 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
8374 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
8375 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
8376 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
8377 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
8378 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
8379 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
8380 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
8381 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8382 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
8383 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
8384 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
8385 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8386 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
8387 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
8388 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8389 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
8390 ; SKIP-CACHE-INV-NEXT: s_endpgm
8392 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_acq_rel_acquire_ret_cmpxchg:
8393 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8394 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
8395 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
8396 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
8397 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
8398 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8399 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
8400 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
8401 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8402 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
8403 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
8404 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
8405 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
8406 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8407 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
8408 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8410 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_acq_rel_acquire_ret_cmpxchg:
8411 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8412 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
8413 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
8414 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
8415 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
8416 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8417 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
8418 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
8419 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8420 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
8421 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
8422 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
8423 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
8424 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8425 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
8426 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8428 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_acq_rel_acquire_ret_cmpxchg:
8429 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
8430 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
8431 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8432 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
8433 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
8434 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8435 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
8436 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
8437 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8438 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
8439 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8440 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
8441 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8442 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8443 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
8444 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
8446 ; GFX940-TGSPLIT-LABEL: flat_singlethread_acq_rel_acquire_ret_cmpxchg:
8447 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
8448 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
8449 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8450 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
8451 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
8452 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8453 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
8454 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
8455 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8456 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
8457 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8458 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
8459 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8460 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8461 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
8462 ; GFX940-TGSPLIT-NEXT: s_endpgm
8464 ; GFX11-WGP-LABEL: flat_singlethread_acq_rel_acquire_ret_cmpxchg:
8465 ; GFX11-WGP: ; %bb.0: ; %entry
8466 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
8467 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
8468 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
8469 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
8470 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
8471 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
8472 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
8473 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8474 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
8475 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
8476 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
8477 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
8478 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
8479 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
8480 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8481 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
8482 ; GFX11-WGP-NEXT: s_endpgm
8484 ; GFX11-CU-LABEL: flat_singlethread_acq_rel_acquire_ret_cmpxchg:
8485 ; GFX11-CU: ; %bb.0: ; %entry
8486 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
8487 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
8488 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
8489 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
8490 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
8491 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
8492 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
8493 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8494 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
8495 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
8496 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
8497 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
8498 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
8499 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
8500 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8501 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
8502 ; GFX11-CU-NEXT: s_endpgm
8504 ; GFX12-WGP-LABEL: flat_singlethread_acq_rel_acquire_ret_cmpxchg:
8505 ; GFX12-WGP: ; %bb.0: ; %entry
8506 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
8507 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
8508 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
8509 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
8510 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
8511 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
8512 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
8513 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8514 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
8515 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
8516 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
8517 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
8518 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
8519 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
8520 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
8521 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
8522 ; GFX12-WGP-NEXT: s_endpgm
8524 ; GFX12-CU-LABEL: flat_singlethread_acq_rel_acquire_ret_cmpxchg:
8525 ; GFX12-CU: ; %bb.0: ; %entry
8526 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
8527 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
8528 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
8529 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
8530 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
8531 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
8532 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
8533 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8534 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
8535 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
8536 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
8537 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
8538 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
8539 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
8540 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
8541 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
8542 ; GFX12-CU-NEXT: s_endpgm
8543 ptr %out, i32 %in, i32 %old) {
8545 %gep = getelementptr i32, ptr %out, i32 4
8546 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") acq_rel acquire
8547 %val0 = extractvalue { i32, i1 } %val, 0
8548 store i32 %val0, ptr %out, align 4
8552 define amdgpu_kernel void @flat_singlethread_seq_cst_acquire_ret_cmpxchg(
8553 ; GFX7-LABEL: flat_singlethread_seq_cst_acquire_ret_cmpxchg:
8554 ; GFX7: ; %bb.0: ; %entry
8555 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
8556 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
8557 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
8558 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
8559 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8560 ; GFX7-NEXT: s_mov_b32 s6, s4
8561 ; GFX7-NEXT: s_mov_b32 s7, s5
8562 ; GFX7-NEXT: s_mov_b32 s11, s12
8563 ; GFX7-NEXT: s_mov_b32 s10, s13
8564 ; GFX7-NEXT: s_add_u32 s6, s6, s11
8565 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
8566 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
8567 ; GFX7-NEXT: s_mov_b32 s7, s10
8568 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
8569 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
8570 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8571 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
8572 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
8573 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
8574 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8575 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
8576 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
8577 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8578 ; GFX7-NEXT: flat_store_dword v[0:1], v2
8579 ; GFX7-NEXT: s_endpgm
8581 ; GFX10-WGP-LABEL: flat_singlethread_seq_cst_acquire_ret_cmpxchg:
8582 ; GFX10-WGP: ; %bb.0: ; %entry
8583 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
8584 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
8585 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
8586 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
8587 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8588 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
8589 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
8590 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
8591 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
8592 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
8593 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
8594 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
8595 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
8596 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
8597 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
8598 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8599 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
8600 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
8601 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
8602 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8603 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
8604 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
8605 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8606 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
8607 ; GFX10-WGP-NEXT: s_endpgm
8609 ; GFX10-CU-LABEL: flat_singlethread_seq_cst_acquire_ret_cmpxchg:
8610 ; GFX10-CU: ; %bb.0: ; %entry
8611 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
8612 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
8613 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
8614 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
8615 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8616 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
8617 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
8618 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
8619 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
8620 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
8621 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
8622 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
8623 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
8624 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
8625 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
8626 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8627 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
8628 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
8629 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
8630 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8631 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
8632 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
8633 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8634 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
8635 ; GFX10-CU-NEXT: s_endpgm
8637 ; SKIP-CACHE-INV-LABEL: flat_singlethread_seq_cst_acquire_ret_cmpxchg:
8638 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8639 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
8640 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
8641 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
8642 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
8643 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8644 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
8645 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
8646 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
8647 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
8648 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
8649 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
8650 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
8651 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
8652 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
8653 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
8654 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8655 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
8656 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
8657 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
8658 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8659 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
8660 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
8661 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8662 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
8663 ; SKIP-CACHE-INV-NEXT: s_endpgm
8665 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_seq_cst_acquire_ret_cmpxchg:
8666 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8667 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
8668 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
8669 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
8670 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
8671 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8672 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
8673 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
8674 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8675 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
8676 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
8677 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
8678 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
8679 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8680 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
8681 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8683 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_seq_cst_acquire_ret_cmpxchg:
8684 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8685 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
8686 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
8687 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
8688 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
8689 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8690 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
8691 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
8692 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8693 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
8694 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
8695 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
8696 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
8697 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8698 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
8699 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8701 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_seq_cst_acquire_ret_cmpxchg:
8702 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
8703 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
8704 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8705 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
8706 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
8707 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8708 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
8709 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
8710 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8711 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
8712 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8713 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
8714 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8715 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8716 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
8717 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
8719 ; GFX940-TGSPLIT-LABEL: flat_singlethread_seq_cst_acquire_ret_cmpxchg:
8720 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
8721 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
8722 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8723 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
8724 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
8725 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8726 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
8727 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
8728 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8729 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
8730 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8731 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
8732 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8733 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8734 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
8735 ; GFX940-TGSPLIT-NEXT: s_endpgm
8737 ; GFX11-WGP-LABEL: flat_singlethread_seq_cst_acquire_ret_cmpxchg:
8738 ; GFX11-WGP: ; %bb.0: ; %entry
8739 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
8740 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
8741 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
8742 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
8743 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
8744 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
8745 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
8746 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8747 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
8748 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
8749 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
8750 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
8751 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
8752 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
8753 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8754 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
8755 ; GFX11-WGP-NEXT: s_endpgm
8757 ; GFX11-CU-LABEL: flat_singlethread_seq_cst_acquire_ret_cmpxchg:
8758 ; GFX11-CU: ; %bb.0: ; %entry
8759 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
8760 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
8761 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
8762 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
8763 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
8764 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
8765 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
8766 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8767 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
8768 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
8769 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
8770 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
8771 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
8772 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
8773 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8774 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
8775 ; GFX11-CU-NEXT: s_endpgm
8777 ; GFX12-WGP-LABEL: flat_singlethread_seq_cst_acquire_ret_cmpxchg:
8778 ; GFX12-WGP: ; %bb.0: ; %entry
8779 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
8780 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
8781 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
8782 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
8783 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
8784 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
8785 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
8786 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8787 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
8788 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
8789 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
8790 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
8791 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
8792 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
8793 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
8794 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
8795 ; GFX12-WGP-NEXT: s_endpgm
8797 ; GFX12-CU-LABEL: flat_singlethread_seq_cst_acquire_ret_cmpxchg:
8798 ; GFX12-CU: ; %bb.0: ; %entry
8799 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
8800 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
8801 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
8802 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
8803 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
8804 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
8805 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
8806 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8807 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
8808 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
8809 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
8810 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
8811 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
8812 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
8813 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
8814 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
8815 ; GFX12-CU-NEXT: s_endpgm
8816 ptr %out, i32 %in, i32 %old) {
8818 %gep = getelementptr i32, ptr %out, i32 4
8819 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") seq_cst acquire
8820 %val0 = extractvalue { i32, i1 } %val, 0
8821 store i32 %val0, ptr %out, align 4
8825 define amdgpu_kernel void @flat_singlethread_monotonic_seq_cst_ret_cmpxchg(
8826 ; GFX7-LABEL: flat_singlethread_monotonic_seq_cst_ret_cmpxchg:
8827 ; GFX7: ; %bb.0: ; %entry
8828 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
8829 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
8830 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
8831 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
8832 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8833 ; GFX7-NEXT: s_mov_b32 s6, s4
8834 ; GFX7-NEXT: s_mov_b32 s7, s5
8835 ; GFX7-NEXT: s_mov_b32 s11, s12
8836 ; GFX7-NEXT: s_mov_b32 s10, s13
8837 ; GFX7-NEXT: s_add_u32 s6, s6, s11
8838 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
8839 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
8840 ; GFX7-NEXT: s_mov_b32 s7, s10
8841 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
8842 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
8843 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8844 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
8845 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
8846 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
8847 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8848 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
8849 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
8850 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8851 ; GFX7-NEXT: flat_store_dword v[0:1], v2
8852 ; GFX7-NEXT: s_endpgm
8854 ; GFX10-WGP-LABEL: flat_singlethread_monotonic_seq_cst_ret_cmpxchg:
8855 ; GFX10-WGP: ; %bb.0: ; %entry
8856 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
8857 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
8858 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
8859 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
8860 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8861 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
8862 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
8863 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
8864 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
8865 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
8866 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
8867 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
8868 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
8869 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
8870 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
8871 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8872 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
8873 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
8874 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
8875 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8876 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
8877 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
8878 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8879 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
8880 ; GFX10-WGP-NEXT: s_endpgm
8882 ; GFX10-CU-LABEL: flat_singlethread_monotonic_seq_cst_ret_cmpxchg:
8883 ; GFX10-CU: ; %bb.0: ; %entry
8884 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
8885 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
8886 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
8887 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
8888 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8889 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
8890 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
8891 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
8892 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
8893 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
8894 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
8895 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
8896 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
8897 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
8898 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
8899 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8900 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
8901 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
8902 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
8903 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8904 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
8905 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
8906 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8907 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
8908 ; GFX10-CU-NEXT: s_endpgm
8910 ; SKIP-CACHE-INV-LABEL: flat_singlethread_monotonic_seq_cst_ret_cmpxchg:
8911 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8912 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
8913 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
8914 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
8915 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
8916 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8917 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
8918 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
8919 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
8920 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
8921 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
8922 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
8923 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
8924 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
8925 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
8926 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
8927 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8928 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
8929 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
8930 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
8931 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8932 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
8933 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
8934 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8935 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
8936 ; SKIP-CACHE-INV-NEXT: s_endpgm
8938 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_monotonic_seq_cst_ret_cmpxchg:
8939 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8940 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
8941 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
8942 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
8943 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
8944 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8945 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
8946 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
8947 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8948 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
8949 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
8950 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
8951 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
8952 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8953 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
8954 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8956 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_monotonic_seq_cst_ret_cmpxchg:
8957 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8958 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
8959 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
8960 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
8961 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
8962 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8963 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
8964 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
8965 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8966 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
8967 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
8968 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
8969 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
8970 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8971 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
8972 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8974 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_monotonic_seq_cst_ret_cmpxchg:
8975 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
8976 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
8977 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8978 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
8979 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
8980 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8981 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
8982 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
8983 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8984 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
8985 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8986 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
8987 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
8988 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8989 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
8990 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
8992 ; GFX940-TGSPLIT-LABEL: flat_singlethread_monotonic_seq_cst_ret_cmpxchg:
8993 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
8994 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
8995 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8996 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
8997 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
8998 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8999 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
9000 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
9001 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9002 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
9003 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
9004 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
9005 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
9006 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9007 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
9008 ; GFX940-TGSPLIT-NEXT: s_endpgm
9010 ; GFX11-WGP-LABEL: flat_singlethread_monotonic_seq_cst_ret_cmpxchg:
9011 ; GFX11-WGP: ; %bb.0: ; %entry
9012 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
9013 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9014 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
9015 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
9016 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
9017 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
9018 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
9019 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9020 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
9021 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
9022 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
9023 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
9024 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
9025 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
9026 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9027 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
9028 ; GFX11-WGP-NEXT: s_endpgm
9030 ; GFX11-CU-LABEL: flat_singlethread_monotonic_seq_cst_ret_cmpxchg:
9031 ; GFX11-CU: ; %bb.0: ; %entry
9032 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
9033 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9034 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
9035 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
9036 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
9037 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
9038 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
9039 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9040 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
9041 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
9042 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
9043 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
9044 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
9045 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
9046 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9047 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
9048 ; GFX11-CU-NEXT: s_endpgm
9050 ; GFX12-WGP-LABEL: flat_singlethread_monotonic_seq_cst_ret_cmpxchg:
9051 ; GFX12-WGP: ; %bb.0: ; %entry
9052 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
9053 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9054 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
9055 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
9056 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
9057 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
9058 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
9059 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9060 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
9061 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
9062 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
9063 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
9064 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
9065 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
9066 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
9067 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
9068 ; GFX12-WGP-NEXT: s_endpgm
9070 ; GFX12-CU-LABEL: flat_singlethread_monotonic_seq_cst_ret_cmpxchg:
9071 ; GFX12-CU: ; %bb.0: ; %entry
9072 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
9073 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9074 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
9075 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
9076 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
9077 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
9078 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
9079 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9080 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
9081 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
9082 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
9083 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
9084 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
9085 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
9086 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
9087 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
9088 ; GFX12-CU-NEXT: s_endpgm
9089 ptr %out, i32 %in, i32 %old) {
9091 %gep = getelementptr i32, ptr %out, i32 4
9092 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") monotonic seq_cst
9093 %val0 = extractvalue { i32, i1 } %val, 0
9094 store i32 %val0, ptr %out, align 4
9098 define amdgpu_kernel void @flat_singlethread_acquire_seq_cst_ret_cmpxchg(
9099 ; GFX7-LABEL: flat_singlethread_acquire_seq_cst_ret_cmpxchg:
9100 ; GFX7: ; %bb.0: ; %entry
9101 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
9102 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
9103 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
9104 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
9105 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
9106 ; GFX7-NEXT: s_mov_b32 s6, s4
9107 ; GFX7-NEXT: s_mov_b32 s7, s5
9108 ; GFX7-NEXT: s_mov_b32 s11, s12
9109 ; GFX7-NEXT: s_mov_b32 s10, s13
9110 ; GFX7-NEXT: s_add_u32 s6, s6, s11
9111 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
9112 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
9113 ; GFX7-NEXT: s_mov_b32 s7, s10
9114 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
9115 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
9116 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9117 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
9118 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
9119 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
9120 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9121 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
9122 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
9123 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9124 ; GFX7-NEXT: flat_store_dword v[0:1], v2
9125 ; GFX7-NEXT: s_endpgm
9127 ; GFX10-WGP-LABEL: flat_singlethread_acquire_seq_cst_ret_cmpxchg:
9128 ; GFX10-WGP: ; %bb.0: ; %entry
9129 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
9130 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
9131 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
9132 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
9133 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
9134 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
9135 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
9136 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
9137 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
9138 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
9139 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
9140 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
9141 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
9142 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
9143 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
9144 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9145 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
9146 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
9147 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
9148 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9149 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
9150 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
9151 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9152 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
9153 ; GFX10-WGP-NEXT: s_endpgm
9155 ; GFX10-CU-LABEL: flat_singlethread_acquire_seq_cst_ret_cmpxchg:
9156 ; GFX10-CU: ; %bb.0: ; %entry
9157 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
9158 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
9159 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
9160 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
9161 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9162 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
9163 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
9164 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
9165 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
9166 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
9167 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
9168 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
9169 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
9170 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
9171 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
9172 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9173 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
9174 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
9175 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
9176 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9177 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
9178 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
9179 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9180 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
9181 ; GFX10-CU-NEXT: s_endpgm
9183 ; SKIP-CACHE-INV-LABEL: flat_singlethread_acquire_seq_cst_ret_cmpxchg:
9184 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
9185 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
9186 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
9187 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
9188 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
9189 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9190 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
9191 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
9192 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
9193 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
9194 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
9195 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
9196 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
9197 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
9198 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
9199 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
9200 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9201 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
9202 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
9203 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
9204 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9205 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
9206 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
9207 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9208 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
9209 ; SKIP-CACHE-INV-NEXT: s_endpgm
9211 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_acquire_seq_cst_ret_cmpxchg:
9212 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
9213 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
9214 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
9215 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
9216 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
9217 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9218 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
9219 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
9220 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9221 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
9222 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
9223 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
9224 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
9225 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9226 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
9227 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
9229 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_acquire_seq_cst_ret_cmpxchg:
9230 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
9231 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
9232 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
9233 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
9234 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
9235 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9236 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
9237 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
9238 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9239 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
9240 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
9241 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
9242 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
9243 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9244 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
9245 ; GFX90A-TGSPLIT-NEXT: s_endpgm
9247 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_acquire_seq_cst_ret_cmpxchg:
9248 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
9249 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
9250 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
9251 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
9252 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
9253 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9254 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
9255 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
9256 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9257 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
9258 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
9259 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
9260 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
9261 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9262 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
9263 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
9265 ; GFX940-TGSPLIT-LABEL: flat_singlethread_acquire_seq_cst_ret_cmpxchg:
9266 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
9267 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
9268 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
9269 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
9270 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
9271 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9272 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
9273 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
9274 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9275 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
9276 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
9277 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
9278 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
9279 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9280 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
9281 ; GFX940-TGSPLIT-NEXT: s_endpgm
9283 ; GFX11-WGP-LABEL: flat_singlethread_acquire_seq_cst_ret_cmpxchg:
9284 ; GFX11-WGP: ; %bb.0: ; %entry
9285 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
9286 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9287 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
9288 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
9289 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
9290 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
9291 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
9292 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9293 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
9294 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
9295 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
9296 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
9297 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
9298 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
9299 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9300 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
9301 ; GFX11-WGP-NEXT: s_endpgm
9303 ; GFX11-CU-LABEL: flat_singlethread_acquire_seq_cst_ret_cmpxchg:
9304 ; GFX11-CU: ; %bb.0: ; %entry
9305 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
9306 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9307 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
9308 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
9309 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
9310 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
9311 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
9312 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9313 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
9314 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
9315 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
9316 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
9317 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
9318 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
9319 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9320 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
9321 ; GFX11-CU-NEXT: s_endpgm
9323 ; GFX12-WGP-LABEL: flat_singlethread_acquire_seq_cst_ret_cmpxchg:
9324 ; GFX12-WGP: ; %bb.0: ; %entry
9325 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
9326 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9327 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
9328 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
9329 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
9330 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
9331 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
9332 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9333 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
9334 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
9335 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
9336 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
9337 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
9338 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
9339 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
9340 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
9341 ; GFX12-WGP-NEXT: s_endpgm
9343 ; GFX12-CU-LABEL: flat_singlethread_acquire_seq_cst_ret_cmpxchg:
9344 ; GFX12-CU: ; %bb.0: ; %entry
9345 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
9346 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9347 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
9348 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
9349 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
9350 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
9351 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
9352 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9353 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
9354 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
9355 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
9356 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
9357 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
9358 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
9359 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
9360 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
9361 ; GFX12-CU-NEXT: s_endpgm
9362 ptr %out, i32 %in, i32 %old) {
9364 %gep = getelementptr i32, ptr %out, i32 4
9365 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") acquire seq_cst
9366 %val0 = extractvalue { i32, i1 } %val, 0
9367 store i32 %val0, ptr %out, align 4
9371 define amdgpu_kernel void @flat_singlethread_release_seq_cst_ret_cmpxchg(
9372 ; GFX7-LABEL: flat_singlethread_release_seq_cst_ret_cmpxchg:
9373 ; GFX7: ; %bb.0: ; %entry
9374 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
9375 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
9376 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
9377 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
9378 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
9379 ; GFX7-NEXT: s_mov_b32 s6, s4
9380 ; GFX7-NEXT: s_mov_b32 s7, s5
9381 ; GFX7-NEXT: s_mov_b32 s11, s12
9382 ; GFX7-NEXT: s_mov_b32 s10, s13
9383 ; GFX7-NEXT: s_add_u32 s6, s6, s11
9384 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
9385 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
9386 ; GFX7-NEXT: s_mov_b32 s7, s10
9387 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
9388 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
9389 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9390 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
9391 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
9392 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
9393 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9394 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
9395 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
9396 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9397 ; GFX7-NEXT: flat_store_dword v[0:1], v2
9398 ; GFX7-NEXT: s_endpgm
9400 ; GFX10-WGP-LABEL: flat_singlethread_release_seq_cst_ret_cmpxchg:
9401 ; GFX10-WGP: ; %bb.0: ; %entry
9402 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
9403 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
9404 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
9405 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
9406 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
9407 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
9408 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
9409 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
9410 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
9411 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
9412 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
9413 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
9414 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
9415 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
9416 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
9417 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9418 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
9419 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
9420 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
9421 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9422 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
9423 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
9424 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9425 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
9426 ; GFX10-WGP-NEXT: s_endpgm
9428 ; GFX10-CU-LABEL: flat_singlethread_release_seq_cst_ret_cmpxchg:
9429 ; GFX10-CU: ; %bb.0: ; %entry
9430 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
9431 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
9432 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
9433 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
9434 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9435 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
9436 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
9437 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
9438 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
9439 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
9440 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
9441 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
9442 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
9443 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
9444 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
9445 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9446 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
9447 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
9448 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
9449 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9450 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
9451 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
9452 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9453 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
9454 ; GFX10-CU-NEXT: s_endpgm
9456 ; SKIP-CACHE-INV-LABEL: flat_singlethread_release_seq_cst_ret_cmpxchg:
9457 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
9458 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
9459 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
9460 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
9461 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
9462 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9463 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
9464 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
9465 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
9466 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
9467 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
9468 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
9469 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
9470 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
9471 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
9472 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
9473 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9474 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
9475 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
9476 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
9477 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9478 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
9479 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
9480 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9481 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
9482 ; SKIP-CACHE-INV-NEXT: s_endpgm
9484 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_release_seq_cst_ret_cmpxchg:
9485 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
9486 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
9487 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
9488 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
9489 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
9490 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9491 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
9492 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
9493 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9494 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
9495 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
9496 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
9497 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
9498 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9499 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
9500 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
9502 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_release_seq_cst_ret_cmpxchg:
9503 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
9504 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
9505 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
9506 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
9507 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
9508 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9509 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
9510 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
9511 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9512 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
9513 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
9514 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
9515 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
9516 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9517 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
9518 ; GFX90A-TGSPLIT-NEXT: s_endpgm
9520 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_release_seq_cst_ret_cmpxchg:
9521 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
9522 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
9523 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
9524 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
9525 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
9526 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9527 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
9528 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
9529 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9530 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
9531 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
9532 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
9533 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
9534 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9535 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
9536 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
9538 ; GFX940-TGSPLIT-LABEL: flat_singlethread_release_seq_cst_ret_cmpxchg:
9539 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
9540 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
9541 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
9542 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
9543 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
9544 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9545 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
9546 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
9547 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9548 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
9549 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
9550 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
9551 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
9552 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9553 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
9554 ; GFX940-TGSPLIT-NEXT: s_endpgm
9556 ; GFX11-WGP-LABEL: flat_singlethread_release_seq_cst_ret_cmpxchg:
9557 ; GFX11-WGP: ; %bb.0: ; %entry
9558 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
9559 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9560 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
9561 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
9562 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
9563 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
9564 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
9565 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9566 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
9567 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
9568 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
9569 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
9570 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
9571 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
9572 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9573 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
9574 ; GFX11-WGP-NEXT: s_endpgm
9576 ; GFX11-CU-LABEL: flat_singlethread_release_seq_cst_ret_cmpxchg:
9577 ; GFX11-CU: ; %bb.0: ; %entry
9578 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
9579 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9580 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
9581 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
9582 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
9583 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
9584 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
9585 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9586 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
9587 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
9588 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
9589 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
9590 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
9591 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
9592 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9593 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
9594 ; GFX11-CU-NEXT: s_endpgm
9596 ; GFX12-WGP-LABEL: flat_singlethread_release_seq_cst_ret_cmpxchg:
9597 ; GFX12-WGP: ; %bb.0: ; %entry
9598 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
9599 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9600 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
9601 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
9602 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
9603 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
9604 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
9605 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9606 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
9607 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
9608 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
9609 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
9610 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
9611 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
9612 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
9613 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
9614 ; GFX12-WGP-NEXT: s_endpgm
9616 ; GFX12-CU-LABEL: flat_singlethread_release_seq_cst_ret_cmpxchg:
9617 ; GFX12-CU: ; %bb.0: ; %entry
9618 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
9619 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9620 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
9621 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
9622 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
9623 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
9624 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
9625 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9626 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
9627 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
9628 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
9629 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
9630 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
9631 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
9632 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
9633 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
9634 ; GFX12-CU-NEXT: s_endpgm
9635 ptr %out, i32 %in, i32 %old) {
9637 %gep = getelementptr i32, ptr %out, i32 4
9638 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") release seq_cst
9639 %val0 = extractvalue { i32, i1 } %val, 0
9640 store i32 %val0, ptr %out, align 4
9644 define amdgpu_kernel void @flat_singlethread_acq_rel_seq_cst_ret_cmpxchg(
9645 ; GFX7-LABEL: flat_singlethread_acq_rel_seq_cst_ret_cmpxchg:
9646 ; GFX7: ; %bb.0: ; %entry
9647 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
9648 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
9649 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
9650 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
9651 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
9652 ; GFX7-NEXT: s_mov_b32 s6, s4
9653 ; GFX7-NEXT: s_mov_b32 s7, s5
9654 ; GFX7-NEXT: s_mov_b32 s11, s12
9655 ; GFX7-NEXT: s_mov_b32 s10, s13
9656 ; GFX7-NEXT: s_add_u32 s6, s6, s11
9657 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
9658 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
9659 ; GFX7-NEXT: s_mov_b32 s7, s10
9660 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
9661 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
9662 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9663 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
9664 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
9665 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
9666 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9667 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
9668 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
9669 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9670 ; GFX7-NEXT: flat_store_dword v[0:1], v2
9671 ; GFX7-NEXT: s_endpgm
9673 ; GFX10-WGP-LABEL: flat_singlethread_acq_rel_seq_cst_ret_cmpxchg:
9674 ; GFX10-WGP: ; %bb.0: ; %entry
9675 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
9676 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
9677 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
9678 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
9679 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
9680 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
9681 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
9682 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
9683 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
9684 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
9685 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
9686 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
9687 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
9688 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
9689 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
9690 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9691 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
9692 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
9693 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
9694 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9695 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
9696 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
9697 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9698 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
9699 ; GFX10-WGP-NEXT: s_endpgm
9701 ; GFX10-CU-LABEL: flat_singlethread_acq_rel_seq_cst_ret_cmpxchg:
9702 ; GFX10-CU: ; %bb.0: ; %entry
9703 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
9704 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
9705 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
9706 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
9707 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9708 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
9709 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
9710 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
9711 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
9712 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
9713 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
9714 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
9715 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
9716 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
9717 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
9718 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9719 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
9720 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
9721 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
9722 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9723 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
9724 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
9725 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9726 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
9727 ; GFX10-CU-NEXT: s_endpgm
9729 ; SKIP-CACHE-INV-LABEL: flat_singlethread_acq_rel_seq_cst_ret_cmpxchg:
9730 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
9731 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
9732 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
9733 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
9734 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
9735 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9736 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
9737 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
9738 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
9739 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
9740 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
9741 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
9742 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
9743 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
9744 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
9745 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
9746 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9747 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
9748 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
9749 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
9750 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9751 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
9752 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
9753 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9754 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
9755 ; SKIP-CACHE-INV-NEXT: s_endpgm
9757 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_acq_rel_seq_cst_ret_cmpxchg:
9758 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
9759 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
9760 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
9761 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
9762 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
9763 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9764 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
9765 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
9766 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9767 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
9768 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
9769 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
9770 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
9771 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9772 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
9773 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
9775 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_acq_rel_seq_cst_ret_cmpxchg:
9776 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
9777 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
9778 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
9779 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
9780 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
9781 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9782 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
9783 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
9784 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9785 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
9786 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
9787 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
9788 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
9789 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9790 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
9791 ; GFX90A-TGSPLIT-NEXT: s_endpgm
9793 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_acq_rel_seq_cst_ret_cmpxchg:
9794 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
9795 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
9796 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
9797 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
9798 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
9799 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9800 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
9801 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
9802 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9803 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
9804 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
9805 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
9806 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
9807 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9808 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
9809 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
9811 ; GFX940-TGSPLIT-LABEL: flat_singlethread_acq_rel_seq_cst_ret_cmpxchg:
9812 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
9813 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
9814 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
9815 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
9816 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
9817 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9818 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
9819 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
9820 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9821 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
9822 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
9823 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
9824 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
9825 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9826 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
9827 ; GFX940-TGSPLIT-NEXT: s_endpgm
9829 ; GFX11-WGP-LABEL: flat_singlethread_acq_rel_seq_cst_ret_cmpxchg:
9830 ; GFX11-WGP: ; %bb.0: ; %entry
9831 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
9832 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9833 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
9834 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
9835 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
9836 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
9837 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
9838 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9839 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
9840 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
9841 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
9842 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
9843 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
9844 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
9845 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9846 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
9847 ; GFX11-WGP-NEXT: s_endpgm
9849 ; GFX11-CU-LABEL: flat_singlethread_acq_rel_seq_cst_ret_cmpxchg:
9850 ; GFX11-CU: ; %bb.0: ; %entry
9851 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
9852 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9853 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
9854 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
9855 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
9856 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
9857 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
9858 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9859 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
9860 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
9861 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
9862 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
9863 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
9864 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
9865 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9866 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
9867 ; GFX11-CU-NEXT: s_endpgm
9869 ; GFX12-WGP-LABEL: flat_singlethread_acq_rel_seq_cst_ret_cmpxchg:
9870 ; GFX12-WGP: ; %bb.0: ; %entry
9871 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
9872 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9873 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
9874 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
9875 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
9876 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
9877 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
9878 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9879 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
9880 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
9881 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
9882 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
9883 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
9884 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
9885 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
9886 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
9887 ; GFX12-WGP-NEXT: s_endpgm
9889 ; GFX12-CU-LABEL: flat_singlethread_acq_rel_seq_cst_ret_cmpxchg:
9890 ; GFX12-CU: ; %bb.0: ; %entry
9891 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
9892 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9893 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
9894 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
9895 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
9896 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
9897 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
9898 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9899 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
9900 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
9901 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
9902 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
9903 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
9904 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
9905 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
9906 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
9907 ; GFX12-CU-NEXT: s_endpgm
9908 ptr %out, i32 %in, i32 %old) {
9910 %gep = getelementptr i32, ptr %out, i32 4
9911 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") acq_rel seq_cst
9912 %val0 = extractvalue { i32, i1 } %val, 0
9913 store i32 %val0, ptr %out, align 4
9917 define amdgpu_kernel void @flat_singlethread_seq_cst_seq_cst_ret_cmpxchg(
9918 ; GFX7-LABEL: flat_singlethread_seq_cst_seq_cst_ret_cmpxchg:
9919 ; GFX7: ; %bb.0: ; %entry
9920 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
9921 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
9922 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
9923 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
9924 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
9925 ; GFX7-NEXT: s_mov_b32 s6, s4
9926 ; GFX7-NEXT: s_mov_b32 s7, s5
9927 ; GFX7-NEXT: s_mov_b32 s11, s12
9928 ; GFX7-NEXT: s_mov_b32 s10, s13
9929 ; GFX7-NEXT: s_add_u32 s6, s6, s11
9930 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
9931 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
9932 ; GFX7-NEXT: s_mov_b32 s7, s10
9933 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
9934 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
9935 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9936 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
9937 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
9938 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
9939 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9940 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
9941 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
9942 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9943 ; GFX7-NEXT: flat_store_dword v[0:1], v2
9944 ; GFX7-NEXT: s_endpgm
9946 ; GFX10-WGP-LABEL: flat_singlethread_seq_cst_seq_cst_ret_cmpxchg:
9947 ; GFX10-WGP: ; %bb.0: ; %entry
9948 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
9949 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
9950 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
9951 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
9952 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
9953 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
9954 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
9955 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
9956 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
9957 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
9958 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
9959 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
9960 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
9961 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
9962 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
9963 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9964 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
9965 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
9966 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
9967 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9968 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
9969 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
9970 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9971 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
9972 ; GFX10-WGP-NEXT: s_endpgm
9974 ; GFX10-CU-LABEL: flat_singlethread_seq_cst_seq_cst_ret_cmpxchg:
9975 ; GFX10-CU: ; %bb.0: ; %entry
9976 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
9977 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
9978 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
9979 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
9980 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9981 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
9982 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
9983 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
9984 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
9985 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
9986 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
9987 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
9988 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
9989 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
9990 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
9991 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9992 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
9993 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
9994 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
9995 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9996 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
9997 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
9998 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9999 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
10000 ; GFX10-CU-NEXT: s_endpgm
10002 ; SKIP-CACHE-INV-LABEL: flat_singlethread_seq_cst_seq_cst_ret_cmpxchg:
10003 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
10004 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
10005 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
10006 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
10007 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
10008 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
10009 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
10010 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
10011 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
10012 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
10013 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
10014 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
10015 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
10016 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
10017 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
10018 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
10019 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
10020 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
10021 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
10022 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
10023 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
10024 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
10025 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
10026 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10027 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
10028 ; SKIP-CACHE-INV-NEXT: s_endpgm
10030 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_seq_cst_seq_cst_ret_cmpxchg:
10031 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
10032 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
10033 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
10034 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
10035 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
10036 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10037 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
10038 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
10039 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
10040 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
10041 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
10042 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
10043 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
10044 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10045 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
10046 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
10048 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_seq_cst_seq_cst_ret_cmpxchg:
10049 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
10050 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
10051 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
10052 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
10053 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
10054 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10055 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
10056 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
10057 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
10058 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
10059 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
10060 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
10061 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
10062 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10063 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
10064 ; GFX90A-TGSPLIT-NEXT: s_endpgm
10066 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_seq_cst_seq_cst_ret_cmpxchg:
10067 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
10068 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
10069 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
10070 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
10071 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
10072 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10073 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
10074 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
10075 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
10076 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
10077 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
10078 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
10079 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
10080 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10081 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
10082 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
10084 ; GFX940-TGSPLIT-LABEL: flat_singlethread_seq_cst_seq_cst_ret_cmpxchg:
10085 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
10086 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
10087 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
10088 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
10089 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
10090 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10091 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
10092 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
10093 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
10094 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
10095 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
10096 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
10097 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
10098 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10099 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
10100 ; GFX940-TGSPLIT-NEXT: s_endpgm
10102 ; GFX11-WGP-LABEL: flat_singlethread_seq_cst_seq_cst_ret_cmpxchg:
10103 ; GFX11-WGP: ; %bb.0: ; %entry
10104 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
10105 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
10106 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
10107 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
10108 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10109 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
10110 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
10111 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
10112 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
10113 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
10114 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
10115 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
10116 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
10117 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
10118 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10119 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
10120 ; GFX11-WGP-NEXT: s_endpgm
10122 ; GFX11-CU-LABEL: flat_singlethread_seq_cst_seq_cst_ret_cmpxchg:
10123 ; GFX11-CU: ; %bb.0: ; %entry
10124 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
10125 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
10126 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
10127 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
10128 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
10129 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
10130 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
10131 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
10132 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
10133 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
10134 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
10135 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
10136 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
10137 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
10138 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10139 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
10140 ; GFX11-CU-NEXT: s_endpgm
10142 ; GFX12-WGP-LABEL: flat_singlethread_seq_cst_seq_cst_ret_cmpxchg:
10143 ; GFX12-WGP: ; %bb.0: ; %entry
10144 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
10145 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
10146 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
10147 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
10148 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
10149 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
10150 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
10151 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
10152 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
10153 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
10154 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
10155 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
10156 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
10157 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
10158 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
10159 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
10160 ; GFX12-WGP-NEXT: s_endpgm
10162 ; GFX12-CU-LABEL: flat_singlethread_seq_cst_seq_cst_ret_cmpxchg:
10163 ; GFX12-CU: ; %bb.0: ; %entry
10164 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
10165 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
10166 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
10167 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
10168 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
10169 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
10170 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
10171 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
10172 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
10173 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
10174 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
10175 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
10176 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
10177 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
10178 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
10179 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
10180 ; GFX12-CU-NEXT: s_endpgm
10181 ptr %out, i32 %in, i32 %old) {
10183 %gep = getelementptr i32, ptr %out, i32 4
10184 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread") seq_cst seq_cst
10185 %val0 = extractvalue { i32, i1 } %val, 0
10186 store i32 %val0, ptr %out, align 4
10190 define amdgpu_kernel void @flat_singlethread_one_as_unordered_load(
10191 ; GFX7-LABEL: flat_singlethread_one_as_unordered_load:
10192 ; GFX7: ; %bb.0: ; %entry
10193 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
10194 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
10195 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
10196 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
10197 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
10198 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
10199 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
10200 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
10201 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
10202 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10203 ; GFX7-NEXT: flat_store_dword v[0:1], v2
10204 ; GFX7-NEXT: s_endpgm
10206 ; GFX10-WGP-LABEL: flat_singlethread_one_as_unordered_load:
10207 ; GFX10-WGP: ; %bb.0: ; %entry
10208 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
10209 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
10210 ; GFX10-WGP-NEXT: s_nop 0
10211 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
10212 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
10213 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
10214 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
10215 ; GFX10-WGP-NEXT: flat_load_dword v2, v[0:1]
10216 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
10217 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
10218 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10219 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
10220 ; GFX10-WGP-NEXT: s_endpgm
10222 ; GFX10-CU-LABEL: flat_singlethread_one_as_unordered_load:
10223 ; GFX10-CU: ; %bb.0: ; %entry
10224 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
10225 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
10226 ; GFX10-CU-NEXT: s_nop 0
10227 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
10228 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
10229 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
10230 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
10231 ; GFX10-CU-NEXT: flat_load_dword v2, v[0:1]
10232 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
10233 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
10234 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10235 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
10236 ; GFX10-CU-NEXT: s_endpgm
10238 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_unordered_load:
10239 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
10240 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
10241 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
10242 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
10243 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
10244 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
10245 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
10246 ; SKIP-CACHE-INV-NEXT: flat_load_dword v2, v[0:1]
10247 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
10248 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
10249 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10250 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
10251 ; SKIP-CACHE-INV-NEXT: s_endpgm
10253 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_unordered_load:
10254 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
10255 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
10256 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
10257 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
10258 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
10259 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10260 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
10261 ; GFX90A-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1]
10262 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
10263 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10264 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
10265 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
10267 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_unordered_load:
10268 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
10269 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
10270 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
10271 ; GFX90A-TGSPLIT-NEXT: s_nop 0
10272 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
10273 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10274 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
10275 ; GFX90A-TGSPLIT-NEXT: flat_load_dword v2, v[0:1]
10276 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
10277 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10278 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
10279 ; GFX90A-TGSPLIT-NEXT: s_endpgm
10281 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_unordered_load:
10282 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
10283 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
10284 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
10285 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
10286 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x8
10287 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10288 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
10289 ; GFX940-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1]
10290 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
10291 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10292 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
10293 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
10295 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_unordered_load:
10296 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
10297 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
10298 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
10299 ; GFX940-TGSPLIT-NEXT: s_nop 0
10300 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x8
10301 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10302 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
10303 ; GFX940-TGSPLIT-NEXT: flat_load_dword v2, v[0:1]
10304 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
10305 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10306 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
10307 ; GFX940-TGSPLIT-NEXT: s_endpgm
10309 ; GFX11-WGP-LABEL: flat_singlethread_one_as_unordered_load:
10310 ; GFX11-WGP: ; %bb.0: ; %entry
10311 ; GFX11-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
10312 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
10313 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
10314 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10315 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
10316 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
10317 ; GFX11-WGP-NEXT: flat_load_b32 v2, v[0:1]
10318 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
10319 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
10320 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10321 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
10322 ; GFX11-WGP-NEXT: s_endpgm
10324 ; GFX11-CU-LABEL: flat_singlethread_one_as_unordered_load:
10325 ; GFX11-CU: ; %bb.0: ; %entry
10326 ; GFX11-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
10327 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
10328 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
10329 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
10330 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
10331 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
10332 ; GFX11-CU-NEXT: flat_load_b32 v2, v[0:1]
10333 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
10334 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
10335 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10336 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
10337 ; GFX11-CU-NEXT: s_endpgm
10339 ; GFX12-WGP-LABEL: flat_singlethread_one_as_unordered_load:
10340 ; GFX12-WGP: ; %bb.0: ; %entry
10341 ; GFX12-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
10342 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
10343 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
10344 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
10345 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
10346 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
10347 ; GFX12-WGP-NEXT: flat_load_b32 v2, v[0:1]
10348 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
10349 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
10350 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
10351 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
10352 ; GFX12-WGP-NEXT: s_endpgm
10354 ; GFX12-CU-LABEL: flat_singlethread_one_as_unordered_load:
10355 ; GFX12-CU: ; %bb.0: ; %entry
10356 ; GFX12-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
10357 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
10358 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
10359 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
10360 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
10361 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
10362 ; GFX12-CU-NEXT: flat_load_b32 v2, v[0:1]
10363 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
10364 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
10365 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
10366 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
10367 ; GFX12-CU-NEXT: s_endpgm
10368 ptr %in, ptr %out) {
10370 %val = load atomic i32, ptr %in syncscope("singlethread-one-as") unordered, align 4
10371 store i32 %val, ptr %out
10375 define amdgpu_kernel void @flat_singlethread_one_as_monotonic_load(
10376 ; GFX7-LABEL: flat_singlethread_one_as_monotonic_load:
10377 ; GFX7: ; %bb.0: ; %entry
10378 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
10379 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
10380 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
10381 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
10382 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
10383 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
10384 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
10385 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
10386 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
10387 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10388 ; GFX7-NEXT: flat_store_dword v[0:1], v2
10389 ; GFX7-NEXT: s_endpgm
10391 ; GFX10-WGP-LABEL: flat_singlethread_one_as_monotonic_load:
10392 ; GFX10-WGP: ; %bb.0: ; %entry
10393 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
10394 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
10395 ; GFX10-WGP-NEXT: s_nop 0
10396 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
10397 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
10398 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
10399 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
10400 ; GFX10-WGP-NEXT: flat_load_dword v2, v[0:1]
10401 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
10402 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
10403 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10404 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
10405 ; GFX10-WGP-NEXT: s_endpgm
10407 ; GFX10-CU-LABEL: flat_singlethread_one_as_monotonic_load:
10408 ; GFX10-CU: ; %bb.0: ; %entry
10409 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
10410 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
10411 ; GFX10-CU-NEXT: s_nop 0
10412 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
10413 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
10414 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
10415 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
10416 ; GFX10-CU-NEXT: flat_load_dword v2, v[0:1]
10417 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
10418 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
10419 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10420 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
10421 ; GFX10-CU-NEXT: s_endpgm
10423 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_monotonic_load:
10424 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
10425 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
10426 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
10427 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
10428 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
10429 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
10430 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
10431 ; SKIP-CACHE-INV-NEXT: flat_load_dword v2, v[0:1]
10432 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
10433 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
10434 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10435 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
10436 ; SKIP-CACHE-INV-NEXT: s_endpgm
10438 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_monotonic_load:
10439 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
10440 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
10441 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
10442 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
10443 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
10444 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10445 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
10446 ; GFX90A-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1]
10447 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
10448 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10449 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
10450 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
10452 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_monotonic_load:
10453 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
10454 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
10455 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
10456 ; GFX90A-TGSPLIT-NEXT: s_nop 0
10457 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
10458 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10459 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
10460 ; GFX90A-TGSPLIT-NEXT: flat_load_dword v2, v[0:1]
10461 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
10462 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10463 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
10464 ; GFX90A-TGSPLIT-NEXT: s_endpgm
10466 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_monotonic_load:
10467 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
10468 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
10469 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
10470 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
10471 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x8
10472 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10473 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
10474 ; GFX940-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1]
10475 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
10476 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10477 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
10478 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
10480 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_monotonic_load:
10481 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
10482 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
10483 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
10484 ; GFX940-TGSPLIT-NEXT: s_nop 0
10485 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x8
10486 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10487 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
10488 ; GFX940-TGSPLIT-NEXT: flat_load_dword v2, v[0:1]
10489 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
10490 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10491 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
10492 ; GFX940-TGSPLIT-NEXT: s_endpgm
10494 ; GFX11-WGP-LABEL: flat_singlethread_one_as_monotonic_load:
10495 ; GFX11-WGP: ; %bb.0: ; %entry
10496 ; GFX11-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
10497 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
10498 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
10499 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10500 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
10501 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
10502 ; GFX11-WGP-NEXT: flat_load_b32 v2, v[0:1]
10503 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
10504 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
10505 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10506 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
10507 ; GFX11-WGP-NEXT: s_endpgm
10509 ; GFX11-CU-LABEL: flat_singlethread_one_as_monotonic_load:
10510 ; GFX11-CU: ; %bb.0: ; %entry
10511 ; GFX11-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
10512 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
10513 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
10514 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
10515 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
10516 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
10517 ; GFX11-CU-NEXT: flat_load_b32 v2, v[0:1]
10518 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
10519 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
10520 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10521 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
10522 ; GFX11-CU-NEXT: s_endpgm
10524 ; GFX12-WGP-LABEL: flat_singlethread_one_as_monotonic_load:
10525 ; GFX12-WGP: ; %bb.0: ; %entry
10526 ; GFX12-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
10527 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
10528 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
10529 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
10530 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
10531 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
10532 ; GFX12-WGP-NEXT: flat_load_b32 v2, v[0:1]
10533 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
10534 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
10535 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
10536 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
10537 ; GFX12-WGP-NEXT: s_endpgm
10539 ; GFX12-CU-LABEL: flat_singlethread_one_as_monotonic_load:
10540 ; GFX12-CU: ; %bb.0: ; %entry
10541 ; GFX12-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
10542 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
10543 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
10544 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
10545 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
10546 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
10547 ; GFX12-CU-NEXT: flat_load_b32 v2, v[0:1]
10548 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
10549 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
10550 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
10551 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
10552 ; GFX12-CU-NEXT: s_endpgm
10553 ptr %in, ptr %out) {
10555 %val = load atomic i32, ptr %in syncscope("singlethread-one-as") monotonic, align 4
10556 store i32 %val, ptr %out
10560 define amdgpu_kernel void @flat_singlethread_one_as_acquire_load(
10561 ; GFX7-LABEL: flat_singlethread_one_as_acquire_load:
10562 ; GFX7: ; %bb.0: ; %entry
10563 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
10564 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
10565 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
10566 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
10567 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
10568 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
10569 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
10570 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
10571 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
10572 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10573 ; GFX7-NEXT: flat_store_dword v[0:1], v2
10574 ; GFX7-NEXT: s_endpgm
10576 ; GFX10-WGP-LABEL: flat_singlethread_one_as_acquire_load:
10577 ; GFX10-WGP: ; %bb.0: ; %entry
10578 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
10579 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
10580 ; GFX10-WGP-NEXT: s_nop 0
10581 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
10582 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
10583 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
10584 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
10585 ; GFX10-WGP-NEXT: flat_load_dword v2, v[0:1]
10586 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
10587 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
10588 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10589 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
10590 ; GFX10-WGP-NEXT: s_endpgm
10592 ; GFX10-CU-LABEL: flat_singlethread_one_as_acquire_load:
10593 ; GFX10-CU: ; %bb.0: ; %entry
10594 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
10595 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
10596 ; GFX10-CU-NEXT: s_nop 0
10597 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
10598 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
10599 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
10600 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
10601 ; GFX10-CU-NEXT: flat_load_dword v2, v[0:1]
10602 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
10603 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
10604 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10605 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
10606 ; GFX10-CU-NEXT: s_endpgm
10608 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_acquire_load:
10609 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
10610 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
10611 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
10612 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
10613 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
10614 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
10615 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
10616 ; SKIP-CACHE-INV-NEXT: flat_load_dword v2, v[0:1]
10617 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
10618 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
10619 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10620 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
10621 ; SKIP-CACHE-INV-NEXT: s_endpgm
10623 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acquire_load:
10624 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
10625 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
10626 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
10627 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
10628 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
10629 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10630 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
10631 ; GFX90A-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1]
10632 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
10633 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10634 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
10635 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
10637 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_acquire_load:
10638 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
10639 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
10640 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
10641 ; GFX90A-TGSPLIT-NEXT: s_nop 0
10642 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
10643 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10644 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
10645 ; GFX90A-TGSPLIT-NEXT: flat_load_dword v2, v[0:1]
10646 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
10647 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10648 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
10649 ; GFX90A-TGSPLIT-NEXT: s_endpgm
10651 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acquire_load:
10652 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
10653 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
10654 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
10655 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
10656 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x8
10657 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10658 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
10659 ; GFX940-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1]
10660 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
10661 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10662 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
10663 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
10665 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_acquire_load:
10666 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
10667 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
10668 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
10669 ; GFX940-TGSPLIT-NEXT: s_nop 0
10670 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x8
10671 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10672 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
10673 ; GFX940-TGSPLIT-NEXT: flat_load_dword v2, v[0:1]
10674 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
10675 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10676 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
10677 ; GFX940-TGSPLIT-NEXT: s_endpgm
10679 ; GFX11-WGP-LABEL: flat_singlethread_one_as_acquire_load:
10680 ; GFX11-WGP: ; %bb.0: ; %entry
10681 ; GFX11-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
10682 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
10683 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
10684 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10685 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
10686 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
10687 ; GFX11-WGP-NEXT: flat_load_b32 v2, v[0:1]
10688 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
10689 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
10690 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10691 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
10692 ; GFX11-WGP-NEXT: s_endpgm
10694 ; GFX11-CU-LABEL: flat_singlethread_one_as_acquire_load:
10695 ; GFX11-CU: ; %bb.0: ; %entry
10696 ; GFX11-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
10697 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
10698 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
10699 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
10700 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
10701 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
10702 ; GFX11-CU-NEXT: flat_load_b32 v2, v[0:1]
10703 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
10704 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
10705 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10706 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
10707 ; GFX11-CU-NEXT: s_endpgm
10709 ; GFX12-WGP-LABEL: flat_singlethread_one_as_acquire_load:
10710 ; GFX12-WGP: ; %bb.0: ; %entry
10711 ; GFX12-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
10712 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
10713 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
10714 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
10715 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
10716 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
10717 ; GFX12-WGP-NEXT: flat_load_b32 v2, v[0:1]
10718 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
10719 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
10720 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
10721 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
10722 ; GFX12-WGP-NEXT: s_endpgm
10724 ; GFX12-CU-LABEL: flat_singlethread_one_as_acquire_load:
10725 ; GFX12-CU: ; %bb.0: ; %entry
10726 ; GFX12-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
10727 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
10728 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
10729 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
10730 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
10731 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
10732 ; GFX12-CU-NEXT: flat_load_b32 v2, v[0:1]
10733 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
10734 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
10735 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
10736 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
10737 ; GFX12-CU-NEXT: s_endpgm
10738 ptr %in, ptr %out) {
10740 %val = load atomic i32, ptr %in syncscope("singlethread-one-as") acquire, align 4
10741 store i32 %val, ptr %out
10745 define amdgpu_kernel void @flat_singlethread_one_as_seq_cst_load(
10746 ; GFX7-LABEL: flat_singlethread_one_as_seq_cst_load:
10747 ; GFX7: ; %bb.0: ; %entry
10748 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
10749 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
10750 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
10751 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
10752 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
10753 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
10754 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
10755 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
10756 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
10757 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10758 ; GFX7-NEXT: flat_store_dword v[0:1], v2
10759 ; GFX7-NEXT: s_endpgm
10761 ; GFX10-WGP-LABEL: flat_singlethread_one_as_seq_cst_load:
10762 ; GFX10-WGP: ; %bb.0: ; %entry
10763 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
10764 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
10765 ; GFX10-WGP-NEXT: s_nop 0
10766 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
10767 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
10768 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
10769 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
10770 ; GFX10-WGP-NEXT: flat_load_dword v2, v[0:1]
10771 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
10772 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
10773 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10774 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
10775 ; GFX10-WGP-NEXT: s_endpgm
10777 ; GFX10-CU-LABEL: flat_singlethread_one_as_seq_cst_load:
10778 ; GFX10-CU: ; %bb.0: ; %entry
10779 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
10780 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
10781 ; GFX10-CU-NEXT: s_nop 0
10782 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
10783 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
10784 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
10785 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
10786 ; GFX10-CU-NEXT: flat_load_dword v2, v[0:1]
10787 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
10788 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
10789 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10790 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
10791 ; GFX10-CU-NEXT: s_endpgm
10793 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_seq_cst_load:
10794 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
10795 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
10796 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
10797 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
10798 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
10799 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
10800 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
10801 ; SKIP-CACHE-INV-NEXT: flat_load_dword v2, v[0:1]
10802 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
10803 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
10804 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10805 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
10806 ; SKIP-CACHE-INV-NEXT: s_endpgm
10808 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_load:
10809 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
10810 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
10811 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
10812 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
10813 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
10814 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10815 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
10816 ; GFX90A-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1]
10817 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
10818 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10819 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
10820 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
10822 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_load:
10823 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
10824 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
10825 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
10826 ; GFX90A-TGSPLIT-NEXT: s_nop 0
10827 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x8
10828 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10829 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
10830 ; GFX90A-TGSPLIT-NEXT: flat_load_dword v2, v[0:1]
10831 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
10832 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10833 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
10834 ; GFX90A-TGSPLIT-NEXT: s_endpgm
10836 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_load:
10837 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
10838 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
10839 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
10840 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
10841 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x8
10842 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10843 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
10844 ; GFX940-NOTTGSPLIT-NEXT: flat_load_dword v2, v[0:1]
10845 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
10846 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10847 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
10848 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
10850 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_load:
10851 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
10852 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
10853 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
10854 ; GFX940-TGSPLIT-NEXT: s_nop 0
10855 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x8
10856 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10857 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
10858 ; GFX940-TGSPLIT-NEXT: flat_load_dword v2, v[0:1]
10859 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
10860 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10861 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
10862 ; GFX940-TGSPLIT-NEXT: s_endpgm
10864 ; GFX11-WGP-LABEL: flat_singlethread_one_as_seq_cst_load:
10865 ; GFX11-WGP: ; %bb.0: ; %entry
10866 ; GFX11-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
10867 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
10868 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
10869 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10870 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
10871 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
10872 ; GFX11-WGP-NEXT: flat_load_b32 v2, v[0:1]
10873 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
10874 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
10875 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10876 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
10877 ; GFX11-WGP-NEXT: s_endpgm
10879 ; GFX11-CU-LABEL: flat_singlethread_one_as_seq_cst_load:
10880 ; GFX11-CU: ; %bb.0: ; %entry
10881 ; GFX11-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
10882 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
10883 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
10884 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
10885 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
10886 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
10887 ; GFX11-CU-NEXT: flat_load_b32 v2, v[0:1]
10888 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
10889 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
10890 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10891 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
10892 ; GFX11-CU-NEXT: s_endpgm
10894 ; GFX12-WGP-LABEL: flat_singlethread_one_as_seq_cst_load:
10895 ; GFX12-WGP: ; %bb.0: ; %entry
10896 ; GFX12-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
10897 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
10898 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
10899 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
10900 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
10901 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
10902 ; GFX12-WGP-NEXT: flat_load_b32 v2, v[0:1]
10903 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
10904 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
10905 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
10906 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
10907 ; GFX12-WGP-NEXT: s_endpgm
10909 ; GFX12-CU-LABEL: flat_singlethread_one_as_seq_cst_load:
10910 ; GFX12-CU: ; %bb.0: ; %entry
10911 ; GFX12-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
10912 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
10913 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[0:1], 0x8
10914 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
10915 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
10916 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
10917 ; GFX12-CU-NEXT: flat_load_b32 v2, v[0:1]
10918 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
10919 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
10920 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
10921 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
10922 ; GFX12-CU-NEXT: s_endpgm
10923 ptr %in, ptr %out) {
10925 %val = load atomic i32, ptr %in syncscope("singlethread-one-as") seq_cst, align 4
10926 store i32 %val, ptr %out
10930 define amdgpu_kernel void @flat_singlethread_one_as_unordered_store(
10931 ; GFX7-LABEL: flat_singlethread_one_as_unordered_store:
10932 ; GFX7: ; %bb.0: ; %entry
10933 ; GFX7-NEXT: s_load_dword s4, s[6:7], 0x0
10934 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x2
10935 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
10936 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
10937 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
10938 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
10939 ; GFX7-NEXT: flat_store_dword v[0:1], v2
10940 ; GFX7-NEXT: s_endpgm
10942 ; GFX10-WGP-LABEL: flat_singlethread_one_as_unordered_store:
10943 ; GFX10-WGP: ; %bb.0: ; %entry
10944 ; GFX10-WGP-NEXT: s_load_dword s4, s[6:7], 0x0
10945 ; GFX10-WGP-NEXT: s_nop 0
10946 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
10947 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
10948 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
10949 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
10950 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s4
10951 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
10952 ; GFX10-WGP-NEXT: s_endpgm
10954 ; GFX10-CU-LABEL: flat_singlethread_one_as_unordered_store:
10955 ; GFX10-CU: ; %bb.0: ; %entry
10956 ; GFX10-CU-NEXT: s_load_dword s4, s[6:7], 0x0
10957 ; GFX10-CU-NEXT: s_nop 0
10958 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
10959 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
10960 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
10961 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
10962 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s4
10963 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
10964 ; GFX10-CU-NEXT: s_endpgm
10966 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_unordered_store:
10967 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
10968 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[2:3], 0x0
10969 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[2:3], 0x2
10970 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
10971 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
10972 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
10973 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
10974 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
10975 ; SKIP-CACHE-INV-NEXT: s_endpgm
10977 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_unordered_store:
10978 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
10979 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s4, s[6:7], 0x0
10980 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
10981 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
10982 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10983 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
10984 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
10985 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
10986 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
10988 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_unordered_store:
10989 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
10990 ; GFX90A-TGSPLIT-NEXT: s_load_dword s4, s[6:7], 0x0
10991 ; GFX90A-TGSPLIT-NEXT: s_nop 0
10992 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
10993 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10994 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
10995 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
10996 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
10997 ; GFX90A-TGSPLIT-NEXT: s_endpgm
10999 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_unordered_store:
11000 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
11001 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s0, s[2:3], 0x0
11002 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
11003 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[2:3], 0x8
11004 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11005 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
11006 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s0
11007 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
11008 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
11010 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_unordered_store:
11011 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
11012 ; GFX940-TGSPLIT-NEXT: s_load_dword s0, s[2:3], 0x0
11013 ; GFX940-TGSPLIT-NEXT: s_nop 0
11014 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[2:3], 0x8
11015 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11016 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
11017 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s0
11018 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
11019 ; GFX940-TGSPLIT-NEXT: s_endpgm
11021 ; GFX11-WGP-LABEL: flat_singlethread_one_as_unordered_store:
11022 ; GFX11-WGP: ; %bb.0: ; %entry
11023 ; GFX11-WGP-NEXT: s_load_b32 s0, s[2:3], 0x0
11024 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
11025 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11026 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
11027 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
11028 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
11029 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
11030 ; GFX11-WGP-NEXT: s_endpgm
11032 ; GFX11-CU-LABEL: flat_singlethread_one_as_unordered_store:
11033 ; GFX11-CU: ; %bb.0: ; %entry
11034 ; GFX11-CU-NEXT: s_load_b32 s0, s[2:3], 0x0
11035 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
11036 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
11037 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
11038 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
11039 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
11040 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
11041 ; GFX11-CU-NEXT: s_endpgm
11043 ; GFX12-WGP-LABEL: flat_singlethread_one_as_unordered_store:
11044 ; GFX12-WGP: ; %bb.0: ; %entry
11045 ; GFX12-WGP-NEXT: s_load_b32 s0, s[2:3], 0x0
11046 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
11047 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
11048 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
11049 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
11050 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s0
11051 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
11052 ; GFX12-WGP-NEXT: s_endpgm
11054 ; GFX12-CU-LABEL: flat_singlethread_one_as_unordered_store:
11055 ; GFX12-CU: ; %bb.0: ; %entry
11056 ; GFX12-CU-NEXT: s_load_b32 s0, s[2:3], 0x0
11057 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
11058 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
11059 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
11060 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
11061 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s0
11062 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
11063 ; GFX12-CU-NEXT: s_endpgm
11064 i32 %in, ptr %out) {
11066 store atomic i32 %in, ptr %out syncscope("singlethread-one-as") unordered, align 4
11070 define amdgpu_kernel void @flat_singlethread_one_as_monotonic_store(
11071 ; GFX7-LABEL: flat_singlethread_one_as_monotonic_store:
11072 ; GFX7: ; %bb.0: ; %entry
11073 ; GFX7-NEXT: s_load_dword s4, s[6:7], 0x0
11074 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x2
11075 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
11076 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
11077 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
11078 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
11079 ; GFX7-NEXT: flat_store_dword v[0:1], v2
11080 ; GFX7-NEXT: s_endpgm
11082 ; GFX10-WGP-LABEL: flat_singlethread_one_as_monotonic_store:
11083 ; GFX10-WGP: ; %bb.0: ; %entry
11084 ; GFX10-WGP-NEXT: s_load_dword s4, s[6:7], 0x0
11085 ; GFX10-WGP-NEXT: s_nop 0
11086 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
11087 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11088 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
11089 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
11090 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s4
11091 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
11092 ; GFX10-WGP-NEXT: s_endpgm
11094 ; GFX10-CU-LABEL: flat_singlethread_one_as_monotonic_store:
11095 ; GFX10-CU: ; %bb.0: ; %entry
11096 ; GFX10-CU-NEXT: s_load_dword s4, s[6:7], 0x0
11097 ; GFX10-CU-NEXT: s_nop 0
11098 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
11099 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
11100 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
11101 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
11102 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s4
11103 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
11104 ; GFX10-CU-NEXT: s_endpgm
11106 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_monotonic_store:
11107 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
11108 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[2:3], 0x0
11109 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[2:3], 0x2
11110 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
11111 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
11112 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
11113 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
11114 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
11115 ; SKIP-CACHE-INV-NEXT: s_endpgm
11117 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_monotonic_store:
11118 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
11119 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s4, s[6:7], 0x0
11120 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
11121 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
11122 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11123 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
11124 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
11125 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
11126 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
11128 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_monotonic_store:
11129 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
11130 ; GFX90A-TGSPLIT-NEXT: s_load_dword s4, s[6:7], 0x0
11131 ; GFX90A-TGSPLIT-NEXT: s_nop 0
11132 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
11133 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11134 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
11135 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
11136 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
11137 ; GFX90A-TGSPLIT-NEXT: s_endpgm
11139 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_monotonic_store:
11140 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
11141 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s0, s[2:3], 0x0
11142 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
11143 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[2:3], 0x8
11144 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11145 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
11146 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s0
11147 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
11148 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
11150 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_monotonic_store:
11151 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
11152 ; GFX940-TGSPLIT-NEXT: s_load_dword s0, s[2:3], 0x0
11153 ; GFX940-TGSPLIT-NEXT: s_nop 0
11154 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[2:3], 0x8
11155 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11156 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
11157 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s0
11158 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
11159 ; GFX940-TGSPLIT-NEXT: s_endpgm
11161 ; GFX11-WGP-LABEL: flat_singlethread_one_as_monotonic_store:
11162 ; GFX11-WGP: ; %bb.0: ; %entry
11163 ; GFX11-WGP-NEXT: s_load_b32 s0, s[2:3], 0x0
11164 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
11165 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11166 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
11167 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
11168 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
11169 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
11170 ; GFX11-WGP-NEXT: s_endpgm
11172 ; GFX11-CU-LABEL: flat_singlethread_one_as_monotonic_store:
11173 ; GFX11-CU: ; %bb.0: ; %entry
11174 ; GFX11-CU-NEXT: s_load_b32 s0, s[2:3], 0x0
11175 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
11176 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
11177 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
11178 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
11179 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
11180 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
11181 ; GFX11-CU-NEXT: s_endpgm
11183 ; GFX12-WGP-LABEL: flat_singlethread_one_as_monotonic_store:
11184 ; GFX12-WGP: ; %bb.0: ; %entry
11185 ; GFX12-WGP-NEXT: s_load_b32 s0, s[2:3], 0x0
11186 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
11187 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
11188 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
11189 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
11190 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s0
11191 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
11192 ; GFX12-WGP-NEXT: s_endpgm
11194 ; GFX12-CU-LABEL: flat_singlethread_one_as_monotonic_store:
11195 ; GFX12-CU: ; %bb.0: ; %entry
11196 ; GFX12-CU-NEXT: s_load_b32 s0, s[2:3], 0x0
11197 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
11198 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
11199 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
11200 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
11201 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s0
11202 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
11203 ; GFX12-CU-NEXT: s_endpgm
11204 i32 %in, ptr %out) {
11206 store atomic i32 %in, ptr %out syncscope("singlethread-one-as") monotonic, align 4
11210 define amdgpu_kernel void @flat_singlethread_one_as_release_store(
11211 ; GFX7-LABEL: flat_singlethread_one_as_release_store:
11212 ; GFX7: ; %bb.0: ; %entry
11213 ; GFX7-NEXT: s_load_dword s4, s[6:7], 0x0
11214 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x2
11215 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
11216 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
11217 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
11218 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
11219 ; GFX7-NEXT: flat_store_dword v[0:1], v2
11220 ; GFX7-NEXT: s_endpgm
11222 ; GFX10-WGP-LABEL: flat_singlethread_one_as_release_store:
11223 ; GFX10-WGP: ; %bb.0: ; %entry
11224 ; GFX10-WGP-NEXT: s_load_dword s4, s[6:7], 0x0
11225 ; GFX10-WGP-NEXT: s_nop 0
11226 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
11227 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11228 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
11229 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
11230 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s4
11231 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
11232 ; GFX10-WGP-NEXT: s_endpgm
11234 ; GFX10-CU-LABEL: flat_singlethread_one_as_release_store:
11235 ; GFX10-CU: ; %bb.0: ; %entry
11236 ; GFX10-CU-NEXT: s_load_dword s4, s[6:7], 0x0
11237 ; GFX10-CU-NEXT: s_nop 0
11238 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
11239 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
11240 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
11241 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
11242 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s4
11243 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
11244 ; GFX10-CU-NEXT: s_endpgm
11246 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_release_store:
11247 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
11248 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[2:3], 0x0
11249 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[2:3], 0x2
11250 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
11251 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
11252 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
11253 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
11254 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
11255 ; SKIP-CACHE-INV-NEXT: s_endpgm
11257 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_release_store:
11258 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
11259 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s4, s[6:7], 0x0
11260 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
11261 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
11262 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11263 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
11264 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
11265 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
11266 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
11268 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_release_store:
11269 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
11270 ; GFX90A-TGSPLIT-NEXT: s_load_dword s4, s[6:7], 0x0
11271 ; GFX90A-TGSPLIT-NEXT: s_nop 0
11272 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
11273 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11274 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
11275 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
11276 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
11277 ; GFX90A-TGSPLIT-NEXT: s_endpgm
11279 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_release_store:
11280 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
11281 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s0, s[2:3], 0x0
11282 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
11283 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[2:3], 0x8
11284 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11285 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
11286 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s0
11287 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
11288 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
11290 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_release_store:
11291 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
11292 ; GFX940-TGSPLIT-NEXT: s_load_dword s0, s[2:3], 0x0
11293 ; GFX940-TGSPLIT-NEXT: s_nop 0
11294 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[2:3], 0x8
11295 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11296 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
11297 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s0
11298 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
11299 ; GFX940-TGSPLIT-NEXT: s_endpgm
11301 ; GFX11-WGP-LABEL: flat_singlethread_one_as_release_store:
11302 ; GFX11-WGP: ; %bb.0: ; %entry
11303 ; GFX11-WGP-NEXT: s_load_b32 s0, s[2:3], 0x0
11304 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
11305 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11306 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
11307 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
11308 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
11309 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
11310 ; GFX11-WGP-NEXT: s_endpgm
11312 ; GFX11-CU-LABEL: flat_singlethread_one_as_release_store:
11313 ; GFX11-CU: ; %bb.0: ; %entry
11314 ; GFX11-CU-NEXT: s_load_b32 s0, s[2:3], 0x0
11315 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
11316 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
11317 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
11318 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
11319 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
11320 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
11321 ; GFX11-CU-NEXT: s_endpgm
11323 ; GFX12-WGP-LABEL: flat_singlethread_one_as_release_store:
11324 ; GFX12-WGP: ; %bb.0: ; %entry
11325 ; GFX12-WGP-NEXT: s_load_b32 s0, s[2:3], 0x0
11326 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
11327 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
11328 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
11329 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
11330 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s0
11331 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
11332 ; GFX12-WGP-NEXT: s_endpgm
11334 ; GFX12-CU-LABEL: flat_singlethread_one_as_release_store:
11335 ; GFX12-CU: ; %bb.0: ; %entry
11336 ; GFX12-CU-NEXT: s_load_b32 s0, s[2:3], 0x0
11337 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
11338 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
11339 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
11340 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
11341 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s0
11342 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
11343 ; GFX12-CU-NEXT: s_endpgm
11344 i32 %in, ptr %out) {
11346 store atomic i32 %in, ptr %out syncscope("singlethread-one-as") release, align 4
11350 define amdgpu_kernel void @flat_singlethread_one_as_seq_cst_store(
11351 ; GFX7-LABEL: flat_singlethread_one_as_seq_cst_store:
11352 ; GFX7: ; %bb.0: ; %entry
11353 ; GFX7-NEXT: s_load_dword s4, s[6:7], 0x0
11354 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x2
11355 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
11356 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
11357 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
11358 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
11359 ; GFX7-NEXT: flat_store_dword v[0:1], v2
11360 ; GFX7-NEXT: s_endpgm
11362 ; GFX10-WGP-LABEL: flat_singlethread_one_as_seq_cst_store:
11363 ; GFX10-WGP: ; %bb.0: ; %entry
11364 ; GFX10-WGP-NEXT: s_load_dword s4, s[6:7], 0x0
11365 ; GFX10-WGP-NEXT: s_nop 0
11366 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
11367 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11368 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
11369 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
11370 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s4
11371 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
11372 ; GFX10-WGP-NEXT: s_endpgm
11374 ; GFX10-CU-LABEL: flat_singlethread_one_as_seq_cst_store:
11375 ; GFX10-CU: ; %bb.0: ; %entry
11376 ; GFX10-CU-NEXT: s_load_dword s4, s[6:7], 0x0
11377 ; GFX10-CU-NEXT: s_nop 0
11378 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
11379 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
11380 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
11381 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
11382 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s4
11383 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
11384 ; GFX10-CU-NEXT: s_endpgm
11386 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_seq_cst_store:
11387 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
11388 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[2:3], 0x0
11389 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[2:3], 0x2
11390 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
11391 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
11392 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
11393 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
11394 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
11395 ; SKIP-CACHE-INV-NEXT: s_endpgm
11397 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_store:
11398 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
11399 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s4, s[6:7], 0x0
11400 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
11401 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
11402 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11403 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
11404 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
11405 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
11406 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
11408 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_store:
11409 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
11410 ; GFX90A-TGSPLIT-NEXT: s_load_dword s4, s[6:7], 0x0
11411 ; GFX90A-TGSPLIT-NEXT: s_nop 0
11412 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[6:7], 0x8
11413 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11414 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
11415 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
11416 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
11417 ; GFX90A-TGSPLIT-NEXT: s_endpgm
11419 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_store:
11420 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
11421 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s0, s[2:3], 0x0
11422 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
11423 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[2:3], 0x8
11424 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11425 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
11426 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s0
11427 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
11428 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
11430 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_store:
11431 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
11432 ; GFX940-TGSPLIT-NEXT: s_load_dword s0, s[2:3], 0x0
11433 ; GFX940-TGSPLIT-NEXT: s_nop 0
11434 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[2:3], 0x8
11435 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11436 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
11437 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s0
11438 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
11439 ; GFX940-TGSPLIT-NEXT: s_endpgm
11441 ; GFX11-WGP-LABEL: flat_singlethread_one_as_seq_cst_store:
11442 ; GFX11-WGP: ; %bb.0: ; %entry
11443 ; GFX11-WGP-NEXT: s_load_b32 s0, s[2:3], 0x0
11444 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
11445 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11446 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
11447 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
11448 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
11449 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
11450 ; GFX11-WGP-NEXT: s_endpgm
11452 ; GFX11-CU-LABEL: flat_singlethread_one_as_seq_cst_store:
11453 ; GFX11-CU: ; %bb.0: ; %entry
11454 ; GFX11-CU-NEXT: s_load_b32 s0, s[2:3], 0x0
11455 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
11456 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
11457 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
11458 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
11459 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
11460 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
11461 ; GFX11-CU-NEXT: s_endpgm
11463 ; GFX12-WGP-LABEL: flat_singlethread_one_as_seq_cst_store:
11464 ; GFX12-WGP: ; %bb.0: ; %entry
11465 ; GFX12-WGP-NEXT: s_load_b32 s0, s[2:3], 0x0
11466 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
11467 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
11468 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
11469 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
11470 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s0
11471 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
11472 ; GFX12-WGP-NEXT: s_endpgm
11474 ; GFX12-CU-LABEL: flat_singlethread_one_as_seq_cst_store:
11475 ; GFX12-CU: ; %bb.0: ; %entry
11476 ; GFX12-CU-NEXT: s_load_b32 s0, s[2:3], 0x0
11477 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[2:3], 0x8
11478 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
11479 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
11480 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
11481 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s0
11482 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
11483 ; GFX12-CU-NEXT: s_endpgm
11484 i32 %in, ptr %out) {
11486 store atomic i32 %in, ptr %out syncscope("singlethread-one-as") seq_cst, align 4
11490 define amdgpu_kernel void @flat_singlethread_one_as_monotonic_atomicrmw(
11491 ; GFX7-LABEL: flat_singlethread_one_as_monotonic_atomicrmw:
11492 ; GFX7: ; %bb.0: ; %entry
11493 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
11494 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
11495 ; GFX7-NEXT: s_load_dword s4, s[4:5], 0x2
11496 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
11497 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
11498 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
11499 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
11500 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
11501 ; GFX7-NEXT: s_endpgm
11503 ; GFX10-WGP-LABEL: flat_singlethread_one_as_monotonic_atomicrmw:
11504 ; GFX10-WGP: ; %bb.0: ; %entry
11505 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
11506 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
11507 ; GFX10-WGP-NEXT: s_nop 0
11508 ; GFX10-WGP-NEXT: s_load_dword s4, s[4:5], 0x8
11509 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11510 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
11511 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
11512 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s4
11513 ; GFX10-WGP-NEXT: flat_atomic_swap v[0:1], v2
11514 ; GFX10-WGP-NEXT: s_endpgm
11516 ; GFX10-CU-LABEL: flat_singlethread_one_as_monotonic_atomicrmw:
11517 ; GFX10-CU: ; %bb.0: ; %entry
11518 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
11519 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
11520 ; GFX10-CU-NEXT: s_nop 0
11521 ; GFX10-CU-NEXT: s_load_dword s4, s[4:5], 0x8
11522 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
11523 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
11524 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
11525 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s4
11526 ; GFX10-CU-NEXT: flat_atomic_swap v[0:1], v2
11527 ; GFX10-CU-NEXT: s_endpgm
11529 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_monotonic_atomicrmw:
11530 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
11531 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
11532 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
11533 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x2
11534 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
11535 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
11536 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
11537 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
11538 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v[0:1], v2
11539 ; SKIP-CACHE-INV-NEXT: s_endpgm
11541 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_monotonic_atomicrmw:
11542 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
11543 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
11544 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
11545 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
11546 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s4, s[4:5], 0x8
11547 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11548 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
11549 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
11550 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
11551 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
11553 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_monotonic_atomicrmw:
11554 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
11555 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
11556 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
11557 ; GFX90A-TGSPLIT-NEXT: s_nop 0
11558 ; GFX90A-TGSPLIT-NEXT: s_load_dword s4, s[4:5], 0x8
11559 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11560 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
11561 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
11562 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
11563 ; GFX90A-TGSPLIT-NEXT: s_endpgm
11565 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_monotonic_atomicrmw:
11566 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
11567 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
11568 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
11569 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
11570 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s0, s[0:1], 0x8
11571 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11572 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
11573 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s0
11574 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
11575 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
11577 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_monotonic_atomicrmw:
11578 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
11579 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
11580 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
11581 ; GFX940-TGSPLIT-NEXT: s_nop 0
11582 ; GFX940-TGSPLIT-NEXT: s_load_dword s0, s[0:1], 0x8
11583 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11584 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
11585 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s0
11586 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
11587 ; GFX940-TGSPLIT-NEXT: s_endpgm
11589 ; GFX11-WGP-LABEL: flat_singlethread_one_as_monotonic_atomicrmw:
11590 ; GFX11-WGP: ; %bb.0: ; %entry
11591 ; GFX11-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
11592 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
11593 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
11594 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11595 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
11596 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
11597 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
11598 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
11599 ; GFX11-WGP-NEXT: s_endpgm
11601 ; GFX11-CU-LABEL: flat_singlethread_one_as_monotonic_atomicrmw:
11602 ; GFX11-CU: ; %bb.0: ; %entry
11603 ; GFX11-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
11604 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
11605 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
11606 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
11607 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
11608 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
11609 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
11610 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
11611 ; GFX11-CU-NEXT: s_endpgm
11613 ; GFX12-WGP-LABEL: flat_singlethread_one_as_monotonic_atomicrmw:
11614 ; GFX12-WGP: ; %bb.0: ; %entry
11615 ; GFX12-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
11616 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
11617 ; GFX12-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
11618 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
11619 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
11620 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
11621 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s0
11622 ; GFX12-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
11623 ; GFX12-WGP-NEXT: s_endpgm
11625 ; GFX12-CU-LABEL: flat_singlethread_one_as_monotonic_atomicrmw:
11626 ; GFX12-CU: ; %bb.0: ; %entry
11627 ; GFX12-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
11628 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
11629 ; GFX12-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
11630 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
11631 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
11632 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
11633 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s0
11634 ; GFX12-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
11635 ; GFX12-CU-NEXT: s_endpgm
11636 ptr %out, i32 %in) {
11638 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("singlethread-one-as") monotonic
11642 define amdgpu_kernel void @flat_singlethread_one_as_acquire_atomicrmw(
11643 ; GFX7-LABEL: flat_singlethread_one_as_acquire_atomicrmw:
11644 ; GFX7: ; %bb.0: ; %entry
11645 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
11646 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
11647 ; GFX7-NEXT: s_load_dword s4, s[4:5], 0x2
11648 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
11649 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
11650 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
11651 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
11652 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
11653 ; GFX7-NEXT: s_endpgm
11655 ; GFX10-WGP-LABEL: flat_singlethread_one_as_acquire_atomicrmw:
11656 ; GFX10-WGP: ; %bb.0: ; %entry
11657 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
11658 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
11659 ; GFX10-WGP-NEXT: s_nop 0
11660 ; GFX10-WGP-NEXT: s_load_dword s4, s[4:5], 0x8
11661 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11662 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
11663 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
11664 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s4
11665 ; GFX10-WGP-NEXT: flat_atomic_swap v[0:1], v2
11666 ; GFX10-WGP-NEXT: s_endpgm
11668 ; GFX10-CU-LABEL: flat_singlethread_one_as_acquire_atomicrmw:
11669 ; GFX10-CU: ; %bb.0: ; %entry
11670 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
11671 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
11672 ; GFX10-CU-NEXT: s_nop 0
11673 ; GFX10-CU-NEXT: s_load_dword s4, s[4:5], 0x8
11674 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
11675 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
11676 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
11677 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s4
11678 ; GFX10-CU-NEXT: flat_atomic_swap v[0:1], v2
11679 ; GFX10-CU-NEXT: s_endpgm
11681 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_acquire_atomicrmw:
11682 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
11683 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
11684 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
11685 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x2
11686 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
11687 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
11688 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
11689 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
11690 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v[0:1], v2
11691 ; SKIP-CACHE-INV-NEXT: s_endpgm
11693 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acquire_atomicrmw:
11694 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
11695 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
11696 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
11697 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
11698 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s4, s[4:5], 0x8
11699 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11700 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
11701 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
11702 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
11703 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
11705 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_acquire_atomicrmw:
11706 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
11707 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
11708 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
11709 ; GFX90A-TGSPLIT-NEXT: s_nop 0
11710 ; GFX90A-TGSPLIT-NEXT: s_load_dword s4, s[4:5], 0x8
11711 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11712 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
11713 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
11714 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
11715 ; GFX90A-TGSPLIT-NEXT: s_endpgm
11717 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acquire_atomicrmw:
11718 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
11719 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
11720 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
11721 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
11722 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s0, s[0:1], 0x8
11723 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11724 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
11725 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s0
11726 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
11727 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
11729 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_acquire_atomicrmw:
11730 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
11731 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
11732 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
11733 ; GFX940-TGSPLIT-NEXT: s_nop 0
11734 ; GFX940-TGSPLIT-NEXT: s_load_dword s0, s[0:1], 0x8
11735 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11736 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
11737 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s0
11738 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
11739 ; GFX940-TGSPLIT-NEXT: s_endpgm
11741 ; GFX11-WGP-LABEL: flat_singlethread_one_as_acquire_atomicrmw:
11742 ; GFX11-WGP: ; %bb.0: ; %entry
11743 ; GFX11-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
11744 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
11745 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
11746 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11747 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
11748 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
11749 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
11750 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
11751 ; GFX11-WGP-NEXT: s_endpgm
11753 ; GFX11-CU-LABEL: flat_singlethread_one_as_acquire_atomicrmw:
11754 ; GFX11-CU: ; %bb.0: ; %entry
11755 ; GFX11-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
11756 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
11757 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
11758 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
11759 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
11760 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
11761 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
11762 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
11763 ; GFX11-CU-NEXT: s_endpgm
11765 ; GFX12-WGP-LABEL: flat_singlethread_one_as_acquire_atomicrmw:
11766 ; GFX12-WGP: ; %bb.0: ; %entry
11767 ; GFX12-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
11768 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
11769 ; GFX12-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
11770 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
11771 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
11772 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
11773 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s0
11774 ; GFX12-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
11775 ; GFX12-WGP-NEXT: s_endpgm
11777 ; GFX12-CU-LABEL: flat_singlethread_one_as_acquire_atomicrmw:
11778 ; GFX12-CU: ; %bb.0: ; %entry
11779 ; GFX12-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
11780 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
11781 ; GFX12-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
11782 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
11783 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
11784 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
11785 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s0
11786 ; GFX12-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
11787 ; GFX12-CU-NEXT: s_endpgm
11788 ptr %out, i32 %in) {
11790 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("singlethread-one-as") acquire
11794 define amdgpu_kernel void @flat_singlethread_one_as_release_atomicrmw(
11795 ; GFX7-LABEL: flat_singlethread_one_as_release_atomicrmw:
11796 ; GFX7: ; %bb.0: ; %entry
11797 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
11798 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
11799 ; GFX7-NEXT: s_load_dword s4, s[4:5], 0x2
11800 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
11801 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
11802 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
11803 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
11804 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
11805 ; GFX7-NEXT: s_endpgm
11807 ; GFX10-WGP-LABEL: flat_singlethread_one_as_release_atomicrmw:
11808 ; GFX10-WGP: ; %bb.0: ; %entry
11809 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
11810 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
11811 ; GFX10-WGP-NEXT: s_nop 0
11812 ; GFX10-WGP-NEXT: s_load_dword s4, s[4:5], 0x8
11813 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11814 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
11815 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
11816 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s4
11817 ; GFX10-WGP-NEXT: flat_atomic_swap v[0:1], v2
11818 ; GFX10-WGP-NEXT: s_endpgm
11820 ; GFX10-CU-LABEL: flat_singlethread_one_as_release_atomicrmw:
11821 ; GFX10-CU: ; %bb.0: ; %entry
11822 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
11823 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
11824 ; GFX10-CU-NEXT: s_nop 0
11825 ; GFX10-CU-NEXT: s_load_dword s4, s[4:5], 0x8
11826 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
11827 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
11828 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
11829 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s4
11830 ; GFX10-CU-NEXT: flat_atomic_swap v[0:1], v2
11831 ; GFX10-CU-NEXT: s_endpgm
11833 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_release_atomicrmw:
11834 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
11835 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
11836 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
11837 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x2
11838 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
11839 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
11840 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
11841 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
11842 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v[0:1], v2
11843 ; SKIP-CACHE-INV-NEXT: s_endpgm
11845 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_release_atomicrmw:
11846 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
11847 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
11848 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
11849 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
11850 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s4, s[4:5], 0x8
11851 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11852 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
11853 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
11854 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
11855 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
11857 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_release_atomicrmw:
11858 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
11859 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
11860 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
11861 ; GFX90A-TGSPLIT-NEXT: s_nop 0
11862 ; GFX90A-TGSPLIT-NEXT: s_load_dword s4, s[4:5], 0x8
11863 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11864 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
11865 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
11866 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
11867 ; GFX90A-TGSPLIT-NEXT: s_endpgm
11869 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_release_atomicrmw:
11870 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
11871 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
11872 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
11873 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
11874 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s0, s[0:1], 0x8
11875 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11876 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
11877 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s0
11878 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
11879 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
11881 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_release_atomicrmw:
11882 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
11883 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
11884 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
11885 ; GFX940-TGSPLIT-NEXT: s_nop 0
11886 ; GFX940-TGSPLIT-NEXT: s_load_dword s0, s[0:1], 0x8
11887 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11888 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
11889 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s0
11890 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
11891 ; GFX940-TGSPLIT-NEXT: s_endpgm
11893 ; GFX11-WGP-LABEL: flat_singlethread_one_as_release_atomicrmw:
11894 ; GFX11-WGP: ; %bb.0: ; %entry
11895 ; GFX11-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
11896 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
11897 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
11898 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11899 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
11900 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
11901 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
11902 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
11903 ; GFX11-WGP-NEXT: s_endpgm
11905 ; GFX11-CU-LABEL: flat_singlethread_one_as_release_atomicrmw:
11906 ; GFX11-CU: ; %bb.0: ; %entry
11907 ; GFX11-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
11908 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
11909 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
11910 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
11911 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
11912 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
11913 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
11914 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
11915 ; GFX11-CU-NEXT: s_endpgm
11917 ; GFX12-WGP-LABEL: flat_singlethread_one_as_release_atomicrmw:
11918 ; GFX12-WGP: ; %bb.0: ; %entry
11919 ; GFX12-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
11920 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
11921 ; GFX12-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
11922 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
11923 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
11924 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
11925 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s0
11926 ; GFX12-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
11927 ; GFX12-WGP-NEXT: s_endpgm
11929 ; GFX12-CU-LABEL: flat_singlethread_one_as_release_atomicrmw:
11930 ; GFX12-CU: ; %bb.0: ; %entry
11931 ; GFX12-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
11932 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
11933 ; GFX12-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
11934 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
11935 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
11936 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
11937 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s0
11938 ; GFX12-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
11939 ; GFX12-CU-NEXT: s_endpgm
11940 ptr %out, i32 %in) {
11942 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("singlethread-one-as") release
11946 define amdgpu_kernel void @flat_singlethread_one_as_acq_rel_atomicrmw(
11947 ; GFX7-LABEL: flat_singlethread_one_as_acq_rel_atomicrmw:
11948 ; GFX7: ; %bb.0: ; %entry
11949 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
11950 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
11951 ; GFX7-NEXT: s_load_dword s4, s[4:5], 0x2
11952 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
11953 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
11954 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
11955 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
11956 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
11957 ; GFX7-NEXT: s_endpgm
11959 ; GFX10-WGP-LABEL: flat_singlethread_one_as_acq_rel_atomicrmw:
11960 ; GFX10-WGP: ; %bb.0: ; %entry
11961 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
11962 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
11963 ; GFX10-WGP-NEXT: s_nop 0
11964 ; GFX10-WGP-NEXT: s_load_dword s4, s[4:5], 0x8
11965 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11966 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
11967 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
11968 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s4
11969 ; GFX10-WGP-NEXT: flat_atomic_swap v[0:1], v2
11970 ; GFX10-WGP-NEXT: s_endpgm
11972 ; GFX10-CU-LABEL: flat_singlethread_one_as_acq_rel_atomicrmw:
11973 ; GFX10-CU: ; %bb.0: ; %entry
11974 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
11975 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
11976 ; GFX10-CU-NEXT: s_nop 0
11977 ; GFX10-CU-NEXT: s_load_dword s4, s[4:5], 0x8
11978 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
11979 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
11980 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
11981 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s4
11982 ; GFX10-CU-NEXT: flat_atomic_swap v[0:1], v2
11983 ; GFX10-CU-NEXT: s_endpgm
11985 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_acq_rel_atomicrmw:
11986 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
11987 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
11988 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
11989 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x2
11990 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
11991 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
11992 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
11993 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
11994 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v[0:1], v2
11995 ; SKIP-CACHE-INV-NEXT: s_endpgm
11997 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_atomicrmw:
11998 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
11999 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
12000 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
12001 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
12002 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s4, s[4:5], 0x8
12003 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12004 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
12005 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
12006 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
12007 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
12009 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_atomicrmw:
12010 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
12011 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
12012 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
12013 ; GFX90A-TGSPLIT-NEXT: s_nop 0
12014 ; GFX90A-TGSPLIT-NEXT: s_load_dword s4, s[4:5], 0x8
12015 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12016 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
12017 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
12018 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
12019 ; GFX90A-TGSPLIT-NEXT: s_endpgm
12021 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_atomicrmw:
12022 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
12023 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
12024 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
12025 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
12026 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s0, s[0:1], 0x8
12027 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12028 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
12029 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s0
12030 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
12031 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
12033 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_atomicrmw:
12034 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
12035 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
12036 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
12037 ; GFX940-TGSPLIT-NEXT: s_nop 0
12038 ; GFX940-TGSPLIT-NEXT: s_load_dword s0, s[0:1], 0x8
12039 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12040 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
12041 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s0
12042 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
12043 ; GFX940-TGSPLIT-NEXT: s_endpgm
12045 ; GFX11-WGP-LABEL: flat_singlethread_one_as_acq_rel_atomicrmw:
12046 ; GFX11-WGP: ; %bb.0: ; %entry
12047 ; GFX11-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
12048 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
12049 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
12050 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
12051 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
12052 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
12053 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
12054 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
12055 ; GFX11-WGP-NEXT: s_endpgm
12057 ; GFX11-CU-LABEL: flat_singlethread_one_as_acq_rel_atomicrmw:
12058 ; GFX11-CU: ; %bb.0: ; %entry
12059 ; GFX11-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
12060 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
12061 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
12062 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
12063 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
12064 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
12065 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
12066 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
12067 ; GFX11-CU-NEXT: s_endpgm
12069 ; GFX12-WGP-LABEL: flat_singlethread_one_as_acq_rel_atomicrmw:
12070 ; GFX12-WGP: ; %bb.0: ; %entry
12071 ; GFX12-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
12072 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
12073 ; GFX12-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
12074 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
12075 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
12076 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
12077 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s0
12078 ; GFX12-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
12079 ; GFX12-WGP-NEXT: s_endpgm
12081 ; GFX12-CU-LABEL: flat_singlethread_one_as_acq_rel_atomicrmw:
12082 ; GFX12-CU: ; %bb.0: ; %entry
12083 ; GFX12-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
12084 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
12085 ; GFX12-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
12086 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
12087 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
12088 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
12089 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s0
12090 ; GFX12-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
12091 ; GFX12-CU-NEXT: s_endpgm
12092 ptr %out, i32 %in) {
12094 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("singlethread-one-as") acq_rel
12098 define amdgpu_kernel void @flat_singlethread_one_as_seq_cst_atomicrmw(
12099 ; GFX7-LABEL: flat_singlethread_one_as_seq_cst_atomicrmw:
12100 ; GFX7: ; %bb.0: ; %entry
12101 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
12102 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
12103 ; GFX7-NEXT: s_load_dword s4, s[4:5], 0x2
12104 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
12105 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
12106 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
12107 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
12108 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
12109 ; GFX7-NEXT: s_endpgm
12111 ; GFX10-WGP-LABEL: flat_singlethread_one_as_seq_cst_atomicrmw:
12112 ; GFX10-WGP: ; %bb.0: ; %entry
12113 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
12114 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
12115 ; GFX10-WGP-NEXT: s_nop 0
12116 ; GFX10-WGP-NEXT: s_load_dword s4, s[4:5], 0x8
12117 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
12118 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
12119 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
12120 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s4
12121 ; GFX10-WGP-NEXT: flat_atomic_swap v[0:1], v2
12122 ; GFX10-WGP-NEXT: s_endpgm
12124 ; GFX10-CU-LABEL: flat_singlethread_one_as_seq_cst_atomicrmw:
12125 ; GFX10-CU: ; %bb.0: ; %entry
12126 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
12127 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
12128 ; GFX10-CU-NEXT: s_nop 0
12129 ; GFX10-CU-NEXT: s_load_dword s4, s[4:5], 0x8
12130 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
12131 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
12132 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
12133 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s4
12134 ; GFX10-CU-NEXT: flat_atomic_swap v[0:1], v2
12135 ; GFX10-CU-NEXT: s_endpgm
12137 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_seq_cst_atomicrmw:
12138 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
12139 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
12140 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
12141 ; SKIP-CACHE-INV-NEXT: s_load_dword s0, s[0:1], 0x2
12142 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
12143 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
12144 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
12145 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s0
12146 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v[0:1], v2
12147 ; SKIP-CACHE-INV-NEXT: s_endpgm
12149 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_atomicrmw:
12150 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
12151 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
12152 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
12153 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
12154 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s4, s[4:5], 0x8
12155 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12156 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
12157 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s4
12158 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
12159 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
12161 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_atomicrmw:
12162 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
12163 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[6:7]
12164 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[4:5], 0x0
12165 ; GFX90A-TGSPLIT-NEXT: s_nop 0
12166 ; GFX90A-TGSPLIT-NEXT: s_load_dword s4, s[4:5], 0x8
12167 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12168 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[6:7], s[6:7] op_sel:[0,1]
12169 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s4
12170 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
12171 ; GFX90A-TGSPLIT-NEXT: s_endpgm
12173 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_atomicrmw:
12174 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
12175 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
12176 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
12177 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
12178 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s0, s[0:1], 0x8
12179 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12180 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
12181 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s0
12182 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
12183 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
12185 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_atomicrmw:
12186 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
12187 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[0:1], s[2:3]
12188 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x0
12189 ; GFX940-TGSPLIT-NEXT: s_nop 0
12190 ; GFX940-TGSPLIT-NEXT: s_load_dword s0, s[0:1], 0x8
12191 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12192 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[2:3]
12193 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s0
12194 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v[0:1], v2
12195 ; GFX940-TGSPLIT-NEXT: s_endpgm
12197 ; GFX11-WGP-LABEL: flat_singlethread_one_as_seq_cst_atomicrmw:
12198 ; GFX11-WGP: ; %bb.0: ; %entry
12199 ; GFX11-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
12200 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
12201 ; GFX11-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
12202 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
12203 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
12204 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
12205 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s0
12206 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
12207 ; GFX11-WGP-NEXT: s_endpgm
12209 ; GFX11-CU-LABEL: flat_singlethread_one_as_seq_cst_atomicrmw:
12210 ; GFX11-CU: ; %bb.0: ; %entry
12211 ; GFX11-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
12212 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
12213 ; GFX11-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
12214 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
12215 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
12216 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
12217 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s0
12218 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
12219 ; GFX11-CU-NEXT: s_endpgm
12221 ; GFX12-WGP-LABEL: flat_singlethread_one_as_seq_cst_atomicrmw:
12222 ; GFX12-WGP: ; %bb.0: ; %entry
12223 ; GFX12-WGP-NEXT: s_mov_b64 s[0:1], s[2:3]
12224 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
12225 ; GFX12-WGP-NEXT: s_load_b32 s0, s[0:1], 0x8
12226 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
12227 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
12228 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
12229 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s0
12230 ; GFX12-WGP-NEXT: flat_atomic_swap_b32 v[0:1], v2
12231 ; GFX12-WGP-NEXT: s_endpgm
12233 ; GFX12-CU-LABEL: flat_singlethread_one_as_seq_cst_atomicrmw:
12234 ; GFX12-CU: ; %bb.0: ; %entry
12235 ; GFX12-CU-NEXT: s_mov_b64 s[0:1], s[2:3]
12236 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[0:1], 0x0
12237 ; GFX12-CU-NEXT: s_load_b32 s0, s[0:1], 0x8
12238 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
12239 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
12240 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
12241 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s0
12242 ; GFX12-CU-NEXT: flat_atomic_swap_b32 v[0:1], v2
12243 ; GFX12-CU-NEXT: s_endpgm
12244 ptr %out, i32 %in) {
12246 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("singlethread-one-as") seq_cst
12250 define amdgpu_kernel void @flat_singlethread_one_as_acquire_ret_atomicrmw(
12251 ; GFX7-LABEL: flat_singlethread_one_as_acquire_ret_atomicrmw:
12252 ; GFX7: ; %bb.0: ; %entry
12253 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
12254 ; GFX7-NEXT: s_load_dword s6, s[6:7], 0x2
12255 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
12256 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
12257 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
12258 ; GFX7-NEXT: v_mov_b32_e32 v2, s6
12259 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
12260 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
12261 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
12262 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12263 ; GFX7-NEXT: flat_store_dword v[0:1], v2
12264 ; GFX7-NEXT: s_endpgm
12266 ; GFX10-WGP-LABEL: flat_singlethread_one_as_acquire_ret_atomicrmw:
12267 ; GFX10-WGP: ; %bb.0: ; %entry
12268 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
12269 ; GFX10-WGP-NEXT: s_nop 0
12270 ; GFX10-WGP-NEXT: s_load_dword s6, s[6:7], 0x8
12271 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
12272 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
12273 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
12274 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s6
12275 ; GFX10-WGP-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
12276 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
12277 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
12278 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12279 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
12280 ; GFX10-WGP-NEXT: s_endpgm
12282 ; GFX10-CU-LABEL: flat_singlethread_one_as_acquire_ret_atomicrmw:
12283 ; GFX10-CU: ; %bb.0: ; %entry
12284 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
12285 ; GFX10-CU-NEXT: s_nop 0
12286 ; GFX10-CU-NEXT: s_load_dword s6, s[6:7], 0x8
12287 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
12288 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
12289 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
12290 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s6
12291 ; GFX10-CU-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
12292 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
12293 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
12294 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12295 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
12296 ; GFX10-CU-NEXT: s_endpgm
12298 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_acquire_ret_atomicrmw:
12299 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
12300 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
12301 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[2:3], 0x2
12302 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
12303 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
12304 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
12305 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
12306 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
12307 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
12308 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
12309 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12310 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
12311 ; SKIP-CACHE-INV-NEXT: s_endpgm
12313 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acquire_ret_atomicrmw:
12314 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
12315 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
12316 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
12317 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[6:7], 0x8
12318 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12319 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
12320 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s6
12321 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
12322 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
12323 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12324 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
12325 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
12327 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_acquire_ret_atomicrmw:
12328 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
12329 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
12330 ; GFX90A-TGSPLIT-NEXT: s_nop 0
12331 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[6:7], 0x8
12332 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12333 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
12334 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s6
12335 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
12336 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
12337 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12338 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
12339 ; GFX90A-TGSPLIT-NEXT: s_endpgm
12341 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acquire_ret_atomicrmw:
12342 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
12343 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
12344 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
12345 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[2:3], 0x8
12346 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12347 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
12348 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
12349 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 sc0
12350 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
12351 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12352 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
12353 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
12355 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_acquire_ret_atomicrmw:
12356 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
12357 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
12358 ; GFX940-TGSPLIT-NEXT: s_nop 0
12359 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[2:3], 0x8
12360 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12361 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
12362 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
12363 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 sc0
12364 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
12365 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12366 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
12367 ; GFX940-TGSPLIT-NEXT: s_endpgm
12369 ; GFX11-WGP-LABEL: flat_singlethread_one_as_acquire_ret_atomicrmw:
12370 ; GFX11-WGP: ; %bb.0: ; %entry
12371 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
12372 ; GFX11-WGP-NEXT: s_load_b32 s2, s[2:3], 0x8
12373 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
12374 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
12375 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
12376 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s2
12377 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 glc
12378 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
12379 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
12380 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12381 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
12382 ; GFX11-WGP-NEXT: s_endpgm
12384 ; GFX11-CU-LABEL: flat_singlethread_one_as_acquire_ret_atomicrmw:
12385 ; GFX11-CU: ; %bb.0: ; %entry
12386 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
12387 ; GFX11-CU-NEXT: s_load_b32 s2, s[2:3], 0x8
12388 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
12389 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
12390 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
12391 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s2
12392 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 glc
12393 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
12394 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
12395 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12396 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
12397 ; GFX11-CU-NEXT: s_endpgm
12399 ; GFX12-WGP-LABEL: flat_singlethread_one_as_acquire_ret_atomicrmw:
12400 ; GFX12-WGP: ; %bb.0: ; %entry
12401 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
12402 ; GFX12-WGP-NEXT: s_load_b32 s2, s[2:3], 0x8
12403 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
12404 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
12405 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
12406 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s2
12407 ; GFX12-WGP-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 th:TH_ATOMIC_RETURN
12408 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
12409 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
12410 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
12411 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
12412 ; GFX12-WGP-NEXT: s_endpgm
12414 ; GFX12-CU-LABEL: flat_singlethread_one_as_acquire_ret_atomicrmw:
12415 ; GFX12-CU: ; %bb.0: ; %entry
12416 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
12417 ; GFX12-CU-NEXT: s_load_b32 s2, s[2:3], 0x8
12418 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
12419 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
12420 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
12421 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s2
12422 ; GFX12-CU-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 th:TH_ATOMIC_RETURN
12423 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
12424 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
12425 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
12426 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
12427 ; GFX12-CU-NEXT: s_endpgm
12428 ptr %out, i32 %in) {
12430 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("singlethread-one-as") acquire
12431 store i32 %val, ptr %out, align 4
12435 define amdgpu_kernel void @flat_singlethread_one_as_acq_rel_ret_atomicrmw(
12436 ; GFX7-LABEL: flat_singlethread_one_as_acq_rel_ret_atomicrmw:
12437 ; GFX7: ; %bb.0: ; %entry
12438 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
12439 ; GFX7-NEXT: s_load_dword s6, s[6:7], 0x2
12440 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
12441 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
12442 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
12443 ; GFX7-NEXT: v_mov_b32_e32 v2, s6
12444 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
12445 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
12446 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
12447 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12448 ; GFX7-NEXT: flat_store_dword v[0:1], v2
12449 ; GFX7-NEXT: s_endpgm
12451 ; GFX10-WGP-LABEL: flat_singlethread_one_as_acq_rel_ret_atomicrmw:
12452 ; GFX10-WGP: ; %bb.0: ; %entry
12453 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
12454 ; GFX10-WGP-NEXT: s_nop 0
12455 ; GFX10-WGP-NEXT: s_load_dword s6, s[6:7], 0x8
12456 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
12457 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
12458 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
12459 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s6
12460 ; GFX10-WGP-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
12461 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
12462 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
12463 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12464 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
12465 ; GFX10-WGP-NEXT: s_endpgm
12467 ; GFX10-CU-LABEL: flat_singlethread_one_as_acq_rel_ret_atomicrmw:
12468 ; GFX10-CU: ; %bb.0: ; %entry
12469 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
12470 ; GFX10-CU-NEXT: s_nop 0
12471 ; GFX10-CU-NEXT: s_load_dword s6, s[6:7], 0x8
12472 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
12473 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
12474 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
12475 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s6
12476 ; GFX10-CU-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
12477 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
12478 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
12479 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12480 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
12481 ; GFX10-CU-NEXT: s_endpgm
12483 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_acq_rel_ret_atomicrmw:
12484 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
12485 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
12486 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[2:3], 0x2
12487 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
12488 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
12489 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
12490 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
12491 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
12492 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
12493 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
12494 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12495 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
12496 ; SKIP-CACHE-INV-NEXT: s_endpgm
12498 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_ret_atomicrmw:
12499 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
12500 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
12501 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
12502 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[6:7], 0x8
12503 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12504 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
12505 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s6
12506 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
12507 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
12508 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12509 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
12510 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
12512 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_ret_atomicrmw:
12513 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
12514 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
12515 ; GFX90A-TGSPLIT-NEXT: s_nop 0
12516 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[6:7], 0x8
12517 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12518 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
12519 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s6
12520 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
12521 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
12522 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12523 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
12524 ; GFX90A-TGSPLIT-NEXT: s_endpgm
12526 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_ret_atomicrmw:
12527 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
12528 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
12529 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
12530 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[2:3], 0x8
12531 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12532 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
12533 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
12534 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 sc0
12535 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
12536 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12537 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
12538 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
12540 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_ret_atomicrmw:
12541 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
12542 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
12543 ; GFX940-TGSPLIT-NEXT: s_nop 0
12544 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[2:3], 0x8
12545 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12546 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
12547 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
12548 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 sc0
12549 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
12550 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12551 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
12552 ; GFX940-TGSPLIT-NEXT: s_endpgm
12554 ; GFX11-WGP-LABEL: flat_singlethread_one_as_acq_rel_ret_atomicrmw:
12555 ; GFX11-WGP: ; %bb.0: ; %entry
12556 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
12557 ; GFX11-WGP-NEXT: s_load_b32 s2, s[2:3], 0x8
12558 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
12559 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
12560 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
12561 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s2
12562 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 glc
12563 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
12564 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
12565 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12566 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
12567 ; GFX11-WGP-NEXT: s_endpgm
12569 ; GFX11-CU-LABEL: flat_singlethread_one_as_acq_rel_ret_atomicrmw:
12570 ; GFX11-CU: ; %bb.0: ; %entry
12571 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
12572 ; GFX11-CU-NEXT: s_load_b32 s2, s[2:3], 0x8
12573 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
12574 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
12575 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
12576 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s2
12577 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 glc
12578 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
12579 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
12580 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12581 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
12582 ; GFX11-CU-NEXT: s_endpgm
12584 ; GFX12-WGP-LABEL: flat_singlethread_one_as_acq_rel_ret_atomicrmw:
12585 ; GFX12-WGP: ; %bb.0: ; %entry
12586 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
12587 ; GFX12-WGP-NEXT: s_load_b32 s2, s[2:3], 0x8
12588 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
12589 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
12590 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
12591 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s2
12592 ; GFX12-WGP-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 th:TH_ATOMIC_RETURN
12593 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
12594 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
12595 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
12596 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
12597 ; GFX12-WGP-NEXT: s_endpgm
12599 ; GFX12-CU-LABEL: flat_singlethread_one_as_acq_rel_ret_atomicrmw:
12600 ; GFX12-CU: ; %bb.0: ; %entry
12601 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
12602 ; GFX12-CU-NEXT: s_load_b32 s2, s[2:3], 0x8
12603 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
12604 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
12605 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
12606 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s2
12607 ; GFX12-CU-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 th:TH_ATOMIC_RETURN
12608 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
12609 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
12610 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
12611 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
12612 ; GFX12-CU-NEXT: s_endpgm
12613 ptr %out, i32 %in) {
12615 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("singlethread-one-as") acq_rel
12616 store i32 %val, ptr %out, align 4
12620 define amdgpu_kernel void @flat_singlethread_one_as_seq_cst_ret_atomicrmw(
12621 ; GFX7-LABEL: flat_singlethread_one_as_seq_cst_ret_atomicrmw:
12622 ; GFX7: ; %bb.0: ; %entry
12623 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
12624 ; GFX7-NEXT: s_load_dword s6, s[6:7], 0x2
12625 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
12626 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
12627 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
12628 ; GFX7-NEXT: v_mov_b32_e32 v2, s6
12629 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
12630 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
12631 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
12632 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12633 ; GFX7-NEXT: flat_store_dword v[0:1], v2
12634 ; GFX7-NEXT: s_endpgm
12636 ; GFX10-WGP-LABEL: flat_singlethread_one_as_seq_cst_ret_atomicrmw:
12637 ; GFX10-WGP: ; %bb.0: ; %entry
12638 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
12639 ; GFX10-WGP-NEXT: s_nop 0
12640 ; GFX10-WGP-NEXT: s_load_dword s6, s[6:7], 0x8
12641 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
12642 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
12643 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
12644 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s6
12645 ; GFX10-WGP-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
12646 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
12647 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
12648 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12649 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
12650 ; GFX10-WGP-NEXT: s_endpgm
12652 ; GFX10-CU-LABEL: flat_singlethread_one_as_seq_cst_ret_atomicrmw:
12653 ; GFX10-CU: ; %bb.0: ; %entry
12654 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
12655 ; GFX10-CU-NEXT: s_nop 0
12656 ; GFX10-CU-NEXT: s_load_dword s6, s[6:7], 0x8
12657 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
12658 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
12659 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
12660 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s6
12661 ; GFX10-CU-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
12662 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
12663 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
12664 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12665 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
12666 ; GFX10-CU-NEXT: s_endpgm
12668 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_seq_cst_ret_atomicrmw:
12669 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
12670 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
12671 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[2:3], 0x2
12672 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
12673 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
12674 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
12675 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s2
12676 ; SKIP-CACHE-INV-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
12677 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
12678 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
12679 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12680 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
12681 ; SKIP-CACHE-INV-NEXT: s_endpgm
12683 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_ret_atomicrmw:
12684 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
12685 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
12686 ; GFX90A-NOTTGSPLIT-NEXT: s_nop 0
12687 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[6:7], 0x8
12688 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12689 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
12690 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s6
12691 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
12692 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
12693 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12694 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
12695 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
12697 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_ret_atomicrmw:
12698 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
12699 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
12700 ; GFX90A-TGSPLIT-NEXT: s_nop 0
12701 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[6:7], 0x8
12702 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12703 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
12704 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s6
12705 ; GFX90A-TGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
12706 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
12707 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12708 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
12709 ; GFX90A-TGSPLIT-NEXT: s_endpgm
12711 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_ret_atomicrmw:
12712 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
12713 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
12714 ; GFX940-NOTTGSPLIT-NEXT: s_nop 0
12715 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[2:3], 0x8
12716 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12717 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
12718 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s2
12719 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 sc0
12720 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
12721 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12722 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
12723 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
12725 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_ret_atomicrmw:
12726 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
12727 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
12728 ; GFX940-TGSPLIT-NEXT: s_nop 0
12729 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[2:3], 0x8
12730 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12731 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
12732 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s2
12733 ; GFX940-TGSPLIT-NEXT: flat_atomic_swap v2, v[0:1], v2 sc0
12734 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
12735 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12736 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
12737 ; GFX940-TGSPLIT-NEXT: s_endpgm
12739 ; GFX11-WGP-LABEL: flat_singlethread_one_as_seq_cst_ret_atomicrmw:
12740 ; GFX11-WGP: ; %bb.0: ; %entry
12741 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
12742 ; GFX11-WGP-NEXT: s_load_b32 s2, s[2:3], 0x8
12743 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
12744 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
12745 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
12746 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s2
12747 ; GFX11-WGP-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 glc
12748 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
12749 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
12750 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12751 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
12752 ; GFX11-WGP-NEXT: s_endpgm
12754 ; GFX11-CU-LABEL: flat_singlethread_one_as_seq_cst_ret_atomicrmw:
12755 ; GFX11-CU: ; %bb.0: ; %entry
12756 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
12757 ; GFX11-CU-NEXT: s_load_b32 s2, s[2:3], 0x8
12758 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
12759 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
12760 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
12761 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s2
12762 ; GFX11-CU-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 glc
12763 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
12764 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
12765 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
12766 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
12767 ; GFX11-CU-NEXT: s_endpgm
12769 ; GFX12-WGP-LABEL: flat_singlethread_one_as_seq_cst_ret_atomicrmw:
12770 ; GFX12-WGP: ; %bb.0: ; %entry
12771 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
12772 ; GFX12-WGP-NEXT: s_load_b32 s2, s[2:3], 0x8
12773 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
12774 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
12775 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
12776 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s2
12777 ; GFX12-WGP-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 th:TH_ATOMIC_RETURN
12778 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
12779 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
12780 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
12781 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
12782 ; GFX12-WGP-NEXT: s_endpgm
12784 ; GFX12-CU-LABEL: flat_singlethread_one_as_seq_cst_ret_atomicrmw:
12785 ; GFX12-CU: ; %bb.0: ; %entry
12786 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
12787 ; GFX12-CU-NEXT: s_load_b32 s2, s[2:3], 0x8
12788 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
12789 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
12790 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
12791 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s2
12792 ; GFX12-CU-NEXT: flat_atomic_swap_b32 v2, v[0:1], v2 th:TH_ATOMIC_RETURN
12793 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
12794 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
12795 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
12796 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
12797 ; GFX12-CU-NEXT: s_endpgm
12798 ptr %out, i32 %in) {
12800 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("singlethread-one-as") seq_cst
12801 store i32 %val, ptr %out, align 4
12805 define amdgpu_kernel void @flat_singlethread_one_as_monotonic_monotonic_cmpxchg(
12806 ; GFX7-LABEL: flat_singlethread_one_as_monotonic_monotonic_cmpxchg:
12807 ; GFX7: ; %bb.0: ; %entry
12808 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
12809 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
12810 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
12811 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
12812 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
12813 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
12814 ; GFX7-NEXT: s_mov_b32 s4, s8
12815 ; GFX7-NEXT: s_mov_b32 s5, s9
12816 ; GFX7-NEXT: s_mov_b32 s9, s10
12817 ; GFX7-NEXT: s_mov_b32 s8, s11
12818 ; GFX7-NEXT: s_add_u32 s4, s4, s9
12819 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
12820 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
12821 ; GFX7-NEXT: s_mov_b32 s5, s8
12822 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
12823 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
12824 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
12825 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
12826 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
12827 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
12828 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
12829 ; GFX7-NEXT: s_endpgm
12831 ; GFX10-WGP-LABEL: flat_singlethread_one_as_monotonic_monotonic_cmpxchg:
12832 ; GFX10-WGP: ; %bb.0: ; %entry
12833 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
12834 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
12835 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
12836 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
12837 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
12838 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
12839 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
12840 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
12841 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
12842 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
12843 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
12844 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
12845 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
12846 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
12847 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
12848 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
12849 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
12850 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
12851 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
12852 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
12853 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
12854 ; GFX10-WGP-NEXT: s_endpgm
12856 ; GFX10-CU-LABEL: flat_singlethread_one_as_monotonic_monotonic_cmpxchg:
12857 ; GFX10-CU: ; %bb.0: ; %entry
12858 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
12859 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
12860 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
12861 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
12862 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
12863 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
12864 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
12865 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
12866 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
12867 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
12868 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
12869 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
12870 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
12871 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
12872 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
12873 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
12874 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
12875 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
12876 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
12877 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
12878 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
12879 ; GFX10-CU-NEXT: s_endpgm
12881 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_monotonic_monotonic_cmpxchg:
12882 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
12883 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
12884 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
12885 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
12886 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
12887 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
12888 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
12889 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
12890 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
12891 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
12892 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
12893 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
12894 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
12895 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
12896 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
12897 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
12898 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
12899 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
12900 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
12901 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
12902 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
12903 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
12904 ; SKIP-CACHE-INV-NEXT: s_endpgm
12906 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_monotonic_monotonic_cmpxchg:
12907 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
12908 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
12909 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12910 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
12911 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
12912 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12913 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
12914 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
12915 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
12916 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
12917 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
12918 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
12919 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
12921 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_monotonic_monotonic_cmpxchg:
12922 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
12923 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
12924 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12925 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
12926 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
12927 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12928 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
12929 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
12930 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
12931 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
12932 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
12933 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
12934 ; GFX90A-TGSPLIT-NEXT: s_endpgm
12936 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_monotonic_monotonic_cmpxchg:
12937 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
12938 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
12939 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
12940 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
12941 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
12942 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12943 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
12944 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
12945 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
12946 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
12947 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
12948 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
12949 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
12951 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_monotonic_monotonic_cmpxchg:
12952 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
12953 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
12954 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
12955 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
12956 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
12957 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12958 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
12959 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
12960 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
12961 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
12962 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
12963 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
12964 ; GFX940-TGSPLIT-NEXT: s_endpgm
12966 ; GFX11-WGP-LABEL: flat_singlethread_one_as_monotonic_monotonic_cmpxchg:
12967 ; GFX11-WGP: ; %bb.0: ; %entry
12968 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
12969 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
12970 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
12971 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
12972 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
12973 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
12974 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
12975 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
12976 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
12977 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
12978 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
12979 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
12980 ; GFX11-WGP-NEXT: s_endpgm
12982 ; GFX11-CU-LABEL: flat_singlethread_one_as_monotonic_monotonic_cmpxchg:
12983 ; GFX11-CU: ; %bb.0: ; %entry
12984 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
12985 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
12986 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
12987 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
12988 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
12989 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
12990 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
12991 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
12992 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
12993 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
12994 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
12995 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
12996 ; GFX11-CU-NEXT: s_endpgm
12998 ; GFX12-WGP-LABEL: flat_singlethread_one_as_monotonic_monotonic_cmpxchg:
12999 ; GFX12-WGP: ; %bb.0: ; %entry
13000 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
13001 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13002 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
13003 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
13004 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
13005 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
13006 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
13007 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13008 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
13009 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
13010 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
13011 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
13012 ; GFX12-WGP-NEXT: s_endpgm
13014 ; GFX12-CU-LABEL: flat_singlethread_one_as_monotonic_monotonic_cmpxchg:
13015 ; GFX12-CU: ; %bb.0: ; %entry
13016 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
13017 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13018 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
13019 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
13020 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
13021 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
13022 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
13023 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13024 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
13025 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
13026 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
13027 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
13028 ; GFX12-CU-NEXT: s_endpgm
13029 ptr %out, i32 %in, i32 %old) {
13031 %gep = getelementptr i32, ptr %out, i32 4
13032 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") monotonic monotonic
13036 define amdgpu_kernel void @flat_singlethread_one_as_acquire_monotonic_cmpxchg(
13037 ; GFX7-LABEL: flat_singlethread_one_as_acquire_monotonic_cmpxchg:
13038 ; GFX7: ; %bb.0: ; %entry
13039 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
13040 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
13041 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
13042 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
13043 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
13044 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
13045 ; GFX7-NEXT: s_mov_b32 s4, s8
13046 ; GFX7-NEXT: s_mov_b32 s5, s9
13047 ; GFX7-NEXT: s_mov_b32 s9, s10
13048 ; GFX7-NEXT: s_mov_b32 s8, s11
13049 ; GFX7-NEXT: s_add_u32 s4, s4, s9
13050 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
13051 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
13052 ; GFX7-NEXT: s_mov_b32 s5, s8
13053 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
13054 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
13055 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13056 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
13057 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
13058 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
13059 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
13060 ; GFX7-NEXT: s_endpgm
13062 ; GFX10-WGP-LABEL: flat_singlethread_one_as_acquire_monotonic_cmpxchg:
13063 ; GFX10-WGP: ; %bb.0: ; %entry
13064 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
13065 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
13066 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
13067 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
13068 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
13069 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
13070 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
13071 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
13072 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
13073 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
13074 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
13075 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
13076 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
13077 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
13078 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
13079 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
13080 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13081 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
13082 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
13083 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
13084 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
13085 ; GFX10-WGP-NEXT: s_endpgm
13087 ; GFX10-CU-LABEL: flat_singlethread_one_as_acquire_monotonic_cmpxchg:
13088 ; GFX10-CU: ; %bb.0: ; %entry
13089 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
13090 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
13091 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
13092 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
13093 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
13094 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
13095 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
13096 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
13097 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
13098 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
13099 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
13100 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
13101 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
13102 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
13103 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
13104 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
13105 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13106 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
13107 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
13108 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
13109 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
13110 ; GFX10-CU-NEXT: s_endpgm
13112 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_acquire_monotonic_cmpxchg:
13113 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
13114 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
13115 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
13116 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
13117 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
13118 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
13119 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
13120 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
13121 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
13122 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
13123 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
13124 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
13125 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
13126 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
13127 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
13128 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
13129 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
13130 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13131 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
13132 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
13133 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
13134 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
13135 ; SKIP-CACHE-INV-NEXT: s_endpgm
13137 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acquire_monotonic_cmpxchg:
13138 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
13139 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
13140 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13141 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
13142 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
13143 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13144 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
13145 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
13146 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13147 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
13148 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
13149 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
13150 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
13152 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_acquire_monotonic_cmpxchg:
13153 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
13154 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
13155 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13156 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
13157 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
13158 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13159 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
13160 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
13161 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13162 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
13163 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
13164 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
13165 ; GFX90A-TGSPLIT-NEXT: s_endpgm
13167 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acquire_monotonic_cmpxchg:
13168 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
13169 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
13170 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
13171 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
13172 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
13173 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13174 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
13175 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
13176 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13177 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
13178 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
13179 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
13180 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
13182 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_acquire_monotonic_cmpxchg:
13183 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
13184 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
13185 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
13186 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
13187 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
13188 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13189 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
13190 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
13191 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13192 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
13193 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
13194 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
13195 ; GFX940-TGSPLIT-NEXT: s_endpgm
13197 ; GFX11-WGP-LABEL: flat_singlethread_one_as_acquire_monotonic_cmpxchg:
13198 ; GFX11-WGP: ; %bb.0: ; %entry
13199 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
13200 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13201 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
13202 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
13203 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
13204 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
13205 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
13206 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13207 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
13208 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
13209 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
13210 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
13211 ; GFX11-WGP-NEXT: s_endpgm
13213 ; GFX11-CU-LABEL: flat_singlethread_one_as_acquire_monotonic_cmpxchg:
13214 ; GFX11-CU: ; %bb.0: ; %entry
13215 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
13216 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13217 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
13218 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
13219 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
13220 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
13221 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
13222 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13223 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
13224 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
13225 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
13226 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
13227 ; GFX11-CU-NEXT: s_endpgm
13229 ; GFX12-WGP-LABEL: flat_singlethread_one_as_acquire_monotonic_cmpxchg:
13230 ; GFX12-WGP: ; %bb.0: ; %entry
13231 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
13232 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13233 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
13234 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
13235 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
13236 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
13237 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
13238 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13239 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
13240 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
13241 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
13242 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
13243 ; GFX12-WGP-NEXT: s_endpgm
13245 ; GFX12-CU-LABEL: flat_singlethread_one_as_acquire_monotonic_cmpxchg:
13246 ; GFX12-CU: ; %bb.0: ; %entry
13247 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
13248 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13249 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
13250 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
13251 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
13252 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
13253 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
13254 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13255 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
13256 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
13257 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
13258 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
13259 ; GFX12-CU-NEXT: s_endpgm
13260 ptr %out, i32 %in, i32 %old) {
13262 %gep = getelementptr i32, ptr %out, i32 4
13263 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") acquire monotonic
13267 define amdgpu_kernel void @flat_singlethread_one_as_release_monotonic_cmpxchg(
13268 ; GFX7-LABEL: flat_singlethread_one_as_release_monotonic_cmpxchg:
13269 ; GFX7: ; %bb.0: ; %entry
13270 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
13271 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
13272 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
13273 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
13274 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
13275 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
13276 ; GFX7-NEXT: s_mov_b32 s4, s8
13277 ; GFX7-NEXT: s_mov_b32 s5, s9
13278 ; GFX7-NEXT: s_mov_b32 s9, s10
13279 ; GFX7-NEXT: s_mov_b32 s8, s11
13280 ; GFX7-NEXT: s_add_u32 s4, s4, s9
13281 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
13282 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
13283 ; GFX7-NEXT: s_mov_b32 s5, s8
13284 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
13285 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
13286 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13287 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
13288 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
13289 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
13290 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
13291 ; GFX7-NEXT: s_endpgm
13293 ; GFX10-WGP-LABEL: flat_singlethread_one_as_release_monotonic_cmpxchg:
13294 ; GFX10-WGP: ; %bb.0: ; %entry
13295 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
13296 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
13297 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
13298 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
13299 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
13300 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
13301 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
13302 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
13303 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
13304 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
13305 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
13306 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
13307 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
13308 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
13309 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
13310 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
13311 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13312 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
13313 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
13314 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
13315 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
13316 ; GFX10-WGP-NEXT: s_endpgm
13318 ; GFX10-CU-LABEL: flat_singlethread_one_as_release_monotonic_cmpxchg:
13319 ; GFX10-CU: ; %bb.0: ; %entry
13320 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
13321 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
13322 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
13323 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
13324 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
13325 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
13326 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
13327 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
13328 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
13329 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
13330 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
13331 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
13332 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
13333 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
13334 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
13335 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
13336 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13337 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
13338 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
13339 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
13340 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
13341 ; GFX10-CU-NEXT: s_endpgm
13343 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_release_monotonic_cmpxchg:
13344 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
13345 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
13346 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
13347 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
13348 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
13349 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
13350 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
13351 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
13352 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
13353 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
13354 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
13355 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
13356 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
13357 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
13358 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
13359 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
13360 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
13361 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13362 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
13363 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
13364 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
13365 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
13366 ; SKIP-CACHE-INV-NEXT: s_endpgm
13368 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_release_monotonic_cmpxchg:
13369 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
13370 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
13371 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13372 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
13373 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
13374 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13375 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
13376 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
13377 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13378 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
13379 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
13380 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
13381 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
13383 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_release_monotonic_cmpxchg:
13384 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
13385 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
13386 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13387 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
13388 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
13389 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13390 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
13391 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
13392 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13393 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
13394 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
13395 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
13396 ; GFX90A-TGSPLIT-NEXT: s_endpgm
13398 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_release_monotonic_cmpxchg:
13399 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
13400 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
13401 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
13402 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
13403 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
13404 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13405 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
13406 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
13407 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13408 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
13409 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
13410 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
13411 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
13413 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_release_monotonic_cmpxchg:
13414 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
13415 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
13416 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
13417 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
13418 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
13419 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13420 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
13421 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
13422 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13423 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
13424 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
13425 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
13426 ; GFX940-TGSPLIT-NEXT: s_endpgm
13428 ; GFX11-WGP-LABEL: flat_singlethread_one_as_release_monotonic_cmpxchg:
13429 ; GFX11-WGP: ; %bb.0: ; %entry
13430 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
13431 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13432 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
13433 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
13434 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
13435 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
13436 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
13437 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13438 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
13439 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
13440 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
13441 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
13442 ; GFX11-WGP-NEXT: s_endpgm
13444 ; GFX11-CU-LABEL: flat_singlethread_one_as_release_monotonic_cmpxchg:
13445 ; GFX11-CU: ; %bb.0: ; %entry
13446 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
13447 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13448 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
13449 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
13450 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
13451 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
13452 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
13453 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13454 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
13455 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
13456 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
13457 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
13458 ; GFX11-CU-NEXT: s_endpgm
13460 ; GFX12-WGP-LABEL: flat_singlethread_one_as_release_monotonic_cmpxchg:
13461 ; GFX12-WGP: ; %bb.0: ; %entry
13462 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
13463 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13464 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
13465 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
13466 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
13467 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
13468 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
13469 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13470 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
13471 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
13472 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
13473 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
13474 ; GFX12-WGP-NEXT: s_endpgm
13476 ; GFX12-CU-LABEL: flat_singlethread_one_as_release_monotonic_cmpxchg:
13477 ; GFX12-CU: ; %bb.0: ; %entry
13478 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
13479 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13480 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
13481 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
13482 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
13483 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
13484 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
13485 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13486 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
13487 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
13488 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
13489 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
13490 ; GFX12-CU-NEXT: s_endpgm
13491 ptr %out, i32 %in, i32 %old) {
13493 %gep = getelementptr i32, ptr %out, i32 4
13494 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") release monotonic
13498 define amdgpu_kernel void @flat_singlethread_one_as_acq_rel_monotonic_cmpxchg(
13499 ; GFX7-LABEL: flat_singlethread_one_as_acq_rel_monotonic_cmpxchg:
13500 ; GFX7: ; %bb.0: ; %entry
13501 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
13502 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
13503 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
13504 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
13505 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
13506 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
13507 ; GFX7-NEXT: s_mov_b32 s4, s8
13508 ; GFX7-NEXT: s_mov_b32 s5, s9
13509 ; GFX7-NEXT: s_mov_b32 s9, s10
13510 ; GFX7-NEXT: s_mov_b32 s8, s11
13511 ; GFX7-NEXT: s_add_u32 s4, s4, s9
13512 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
13513 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
13514 ; GFX7-NEXT: s_mov_b32 s5, s8
13515 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
13516 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
13517 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13518 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
13519 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
13520 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
13521 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
13522 ; GFX7-NEXT: s_endpgm
13524 ; GFX10-WGP-LABEL: flat_singlethread_one_as_acq_rel_monotonic_cmpxchg:
13525 ; GFX10-WGP: ; %bb.0: ; %entry
13526 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
13527 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
13528 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
13529 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
13530 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
13531 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
13532 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
13533 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
13534 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
13535 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
13536 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
13537 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
13538 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
13539 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
13540 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
13541 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
13542 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13543 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
13544 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
13545 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
13546 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
13547 ; GFX10-WGP-NEXT: s_endpgm
13549 ; GFX10-CU-LABEL: flat_singlethread_one_as_acq_rel_monotonic_cmpxchg:
13550 ; GFX10-CU: ; %bb.0: ; %entry
13551 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
13552 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
13553 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
13554 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
13555 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
13556 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
13557 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
13558 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
13559 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
13560 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
13561 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
13562 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
13563 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
13564 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
13565 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
13566 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
13567 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13568 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
13569 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
13570 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
13571 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
13572 ; GFX10-CU-NEXT: s_endpgm
13574 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_acq_rel_monotonic_cmpxchg:
13575 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
13576 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
13577 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
13578 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
13579 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
13580 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
13581 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
13582 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
13583 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
13584 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
13585 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
13586 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
13587 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
13588 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
13589 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
13590 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
13591 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
13592 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13593 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
13594 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
13595 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
13596 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
13597 ; SKIP-CACHE-INV-NEXT: s_endpgm
13599 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_monotonic_cmpxchg:
13600 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
13601 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
13602 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13603 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
13604 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
13605 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13606 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
13607 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
13608 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13609 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
13610 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
13611 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
13612 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
13614 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_monotonic_cmpxchg:
13615 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
13616 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
13617 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13618 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
13619 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
13620 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13621 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
13622 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
13623 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13624 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
13625 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
13626 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
13627 ; GFX90A-TGSPLIT-NEXT: s_endpgm
13629 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_monotonic_cmpxchg:
13630 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
13631 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
13632 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
13633 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
13634 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
13635 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13636 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
13637 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
13638 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13639 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
13640 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
13641 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
13642 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
13644 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_monotonic_cmpxchg:
13645 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
13646 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
13647 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
13648 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
13649 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
13650 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13651 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
13652 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
13653 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13654 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
13655 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
13656 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
13657 ; GFX940-TGSPLIT-NEXT: s_endpgm
13659 ; GFX11-WGP-LABEL: flat_singlethread_one_as_acq_rel_monotonic_cmpxchg:
13660 ; GFX11-WGP: ; %bb.0: ; %entry
13661 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
13662 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13663 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
13664 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
13665 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
13666 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
13667 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
13668 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13669 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
13670 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
13671 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
13672 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
13673 ; GFX11-WGP-NEXT: s_endpgm
13675 ; GFX11-CU-LABEL: flat_singlethread_one_as_acq_rel_monotonic_cmpxchg:
13676 ; GFX11-CU: ; %bb.0: ; %entry
13677 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
13678 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13679 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
13680 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
13681 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
13682 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
13683 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
13684 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13685 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
13686 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
13687 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
13688 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
13689 ; GFX11-CU-NEXT: s_endpgm
13691 ; GFX12-WGP-LABEL: flat_singlethread_one_as_acq_rel_monotonic_cmpxchg:
13692 ; GFX12-WGP: ; %bb.0: ; %entry
13693 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
13694 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13695 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
13696 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
13697 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
13698 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
13699 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
13700 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13701 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
13702 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
13703 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
13704 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
13705 ; GFX12-WGP-NEXT: s_endpgm
13707 ; GFX12-CU-LABEL: flat_singlethread_one_as_acq_rel_monotonic_cmpxchg:
13708 ; GFX12-CU: ; %bb.0: ; %entry
13709 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
13710 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13711 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
13712 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
13713 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
13714 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
13715 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
13716 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13717 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
13718 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
13719 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
13720 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
13721 ; GFX12-CU-NEXT: s_endpgm
13722 ptr %out, i32 %in, i32 %old) {
13724 %gep = getelementptr i32, ptr %out, i32 4
13725 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") acq_rel monotonic
13729 define amdgpu_kernel void @flat_singlethread_one_as_seq_cst_monotonic_cmpxchg(
13730 ; GFX7-LABEL: flat_singlethread_one_as_seq_cst_monotonic_cmpxchg:
13731 ; GFX7: ; %bb.0: ; %entry
13732 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
13733 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
13734 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
13735 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
13736 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
13737 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
13738 ; GFX7-NEXT: s_mov_b32 s4, s8
13739 ; GFX7-NEXT: s_mov_b32 s5, s9
13740 ; GFX7-NEXT: s_mov_b32 s9, s10
13741 ; GFX7-NEXT: s_mov_b32 s8, s11
13742 ; GFX7-NEXT: s_add_u32 s4, s4, s9
13743 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
13744 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
13745 ; GFX7-NEXT: s_mov_b32 s5, s8
13746 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
13747 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
13748 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13749 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
13750 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
13751 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
13752 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
13753 ; GFX7-NEXT: s_endpgm
13755 ; GFX10-WGP-LABEL: flat_singlethread_one_as_seq_cst_monotonic_cmpxchg:
13756 ; GFX10-WGP: ; %bb.0: ; %entry
13757 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
13758 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
13759 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
13760 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
13761 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
13762 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
13763 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
13764 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
13765 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
13766 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
13767 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
13768 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
13769 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
13770 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
13771 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
13772 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
13773 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13774 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
13775 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
13776 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
13777 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
13778 ; GFX10-WGP-NEXT: s_endpgm
13780 ; GFX10-CU-LABEL: flat_singlethread_one_as_seq_cst_monotonic_cmpxchg:
13781 ; GFX10-CU: ; %bb.0: ; %entry
13782 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
13783 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
13784 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
13785 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
13786 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
13787 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
13788 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
13789 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
13790 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
13791 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
13792 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
13793 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
13794 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
13795 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
13796 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
13797 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
13798 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13799 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
13800 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
13801 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
13802 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
13803 ; GFX10-CU-NEXT: s_endpgm
13805 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_seq_cst_monotonic_cmpxchg:
13806 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
13807 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
13808 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
13809 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
13810 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
13811 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
13812 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
13813 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
13814 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
13815 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
13816 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
13817 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
13818 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
13819 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
13820 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
13821 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
13822 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
13823 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13824 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
13825 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
13826 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
13827 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
13828 ; SKIP-CACHE-INV-NEXT: s_endpgm
13830 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_monotonic_cmpxchg:
13831 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
13832 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
13833 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13834 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
13835 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
13836 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13837 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
13838 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
13839 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13840 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
13841 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
13842 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
13843 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
13845 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_monotonic_cmpxchg:
13846 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
13847 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
13848 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13849 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
13850 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
13851 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13852 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
13853 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
13854 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13855 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
13856 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
13857 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
13858 ; GFX90A-TGSPLIT-NEXT: s_endpgm
13860 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_monotonic_cmpxchg:
13861 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
13862 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
13863 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
13864 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
13865 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
13866 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13867 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
13868 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
13869 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13870 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
13871 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
13872 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
13873 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
13875 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_monotonic_cmpxchg:
13876 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
13877 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
13878 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
13879 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
13880 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
13881 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13882 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
13883 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
13884 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13885 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
13886 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
13887 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
13888 ; GFX940-TGSPLIT-NEXT: s_endpgm
13890 ; GFX11-WGP-LABEL: flat_singlethread_one_as_seq_cst_monotonic_cmpxchg:
13891 ; GFX11-WGP: ; %bb.0: ; %entry
13892 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
13893 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13894 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
13895 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
13896 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
13897 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
13898 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
13899 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13900 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
13901 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
13902 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
13903 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
13904 ; GFX11-WGP-NEXT: s_endpgm
13906 ; GFX11-CU-LABEL: flat_singlethread_one_as_seq_cst_monotonic_cmpxchg:
13907 ; GFX11-CU: ; %bb.0: ; %entry
13908 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
13909 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13910 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
13911 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
13912 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
13913 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
13914 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
13915 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13916 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
13917 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
13918 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
13919 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
13920 ; GFX11-CU-NEXT: s_endpgm
13922 ; GFX12-WGP-LABEL: flat_singlethread_one_as_seq_cst_monotonic_cmpxchg:
13923 ; GFX12-WGP: ; %bb.0: ; %entry
13924 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
13925 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13926 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
13927 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
13928 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
13929 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
13930 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
13931 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13932 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
13933 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
13934 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
13935 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
13936 ; GFX12-WGP-NEXT: s_endpgm
13938 ; GFX12-CU-LABEL: flat_singlethread_one_as_seq_cst_monotonic_cmpxchg:
13939 ; GFX12-CU: ; %bb.0: ; %entry
13940 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
13941 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13942 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
13943 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
13944 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
13945 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
13946 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
13947 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13948 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
13949 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
13950 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
13951 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
13952 ; GFX12-CU-NEXT: s_endpgm
13953 ptr %out, i32 %in, i32 %old) {
13955 %gep = getelementptr i32, ptr %out, i32 4
13956 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") seq_cst monotonic
13960 define amdgpu_kernel void @flat_singlethread_one_as_monotonic_acquire_cmpxchg(
13961 ; GFX7-LABEL: flat_singlethread_one_as_monotonic_acquire_cmpxchg:
13962 ; GFX7: ; %bb.0: ; %entry
13963 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
13964 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
13965 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
13966 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
13967 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
13968 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
13969 ; GFX7-NEXT: s_mov_b32 s4, s8
13970 ; GFX7-NEXT: s_mov_b32 s5, s9
13971 ; GFX7-NEXT: s_mov_b32 s9, s10
13972 ; GFX7-NEXT: s_mov_b32 s8, s11
13973 ; GFX7-NEXT: s_add_u32 s4, s4, s9
13974 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
13975 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
13976 ; GFX7-NEXT: s_mov_b32 s5, s8
13977 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
13978 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
13979 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13980 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
13981 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
13982 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
13983 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
13984 ; GFX7-NEXT: s_endpgm
13986 ; GFX10-WGP-LABEL: flat_singlethread_one_as_monotonic_acquire_cmpxchg:
13987 ; GFX10-WGP: ; %bb.0: ; %entry
13988 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
13989 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
13990 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
13991 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
13992 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
13993 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
13994 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
13995 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
13996 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
13997 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
13998 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
13999 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
14000 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
14001 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
14002 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
14003 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
14004 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14005 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
14006 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
14007 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
14008 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
14009 ; GFX10-WGP-NEXT: s_endpgm
14011 ; GFX10-CU-LABEL: flat_singlethread_one_as_monotonic_acquire_cmpxchg:
14012 ; GFX10-CU: ; %bb.0: ; %entry
14013 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
14014 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
14015 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
14016 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
14017 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
14018 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
14019 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
14020 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
14021 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
14022 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
14023 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
14024 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
14025 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
14026 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
14027 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
14028 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
14029 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14030 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
14031 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
14032 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
14033 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
14034 ; GFX10-CU-NEXT: s_endpgm
14036 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_monotonic_acquire_cmpxchg:
14037 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
14038 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
14039 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
14040 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
14041 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
14042 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
14043 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
14044 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
14045 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
14046 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
14047 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
14048 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
14049 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
14050 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
14051 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
14052 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
14053 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
14054 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14055 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
14056 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
14057 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
14058 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
14059 ; SKIP-CACHE-INV-NEXT: s_endpgm
14061 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_monotonic_acquire_cmpxchg:
14062 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
14063 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
14064 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
14065 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
14066 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
14067 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14068 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
14069 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
14070 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14071 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
14072 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
14073 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
14074 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
14076 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_monotonic_acquire_cmpxchg:
14077 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
14078 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
14079 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
14080 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
14081 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
14082 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14083 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
14084 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
14085 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14086 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
14087 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
14088 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
14089 ; GFX90A-TGSPLIT-NEXT: s_endpgm
14091 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_monotonic_acquire_cmpxchg:
14092 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
14093 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
14094 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
14095 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
14096 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
14097 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14098 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
14099 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
14100 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14101 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
14102 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
14103 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
14104 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
14106 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_monotonic_acquire_cmpxchg:
14107 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
14108 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
14109 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
14110 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
14111 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
14112 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14113 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
14114 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
14115 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14116 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
14117 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
14118 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
14119 ; GFX940-TGSPLIT-NEXT: s_endpgm
14121 ; GFX11-WGP-LABEL: flat_singlethread_one_as_monotonic_acquire_cmpxchg:
14122 ; GFX11-WGP: ; %bb.0: ; %entry
14123 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
14124 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14125 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
14126 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
14127 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
14128 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
14129 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
14130 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14131 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
14132 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
14133 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
14134 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
14135 ; GFX11-WGP-NEXT: s_endpgm
14137 ; GFX11-CU-LABEL: flat_singlethread_one_as_monotonic_acquire_cmpxchg:
14138 ; GFX11-CU: ; %bb.0: ; %entry
14139 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
14140 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14141 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
14142 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
14143 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
14144 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
14145 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
14146 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14147 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
14148 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
14149 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
14150 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
14151 ; GFX11-CU-NEXT: s_endpgm
14153 ; GFX12-WGP-LABEL: flat_singlethread_one_as_monotonic_acquire_cmpxchg:
14154 ; GFX12-WGP: ; %bb.0: ; %entry
14155 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
14156 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14157 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
14158 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
14159 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
14160 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
14161 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
14162 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14163 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
14164 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
14165 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
14166 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
14167 ; GFX12-WGP-NEXT: s_endpgm
14169 ; GFX12-CU-LABEL: flat_singlethread_one_as_monotonic_acquire_cmpxchg:
14170 ; GFX12-CU: ; %bb.0: ; %entry
14171 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
14172 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14173 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
14174 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
14175 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
14176 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
14177 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
14178 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14179 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
14180 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
14181 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
14182 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
14183 ; GFX12-CU-NEXT: s_endpgm
14184 ptr %out, i32 %in, i32 %old) {
14186 %gep = getelementptr i32, ptr %out, i32 4
14187 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") monotonic acquire
14191 define amdgpu_kernel void @flat_singlethread_one_as_acquire_acquire_cmpxchg(
14192 ; GFX7-LABEL: flat_singlethread_one_as_acquire_acquire_cmpxchg:
14193 ; GFX7: ; %bb.0: ; %entry
14194 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
14195 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
14196 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
14197 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
14198 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
14199 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
14200 ; GFX7-NEXT: s_mov_b32 s4, s8
14201 ; GFX7-NEXT: s_mov_b32 s5, s9
14202 ; GFX7-NEXT: s_mov_b32 s9, s10
14203 ; GFX7-NEXT: s_mov_b32 s8, s11
14204 ; GFX7-NEXT: s_add_u32 s4, s4, s9
14205 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
14206 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
14207 ; GFX7-NEXT: s_mov_b32 s5, s8
14208 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
14209 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
14210 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14211 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
14212 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
14213 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
14214 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
14215 ; GFX7-NEXT: s_endpgm
14217 ; GFX10-WGP-LABEL: flat_singlethread_one_as_acquire_acquire_cmpxchg:
14218 ; GFX10-WGP: ; %bb.0: ; %entry
14219 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
14220 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
14221 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
14222 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
14223 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
14224 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
14225 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
14226 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
14227 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
14228 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
14229 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
14230 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
14231 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
14232 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
14233 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
14234 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
14235 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14236 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
14237 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
14238 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
14239 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
14240 ; GFX10-WGP-NEXT: s_endpgm
14242 ; GFX10-CU-LABEL: flat_singlethread_one_as_acquire_acquire_cmpxchg:
14243 ; GFX10-CU: ; %bb.0: ; %entry
14244 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
14245 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
14246 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
14247 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
14248 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
14249 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
14250 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
14251 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
14252 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
14253 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
14254 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
14255 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
14256 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
14257 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
14258 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
14259 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
14260 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14261 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
14262 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
14263 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
14264 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
14265 ; GFX10-CU-NEXT: s_endpgm
14267 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_acquire_acquire_cmpxchg:
14268 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
14269 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
14270 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
14271 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
14272 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
14273 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
14274 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
14275 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
14276 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
14277 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
14278 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
14279 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
14280 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
14281 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
14282 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
14283 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
14284 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
14285 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14286 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
14287 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
14288 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
14289 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
14290 ; SKIP-CACHE-INV-NEXT: s_endpgm
14292 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acquire_acquire_cmpxchg:
14293 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
14294 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
14295 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
14296 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
14297 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
14298 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14299 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
14300 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
14301 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14302 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
14303 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
14304 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
14305 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
14307 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_acquire_acquire_cmpxchg:
14308 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
14309 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
14310 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
14311 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
14312 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
14313 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14314 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
14315 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
14316 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14317 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
14318 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
14319 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
14320 ; GFX90A-TGSPLIT-NEXT: s_endpgm
14322 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acquire_acquire_cmpxchg:
14323 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
14324 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
14325 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
14326 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
14327 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
14328 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14329 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
14330 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
14331 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14332 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
14333 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
14334 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
14335 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
14337 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_acquire_acquire_cmpxchg:
14338 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
14339 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
14340 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
14341 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
14342 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
14343 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14344 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
14345 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
14346 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14347 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
14348 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
14349 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
14350 ; GFX940-TGSPLIT-NEXT: s_endpgm
14352 ; GFX11-WGP-LABEL: flat_singlethread_one_as_acquire_acquire_cmpxchg:
14353 ; GFX11-WGP: ; %bb.0: ; %entry
14354 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
14355 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14356 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
14357 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
14358 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
14359 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
14360 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
14361 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14362 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
14363 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
14364 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
14365 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
14366 ; GFX11-WGP-NEXT: s_endpgm
14368 ; GFX11-CU-LABEL: flat_singlethread_one_as_acquire_acquire_cmpxchg:
14369 ; GFX11-CU: ; %bb.0: ; %entry
14370 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
14371 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14372 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
14373 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
14374 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
14375 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
14376 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
14377 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14378 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
14379 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
14380 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
14381 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
14382 ; GFX11-CU-NEXT: s_endpgm
14384 ; GFX12-WGP-LABEL: flat_singlethread_one_as_acquire_acquire_cmpxchg:
14385 ; GFX12-WGP: ; %bb.0: ; %entry
14386 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
14387 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14388 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
14389 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
14390 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
14391 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
14392 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
14393 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14394 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
14395 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
14396 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
14397 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
14398 ; GFX12-WGP-NEXT: s_endpgm
14400 ; GFX12-CU-LABEL: flat_singlethread_one_as_acquire_acquire_cmpxchg:
14401 ; GFX12-CU: ; %bb.0: ; %entry
14402 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
14403 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14404 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
14405 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
14406 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
14407 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
14408 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
14409 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14410 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
14411 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
14412 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
14413 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
14414 ; GFX12-CU-NEXT: s_endpgm
14415 ptr %out, i32 %in, i32 %old) {
14417 %gep = getelementptr i32, ptr %out, i32 4
14418 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") acquire acquire
14422 define amdgpu_kernel void @flat_singlethread_one_as_release_acquire_cmpxchg(
14423 ; GFX7-LABEL: flat_singlethread_one_as_release_acquire_cmpxchg:
14424 ; GFX7: ; %bb.0: ; %entry
14425 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
14426 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
14427 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
14428 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
14429 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
14430 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
14431 ; GFX7-NEXT: s_mov_b32 s4, s8
14432 ; GFX7-NEXT: s_mov_b32 s5, s9
14433 ; GFX7-NEXT: s_mov_b32 s9, s10
14434 ; GFX7-NEXT: s_mov_b32 s8, s11
14435 ; GFX7-NEXT: s_add_u32 s4, s4, s9
14436 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
14437 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
14438 ; GFX7-NEXT: s_mov_b32 s5, s8
14439 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
14440 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
14441 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14442 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
14443 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
14444 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
14445 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
14446 ; GFX7-NEXT: s_endpgm
14448 ; GFX10-WGP-LABEL: flat_singlethread_one_as_release_acquire_cmpxchg:
14449 ; GFX10-WGP: ; %bb.0: ; %entry
14450 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
14451 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
14452 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
14453 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
14454 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
14455 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
14456 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
14457 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
14458 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
14459 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
14460 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
14461 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
14462 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
14463 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
14464 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
14465 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
14466 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14467 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
14468 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
14469 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
14470 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
14471 ; GFX10-WGP-NEXT: s_endpgm
14473 ; GFX10-CU-LABEL: flat_singlethread_one_as_release_acquire_cmpxchg:
14474 ; GFX10-CU: ; %bb.0: ; %entry
14475 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
14476 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
14477 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
14478 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
14479 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
14480 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
14481 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
14482 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
14483 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
14484 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
14485 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
14486 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
14487 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
14488 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
14489 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
14490 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
14491 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14492 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
14493 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
14494 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
14495 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
14496 ; GFX10-CU-NEXT: s_endpgm
14498 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_release_acquire_cmpxchg:
14499 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
14500 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
14501 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
14502 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
14503 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
14504 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
14505 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
14506 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
14507 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
14508 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
14509 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
14510 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
14511 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
14512 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
14513 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
14514 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
14515 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
14516 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14517 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
14518 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
14519 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
14520 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
14521 ; SKIP-CACHE-INV-NEXT: s_endpgm
14523 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_release_acquire_cmpxchg:
14524 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
14525 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
14526 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
14527 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
14528 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
14529 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14530 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
14531 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
14532 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14533 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
14534 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
14535 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
14536 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
14538 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_release_acquire_cmpxchg:
14539 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
14540 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
14541 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
14542 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
14543 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
14544 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14545 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
14546 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
14547 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14548 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
14549 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
14550 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
14551 ; GFX90A-TGSPLIT-NEXT: s_endpgm
14553 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_release_acquire_cmpxchg:
14554 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
14555 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
14556 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
14557 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
14558 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
14559 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14560 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
14561 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
14562 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14563 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
14564 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
14565 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
14566 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
14568 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_release_acquire_cmpxchg:
14569 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
14570 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
14571 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
14572 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
14573 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
14574 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14575 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
14576 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
14577 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14578 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
14579 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
14580 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
14581 ; GFX940-TGSPLIT-NEXT: s_endpgm
14583 ; GFX11-WGP-LABEL: flat_singlethread_one_as_release_acquire_cmpxchg:
14584 ; GFX11-WGP: ; %bb.0: ; %entry
14585 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
14586 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14587 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
14588 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
14589 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
14590 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
14591 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
14592 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14593 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
14594 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
14595 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
14596 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
14597 ; GFX11-WGP-NEXT: s_endpgm
14599 ; GFX11-CU-LABEL: flat_singlethread_one_as_release_acquire_cmpxchg:
14600 ; GFX11-CU: ; %bb.0: ; %entry
14601 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
14602 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14603 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
14604 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
14605 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
14606 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
14607 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
14608 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14609 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
14610 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
14611 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
14612 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
14613 ; GFX11-CU-NEXT: s_endpgm
14615 ; GFX12-WGP-LABEL: flat_singlethread_one_as_release_acquire_cmpxchg:
14616 ; GFX12-WGP: ; %bb.0: ; %entry
14617 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
14618 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14619 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
14620 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
14621 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
14622 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
14623 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
14624 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14625 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
14626 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
14627 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
14628 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
14629 ; GFX12-WGP-NEXT: s_endpgm
14631 ; GFX12-CU-LABEL: flat_singlethread_one_as_release_acquire_cmpxchg:
14632 ; GFX12-CU: ; %bb.0: ; %entry
14633 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
14634 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14635 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
14636 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
14637 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
14638 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
14639 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
14640 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14641 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
14642 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
14643 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
14644 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
14645 ; GFX12-CU-NEXT: s_endpgm
14646 ptr %out, i32 %in, i32 %old) {
14648 %gep = getelementptr i32, ptr %out, i32 4
14649 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") release acquire
14653 define amdgpu_kernel void @flat_singlethread_one_as_acq_rel_acquire_cmpxchg(
14654 ; GFX7-LABEL: flat_singlethread_one_as_acq_rel_acquire_cmpxchg:
14655 ; GFX7: ; %bb.0: ; %entry
14656 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
14657 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
14658 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
14659 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
14660 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
14661 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
14662 ; GFX7-NEXT: s_mov_b32 s4, s8
14663 ; GFX7-NEXT: s_mov_b32 s5, s9
14664 ; GFX7-NEXT: s_mov_b32 s9, s10
14665 ; GFX7-NEXT: s_mov_b32 s8, s11
14666 ; GFX7-NEXT: s_add_u32 s4, s4, s9
14667 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
14668 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
14669 ; GFX7-NEXT: s_mov_b32 s5, s8
14670 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
14671 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
14672 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14673 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
14674 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
14675 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
14676 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
14677 ; GFX7-NEXT: s_endpgm
14679 ; GFX10-WGP-LABEL: flat_singlethread_one_as_acq_rel_acquire_cmpxchg:
14680 ; GFX10-WGP: ; %bb.0: ; %entry
14681 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
14682 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
14683 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
14684 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
14685 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
14686 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
14687 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
14688 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
14689 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
14690 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
14691 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
14692 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
14693 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
14694 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
14695 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
14696 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
14697 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14698 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
14699 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
14700 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
14701 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
14702 ; GFX10-WGP-NEXT: s_endpgm
14704 ; GFX10-CU-LABEL: flat_singlethread_one_as_acq_rel_acquire_cmpxchg:
14705 ; GFX10-CU: ; %bb.0: ; %entry
14706 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
14707 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
14708 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
14709 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
14710 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
14711 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
14712 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
14713 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
14714 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
14715 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
14716 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
14717 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
14718 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
14719 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
14720 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
14721 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
14722 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14723 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
14724 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
14725 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
14726 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
14727 ; GFX10-CU-NEXT: s_endpgm
14729 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_acq_rel_acquire_cmpxchg:
14730 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
14731 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
14732 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
14733 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
14734 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
14735 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
14736 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
14737 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
14738 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
14739 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
14740 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
14741 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
14742 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
14743 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
14744 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
14745 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
14746 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
14747 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14748 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
14749 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
14750 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
14751 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
14752 ; SKIP-CACHE-INV-NEXT: s_endpgm
14754 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_acquire_cmpxchg:
14755 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
14756 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
14757 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
14758 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
14759 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
14760 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14761 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
14762 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
14763 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14764 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
14765 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
14766 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
14767 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
14769 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_acquire_cmpxchg:
14770 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
14771 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
14772 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
14773 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
14774 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
14775 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14776 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
14777 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
14778 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14779 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
14780 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
14781 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
14782 ; GFX90A-TGSPLIT-NEXT: s_endpgm
14784 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_acquire_cmpxchg:
14785 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
14786 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
14787 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
14788 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
14789 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
14790 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14791 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
14792 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
14793 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14794 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
14795 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
14796 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
14797 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
14799 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_acquire_cmpxchg:
14800 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
14801 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
14802 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
14803 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
14804 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
14805 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14806 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
14807 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
14808 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14809 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
14810 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
14811 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
14812 ; GFX940-TGSPLIT-NEXT: s_endpgm
14814 ; GFX11-WGP-LABEL: flat_singlethread_one_as_acq_rel_acquire_cmpxchg:
14815 ; GFX11-WGP: ; %bb.0: ; %entry
14816 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
14817 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14818 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
14819 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
14820 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
14821 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
14822 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
14823 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14824 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
14825 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
14826 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
14827 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
14828 ; GFX11-WGP-NEXT: s_endpgm
14830 ; GFX11-CU-LABEL: flat_singlethread_one_as_acq_rel_acquire_cmpxchg:
14831 ; GFX11-CU: ; %bb.0: ; %entry
14832 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
14833 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14834 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
14835 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
14836 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
14837 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
14838 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
14839 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14840 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
14841 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
14842 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
14843 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
14844 ; GFX11-CU-NEXT: s_endpgm
14846 ; GFX12-WGP-LABEL: flat_singlethread_one_as_acq_rel_acquire_cmpxchg:
14847 ; GFX12-WGP: ; %bb.0: ; %entry
14848 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
14849 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14850 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
14851 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
14852 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
14853 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
14854 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
14855 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14856 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
14857 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
14858 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
14859 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
14860 ; GFX12-WGP-NEXT: s_endpgm
14862 ; GFX12-CU-LABEL: flat_singlethread_one_as_acq_rel_acquire_cmpxchg:
14863 ; GFX12-CU: ; %bb.0: ; %entry
14864 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
14865 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14866 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
14867 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
14868 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
14869 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
14870 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
14871 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14872 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
14873 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
14874 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
14875 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
14876 ; GFX12-CU-NEXT: s_endpgm
14877 ptr %out, i32 %in, i32 %old) {
14879 %gep = getelementptr i32, ptr %out, i32 4
14880 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") acq_rel acquire
14884 define amdgpu_kernel void @flat_singlethread_one_as_seq_cst_acquire_cmpxchg(
14885 ; GFX7-LABEL: flat_singlethread_one_as_seq_cst_acquire_cmpxchg:
14886 ; GFX7: ; %bb.0: ; %entry
14887 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
14888 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
14889 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
14890 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
14891 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
14892 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
14893 ; GFX7-NEXT: s_mov_b32 s4, s8
14894 ; GFX7-NEXT: s_mov_b32 s5, s9
14895 ; GFX7-NEXT: s_mov_b32 s9, s10
14896 ; GFX7-NEXT: s_mov_b32 s8, s11
14897 ; GFX7-NEXT: s_add_u32 s4, s4, s9
14898 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
14899 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
14900 ; GFX7-NEXT: s_mov_b32 s5, s8
14901 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
14902 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
14903 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14904 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
14905 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
14906 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
14907 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
14908 ; GFX7-NEXT: s_endpgm
14910 ; GFX10-WGP-LABEL: flat_singlethread_one_as_seq_cst_acquire_cmpxchg:
14911 ; GFX10-WGP: ; %bb.0: ; %entry
14912 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
14913 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
14914 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
14915 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
14916 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
14917 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
14918 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
14919 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
14920 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
14921 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
14922 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
14923 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
14924 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
14925 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
14926 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
14927 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
14928 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14929 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
14930 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
14931 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
14932 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
14933 ; GFX10-WGP-NEXT: s_endpgm
14935 ; GFX10-CU-LABEL: flat_singlethread_one_as_seq_cst_acquire_cmpxchg:
14936 ; GFX10-CU: ; %bb.0: ; %entry
14937 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
14938 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
14939 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
14940 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
14941 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
14942 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
14943 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
14944 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
14945 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
14946 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
14947 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
14948 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
14949 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
14950 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
14951 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
14952 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
14953 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14954 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
14955 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
14956 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
14957 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
14958 ; GFX10-CU-NEXT: s_endpgm
14960 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_seq_cst_acquire_cmpxchg:
14961 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
14962 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
14963 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
14964 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
14965 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
14966 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
14967 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
14968 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
14969 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
14970 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
14971 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
14972 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
14973 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
14974 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
14975 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
14976 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
14977 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
14978 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14979 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
14980 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
14981 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
14982 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
14983 ; SKIP-CACHE-INV-NEXT: s_endpgm
14985 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_acquire_cmpxchg:
14986 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
14987 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
14988 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
14989 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
14990 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
14991 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14992 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
14993 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
14994 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14995 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
14996 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
14997 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
14998 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
15000 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_acquire_cmpxchg:
15001 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
15002 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
15003 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
15004 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
15005 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
15006 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15007 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
15008 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
15009 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15010 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
15011 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
15012 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
15013 ; GFX90A-TGSPLIT-NEXT: s_endpgm
15015 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_acquire_cmpxchg:
15016 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
15017 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
15018 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
15019 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
15020 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
15021 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15022 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
15023 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
15024 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15025 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
15026 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
15027 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
15028 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
15030 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_acquire_cmpxchg:
15031 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
15032 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
15033 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
15034 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
15035 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
15036 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15037 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
15038 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
15039 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15040 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
15041 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
15042 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
15043 ; GFX940-TGSPLIT-NEXT: s_endpgm
15045 ; GFX11-WGP-LABEL: flat_singlethread_one_as_seq_cst_acquire_cmpxchg:
15046 ; GFX11-WGP: ; %bb.0: ; %entry
15047 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
15048 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15049 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
15050 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
15051 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
15052 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
15053 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
15054 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15055 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
15056 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
15057 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
15058 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
15059 ; GFX11-WGP-NEXT: s_endpgm
15061 ; GFX11-CU-LABEL: flat_singlethread_one_as_seq_cst_acquire_cmpxchg:
15062 ; GFX11-CU: ; %bb.0: ; %entry
15063 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
15064 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15065 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
15066 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
15067 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
15068 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
15069 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
15070 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15071 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
15072 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
15073 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
15074 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
15075 ; GFX11-CU-NEXT: s_endpgm
15077 ; GFX12-WGP-LABEL: flat_singlethread_one_as_seq_cst_acquire_cmpxchg:
15078 ; GFX12-WGP: ; %bb.0: ; %entry
15079 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
15080 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15081 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
15082 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
15083 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
15084 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
15085 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
15086 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15087 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
15088 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
15089 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
15090 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
15091 ; GFX12-WGP-NEXT: s_endpgm
15093 ; GFX12-CU-LABEL: flat_singlethread_one_as_seq_cst_acquire_cmpxchg:
15094 ; GFX12-CU: ; %bb.0: ; %entry
15095 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
15096 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15097 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
15098 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
15099 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
15100 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
15101 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
15102 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15103 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
15104 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
15105 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
15106 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
15107 ; GFX12-CU-NEXT: s_endpgm
15108 ptr %out, i32 %in, i32 %old) {
15110 %gep = getelementptr i32, ptr %out, i32 4
15111 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") seq_cst acquire
15115 define amdgpu_kernel void @flat_singlethread_one_as_monotonic_seq_cst_cmpxchg(
15116 ; GFX7-LABEL: flat_singlethread_one_as_monotonic_seq_cst_cmpxchg:
15117 ; GFX7: ; %bb.0: ; %entry
15118 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
15119 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
15120 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
15121 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
15122 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
15123 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
15124 ; GFX7-NEXT: s_mov_b32 s4, s8
15125 ; GFX7-NEXT: s_mov_b32 s5, s9
15126 ; GFX7-NEXT: s_mov_b32 s9, s10
15127 ; GFX7-NEXT: s_mov_b32 s8, s11
15128 ; GFX7-NEXT: s_add_u32 s4, s4, s9
15129 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
15130 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
15131 ; GFX7-NEXT: s_mov_b32 s5, s8
15132 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
15133 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
15134 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15135 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
15136 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
15137 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
15138 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
15139 ; GFX7-NEXT: s_endpgm
15141 ; GFX10-WGP-LABEL: flat_singlethread_one_as_monotonic_seq_cst_cmpxchg:
15142 ; GFX10-WGP: ; %bb.0: ; %entry
15143 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
15144 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
15145 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
15146 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
15147 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
15148 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
15149 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
15150 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
15151 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
15152 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
15153 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
15154 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
15155 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
15156 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
15157 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
15158 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
15159 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15160 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
15161 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
15162 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
15163 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
15164 ; GFX10-WGP-NEXT: s_endpgm
15166 ; GFX10-CU-LABEL: flat_singlethread_one_as_monotonic_seq_cst_cmpxchg:
15167 ; GFX10-CU: ; %bb.0: ; %entry
15168 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
15169 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
15170 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
15171 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
15172 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
15173 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
15174 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
15175 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
15176 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
15177 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
15178 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
15179 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
15180 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
15181 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
15182 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
15183 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
15184 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15185 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
15186 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
15187 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
15188 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
15189 ; GFX10-CU-NEXT: s_endpgm
15191 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_monotonic_seq_cst_cmpxchg:
15192 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
15193 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
15194 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
15195 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
15196 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
15197 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
15198 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
15199 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
15200 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
15201 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
15202 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
15203 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
15204 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
15205 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
15206 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
15207 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
15208 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
15209 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15210 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
15211 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
15212 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
15213 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
15214 ; SKIP-CACHE-INV-NEXT: s_endpgm
15216 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_monotonic_seq_cst_cmpxchg:
15217 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
15218 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
15219 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
15220 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
15221 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
15222 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15223 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
15224 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
15225 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15226 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
15227 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
15228 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
15229 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
15231 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_monotonic_seq_cst_cmpxchg:
15232 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
15233 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
15234 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
15235 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
15236 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
15237 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15238 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
15239 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
15240 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15241 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
15242 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
15243 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
15244 ; GFX90A-TGSPLIT-NEXT: s_endpgm
15246 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_monotonic_seq_cst_cmpxchg:
15247 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
15248 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
15249 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
15250 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
15251 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
15252 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15253 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
15254 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
15255 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15256 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
15257 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
15258 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
15259 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
15261 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_monotonic_seq_cst_cmpxchg:
15262 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
15263 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
15264 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
15265 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
15266 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
15267 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15268 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
15269 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
15270 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15271 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
15272 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
15273 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
15274 ; GFX940-TGSPLIT-NEXT: s_endpgm
15276 ; GFX11-WGP-LABEL: flat_singlethread_one_as_monotonic_seq_cst_cmpxchg:
15277 ; GFX11-WGP: ; %bb.0: ; %entry
15278 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
15279 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15280 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
15281 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
15282 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
15283 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
15284 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
15285 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15286 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
15287 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
15288 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
15289 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
15290 ; GFX11-WGP-NEXT: s_endpgm
15292 ; GFX11-CU-LABEL: flat_singlethread_one_as_monotonic_seq_cst_cmpxchg:
15293 ; GFX11-CU: ; %bb.0: ; %entry
15294 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
15295 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15296 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
15297 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
15298 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
15299 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
15300 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
15301 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15302 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
15303 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
15304 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
15305 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
15306 ; GFX11-CU-NEXT: s_endpgm
15308 ; GFX12-WGP-LABEL: flat_singlethread_one_as_monotonic_seq_cst_cmpxchg:
15309 ; GFX12-WGP: ; %bb.0: ; %entry
15310 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
15311 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15312 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
15313 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
15314 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
15315 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
15316 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
15317 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15318 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
15319 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
15320 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
15321 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
15322 ; GFX12-WGP-NEXT: s_endpgm
15324 ; GFX12-CU-LABEL: flat_singlethread_one_as_monotonic_seq_cst_cmpxchg:
15325 ; GFX12-CU: ; %bb.0: ; %entry
15326 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
15327 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15328 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
15329 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
15330 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
15331 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
15332 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
15333 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15334 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
15335 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
15336 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
15337 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
15338 ; GFX12-CU-NEXT: s_endpgm
15339 ptr %out, i32 %in, i32 %old) {
15341 %gep = getelementptr i32, ptr %out, i32 4
15342 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") monotonic seq_cst
15346 define amdgpu_kernel void @flat_singlethread_one_as_acquire_seq_cst_cmpxchg(
15347 ; GFX7-LABEL: flat_singlethread_one_as_acquire_seq_cst_cmpxchg:
15348 ; GFX7: ; %bb.0: ; %entry
15349 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
15350 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
15351 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
15352 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
15353 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
15354 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
15355 ; GFX7-NEXT: s_mov_b32 s4, s8
15356 ; GFX7-NEXT: s_mov_b32 s5, s9
15357 ; GFX7-NEXT: s_mov_b32 s9, s10
15358 ; GFX7-NEXT: s_mov_b32 s8, s11
15359 ; GFX7-NEXT: s_add_u32 s4, s4, s9
15360 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
15361 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
15362 ; GFX7-NEXT: s_mov_b32 s5, s8
15363 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
15364 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
15365 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15366 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
15367 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
15368 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
15369 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
15370 ; GFX7-NEXT: s_endpgm
15372 ; GFX10-WGP-LABEL: flat_singlethread_one_as_acquire_seq_cst_cmpxchg:
15373 ; GFX10-WGP: ; %bb.0: ; %entry
15374 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
15375 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
15376 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
15377 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
15378 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
15379 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
15380 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
15381 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
15382 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
15383 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
15384 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
15385 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
15386 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
15387 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
15388 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
15389 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
15390 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15391 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
15392 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
15393 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
15394 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
15395 ; GFX10-WGP-NEXT: s_endpgm
15397 ; GFX10-CU-LABEL: flat_singlethread_one_as_acquire_seq_cst_cmpxchg:
15398 ; GFX10-CU: ; %bb.0: ; %entry
15399 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
15400 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
15401 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
15402 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
15403 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
15404 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
15405 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
15406 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
15407 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
15408 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
15409 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
15410 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
15411 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
15412 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
15413 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
15414 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
15415 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15416 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
15417 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
15418 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
15419 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
15420 ; GFX10-CU-NEXT: s_endpgm
15422 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_acquire_seq_cst_cmpxchg:
15423 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
15424 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
15425 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
15426 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
15427 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
15428 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
15429 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
15430 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
15431 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
15432 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
15433 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
15434 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
15435 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
15436 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
15437 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
15438 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
15439 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
15440 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15441 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
15442 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
15443 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
15444 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
15445 ; SKIP-CACHE-INV-NEXT: s_endpgm
15447 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acquire_seq_cst_cmpxchg:
15448 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
15449 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
15450 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
15451 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
15452 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
15453 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15454 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
15455 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
15456 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15457 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
15458 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
15459 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
15460 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
15462 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_acquire_seq_cst_cmpxchg:
15463 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
15464 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
15465 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
15466 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
15467 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
15468 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15469 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
15470 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
15471 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15472 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
15473 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
15474 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
15475 ; GFX90A-TGSPLIT-NEXT: s_endpgm
15477 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acquire_seq_cst_cmpxchg:
15478 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
15479 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
15480 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
15481 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
15482 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
15483 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15484 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
15485 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
15486 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15487 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
15488 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
15489 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
15490 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
15492 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_acquire_seq_cst_cmpxchg:
15493 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
15494 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
15495 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
15496 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
15497 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
15498 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15499 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
15500 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
15501 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15502 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
15503 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
15504 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
15505 ; GFX940-TGSPLIT-NEXT: s_endpgm
15507 ; GFX11-WGP-LABEL: flat_singlethread_one_as_acquire_seq_cst_cmpxchg:
15508 ; GFX11-WGP: ; %bb.0: ; %entry
15509 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
15510 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15511 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
15512 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
15513 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
15514 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
15515 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
15516 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15517 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
15518 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
15519 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
15520 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
15521 ; GFX11-WGP-NEXT: s_endpgm
15523 ; GFX11-CU-LABEL: flat_singlethread_one_as_acquire_seq_cst_cmpxchg:
15524 ; GFX11-CU: ; %bb.0: ; %entry
15525 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
15526 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15527 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
15528 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
15529 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
15530 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
15531 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
15532 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15533 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
15534 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
15535 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
15536 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
15537 ; GFX11-CU-NEXT: s_endpgm
15539 ; GFX12-WGP-LABEL: flat_singlethread_one_as_acquire_seq_cst_cmpxchg:
15540 ; GFX12-WGP: ; %bb.0: ; %entry
15541 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
15542 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15543 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
15544 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
15545 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
15546 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
15547 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
15548 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15549 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
15550 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
15551 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
15552 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
15553 ; GFX12-WGP-NEXT: s_endpgm
15555 ; GFX12-CU-LABEL: flat_singlethread_one_as_acquire_seq_cst_cmpxchg:
15556 ; GFX12-CU: ; %bb.0: ; %entry
15557 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
15558 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15559 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
15560 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
15561 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
15562 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
15563 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
15564 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15565 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
15566 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
15567 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
15568 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
15569 ; GFX12-CU-NEXT: s_endpgm
15570 ptr %out, i32 %in, i32 %old) {
15572 %gep = getelementptr i32, ptr %out, i32 4
15573 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") acquire seq_cst
15577 define amdgpu_kernel void @flat_singlethread_one_as_release_seq_cst_cmpxchg(
15578 ; GFX7-LABEL: flat_singlethread_one_as_release_seq_cst_cmpxchg:
15579 ; GFX7: ; %bb.0: ; %entry
15580 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
15581 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
15582 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
15583 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
15584 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
15585 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
15586 ; GFX7-NEXT: s_mov_b32 s4, s8
15587 ; GFX7-NEXT: s_mov_b32 s5, s9
15588 ; GFX7-NEXT: s_mov_b32 s9, s10
15589 ; GFX7-NEXT: s_mov_b32 s8, s11
15590 ; GFX7-NEXT: s_add_u32 s4, s4, s9
15591 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
15592 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
15593 ; GFX7-NEXT: s_mov_b32 s5, s8
15594 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
15595 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
15596 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15597 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
15598 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
15599 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
15600 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
15601 ; GFX7-NEXT: s_endpgm
15603 ; GFX10-WGP-LABEL: flat_singlethread_one_as_release_seq_cst_cmpxchg:
15604 ; GFX10-WGP: ; %bb.0: ; %entry
15605 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
15606 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
15607 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
15608 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
15609 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
15610 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
15611 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
15612 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
15613 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
15614 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
15615 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
15616 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
15617 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
15618 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
15619 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
15620 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
15621 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15622 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
15623 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
15624 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
15625 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
15626 ; GFX10-WGP-NEXT: s_endpgm
15628 ; GFX10-CU-LABEL: flat_singlethread_one_as_release_seq_cst_cmpxchg:
15629 ; GFX10-CU: ; %bb.0: ; %entry
15630 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
15631 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
15632 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
15633 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
15634 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
15635 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
15636 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
15637 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
15638 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
15639 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
15640 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
15641 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
15642 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
15643 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
15644 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
15645 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
15646 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15647 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
15648 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
15649 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
15650 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
15651 ; GFX10-CU-NEXT: s_endpgm
15653 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_release_seq_cst_cmpxchg:
15654 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
15655 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
15656 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
15657 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
15658 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
15659 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
15660 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
15661 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
15662 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
15663 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
15664 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
15665 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
15666 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
15667 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
15668 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
15669 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
15670 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
15671 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15672 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
15673 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
15674 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
15675 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
15676 ; SKIP-CACHE-INV-NEXT: s_endpgm
15678 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_release_seq_cst_cmpxchg:
15679 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
15680 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
15681 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
15682 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
15683 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
15684 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15685 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
15686 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
15687 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15688 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
15689 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
15690 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
15691 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
15693 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_release_seq_cst_cmpxchg:
15694 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
15695 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
15696 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
15697 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
15698 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
15699 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15700 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
15701 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
15702 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15703 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
15704 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
15705 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
15706 ; GFX90A-TGSPLIT-NEXT: s_endpgm
15708 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_release_seq_cst_cmpxchg:
15709 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
15710 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
15711 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
15712 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
15713 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
15714 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15715 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
15716 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
15717 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15718 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
15719 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
15720 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
15721 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
15723 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_release_seq_cst_cmpxchg:
15724 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
15725 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
15726 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
15727 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
15728 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
15729 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15730 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
15731 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
15732 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15733 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
15734 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
15735 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
15736 ; GFX940-TGSPLIT-NEXT: s_endpgm
15738 ; GFX11-WGP-LABEL: flat_singlethread_one_as_release_seq_cst_cmpxchg:
15739 ; GFX11-WGP: ; %bb.0: ; %entry
15740 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
15741 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15742 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
15743 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
15744 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
15745 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
15746 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
15747 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15748 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
15749 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
15750 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
15751 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
15752 ; GFX11-WGP-NEXT: s_endpgm
15754 ; GFX11-CU-LABEL: flat_singlethread_one_as_release_seq_cst_cmpxchg:
15755 ; GFX11-CU: ; %bb.0: ; %entry
15756 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
15757 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15758 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
15759 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
15760 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
15761 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
15762 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
15763 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15764 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
15765 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
15766 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
15767 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
15768 ; GFX11-CU-NEXT: s_endpgm
15770 ; GFX12-WGP-LABEL: flat_singlethread_one_as_release_seq_cst_cmpxchg:
15771 ; GFX12-WGP: ; %bb.0: ; %entry
15772 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
15773 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15774 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
15775 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
15776 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
15777 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
15778 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
15779 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15780 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
15781 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
15782 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
15783 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
15784 ; GFX12-WGP-NEXT: s_endpgm
15786 ; GFX12-CU-LABEL: flat_singlethread_one_as_release_seq_cst_cmpxchg:
15787 ; GFX12-CU: ; %bb.0: ; %entry
15788 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
15789 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15790 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
15791 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
15792 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
15793 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
15794 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
15795 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15796 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
15797 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
15798 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
15799 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
15800 ; GFX12-CU-NEXT: s_endpgm
15801 ptr %out, i32 %in, i32 %old) {
15803 %gep = getelementptr i32, ptr %out, i32 4
15804 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") release seq_cst
15808 define amdgpu_kernel void @flat_singlethread_one_as_acq_rel_seq_cst_cmpxchg(
15809 ; GFX7-LABEL: flat_singlethread_one_as_acq_rel_seq_cst_cmpxchg:
15810 ; GFX7: ; %bb.0: ; %entry
15811 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
15812 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
15813 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
15814 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
15815 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
15816 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
15817 ; GFX7-NEXT: s_mov_b32 s4, s8
15818 ; GFX7-NEXT: s_mov_b32 s5, s9
15819 ; GFX7-NEXT: s_mov_b32 s9, s10
15820 ; GFX7-NEXT: s_mov_b32 s8, s11
15821 ; GFX7-NEXT: s_add_u32 s4, s4, s9
15822 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
15823 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
15824 ; GFX7-NEXT: s_mov_b32 s5, s8
15825 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
15826 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
15827 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15828 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
15829 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
15830 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
15831 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
15832 ; GFX7-NEXT: s_endpgm
15834 ; GFX10-WGP-LABEL: flat_singlethread_one_as_acq_rel_seq_cst_cmpxchg:
15835 ; GFX10-WGP: ; %bb.0: ; %entry
15836 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
15837 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
15838 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
15839 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
15840 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
15841 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
15842 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
15843 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
15844 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
15845 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
15846 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
15847 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
15848 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
15849 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
15850 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
15851 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
15852 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15853 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
15854 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
15855 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
15856 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
15857 ; GFX10-WGP-NEXT: s_endpgm
15859 ; GFX10-CU-LABEL: flat_singlethread_one_as_acq_rel_seq_cst_cmpxchg:
15860 ; GFX10-CU: ; %bb.0: ; %entry
15861 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
15862 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
15863 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
15864 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
15865 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
15866 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
15867 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
15868 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
15869 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
15870 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
15871 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
15872 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
15873 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
15874 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
15875 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
15876 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
15877 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15878 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
15879 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
15880 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
15881 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
15882 ; GFX10-CU-NEXT: s_endpgm
15884 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_acq_rel_seq_cst_cmpxchg:
15885 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
15886 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
15887 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
15888 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
15889 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
15890 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
15891 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
15892 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
15893 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
15894 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
15895 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
15896 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
15897 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
15898 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
15899 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
15900 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
15901 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
15902 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15903 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
15904 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
15905 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
15906 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
15907 ; SKIP-CACHE-INV-NEXT: s_endpgm
15909 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_seq_cst_cmpxchg:
15910 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
15911 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
15912 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
15913 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
15914 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
15915 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15916 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
15917 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
15918 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15919 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
15920 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
15921 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
15922 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
15924 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_seq_cst_cmpxchg:
15925 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
15926 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
15927 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
15928 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
15929 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
15930 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15931 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
15932 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
15933 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15934 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
15935 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
15936 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
15937 ; GFX90A-TGSPLIT-NEXT: s_endpgm
15939 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_seq_cst_cmpxchg:
15940 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
15941 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
15942 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
15943 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
15944 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
15945 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15946 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
15947 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
15948 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15949 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
15950 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
15951 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
15952 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
15954 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_seq_cst_cmpxchg:
15955 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
15956 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
15957 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
15958 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
15959 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
15960 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15961 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
15962 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
15963 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15964 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
15965 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
15966 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
15967 ; GFX940-TGSPLIT-NEXT: s_endpgm
15969 ; GFX11-WGP-LABEL: flat_singlethread_one_as_acq_rel_seq_cst_cmpxchg:
15970 ; GFX11-WGP: ; %bb.0: ; %entry
15971 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
15972 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15973 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
15974 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
15975 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
15976 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
15977 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
15978 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15979 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
15980 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
15981 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
15982 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
15983 ; GFX11-WGP-NEXT: s_endpgm
15985 ; GFX11-CU-LABEL: flat_singlethread_one_as_acq_rel_seq_cst_cmpxchg:
15986 ; GFX11-CU: ; %bb.0: ; %entry
15987 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
15988 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15989 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
15990 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
15991 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
15992 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
15993 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
15994 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15995 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
15996 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
15997 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
15998 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
15999 ; GFX11-CU-NEXT: s_endpgm
16001 ; GFX12-WGP-LABEL: flat_singlethread_one_as_acq_rel_seq_cst_cmpxchg:
16002 ; GFX12-WGP: ; %bb.0: ; %entry
16003 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
16004 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16005 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
16006 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
16007 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
16008 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
16009 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
16010 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16011 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
16012 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
16013 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
16014 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
16015 ; GFX12-WGP-NEXT: s_endpgm
16017 ; GFX12-CU-LABEL: flat_singlethread_one_as_acq_rel_seq_cst_cmpxchg:
16018 ; GFX12-CU: ; %bb.0: ; %entry
16019 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
16020 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16021 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
16022 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
16023 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
16024 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
16025 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
16026 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16027 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
16028 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
16029 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
16030 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
16031 ; GFX12-CU-NEXT: s_endpgm
16032 ptr %out, i32 %in, i32 %old) {
16034 %gep = getelementptr i32, ptr %out, i32 4
16035 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") acq_rel seq_cst
16039 define amdgpu_kernel void @flat_singlethread_one_as_seq_cst_seq_cst_cmpxchg(
16040 ; GFX7-LABEL: flat_singlethread_one_as_seq_cst_seq_cst_cmpxchg:
16041 ; GFX7: ; %bb.0: ; %entry
16042 ; GFX7-NEXT: s_mov_b64 s[4:5], s[6:7]
16043 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
16044 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
16045 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
16046 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
16047 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
16048 ; GFX7-NEXT: s_mov_b32 s4, s8
16049 ; GFX7-NEXT: s_mov_b32 s5, s9
16050 ; GFX7-NEXT: s_mov_b32 s9, s10
16051 ; GFX7-NEXT: s_mov_b32 s8, s11
16052 ; GFX7-NEXT: s_add_u32 s4, s4, s9
16053 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
16054 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
16055 ; GFX7-NEXT: s_mov_b32 s5, s8
16056 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
16057 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
16058 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16059 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
16060 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
16061 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
16062 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
16063 ; GFX7-NEXT: s_endpgm
16065 ; GFX10-WGP-LABEL: flat_singlethread_one_as_seq_cst_seq_cst_cmpxchg:
16066 ; GFX10-WGP: ; %bb.0: ; %entry
16067 ; GFX10-WGP-NEXT: s_mov_b64 s[4:5], s[6:7]
16068 ; GFX10-WGP-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
16069 ; GFX10-WGP-NEXT: s_load_dword s7, s[4:5], 0x8
16070 ; GFX10-WGP-NEXT: s_load_dword s6, s[4:5], 0xc
16071 ; GFX10-WGP-NEXT: s_mov_b64 s[10:11], 16
16072 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
16073 ; GFX10-WGP-NEXT: s_mov_b32 s4, s8
16074 ; GFX10-WGP-NEXT: s_mov_b32 s5, s9
16075 ; GFX10-WGP-NEXT: s_mov_b32 s9, s10
16076 ; GFX10-WGP-NEXT: s_mov_b32 s8, s11
16077 ; GFX10-WGP-NEXT: s_add_u32 s4, s4, s9
16078 ; GFX10-WGP-NEXT: s_addc_u32 s8, s5, s8
16079 ; GFX10-WGP-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
16080 ; GFX10-WGP-NEXT: s_mov_b32 s5, s8
16081 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s7
16082 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
16083 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16084 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
16085 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
16086 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
16087 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
16088 ; GFX10-WGP-NEXT: s_endpgm
16090 ; GFX10-CU-LABEL: flat_singlethread_one_as_seq_cst_seq_cst_cmpxchg:
16091 ; GFX10-CU: ; %bb.0: ; %entry
16092 ; GFX10-CU-NEXT: s_mov_b64 s[4:5], s[6:7]
16093 ; GFX10-CU-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
16094 ; GFX10-CU-NEXT: s_load_dword s7, s[4:5], 0x8
16095 ; GFX10-CU-NEXT: s_load_dword s6, s[4:5], 0xc
16096 ; GFX10-CU-NEXT: s_mov_b64 s[10:11], 16
16097 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
16098 ; GFX10-CU-NEXT: s_mov_b32 s4, s8
16099 ; GFX10-CU-NEXT: s_mov_b32 s5, s9
16100 ; GFX10-CU-NEXT: s_mov_b32 s9, s10
16101 ; GFX10-CU-NEXT: s_mov_b32 s8, s11
16102 ; GFX10-CU-NEXT: s_add_u32 s4, s4, s9
16103 ; GFX10-CU-NEXT: s_addc_u32 s8, s5, s8
16104 ; GFX10-CU-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
16105 ; GFX10-CU-NEXT: s_mov_b32 s5, s8
16106 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s7
16107 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
16108 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16109 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
16110 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
16111 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
16112 ; GFX10-CU-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
16113 ; GFX10-CU-NEXT: s_endpgm
16115 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_seq_cst_seq_cst_cmpxchg:
16116 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
16117 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[2:3]
16118 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
16119 ; SKIP-CACHE-INV-NEXT: s_load_dword s3, s[0:1], 0x2
16120 ; SKIP-CACHE-INV-NEXT: s_load_dword s2, s[0:1], 0x3
16121 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[6:7], 16
16122 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
16123 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s0, s4
16124 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s5
16125 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s6
16126 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s4, s7
16127 ; SKIP-CACHE-INV-NEXT: s_add_u32 s0, s0, s5
16128 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s4, s1, s4
16129 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1
16130 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s4
16131 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s3
16132 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
16133 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16134 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
16135 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
16136 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
16137 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
16138 ; SKIP-CACHE-INV-NEXT: s_endpgm
16140 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_seq_cst_cmpxchg:
16141 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
16142 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
16143 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
16144 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
16145 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
16146 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16147 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
16148 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
16149 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16150 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
16151 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
16152 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
16153 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
16155 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_seq_cst_cmpxchg:
16156 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
16157 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
16158 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
16159 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
16160 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
16161 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16162 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
16163 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
16164 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16165 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
16166 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
16167 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
16168 ; GFX90A-TGSPLIT-NEXT: s_endpgm
16170 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_seq_cst_cmpxchg:
16171 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
16172 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
16173 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
16174 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
16175 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
16176 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16177 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
16178 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
16179 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16180 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
16181 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
16182 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
16183 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
16185 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_seq_cst_cmpxchg:
16186 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
16187 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
16188 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
16189 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
16190 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
16191 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16192 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
16193 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
16194 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16195 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
16196 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
16197 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
16198 ; GFX940-TGSPLIT-NEXT: s_endpgm
16200 ; GFX11-WGP-LABEL: flat_singlethread_one_as_seq_cst_seq_cst_cmpxchg:
16201 ; GFX11-WGP: ; %bb.0: ; %entry
16202 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
16203 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16204 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
16205 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
16206 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
16207 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
16208 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
16209 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16210 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
16211 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
16212 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
16213 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
16214 ; GFX11-WGP-NEXT: s_endpgm
16216 ; GFX11-CU-LABEL: flat_singlethread_one_as_seq_cst_seq_cst_cmpxchg:
16217 ; GFX11-CU: ; %bb.0: ; %entry
16218 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
16219 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16220 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
16221 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
16222 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
16223 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
16224 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
16225 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16226 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
16227 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
16228 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
16229 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
16230 ; GFX11-CU-NEXT: s_endpgm
16232 ; GFX12-WGP-LABEL: flat_singlethread_one_as_seq_cst_seq_cst_cmpxchg:
16233 ; GFX12-WGP: ; %bb.0: ; %entry
16234 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
16235 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16236 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
16237 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
16238 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
16239 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
16240 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
16241 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16242 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
16243 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
16244 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
16245 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
16246 ; GFX12-WGP-NEXT: s_endpgm
16248 ; GFX12-CU-LABEL: flat_singlethread_one_as_seq_cst_seq_cst_cmpxchg:
16249 ; GFX12-CU: ; %bb.0: ; %entry
16250 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
16251 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16252 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
16253 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
16254 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
16255 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
16256 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
16257 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16258 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
16259 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
16260 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
16261 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v[0:1], v[2:3] offset:16
16262 ; GFX12-CU-NEXT: s_endpgm
16263 ptr %out, i32 %in, i32 %old) {
16265 %gep = getelementptr i32, ptr %out, i32 4
16266 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") seq_cst seq_cst
16270 define amdgpu_kernel void @flat_singlethread_one_as_monotonic_monotonic_ret_cmpxchg(
16271 ; GFX7-LABEL: flat_singlethread_one_as_monotonic_monotonic_ret_cmpxchg:
16272 ; GFX7: ; %bb.0: ; %entry
16273 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
16274 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
16275 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
16276 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
16277 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
16278 ; GFX7-NEXT: s_mov_b32 s6, s4
16279 ; GFX7-NEXT: s_mov_b32 s7, s5
16280 ; GFX7-NEXT: s_mov_b32 s11, s12
16281 ; GFX7-NEXT: s_mov_b32 s10, s13
16282 ; GFX7-NEXT: s_add_u32 s6, s6, s11
16283 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
16284 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
16285 ; GFX7-NEXT: s_mov_b32 s7, s10
16286 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
16287 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
16288 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16289 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
16290 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
16291 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
16292 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
16293 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
16294 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
16295 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
16296 ; GFX7-NEXT: flat_store_dword v[0:1], v2
16297 ; GFX7-NEXT: s_endpgm
16299 ; GFX10-WGP-LABEL: flat_singlethread_one_as_monotonic_monotonic_ret_cmpxchg:
16300 ; GFX10-WGP: ; %bb.0: ; %entry
16301 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
16302 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
16303 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
16304 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
16305 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
16306 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
16307 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
16308 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
16309 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
16310 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
16311 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
16312 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
16313 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
16314 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
16315 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
16316 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16317 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
16318 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
16319 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
16320 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
16321 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
16322 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
16323 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
16324 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
16325 ; GFX10-WGP-NEXT: s_endpgm
16327 ; GFX10-CU-LABEL: flat_singlethread_one_as_monotonic_monotonic_ret_cmpxchg:
16328 ; GFX10-CU: ; %bb.0: ; %entry
16329 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
16330 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
16331 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
16332 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
16333 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
16334 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
16335 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
16336 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
16337 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
16338 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
16339 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
16340 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
16341 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
16342 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
16343 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
16344 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16345 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
16346 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
16347 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
16348 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
16349 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
16350 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
16351 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
16352 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
16353 ; GFX10-CU-NEXT: s_endpgm
16355 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_monotonic_monotonic_ret_cmpxchg:
16356 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
16357 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
16358 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
16359 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
16360 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
16361 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
16362 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
16363 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
16364 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
16365 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
16366 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
16367 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
16368 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
16369 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
16370 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
16371 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
16372 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16373 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
16374 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
16375 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
16376 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
16377 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
16378 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
16379 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
16380 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
16381 ; SKIP-CACHE-INV-NEXT: s_endpgm
16383 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_monotonic_monotonic_ret_cmpxchg:
16384 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
16385 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
16386 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
16387 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
16388 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
16389 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16390 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
16391 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
16392 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16393 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
16394 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
16395 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
16396 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
16397 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
16398 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
16399 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
16401 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_monotonic_monotonic_ret_cmpxchg:
16402 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
16403 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
16404 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
16405 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
16406 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
16407 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16408 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
16409 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
16410 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16411 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
16412 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
16413 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
16414 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
16415 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
16416 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
16417 ; GFX90A-TGSPLIT-NEXT: s_endpgm
16419 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_monotonic_monotonic_ret_cmpxchg:
16420 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
16421 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
16422 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
16423 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
16424 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
16425 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16426 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
16427 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
16428 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16429 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
16430 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
16431 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
16432 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
16433 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
16434 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
16435 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
16437 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_monotonic_monotonic_ret_cmpxchg:
16438 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
16439 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
16440 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
16441 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
16442 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
16443 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16444 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
16445 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
16446 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16447 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
16448 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
16449 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
16450 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
16451 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
16452 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
16453 ; GFX940-TGSPLIT-NEXT: s_endpgm
16455 ; GFX11-WGP-LABEL: flat_singlethread_one_as_monotonic_monotonic_ret_cmpxchg:
16456 ; GFX11-WGP: ; %bb.0: ; %entry
16457 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
16458 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16459 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
16460 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
16461 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
16462 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
16463 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
16464 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16465 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
16466 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
16467 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
16468 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
16469 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
16470 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
16471 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
16472 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
16473 ; GFX11-WGP-NEXT: s_endpgm
16475 ; GFX11-CU-LABEL: flat_singlethread_one_as_monotonic_monotonic_ret_cmpxchg:
16476 ; GFX11-CU: ; %bb.0: ; %entry
16477 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
16478 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16479 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
16480 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
16481 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
16482 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
16483 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
16484 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16485 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
16486 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
16487 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
16488 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
16489 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
16490 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
16491 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
16492 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
16493 ; GFX11-CU-NEXT: s_endpgm
16495 ; GFX12-WGP-LABEL: flat_singlethread_one_as_monotonic_monotonic_ret_cmpxchg:
16496 ; GFX12-WGP: ; %bb.0: ; %entry
16497 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
16498 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16499 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
16500 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
16501 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
16502 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
16503 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
16504 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16505 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
16506 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
16507 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
16508 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
16509 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
16510 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
16511 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
16512 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
16513 ; GFX12-WGP-NEXT: s_endpgm
16515 ; GFX12-CU-LABEL: flat_singlethread_one_as_monotonic_monotonic_ret_cmpxchg:
16516 ; GFX12-CU: ; %bb.0: ; %entry
16517 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
16518 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16519 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
16520 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
16521 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
16522 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
16523 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
16524 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16525 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
16526 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
16527 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
16528 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
16529 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
16530 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
16531 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
16532 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
16533 ; GFX12-CU-NEXT: s_endpgm
16534 ptr %out, i32 %in, i32 %old) {
16536 %gep = getelementptr i32, ptr %out, i32 4
16537 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") monotonic monotonic
16538 %val0 = extractvalue { i32, i1 } %val, 0
16539 store i32 %val0, ptr %out, align 4
16543 define amdgpu_kernel void @flat_singlethread_one_as_acquire_monotonic_ret_cmpxchg(
16544 ; GFX7-LABEL: flat_singlethread_one_as_acquire_monotonic_ret_cmpxchg:
16545 ; GFX7: ; %bb.0: ; %entry
16546 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
16547 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
16548 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
16549 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
16550 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
16551 ; GFX7-NEXT: s_mov_b32 s6, s4
16552 ; GFX7-NEXT: s_mov_b32 s7, s5
16553 ; GFX7-NEXT: s_mov_b32 s11, s12
16554 ; GFX7-NEXT: s_mov_b32 s10, s13
16555 ; GFX7-NEXT: s_add_u32 s6, s6, s11
16556 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
16557 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
16558 ; GFX7-NEXT: s_mov_b32 s7, s10
16559 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
16560 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
16561 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16562 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
16563 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
16564 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
16565 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
16566 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
16567 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
16568 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
16569 ; GFX7-NEXT: flat_store_dword v[0:1], v2
16570 ; GFX7-NEXT: s_endpgm
16572 ; GFX10-WGP-LABEL: flat_singlethread_one_as_acquire_monotonic_ret_cmpxchg:
16573 ; GFX10-WGP: ; %bb.0: ; %entry
16574 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
16575 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
16576 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
16577 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
16578 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
16579 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
16580 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
16581 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
16582 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
16583 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
16584 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
16585 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
16586 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
16587 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
16588 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
16589 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16590 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
16591 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
16592 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
16593 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
16594 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
16595 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
16596 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
16597 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
16598 ; GFX10-WGP-NEXT: s_endpgm
16600 ; GFX10-CU-LABEL: flat_singlethread_one_as_acquire_monotonic_ret_cmpxchg:
16601 ; GFX10-CU: ; %bb.0: ; %entry
16602 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
16603 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
16604 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
16605 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
16606 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
16607 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
16608 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
16609 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
16610 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
16611 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
16612 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
16613 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
16614 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
16615 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
16616 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
16617 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16618 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
16619 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
16620 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
16621 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
16622 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
16623 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
16624 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
16625 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
16626 ; GFX10-CU-NEXT: s_endpgm
16628 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_acquire_monotonic_ret_cmpxchg:
16629 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
16630 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
16631 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
16632 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
16633 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
16634 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
16635 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
16636 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
16637 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
16638 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
16639 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
16640 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
16641 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
16642 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
16643 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
16644 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
16645 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16646 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
16647 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
16648 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
16649 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
16650 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
16651 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
16652 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
16653 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
16654 ; SKIP-CACHE-INV-NEXT: s_endpgm
16656 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acquire_monotonic_ret_cmpxchg:
16657 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
16658 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
16659 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
16660 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
16661 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
16662 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16663 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
16664 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
16665 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16666 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
16667 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
16668 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
16669 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
16670 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
16671 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
16672 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
16674 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_acquire_monotonic_ret_cmpxchg:
16675 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
16676 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
16677 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
16678 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
16679 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
16680 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16681 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
16682 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
16683 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16684 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
16685 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
16686 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
16687 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
16688 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
16689 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
16690 ; GFX90A-TGSPLIT-NEXT: s_endpgm
16692 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acquire_monotonic_ret_cmpxchg:
16693 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
16694 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
16695 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
16696 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
16697 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
16698 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16699 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
16700 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
16701 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16702 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
16703 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
16704 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
16705 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
16706 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
16707 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
16708 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
16710 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_acquire_monotonic_ret_cmpxchg:
16711 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
16712 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
16713 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
16714 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
16715 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
16716 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16717 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
16718 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
16719 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16720 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
16721 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
16722 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
16723 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
16724 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
16725 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
16726 ; GFX940-TGSPLIT-NEXT: s_endpgm
16728 ; GFX11-WGP-LABEL: flat_singlethread_one_as_acquire_monotonic_ret_cmpxchg:
16729 ; GFX11-WGP: ; %bb.0: ; %entry
16730 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
16731 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16732 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
16733 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
16734 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
16735 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
16736 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
16737 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16738 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
16739 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
16740 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
16741 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
16742 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
16743 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
16744 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
16745 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
16746 ; GFX11-WGP-NEXT: s_endpgm
16748 ; GFX11-CU-LABEL: flat_singlethread_one_as_acquire_monotonic_ret_cmpxchg:
16749 ; GFX11-CU: ; %bb.0: ; %entry
16750 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
16751 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16752 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
16753 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
16754 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
16755 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
16756 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
16757 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16758 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
16759 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
16760 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
16761 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
16762 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
16763 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
16764 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
16765 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
16766 ; GFX11-CU-NEXT: s_endpgm
16768 ; GFX12-WGP-LABEL: flat_singlethread_one_as_acquire_monotonic_ret_cmpxchg:
16769 ; GFX12-WGP: ; %bb.0: ; %entry
16770 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
16771 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16772 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
16773 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
16774 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
16775 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
16776 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
16777 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16778 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
16779 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
16780 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
16781 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
16782 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
16783 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
16784 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
16785 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
16786 ; GFX12-WGP-NEXT: s_endpgm
16788 ; GFX12-CU-LABEL: flat_singlethread_one_as_acquire_monotonic_ret_cmpxchg:
16789 ; GFX12-CU: ; %bb.0: ; %entry
16790 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
16791 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16792 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
16793 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
16794 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
16795 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
16796 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
16797 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16798 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
16799 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
16800 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
16801 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
16802 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
16803 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
16804 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
16805 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
16806 ; GFX12-CU-NEXT: s_endpgm
16807 ptr %out, i32 %in, i32 %old) {
16809 %gep = getelementptr i32, ptr %out, i32 4
16810 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") acquire monotonic
16811 %val0 = extractvalue { i32, i1 } %val, 0
16812 store i32 %val0, ptr %out, align 4
16816 define amdgpu_kernel void @flat_singlethread_one_as_release_monotonic_ret_cmpxchg(
16817 ; GFX7-LABEL: flat_singlethread_one_as_release_monotonic_ret_cmpxchg:
16818 ; GFX7: ; %bb.0: ; %entry
16819 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
16820 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
16821 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
16822 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
16823 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
16824 ; GFX7-NEXT: s_mov_b32 s6, s4
16825 ; GFX7-NEXT: s_mov_b32 s7, s5
16826 ; GFX7-NEXT: s_mov_b32 s11, s12
16827 ; GFX7-NEXT: s_mov_b32 s10, s13
16828 ; GFX7-NEXT: s_add_u32 s6, s6, s11
16829 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
16830 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
16831 ; GFX7-NEXT: s_mov_b32 s7, s10
16832 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
16833 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
16834 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16835 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
16836 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
16837 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
16838 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
16839 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
16840 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
16841 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
16842 ; GFX7-NEXT: flat_store_dword v[0:1], v2
16843 ; GFX7-NEXT: s_endpgm
16845 ; GFX10-WGP-LABEL: flat_singlethread_one_as_release_monotonic_ret_cmpxchg:
16846 ; GFX10-WGP: ; %bb.0: ; %entry
16847 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
16848 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
16849 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
16850 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
16851 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
16852 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
16853 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
16854 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
16855 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
16856 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
16857 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
16858 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
16859 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
16860 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
16861 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
16862 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16863 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
16864 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
16865 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
16866 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
16867 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
16868 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
16869 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
16870 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
16871 ; GFX10-WGP-NEXT: s_endpgm
16873 ; GFX10-CU-LABEL: flat_singlethread_one_as_release_monotonic_ret_cmpxchg:
16874 ; GFX10-CU: ; %bb.0: ; %entry
16875 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
16876 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
16877 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
16878 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
16879 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
16880 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
16881 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
16882 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
16883 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
16884 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
16885 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
16886 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
16887 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
16888 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
16889 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
16890 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16891 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
16892 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
16893 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
16894 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
16895 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
16896 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
16897 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
16898 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
16899 ; GFX10-CU-NEXT: s_endpgm
16901 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_release_monotonic_ret_cmpxchg:
16902 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
16903 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
16904 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
16905 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
16906 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
16907 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
16908 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
16909 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
16910 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
16911 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
16912 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
16913 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
16914 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
16915 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
16916 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
16917 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
16918 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16919 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
16920 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
16921 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
16922 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
16923 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
16924 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
16925 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
16926 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
16927 ; SKIP-CACHE-INV-NEXT: s_endpgm
16929 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_release_monotonic_ret_cmpxchg:
16930 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
16931 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
16932 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
16933 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
16934 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
16935 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16936 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
16937 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
16938 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16939 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
16940 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
16941 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
16942 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
16943 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
16944 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
16945 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
16947 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_release_monotonic_ret_cmpxchg:
16948 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
16949 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
16950 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
16951 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
16952 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
16953 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16954 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
16955 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
16956 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16957 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
16958 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
16959 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
16960 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
16961 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
16962 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
16963 ; GFX90A-TGSPLIT-NEXT: s_endpgm
16965 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_release_monotonic_ret_cmpxchg:
16966 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
16967 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
16968 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
16969 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
16970 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
16971 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16972 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
16973 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
16974 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16975 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
16976 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
16977 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
16978 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
16979 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
16980 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
16981 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
16983 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_release_monotonic_ret_cmpxchg:
16984 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
16985 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
16986 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
16987 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
16988 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
16989 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16990 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
16991 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
16992 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16993 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
16994 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
16995 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
16996 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
16997 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
16998 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
16999 ; GFX940-TGSPLIT-NEXT: s_endpgm
17001 ; GFX11-WGP-LABEL: flat_singlethread_one_as_release_monotonic_ret_cmpxchg:
17002 ; GFX11-WGP: ; %bb.0: ; %entry
17003 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
17004 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17005 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
17006 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
17007 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
17008 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
17009 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
17010 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17011 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
17012 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
17013 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
17014 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
17015 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
17016 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
17017 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17018 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
17019 ; GFX11-WGP-NEXT: s_endpgm
17021 ; GFX11-CU-LABEL: flat_singlethread_one_as_release_monotonic_ret_cmpxchg:
17022 ; GFX11-CU: ; %bb.0: ; %entry
17023 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
17024 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17025 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
17026 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
17027 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
17028 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
17029 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
17030 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17031 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
17032 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
17033 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
17034 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
17035 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
17036 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
17037 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17038 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
17039 ; GFX11-CU-NEXT: s_endpgm
17041 ; GFX12-WGP-LABEL: flat_singlethread_one_as_release_monotonic_ret_cmpxchg:
17042 ; GFX12-WGP: ; %bb.0: ; %entry
17043 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
17044 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17045 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
17046 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
17047 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
17048 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
17049 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
17050 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17051 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
17052 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
17053 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
17054 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
17055 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
17056 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
17057 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
17058 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
17059 ; GFX12-WGP-NEXT: s_endpgm
17061 ; GFX12-CU-LABEL: flat_singlethread_one_as_release_monotonic_ret_cmpxchg:
17062 ; GFX12-CU: ; %bb.0: ; %entry
17063 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
17064 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17065 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
17066 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
17067 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
17068 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
17069 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
17070 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17071 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
17072 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
17073 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
17074 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
17075 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
17076 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
17077 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
17078 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
17079 ; GFX12-CU-NEXT: s_endpgm
17080 ptr %out, i32 %in, i32 %old) {
17082 %gep = getelementptr i32, ptr %out, i32 4
17083 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") release monotonic
17084 %val0 = extractvalue { i32, i1 } %val, 0
17085 store i32 %val0, ptr %out, align 4
17089 define amdgpu_kernel void @flat_singlethread_one_as_acq_rel_monotonic_ret_cmpxchg(
17090 ; GFX7-LABEL: flat_singlethread_one_as_acq_rel_monotonic_ret_cmpxchg:
17091 ; GFX7: ; %bb.0: ; %entry
17092 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
17093 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
17094 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
17095 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
17096 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
17097 ; GFX7-NEXT: s_mov_b32 s6, s4
17098 ; GFX7-NEXT: s_mov_b32 s7, s5
17099 ; GFX7-NEXT: s_mov_b32 s11, s12
17100 ; GFX7-NEXT: s_mov_b32 s10, s13
17101 ; GFX7-NEXT: s_add_u32 s6, s6, s11
17102 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
17103 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
17104 ; GFX7-NEXT: s_mov_b32 s7, s10
17105 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
17106 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
17107 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17108 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
17109 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
17110 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
17111 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
17112 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
17113 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
17114 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17115 ; GFX7-NEXT: flat_store_dword v[0:1], v2
17116 ; GFX7-NEXT: s_endpgm
17118 ; GFX10-WGP-LABEL: flat_singlethread_one_as_acq_rel_monotonic_ret_cmpxchg:
17119 ; GFX10-WGP: ; %bb.0: ; %entry
17120 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
17121 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
17122 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
17123 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
17124 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
17125 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
17126 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
17127 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
17128 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
17129 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
17130 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
17131 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
17132 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
17133 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
17134 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
17135 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17136 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
17137 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
17138 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
17139 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
17140 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
17141 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
17142 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17143 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
17144 ; GFX10-WGP-NEXT: s_endpgm
17146 ; GFX10-CU-LABEL: flat_singlethread_one_as_acq_rel_monotonic_ret_cmpxchg:
17147 ; GFX10-CU: ; %bb.0: ; %entry
17148 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
17149 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
17150 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
17151 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
17152 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
17153 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
17154 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
17155 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
17156 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
17157 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
17158 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
17159 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
17160 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
17161 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
17162 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
17163 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17164 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
17165 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
17166 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
17167 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
17168 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
17169 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
17170 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17171 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
17172 ; GFX10-CU-NEXT: s_endpgm
17174 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_acq_rel_monotonic_ret_cmpxchg:
17175 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
17176 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
17177 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
17178 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
17179 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
17180 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
17181 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
17182 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
17183 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
17184 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
17185 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
17186 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
17187 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
17188 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
17189 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
17190 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
17191 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17192 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
17193 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
17194 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
17195 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
17196 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
17197 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
17198 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17199 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
17200 ; SKIP-CACHE-INV-NEXT: s_endpgm
17202 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_monotonic_ret_cmpxchg:
17203 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
17204 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
17205 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
17206 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
17207 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
17208 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
17209 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
17210 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
17211 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17212 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
17213 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
17214 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
17215 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
17216 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17217 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
17218 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
17220 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_monotonic_ret_cmpxchg:
17221 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
17222 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
17223 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
17224 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
17225 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
17226 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
17227 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
17228 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
17229 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17230 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
17231 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
17232 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
17233 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
17234 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
17235 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
17236 ; GFX90A-TGSPLIT-NEXT: s_endpgm
17238 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_monotonic_ret_cmpxchg:
17239 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
17240 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
17241 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
17242 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
17243 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
17244 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
17245 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
17246 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
17247 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17248 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
17249 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
17250 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
17251 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
17252 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17253 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
17254 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
17256 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_monotonic_ret_cmpxchg:
17257 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
17258 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
17259 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
17260 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
17261 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
17262 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
17263 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
17264 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
17265 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17266 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
17267 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
17268 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
17269 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
17270 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
17271 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
17272 ; GFX940-TGSPLIT-NEXT: s_endpgm
17274 ; GFX11-WGP-LABEL: flat_singlethread_one_as_acq_rel_monotonic_ret_cmpxchg:
17275 ; GFX11-WGP: ; %bb.0: ; %entry
17276 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
17277 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17278 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
17279 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
17280 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
17281 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
17282 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
17283 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17284 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
17285 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
17286 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
17287 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
17288 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
17289 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
17290 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17291 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
17292 ; GFX11-WGP-NEXT: s_endpgm
17294 ; GFX11-CU-LABEL: flat_singlethread_one_as_acq_rel_monotonic_ret_cmpxchg:
17295 ; GFX11-CU: ; %bb.0: ; %entry
17296 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
17297 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17298 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
17299 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
17300 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
17301 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
17302 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
17303 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17304 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
17305 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
17306 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
17307 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
17308 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
17309 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
17310 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17311 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
17312 ; GFX11-CU-NEXT: s_endpgm
17314 ; GFX12-WGP-LABEL: flat_singlethread_one_as_acq_rel_monotonic_ret_cmpxchg:
17315 ; GFX12-WGP: ; %bb.0: ; %entry
17316 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
17317 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17318 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
17319 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
17320 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
17321 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
17322 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
17323 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17324 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
17325 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
17326 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
17327 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
17328 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
17329 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
17330 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
17331 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
17332 ; GFX12-WGP-NEXT: s_endpgm
17334 ; GFX12-CU-LABEL: flat_singlethread_one_as_acq_rel_monotonic_ret_cmpxchg:
17335 ; GFX12-CU: ; %bb.0: ; %entry
17336 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
17337 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17338 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
17339 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
17340 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
17341 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
17342 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
17343 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17344 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
17345 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
17346 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
17347 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
17348 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
17349 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
17350 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
17351 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
17352 ; GFX12-CU-NEXT: s_endpgm
17353 ptr %out, i32 %in, i32 %old) {
17355 %gep = getelementptr i32, ptr %out, i32 4
17356 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") acq_rel monotonic
17357 %val0 = extractvalue { i32, i1 } %val, 0
17358 store i32 %val0, ptr %out, align 4
17362 define amdgpu_kernel void @flat_singlethread_one_as_seq_cst_monotonic_ret_cmpxchg(
17363 ; GFX7-LABEL: flat_singlethread_one_as_seq_cst_monotonic_ret_cmpxchg:
17364 ; GFX7: ; %bb.0: ; %entry
17365 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
17366 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
17367 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
17368 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
17369 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
17370 ; GFX7-NEXT: s_mov_b32 s6, s4
17371 ; GFX7-NEXT: s_mov_b32 s7, s5
17372 ; GFX7-NEXT: s_mov_b32 s11, s12
17373 ; GFX7-NEXT: s_mov_b32 s10, s13
17374 ; GFX7-NEXT: s_add_u32 s6, s6, s11
17375 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
17376 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
17377 ; GFX7-NEXT: s_mov_b32 s7, s10
17378 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
17379 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
17380 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17381 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
17382 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
17383 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
17384 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
17385 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
17386 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
17387 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17388 ; GFX7-NEXT: flat_store_dword v[0:1], v2
17389 ; GFX7-NEXT: s_endpgm
17391 ; GFX10-WGP-LABEL: flat_singlethread_one_as_seq_cst_monotonic_ret_cmpxchg:
17392 ; GFX10-WGP: ; %bb.0: ; %entry
17393 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
17394 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
17395 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
17396 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
17397 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
17398 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
17399 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
17400 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
17401 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
17402 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
17403 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
17404 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
17405 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
17406 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
17407 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
17408 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17409 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
17410 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
17411 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
17412 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
17413 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
17414 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
17415 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17416 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
17417 ; GFX10-WGP-NEXT: s_endpgm
17419 ; GFX10-CU-LABEL: flat_singlethread_one_as_seq_cst_monotonic_ret_cmpxchg:
17420 ; GFX10-CU: ; %bb.0: ; %entry
17421 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
17422 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
17423 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
17424 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
17425 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
17426 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
17427 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
17428 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
17429 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
17430 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
17431 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
17432 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
17433 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
17434 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
17435 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
17436 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17437 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
17438 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
17439 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
17440 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
17441 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
17442 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
17443 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17444 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
17445 ; GFX10-CU-NEXT: s_endpgm
17447 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_seq_cst_monotonic_ret_cmpxchg:
17448 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
17449 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
17450 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
17451 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
17452 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
17453 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
17454 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
17455 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
17456 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
17457 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
17458 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
17459 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
17460 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
17461 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
17462 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
17463 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
17464 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17465 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
17466 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
17467 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
17468 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
17469 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
17470 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
17471 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17472 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
17473 ; SKIP-CACHE-INV-NEXT: s_endpgm
17475 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_monotonic_ret_cmpxchg:
17476 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
17477 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
17478 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
17479 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
17480 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
17481 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
17482 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
17483 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
17484 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17485 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
17486 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
17487 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
17488 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
17489 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17490 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
17491 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
17493 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_monotonic_ret_cmpxchg:
17494 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
17495 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
17496 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
17497 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
17498 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
17499 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
17500 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
17501 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
17502 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17503 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
17504 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
17505 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
17506 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
17507 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
17508 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
17509 ; GFX90A-TGSPLIT-NEXT: s_endpgm
17511 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_monotonic_ret_cmpxchg:
17512 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
17513 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
17514 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
17515 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
17516 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
17517 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
17518 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
17519 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
17520 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17521 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
17522 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
17523 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
17524 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
17525 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17526 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
17527 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
17529 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_monotonic_ret_cmpxchg:
17530 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
17531 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
17532 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
17533 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
17534 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
17535 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
17536 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
17537 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
17538 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17539 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
17540 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
17541 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
17542 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
17543 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
17544 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
17545 ; GFX940-TGSPLIT-NEXT: s_endpgm
17547 ; GFX11-WGP-LABEL: flat_singlethread_one_as_seq_cst_monotonic_ret_cmpxchg:
17548 ; GFX11-WGP: ; %bb.0: ; %entry
17549 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
17550 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17551 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
17552 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
17553 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
17554 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
17555 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
17556 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17557 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
17558 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
17559 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
17560 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
17561 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
17562 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
17563 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17564 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
17565 ; GFX11-WGP-NEXT: s_endpgm
17567 ; GFX11-CU-LABEL: flat_singlethread_one_as_seq_cst_monotonic_ret_cmpxchg:
17568 ; GFX11-CU: ; %bb.0: ; %entry
17569 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
17570 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17571 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
17572 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
17573 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
17574 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
17575 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
17576 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17577 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
17578 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
17579 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
17580 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
17581 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
17582 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
17583 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17584 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
17585 ; GFX11-CU-NEXT: s_endpgm
17587 ; GFX12-WGP-LABEL: flat_singlethread_one_as_seq_cst_monotonic_ret_cmpxchg:
17588 ; GFX12-WGP: ; %bb.0: ; %entry
17589 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
17590 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17591 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
17592 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
17593 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
17594 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
17595 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
17596 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17597 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
17598 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
17599 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
17600 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
17601 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
17602 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
17603 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
17604 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
17605 ; GFX12-WGP-NEXT: s_endpgm
17607 ; GFX12-CU-LABEL: flat_singlethread_one_as_seq_cst_monotonic_ret_cmpxchg:
17608 ; GFX12-CU: ; %bb.0: ; %entry
17609 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
17610 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17611 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
17612 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
17613 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
17614 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
17615 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
17616 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17617 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
17618 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
17619 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
17620 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
17621 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
17622 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
17623 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
17624 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
17625 ; GFX12-CU-NEXT: s_endpgm
17626 ptr %out, i32 %in, i32 %old) {
17628 %gep = getelementptr i32, ptr %out, i32 4
17629 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") seq_cst monotonic
17630 %val0 = extractvalue { i32, i1 } %val, 0
17631 store i32 %val0, ptr %out, align 4
17635 define amdgpu_kernel void @flat_singlethread_one_as_monotonic_acquire_ret_cmpxchg(
17636 ; GFX7-LABEL: flat_singlethread_one_as_monotonic_acquire_ret_cmpxchg:
17637 ; GFX7: ; %bb.0: ; %entry
17638 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
17639 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
17640 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
17641 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
17642 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
17643 ; GFX7-NEXT: s_mov_b32 s6, s4
17644 ; GFX7-NEXT: s_mov_b32 s7, s5
17645 ; GFX7-NEXT: s_mov_b32 s11, s12
17646 ; GFX7-NEXT: s_mov_b32 s10, s13
17647 ; GFX7-NEXT: s_add_u32 s6, s6, s11
17648 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
17649 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
17650 ; GFX7-NEXT: s_mov_b32 s7, s10
17651 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
17652 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
17653 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17654 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
17655 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
17656 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
17657 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
17658 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
17659 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
17660 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17661 ; GFX7-NEXT: flat_store_dword v[0:1], v2
17662 ; GFX7-NEXT: s_endpgm
17664 ; GFX10-WGP-LABEL: flat_singlethread_one_as_monotonic_acquire_ret_cmpxchg:
17665 ; GFX10-WGP: ; %bb.0: ; %entry
17666 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
17667 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
17668 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
17669 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
17670 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
17671 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
17672 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
17673 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
17674 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
17675 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
17676 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
17677 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
17678 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
17679 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
17680 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
17681 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17682 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
17683 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
17684 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
17685 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
17686 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
17687 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
17688 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17689 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
17690 ; GFX10-WGP-NEXT: s_endpgm
17692 ; GFX10-CU-LABEL: flat_singlethread_one_as_monotonic_acquire_ret_cmpxchg:
17693 ; GFX10-CU: ; %bb.0: ; %entry
17694 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
17695 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
17696 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
17697 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
17698 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
17699 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
17700 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
17701 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
17702 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
17703 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
17704 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
17705 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
17706 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
17707 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
17708 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
17709 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17710 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
17711 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
17712 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
17713 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
17714 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
17715 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
17716 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17717 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
17718 ; GFX10-CU-NEXT: s_endpgm
17720 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_monotonic_acquire_ret_cmpxchg:
17721 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
17722 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
17723 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
17724 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
17725 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
17726 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
17727 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
17728 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
17729 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
17730 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
17731 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
17732 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
17733 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
17734 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
17735 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
17736 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
17737 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17738 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
17739 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
17740 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
17741 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
17742 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
17743 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
17744 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17745 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
17746 ; SKIP-CACHE-INV-NEXT: s_endpgm
17748 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_monotonic_acquire_ret_cmpxchg:
17749 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
17750 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
17751 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
17752 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
17753 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
17754 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
17755 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
17756 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
17757 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17758 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
17759 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
17760 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
17761 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
17762 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17763 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
17764 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
17766 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_monotonic_acquire_ret_cmpxchg:
17767 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
17768 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
17769 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
17770 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
17771 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
17772 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
17773 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
17774 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
17775 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17776 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
17777 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
17778 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
17779 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
17780 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
17781 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
17782 ; GFX90A-TGSPLIT-NEXT: s_endpgm
17784 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_monotonic_acquire_ret_cmpxchg:
17785 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
17786 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
17787 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
17788 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
17789 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
17790 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
17791 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
17792 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
17793 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17794 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
17795 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
17796 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
17797 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
17798 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17799 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
17800 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
17802 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_monotonic_acquire_ret_cmpxchg:
17803 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
17804 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
17805 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
17806 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
17807 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
17808 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
17809 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
17810 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
17811 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17812 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
17813 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
17814 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
17815 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
17816 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
17817 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
17818 ; GFX940-TGSPLIT-NEXT: s_endpgm
17820 ; GFX11-WGP-LABEL: flat_singlethread_one_as_monotonic_acquire_ret_cmpxchg:
17821 ; GFX11-WGP: ; %bb.0: ; %entry
17822 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
17823 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17824 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
17825 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
17826 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
17827 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
17828 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
17829 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17830 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
17831 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
17832 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
17833 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
17834 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
17835 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
17836 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17837 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
17838 ; GFX11-WGP-NEXT: s_endpgm
17840 ; GFX11-CU-LABEL: flat_singlethread_one_as_monotonic_acquire_ret_cmpxchg:
17841 ; GFX11-CU: ; %bb.0: ; %entry
17842 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
17843 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17844 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
17845 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
17846 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
17847 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
17848 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
17849 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17850 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
17851 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
17852 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
17853 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
17854 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
17855 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
17856 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17857 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
17858 ; GFX11-CU-NEXT: s_endpgm
17860 ; GFX12-WGP-LABEL: flat_singlethread_one_as_monotonic_acquire_ret_cmpxchg:
17861 ; GFX12-WGP: ; %bb.0: ; %entry
17862 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
17863 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17864 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
17865 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
17866 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
17867 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
17868 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
17869 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17870 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
17871 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
17872 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
17873 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
17874 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
17875 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
17876 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
17877 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
17878 ; GFX12-WGP-NEXT: s_endpgm
17880 ; GFX12-CU-LABEL: flat_singlethread_one_as_monotonic_acquire_ret_cmpxchg:
17881 ; GFX12-CU: ; %bb.0: ; %entry
17882 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
17883 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17884 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
17885 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
17886 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
17887 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
17888 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
17889 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17890 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
17891 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
17892 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
17893 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
17894 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
17895 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
17896 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
17897 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
17898 ; GFX12-CU-NEXT: s_endpgm
17899 ptr %out, i32 %in, i32 %old) {
17901 %gep = getelementptr i32, ptr %out, i32 4
17902 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") monotonic acquire
17903 %val0 = extractvalue { i32, i1 } %val, 0
17904 store i32 %val0, ptr %out, align 4
17908 define amdgpu_kernel void @flat_singlethread_one_as_acquire_acquire_ret_cmpxchg(
17909 ; GFX7-LABEL: flat_singlethread_one_as_acquire_acquire_ret_cmpxchg:
17910 ; GFX7: ; %bb.0: ; %entry
17911 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
17912 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
17913 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
17914 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
17915 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
17916 ; GFX7-NEXT: s_mov_b32 s6, s4
17917 ; GFX7-NEXT: s_mov_b32 s7, s5
17918 ; GFX7-NEXT: s_mov_b32 s11, s12
17919 ; GFX7-NEXT: s_mov_b32 s10, s13
17920 ; GFX7-NEXT: s_add_u32 s6, s6, s11
17921 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
17922 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
17923 ; GFX7-NEXT: s_mov_b32 s7, s10
17924 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
17925 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
17926 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17927 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
17928 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
17929 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
17930 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
17931 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
17932 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
17933 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17934 ; GFX7-NEXT: flat_store_dword v[0:1], v2
17935 ; GFX7-NEXT: s_endpgm
17937 ; GFX10-WGP-LABEL: flat_singlethread_one_as_acquire_acquire_ret_cmpxchg:
17938 ; GFX10-WGP: ; %bb.0: ; %entry
17939 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
17940 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
17941 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
17942 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
17943 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
17944 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
17945 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
17946 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
17947 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
17948 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
17949 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
17950 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
17951 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
17952 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
17953 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
17954 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17955 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
17956 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
17957 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
17958 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
17959 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
17960 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
17961 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17962 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
17963 ; GFX10-WGP-NEXT: s_endpgm
17965 ; GFX10-CU-LABEL: flat_singlethread_one_as_acquire_acquire_ret_cmpxchg:
17966 ; GFX10-CU: ; %bb.0: ; %entry
17967 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
17968 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
17969 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
17970 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
17971 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
17972 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
17973 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
17974 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
17975 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
17976 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
17977 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
17978 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
17979 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
17980 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
17981 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
17982 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17983 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
17984 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
17985 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
17986 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
17987 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
17988 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
17989 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
17990 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
17991 ; GFX10-CU-NEXT: s_endpgm
17993 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_acquire_acquire_ret_cmpxchg:
17994 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
17995 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
17996 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
17997 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
17998 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
17999 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
18000 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
18001 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
18002 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
18003 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
18004 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
18005 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
18006 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
18007 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
18008 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
18009 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
18010 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18011 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
18012 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
18013 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
18014 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
18015 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
18016 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
18017 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18018 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
18019 ; SKIP-CACHE-INV-NEXT: s_endpgm
18021 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acquire_acquire_ret_cmpxchg:
18022 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
18023 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
18024 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
18025 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
18026 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
18027 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18028 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
18029 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
18030 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18031 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
18032 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
18033 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
18034 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
18035 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18036 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
18037 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
18039 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_acquire_acquire_ret_cmpxchg:
18040 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
18041 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
18042 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
18043 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
18044 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
18045 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18046 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
18047 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
18048 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18049 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
18050 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
18051 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
18052 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
18053 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
18054 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
18055 ; GFX90A-TGSPLIT-NEXT: s_endpgm
18057 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acquire_acquire_ret_cmpxchg:
18058 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
18059 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
18060 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
18061 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
18062 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
18063 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18064 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
18065 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
18066 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18067 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
18068 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
18069 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
18070 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
18071 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18072 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
18073 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
18075 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_acquire_acquire_ret_cmpxchg:
18076 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
18077 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
18078 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
18079 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
18080 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
18081 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18082 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
18083 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
18084 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18085 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
18086 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
18087 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
18088 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
18089 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
18090 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
18091 ; GFX940-TGSPLIT-NEXT: s_endpgm
18093 ; GFX11-WGP-LABEL: flat_singlethread_one_as_acquire_acquire_ret_cmpxchg:
18094 ; GFX11-WGP: ; %bb.0: ; %entry
18095 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
18096 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18097 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
18098 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
18099 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
18100 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
18101 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
18102 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18103 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
18104 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
18105 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
18106 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
18107 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
18108 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
18109 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18110 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
18111 ; GFX11-WGP-NEXT: s_endpgm
18113 ; GFX11-CU-LABEL: flat_singlethread_one_as_acquire_acquire_ret_cmpxchg:
18114 ; GFX11-CU: ; %bb.0: ; %entry
18115 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
18116 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18117 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
18118 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
18119 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
18120 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
18121 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
18122 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18123 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
18124 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
18125 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
18126 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
18127 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
18128 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
18129 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18130 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
18131 ; GFX11-CU-NEXT: s_endpgm
18133 ; GFX12-WGP-LABEL: flat_singlethread_one_as_acquire_acquire_ret_cmpxchg:
18134 ; GFX12-WGP: ; %bb.0: ; %entry
18135 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
18136 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18137 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
18138 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
18139 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
18140 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
18141 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
18142 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18143 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
18144 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
18145 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
18146 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
18147 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
18148 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
18149 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
18150 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
18151 ; GFX12-WGP-NEXT: s_endpgm
18153 ; GFX12-CU-LABEL: flat_singlethread_one_as_acquire_acquire_ret_cmpxchg:
18154 ; GFX12-CU: ; %bb.0: ; %entry
18155 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
18156 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18157 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
18158 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
18159 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
18160 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
18161 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
18162 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18163 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
18164 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
18165 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
18166 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
18167 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
18168 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
18169 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
18170 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
18171 ; GFX12-CU-NEXT: s_endpgm
18172 ptr %out, i32 %in, i32 %old) {
18174 %gep = getelementptr i32, ptr %out, i32 4
18175 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") acquire acquire
18176 %val0 = extractvalue { i32, i1 } %val, 0
18177 store i32 %val0, ptr %out, align 4
18181 define amdgpu_kernel void @flat_singlethread_one_as_release_acquire_ret_cmpxchg(
18182 ; GFX7-LABEL: flat_singlethread_one_as_release_acquire_ret_cmpxchg:
18183 ; GFX7: ; %bb.0: ; %entry
18184 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
18185 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
18186 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
18187 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
18188 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
18189 ; GFX7-NEXT: s_mov_b32 s6, s4
18190 ; GFX7-NEXT: s_mov_b32 s7, s5
18191 ; GFX7-NEXT: s_mov_b32 s11, s12
18192 ; GFX7-NEXT: s_mov_b32 s10, s13
18193 ; GFX7-NEXT: s_add_u32 s6, s6, s11
18194 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
18195 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
18196 ; GFX7-NEXT: s_mov_b32 s7, s10
18197 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
18198 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
18199 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18200 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
18201 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
18202 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
18203 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
18204 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
18205 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
18206 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18207 ; GFX7-NEXT: flat_store_dword v[0:1], v2
18208 ; GFX7-NEXT: s_endpgm
18210 ; GFX10-WGP-LABEL: flat_singlethread_one_as_release_acquire_ret_cmpxchg:
18211 ; GFX10-WGP: ; %bb.0: ; %entry
18212 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
18213 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
18214 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
18215 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
18216 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
18217 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
18218 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
18219 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
18220 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
18221 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
18222 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
18223 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
18224 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
18225 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
18226 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
18227 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18228 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
18229 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
18230 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
18231 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
18232 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
18233 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
18234 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18235 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
18236 ; GFX10-WGP-NEXT: s_endpgm
18238 ; GFX10-CU-LABEL: flat_singlethread_one_as_release_acquire_ret_cmpxchg:
18239 ; GFX10-CU: ; %bb.0: ; %entry
18240 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
18241 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
18242 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
18243 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
18244 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
18245 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
18246 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
18247 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
18248 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
18249 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
18250 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
18251 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
18252 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
18253 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
18254 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
18255 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18256 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
18257 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
18258 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
18259 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
18260 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
18261 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
18262 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18263 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
18264 ; GFX10-CU-NEXT: s_endpgm
18266 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_release_acquire_ret_cmpxchg:
18267 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
18268 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
18269 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
18270 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
18271 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
18272 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
18273 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
18274 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
18275 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
18276 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
18277 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
18278 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
18279 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
18280 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
18281 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
18282 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
18283 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18284 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
18285 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
18286 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
18287 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
18288 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
18289 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
18290 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18291 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
18292 ; SKIP-CACHE-INV-NEXT: s_endpgm
18294 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_release_acquire_ret_cmpxchg:
18295 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
18296 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
18297 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
18298 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
18299 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
18300 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18301 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
18302 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
18303 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18304 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
18305 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
18306 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
18307 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
18308 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18309 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
18310 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
18312 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_release_acquire_ret_cmpxchg:
18313 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
18314 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
18315 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
18316 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
18317 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
18318 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18319 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
18320 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
18321 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18322 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
18323 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
18324 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
18325 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
18326 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
18327 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
18328 ; GFX90A-TGSPLIT-NEXT: s_endpgm
18330 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_release_acquire_ret_cmpxchg:
18331 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
18332 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
18333 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
18334 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
18335 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
18336 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18337 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
18338 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
18339 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18340 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
18341 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
18342 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
18343 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
18344 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18345 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
18346 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
18348 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_release_acquire_ret_cmpxchg:
18349 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
18350 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
18351 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
18352 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
18353 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
18354 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18355 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
18356 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
18357 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18358 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
18359 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
18360 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
18361 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
18362 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
18363 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
18364 ; GFX940-TGSPLIT-NEXT: s_endpgm
18366 ; GFX11-WGP-LABEL: flat_singlethread_one_as_release_acquire_ret_cmpxchg:
18367 ; GFX11-WGP: ; %bb.0: ; %entry
18368 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
18369 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18370 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
18371 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
18372 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
18373 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
18374 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
18375 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18376 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
18377 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
18378 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
18379 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
18380 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
18381 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
18382 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18383 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
18384 ; GFX11-WGP-NEXT: s_endpgm
18386 ; GFX11-CU-LABEL: flat_singlethread_one_as_release_acquire_ret_cmpxchg:
18387 ; GFX11-CU: ; %bb.0: ; %entry
18388 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
18389 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18390 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
18391 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
18392 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
18393 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
18394 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
18395 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18396 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
18397 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
18398 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
18399 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
18400 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
18401 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
18402 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18403 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
18404 ; GFX11-CU-NEXT: s_endpgm
18406 ; GFX12-WGP-LABEL: flat_singlethread_one_as_release_acquire_ret_cmpxchg:
18407 ; GFX12-WGP: ; %bb.0: ; %entry
18408 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
18409 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18410 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
18411 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
18412 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
18413 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
18414 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
18415 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18416 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
18417 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
18418 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
18419 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
18420 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
18421 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
18422 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
18423 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
18424 ; GFX12-WGP-NEXT: s_endpgm
18426 ; GFX12-CU-LABEL: flat_singlethread_one_as_release_acquire_ret_cmpxchg:
18427 ; GFX12-CU: ; %bb.0: ; %entry
18428 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
18429 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18430 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
18431 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
18432 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
18433 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
18434 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
18435 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18436 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
18437 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
18438 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
18439 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
18440 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
18441 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
18442 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
18443 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
18444 ; GFX12-CU-NEXT: s_endpgm
18445 ptr %out, i32 %in, i32 %old) {
18447 %gep = getelementptr i32, ptr %out, i32 4
18448 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") release acquire
18449 %val0 = extractvalue { i32, i1 } %val, 0
18450 store i32 %val0, ptr %out, align 4
18454 define amdgpu_kernel void @flat_singlethread_one_as_acq_rel_acquire_ret_cmpxchg(
18455 ; GFX7-LABEL: flat_singlethread_one_as_acq_rel_acquire_ret_cmpxchg:
18456 ; GFX7: ; %bb.0: ; %entry
18457 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
18458 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
18459 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
18460 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
18461 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
18462 ; GFX7-NEXT: s_mov_b32 s6, s4
18463 ; GFX7-NEXT: s_mov_b32 s7, s5
18464 ; GFX7-NEXT: s_mov_b32 s11, s12
18465 ; GFX7-NEXT: s_mov_b32 s10, s13
18466 ; GFX7-NEXT: s_add_u32 s6, s6, s11
18467 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
18468 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
18469 ; GFX7-NEXT: s_mov_b32 s7, s10
18470 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
18471 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
18472 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18473 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
18474 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
18475 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
18476 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
18477 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
18478 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
18479 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18480 ; GFX7-NEXT: flat_store_dword v[0:1], v2
18481 ; GFX7-NEXT: s_endpgm
18483 ; GFX10-WGP-LABEL: flat_singlethread_one_as_acq_rel_acquire_ret_cmpxchg:
18484 ; GFX10-WGP: ; %bb.0: ; %entry
18485 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
18486 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
18487 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
18488 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
18489 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
18490 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
18491 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
18492 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
18493 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
18494 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
18495 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
18496 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
18497 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
18498 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
18499 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
18500 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18501 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
18502 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
18503 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
18504 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
18505 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
18506 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
18507 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18508 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
18509 ; GFX10-WGP-NEXT: s_endpgm
18511 ; GFX10-CU-LABEL: flat_singlethread_one_as_acq_rel_acquire_ret_cmpxchg:
18512 ; GFX10-CU: ; %bb.0: ; %entry
18513 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
18514 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
18515 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
18516 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
18517 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
18518 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
18519 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
18520 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
18521 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
18522 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
18523 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
18524 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
18525 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
18526 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
18527 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
18528 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18529 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
18530 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
18531 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
18532 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
18533 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
18534 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
18535 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18536 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
18537 ; GFX10-CU-NEXT: s_endpgm
18539 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_acq_rel_acquire_ret_cmpxchg:
18540 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
18541 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
18542 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
18543 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
18544 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
18545 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
18546 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
18547 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
18548 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
18549 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
18550 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
18551 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
18552 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
18553 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
18554 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
18555 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
18556 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18557 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
18558 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
18559 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
18560 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
18561 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
18562 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
18563 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18564 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
18565 ; SKIP-CACHE-INV-NEXT: s_endpgm
18567 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_acquire_ret_cmpxchg:
18568 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
18569 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
18570 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
18571 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
18572 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
18573 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18574 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
18575 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
18576 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18577 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
18578 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
18579 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
18580 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
18581 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18582 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
18583 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
18585 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_acquire_ret_cmpxchg:
18586 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
18587 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
18588 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
18589 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
18590 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
18591 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18592 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
18593 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
18594 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18595 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
18596 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
18597 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
18598 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
18599 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
18600 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
18601 ; GFX90A-TGSPLIT-NEXT: s_endpgm
18603 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_acquire_ret_cmpxchg:
18604 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
18605 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
18606 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
18607 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
18608 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
18609 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18610 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
18611 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
18612 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18613 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
18614 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
18615 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
18616 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
18617 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18618 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
18619 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
18621 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_acquire_ret_cmpxchg:
18622 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
18623 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
18624 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
18625 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
18626 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
18627 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18628 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
18629 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
18630 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18631 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
18632 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
18633 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
18634 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
18635 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
18636 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
18637 ; GFX940-TGSPLIT-NEXT: s_endpgm
18639 ; GFX11-WGP-LABEL: flat_singlethread_one_as_acq_rel_acquire_ret_cmpxchg:
18640 ; GFX11-WGP: ; %bb.0: ; %entry
18641 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
18642 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18643 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
18644 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
18645 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
18646 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
18647 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
18648 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18649 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
18650 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
18651 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
18652 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
18653 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
18654 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
18655 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18656 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
18657 ; GFX11-WGP-NEXT: s_endpgm
18659 ; GFX11-CU-LABEL: flat_singlethread_one_as_acq_rel_acquire_ret_cmpxchg:
18660 ; GFX11-CU: ; %bb.0: ; %entry
18661 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
18662 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18663 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
18664 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
18665 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
18666 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
18667 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
18668 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18669 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
18670 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
18671 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
18672 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
18673 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
18674 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
18675 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18676 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
18677 ; GFX11-CU-NEXT: s_endpgm
18679 ; GFX12-WGP-LABEL: flat_singlethread_one_as_acq_rel_acquire_ret_cmpxchg:
18680 ; GFX12-WGP: ; %bb.0: ; %entry
18681 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
18682 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18683 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
18684 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
18685 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
18686 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
18687 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
18688 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18689 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
18690 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
18691 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
18692 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
18693 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
18694 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
18695 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
18696 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
18697 ; GFX12-WGP-NEXT: s_endpgm
18699 ; GFX12-CU-LABEL: flat_singlethread_one_as_acq_rel_acquire_ret_cmpxchg:
18700 ; GFX12-CU: ; %bb.0: ; %entry
18701 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
18702 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18703 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
18704 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
18705 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
18706 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
18707 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
18708 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18709 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
18710 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
18711 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
18712 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
18713 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
18714 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
18715 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
18716 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
18717 ; GFX12-CU-NEXT: s_endpgm
18718 ptr %out, i32 %in, i32 %old) {
18720 %gep = getelementptr i32, ptr %out, i32 4
18721 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") acq_rel acquire
18722 %val0 = extractvalue { i32, i1 } %val, 0
18723 store i32 %val0, ptr %out, align 4
18727 define amdgpu_kernel void @flat_singlethread_one_as_seq_cst_acquire_ret_cmpxchg(
18728 ; GFX7-LABEL: flat_singlethread_one_as_seq_cst_acquire_ret_cmpxchg:
18729 ; GFX7: ; %bb.0: ; %entry
18730 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
18731 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
18732 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
18733 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
18734 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
18735 ; GFX7-NEXT: s_mov_b32 s6, s4
18736 ; GFX7-NEXT: s_mov_b32 s7, s5
18737 ; GFX7-NEXT: s_mov_b32 s11, s12
18738 ; GFX7-NEXT: s_mov_b32 s10, s13
18739 ; GFX7-NEXT: s_add_u32 s6, s6, s11
18740 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
18741 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
18742 ; GFX7-NEXT: s_mov_b32 s7, s10
18743 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
18744 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
18745 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18746 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
18747 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
18748 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
18749 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
18750 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
18751 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
18752 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18753 ; GFX7-NEXT: flat_store_dword v[0:1], v2
18754 ; GFX7-NEXT: s_endpgm
18756 ; GFX10-WGP-LABEL: flat_singlethread_one_as_seq_cst_acquire_ret_cmpxchg:
18757 ; GFX10-WGP: ; %bb.0: ; %entry
18758 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
18759 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
18760 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
18761 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
18762 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
18763 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
18764 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
18765 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
18766 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
18767 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
18768 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
18769 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
18770 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
18771 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
18772 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
18773 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18774 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
18775 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
18776 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
18777 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
18778 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
18779 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
18780 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18781 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
18782 ; GFX10-WGP-NEXT: s_endpgm
18784 ; GFX10-CU-LABEL: flat_singlethread_one_as_seq_cst_acquire_ret_cmpxchg:
18785 ; GFX10-CU: ; %bb.0: ; %entry
18786 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
18787 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
18788 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
18789 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
18790 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
18791 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
18792 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
18793 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
18794 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
18795 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
18796 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
18797 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
18798 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
18799 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
18800 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
18801 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18802 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
18803 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
18804 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
18805 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
18806 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
18807 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
18808 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18809 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
18810 ; GFX10-CU-NEXT: s_endpgm
18812 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_seq_cst_acquire_ret_cmpxchg:
18813 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
18814 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
18815 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
18816 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
18817 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
18818 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
18819 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
18820 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
18821 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
18822 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
18823 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
18824 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
18825 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
18826 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
18827 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
18828 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
18829 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18830 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
18831 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
18832 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
18833 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
18834 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
18835 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
18836 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18837 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
18838 ; SKIP-CACHE-INV-NEXT: s_endpgm
18840 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_acquire_ret_cmpxchg:
18841 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
18842 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
18843 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
18844 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
18845 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
18846 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18847 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
18848 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
18849 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18850 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
18851 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
18852 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
18853 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
18854 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18855 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
18856 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
18858 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_acquire_ret_cmpxchg:
18859 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
18860 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
18861 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
18862 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
18863 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
18864 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18865 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
18866 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
18867 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18868 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
18869 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
18870 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
18871 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
18872 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
18873 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
18874 ; GFX90A-TGSPLIT-NEXT: s_endpgm
18876 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_acquire_ret_cmpxchg:
18877 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
18878 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
18879 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
18880 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
18881 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
18882 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18883 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
18884 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
18885 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18886 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
18887 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
18888 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
18889 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
18890 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18891 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
18892 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
18894 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_acquire_ret_cmpxchg:
18895 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
18896 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
18897 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
18898 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
18899 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
18900 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18901 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
18902 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
18903 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18904 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
18905 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
18906 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
18907 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
18908 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
18909 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
18910 ; GFX940-TGSPLIT-NEXT: s_endpgm
18912 ; GFX11-WGP-LABEL: flat_singlethread_one_as_seq_cst_acquire_ret_cmpxchg:
18913 ; GFX11-WGP: ; %bb.0: ; %entry
18914 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
18915 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18916 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
18917 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
18918 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
18919 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
18920 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
18921 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18922 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
18923 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
18924 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
18925 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
18926 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
18927 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
18928 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18929 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
18930 ; GFX11-WGP-NEXT: s_endpgm
18932 ; GFX11-CU-LABEL: flat_singlethread_one_as_seq_cst_acquire_ret_cmpxchg:
18933 ; GFX11-CU: ; %bb.0: ; %entry
18934 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
18935 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18936 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
18937 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
18938 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
18939 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
18940 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
18941 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18942 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
18943 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
18944 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
18945 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
18946 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
18947 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
18948 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18949 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
18950 ; GFX11-CU-NEXT: s_endpgm
18952 ; GFX12-WGP-LABEL: flat_singlethread_one_as_seq_cst_acquire_ret_cmpxchg:
18953 ; GFX12-WGP: ; %bb.0: ; %entry
18954 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
18955 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18956 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
18957 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
18958 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
18959 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
18960 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
18961 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18962 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
18963 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
18964 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
18965 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
18966 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
18967 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
18968 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
18969 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
18970 ; GFX12-WGP-NEXT: s_endpgm
18972 ; GFX12-CU-LABEL: flat_singlethread_one_as_seq_cst_acquire_ret_cmpxchg:
18973 ; GFX12-CU: ; %bb.0: ; %entry
18974 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
18975 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18976 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
18977 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
18978 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
18979 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
18980 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
18981 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18982 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
18983 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
18984 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
18985 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
18986 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
18987 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
18988 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
18989 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
18990 ; GFX12-CU-NEXT: s_endpgm
18991 ptr %out, i32 %in, i32 %old) {
18993 %gep = getelementptr i32, ptr %out, i32 4
18994 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") seq_cst acquire
18995 %val0 = extractvalue { i32, i1 } %val, 0
18996 store i32 %val0, ptr %out, align 4
19000 define amdgpu_kernel void @flat_singlethread_one_as_monotonic_seq_cst_ret_cmpxchg(
19001 ; GFX7-LABEL: flat_singlethread_one_as_monotonic_seq_cst_ret_cmpxchg:
19002 ; GFX7: ; %bb.0: ; %entry
19003 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
19004 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
19005 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
19006 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
19007 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
19008 ; GFX7-NEXT: s_mov_b32 s6, s4
19009 ; GFX7-NEXT: s_mov_b32 s7, s5
19010 ; GFX7-NEXT: s_mov_b32 s11, s12
19011 ; GFX7-NEXT: s_mov_b32 s10, s13
19012 ; GFX7-NEXT: s_add_u32 s6, s6, s11
19013 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
19014 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
19015 ; GFX7-NEXT: s_mov_b32 s7, s10
19016 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
19017 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
19018 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19019 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
19020 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
19021 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
19022 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
19023 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
19024 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
19025 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19026 ; GFX7-NEXT: flat_store_dword v[0:1], v2
19027 ; GFX7-NEXT: s_endpgm
19029 ; GFX10-WGP-LABEL: flat_singlethread_one_as_monotonic_seq_cst_ret_cmpxchg:
19030 ; GFX10-WGP: ; %bb.0: ; %entry
19031 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
19032 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
19033 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
19034 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
19035 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
19036 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
19037 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
19038 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
19039 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
19040 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
19041 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
19042 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
19043 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
19044 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
19045 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
19046 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19047 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
19048 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
19049 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
19050 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
19051 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
19052 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
19053 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19054 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
19055 ; GFX10-WGP-NEXT: s_endpgm
19057 ; GFX10-CU-LABEL: flat_singlethread_one_as_monotonic_seq_cst_ret_cmpxchg:
19058 ; GFX10-CU: ; %bb.0: ; %entry
19059 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
19060 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
19061 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
19062 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
19063 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
19064 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
19065 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
19066 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
19067 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
19068 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
19069 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
19070 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
19071 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
19072 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
19073 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
19074 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19075 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
19076 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
19077 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
19078 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
19079 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
19080 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
19081 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19082 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
19083 ; GFX10-CU-NEXT: s_endpgm
19085 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_monotonic_seq_cst_ret_cmpxchg:
19086 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
19087 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
19088 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
19089 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
19090 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
19091 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
19092 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
19093 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
19094 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
19095 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
19096 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
19097 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
19098 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
19099 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
19100 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
19101 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
19102 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19103 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
19104 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
19105 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
19106 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
19107 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
19108 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
19109 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19110 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
19111 ; SKIP-CACHE-INV-NEXT: s_endpgm
19113 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_monotonic_seq_cst_ret_cmpxchg:
19114 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
19115 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
19116 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
19117 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
19118 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
19119 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19120 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
19121 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
19122 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19123 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
19124 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
19125 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
19126 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
19127 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19128 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
19129 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
19131 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_monotonic_seq_cst_ret_cmpxchg:
19132 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
19133 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
19134 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
19135 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
19136 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
19137 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19138 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
19139 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
19140 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19141 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
19142 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
19143 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
19144 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
19145 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
19146 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
19147 ; GFX90A-TGSPLIT-NEXT: s_endpgm
19149 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_monotonic_seq_cst_ret_cmpxchg:
19150 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
19151 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
19152 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
19153 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
19154 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
19155 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19156 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
19157 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
19158 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19159 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
19160 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
19161 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
19162 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
19163 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19164 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
19165 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
19167 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_monotonic_seq_cst_ret_cmpxchg:
19168 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
19169 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
19170 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
19171 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
19172 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
19173 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19174 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
19175 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
19176 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19177 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
19178 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
19179 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
19180 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
19181 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
19182 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
19183 ; GFX940-TGSPLIT-NEXT: s_endpgm
19185 ; GFX11-WGP-LABEL: flat_singlethread_one_as_monotonic_seq_cst_ret_cmpxchg:
19186 ; GFX11-WGP: ; %bb.0: ; %entry
19187 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
19188 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
19189 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
19190 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
19191 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
19192 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
19193 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
19194 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19195 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
19196 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
19197 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
19198 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
19199 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
19200 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
19201 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19202 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
19203 ; GFX11-WGP-NEXT: s_endpgm
19205 ; GFX11-CU-LABEL: flat_singlethread_one_as_monotonic_seq_cst_ret_cmpxchg:
19206 ; GFX11-CU: ; %bb.0: ; %entry
19207 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
19208 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
19209 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
19210 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
19211 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
19212 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
19213 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
19214 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19215 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
19216 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
19217 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
19218 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
19219 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
19220 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
19221 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19222 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
19223 ; GFX11-CU-NEXT: s_endpgm
19225 ; GFX12-WGP-LABEL: flat_singlethread_one_as_monotonic_seq_cst_ret_cmpxchg:
19226 ; GFX12-WGP: ; %bb.0: ; %entry
19227 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
19228 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
19229 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
19230 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
19231 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
19232 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
19233 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
19234 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19235 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
19236 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
19237 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
19238 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
19239 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
19240 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
19241 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
19242 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
19243 ; GFX12-WGP-NEXT: s_endpgm
19245 ; GFX12-CU-LABEL: flat_singlethread_one_as_monotonic_seq_cst_ret_cmpxchg:
19246 ; GFX12-CU: ; %bb.0: ; %entry
19247 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
19248 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
19249 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
19250 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
19251 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
19252 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
19253 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
19254 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19255 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
19256 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
19257 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
19258 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
19259 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
19260 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
19261 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
19262 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
19263 ; GFX12-CU-NEXT: s_endpgm
19264 ptr %out, i32 %in, i32 %old) {
19266 %gep = getelementptr i32, ptr %out, i32 4
19267 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") monotonic seq_cst
19268 %val0 = extractvalue { i32, i1 } %val, 0
19269 store i32 %val0, ptr %out, align 4
19273 define amdgpu_kernel void @flat_singlethread_one_as_acquire_seq_cst_ret_cmpxchg(
19274 ; GFX7-LABEL: flat_singlethread_one_as_acquire_seq_cst_ret_cmpxchg:
19275 ; GFX7: ; %bb.0: ; %entry
19276 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
19277 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
19278 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
19279 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
19280 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
19281 ; GFX7-NEXT: s_mov_b32 s6, s4
19282 ; GFX7-NEXT: s_mov_b32 s7, s5
19283 ; GFX7-NEXT: s_mov_b32 s11, s12
19284 ; GFX7-NEXT: s_mov_b32 s10, s13
19285 ; GFX7-NEXT: s_add_u32 s6, s6, s11
19286 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
19287 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
19288 ; GFX7-NEXT: s_mov_b32 s7, s10
19289 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
19290 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
19291 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19292 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
19293 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
19294 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
19295 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
19296 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
19297 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
19298 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19299 ; GFX7-NEXT: flat_store_dword v[0:1], v2
19300 ; GFX7-NEXT: s_endpgm
19302 ; GFX10-WGP-LABEL: flat_singlethread_one_as_acquire_seq_cst_ret_cmpxchg:
19303 ; GFX10-WGP: ; %bb.0: ; %entry
19304 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
19305 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
19306 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
19307 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
19308 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
19309 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
19310 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
19311 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
19312 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
19313 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
19314 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
19315 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
19316 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
19317 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
19318 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
19319 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19320 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
19321 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
19322 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
19323 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
19324 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
19325 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
19326 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19327 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
19328 ; GFX10-WGP-NEXT: s_endpgm
19330 ; GFX10-CU-LABEL: flat_singlethread_one_as_acquire_seq_cst_ret_cmpxchg:
19331 ; GFX10-CU: ; %bb.0: ; %entry
19332 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
19333 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
19334 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
19335 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
19336 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
19337 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
19338 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
19339 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
19340 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
19341 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
19342 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
19343 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
19344 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
19345 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
19346 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
19347 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19348 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
19349 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
19350 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
19351 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
19352 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
19353 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
19354 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19355 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
19356 ; GFX10-CU-NEXT: s_endpgm
19358 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_acquire_seq_cst_ret_cmpxchg:
19359 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
19360 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
19361 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
19362 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
19363 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
19364 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
19365 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
19366 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
19367 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
19368 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
19369 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
19370 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
19371 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
19372 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
19373 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
19374 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
19375 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19376 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
19377 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
19378 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
19379 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
19380 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
19381 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
19382 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19383 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
19384 ; SKIP-CACHE-INV-NEXT: s_endpgm
19386 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acquire_seq_cst_ret_cmpxchg:
19387 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
19388 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
19389 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
19390 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
19391 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
19392 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19393 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
19394 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
19395 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19396 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
19397 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
19398 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
19399 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
19400 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19401 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
19402 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
19404 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_acquire_seq_cst_ret_cmpxchg:
19405 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
19406 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
19407 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
19408 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
19409 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
19410 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19411 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
19412 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
19413 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19414 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
19415 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
19416 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
19417 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
19418 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
19419 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
19420 ; GFX90A-TGSPLIT-NEXT: s_endpgm
19422 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acquire_seq_cst_ret_cmpxchg:
19423 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
19424 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
19425 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
19426 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
19427 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
19428 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19429 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
19430 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
19431 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19432 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
19433 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
19434 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
19435 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
19436 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19437 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
19438 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
19440 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_acquire_seq_cst_ret_cmpxchg:
19441 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
19442 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
19443 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
19444 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
19445 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
19446 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19447 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
19448 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
19449 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19450 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
19451 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
19452 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
19453 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
19454 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
19455 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
19456 ; GFX940-TGSPLIT-NEXT: s_endpgm
19458 ; GFX11-WGP-LABEL: flat_singlethread_one_as_acquire_seq_cst_ret_cmpxchg:
19459 ; GFX11-WGP: ; %bb.0: ; %entry
19460 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
19461 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
19462 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
19463 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
19464 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
19465 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
19466 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
19467 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19468 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
19469 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
19470 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
19471 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
19472 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
19473 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
19474 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19475 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
19476 ; GFX11-WGP-NEXT: s_endpgm
19478 ; GFX11-CU-LABEL: flat_singlethread_one_as_acquire_seq_cst_ret_cmpxchg:
19479 ; GFX11-CU: ; %bb.0: ; %entry
19480 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
19481 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
19482 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
19483 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
19484 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
19485 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
19486 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
19487 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19488 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
19489 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
19490 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
19491 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
19492 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
19493 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
19494 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19495 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
19496 ; GFX11-CU-NEXT: s_endpgm
19498 ; GFX12-WGP-LABEL: flat_singlethread_one_as_acquire_seq_cst_ret_cmpxchg:
19499 ; GFX12-WGP: ; %bb.0: ; %entry
19500 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
19501 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
19502 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
19503 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
19504 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
19505 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
19506 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
19507 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19508 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
19509 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
19510 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
19511 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
19512 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
19513 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
19514 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
19515 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
19516 ; GFX12-WGP-NEXT: s_endpgm
19518 ; GFX12-CU-LABEL: flat_singlethread_one_as_acquire_seq_cst_ret_cmpxchg:
19519 ; GFX12-CU: ; %bb.0: ; %entry
19520 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
19521 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
19522 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
19523 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
19524 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
19525 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
19526 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
19527 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19528 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
19529 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
19530 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
19531 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
19532 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
19533 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
19534 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
19535 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
19536 ; GFX12-CU-NEXT: s_endpgm
19537 ptr %out, i32 %in, i32 %old) {
19539 %gep = getelementptr i32, ptr %out, i32 4
19540 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") acquire seq_cst
19541 %val0 = extractvalue { i32, i1 } %val, 0
19542 store i32 %val0, ptr %out, align 4
19546 define amdgpu_kernel void @flat_singlethread_one_as_release_seq_cst_ret_cmpxchg(
19547 ; GFX7-LABEL: flat_singlethread_one_as_release_seq_cst_ret_cmpxchg:
19548 ; GFX7: ; %bb.0: ; %entry
19549 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
19550 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
19551 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
19552 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
19553 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
19554 ; GFX7-NEXT: s_mov_b32 s6, s4
19555 ; GFX7-NEXT: s_mov_b32 s7, s5
19556 ; GFX7-NEXT: s_mov_b32 s11, s12
19557 ; GFX7-NEXT: s_mov_b32 s10, s13
19558 ; GFX7-NEXT: s_add_u32 s6, s6, s11
19559 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
19560 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
19561 ; GFX7-NEXT: s_mov_b32 s7, s10
19562 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
19563 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
19564 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19565 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
19566 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
19567 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
19568 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
19569 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
19570 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
19571 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19572 ; GFX7-NEXT: flat_store_dword v[0:1], v2
19573 ; GFX7-NEXT: s_endpgm
19575 ; GFX10-WGP-LABEL: flat_singlethread_one_as_release_seq_cst_ret_cmpxchg:
19576 ; GFX10-WGP: ; %bb.0: ; %entry
19577 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
19578 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
19579 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
19580 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
19581 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
19582 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
19583 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
19584 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
19585 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
19586 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
19587 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
19588 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
19589 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
19590 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
19591 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
19592 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19593 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
19594 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
19595 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
19596 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
19597 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
19598 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
19599 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19600 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
19601 ; GFX10-WGP-NEXT: s_endpgm
19603 ; GFX10-CU-LABEL: flat_singlethread_one_as_release_seq_cst_ret_cmpxchg:
19604 ; GFX10-CU: ; %bb.0: ; %entry
19605 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
19606 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
19607 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
19608 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
19609 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
19610 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
19611 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
19612 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
19613 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
19614 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
19615 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
19616 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
19617 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
19618 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
19619 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
19620 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19621 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
19622 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
19623 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
19624 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
19625 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
19626 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
19627 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19628 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
19629 ; GFX10-CU-NEXT: s_endpgm
19631 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_release_seq_cst_ret_cmpxchg:
19632 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
19633 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
19634 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
19635 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
19636 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
19637 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
19638 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
19639 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
19640 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
19641 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
19642 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
19643 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
19644 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
19645 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
19646 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
19647 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
19648 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19649 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
19650 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
19651 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
19652 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
19653 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
19654 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
19655 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19656 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
19657 ; SKIP-CACHE-INV-NEXT: s_endpgm
19659 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_release_seq_cst_ret_cmpxchg:
19660 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
19661 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
19662 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
19663 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
19664 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
19665 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19666 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
19667 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
19668 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19669 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
19670 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
19671 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
19672 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
19673 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19674 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
19675 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
19677 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_release_seq_cst_ret_cmpxchg:
19678 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
19679 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
19680 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
19681 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
19682 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
19683 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19684 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
19685 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
19686 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19687 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
19688 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
19689 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
19690 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
19691 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
19692 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
19693 ; GFX90A-TGSPLIT-NEXT: s_endpgm
19695 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_release_seq_cst_ret_cmpxchg:
19696 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
19697 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
19698 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
19699 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
19700 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
19701 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19702 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
19703 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
19704 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19705 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
19706 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
19707 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
19708 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
19709 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19710 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
19711 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
19713 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_release_seq_cst_ret_cmpxchg:
19714 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
19715 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
19716 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
19717 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
19718 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
19719 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19720 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
19721 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
19722 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19723 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
19724 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
19725 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
19726 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
19727 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
19728 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
19729 ; GFX940-TGSPLIT-NEXT: s_endpgm
19731 ; GFX11-WGP-LABEL: flat_singlethread_one_as_release_seq_cst_ret_cmpxchg:
19732 ; GFX11-WGP: ; %bb.0: ; %entry
19733 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
19734 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
19735 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
19736 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
19737 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
19738 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
19739 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
19740 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19741 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
19742 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
19743 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
19744 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
19745 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
19746 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
19747 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19748 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
19749 ; GFX11-WGP-NEXT: s_endpgm
19751 ; GFX11-CU-LABEL: flat_singlethread_one_as_release_seq_cst_ret_cmpxchg:
19752 ; GFX11-CU: ; %bb.0: ; %entry
19753 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
19754 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
19755 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
19756 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
19757 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
19758 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
19759 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
19760 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19761 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
19762 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
19763 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
19764 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
19765 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
19766 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
19767 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19768 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
19769 ; GFX11-CU-NEXT: s_endpgm
19771 ; GFX12-WGP-LABEL: flat_singlethread_one_as_release_seq_cst_ret_cmpxchg:
19772 ; GFX12-WGP: ; %bb.0: ; %entry
19773 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
19774 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
19775 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
19776 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
19777 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
19778 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
19779 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
19780 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19781 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
19782 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
19783 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
19784 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
19785 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
19786 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
19787 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
19788 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
19789 ; GFX12-WGP-NEXT: s_endpgm
19791 ; GFX12-CU-LABEL: flat_singlethread_one_as_release_seq_cst_ret_cmpxchg:
19792 ; GFX12-CU: ; %bb.0: ; %entry
19793 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
19794 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
19795 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
19796 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
19797 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
19798 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
19799 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
19800 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19801 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
19802 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
19803 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
19804 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
19805 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
19806 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
19807 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
19808 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
19809 ; GFX12-CU-NEXT: s_endpgm
19810 ptr %out, i32 %in, i32 %old) {
19812 %gep = getelementptr i32, ptr %out, i32 4
19813 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") release seq_cst
19814 %val0 = extractvalue { i32, i1 } %val, 0
19815 store i32 %val0, ptr %out, align 4
19819 define amdgpu_kernel void @flat_singlethread_one_as_acq_rel_seq_cst_ret_cmpxchg(
19820 ; GFX7-LABEL: flat_singlethread_one_as_acq_rel_seq_cst_ret_cmpxchg:
19821 ; GFX7: ; %bb.0: ; %entry
19822 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
19823 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
19824 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
19825 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
19826 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
19827 ; GFX7-NEXT: s_mov_b32 s6, s4
19828 ; GFX7-NEXT: s_mov_b32 s7, s5
19829 ; GFX7-NEXT: s_mov_b32 s11, s12
19830 ; GFX7-NEXT: s_mov_b32 s10, s13
19831 ; GFX7-NEXT: s_add_u32 s6, s6, s11
19832 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
19833 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
19834 ; GFX7-NEXT: s_mov_b32 s7, s10
19835 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
19836 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
19837 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19838 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
19839 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
19840 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
19841 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
19842 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
19843 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
19844 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19845 ; GFX7-NEXT: flat_store_dword v[0:1], v2
19846 ; GFX7-NEXT: s_endpgm
19848 ; GFX10-WGP-LABEL: flat_singlethread_one_as_acq_rel_seq_cst_ret_cmpxchg:
19849 ; GFX10-WGP: ; %bb.0: ; %entry
19850 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
19851 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
19852 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
19853 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
19854 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
19855 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
19856 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
19857 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
19858 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
19859 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
19860 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
19861 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
19862 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
19863 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
19864 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
19865 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19866 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
19867 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
19868 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
19869 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
19870 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
19871 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
19872 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19873 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
19874 ; GFX10-WGP-NEXT: s_endpgm
19876 ; GFX10-CU-LABEL: flat_singlethread_one_as_acq_rel_seq_cst_ret_cmpxchg:
19877 ; GFX10-CU: ; %bb.0: ; %entry
19878 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
19879 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
19880 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
19881 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
19882 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
19883 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
19884 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
19885 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
19886 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
19887 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
19888 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
19889 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
19890 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
19891 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
19892 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
19893 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19894 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
19895 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
19896 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
19897 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
19898 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
19899 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
19900 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19901 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
19902 ; GFX10-CU-NEXT: s_endpgm
19904 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_acq_rel_seq_cst_ret_cmpxchg:
19905 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
19906 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
19907 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
19908 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
19909 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
19910 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
19911 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
19912 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
19913 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
19914 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
19915 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
19916 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
19917 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
19918 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
19919 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
19920 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
19921 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19922 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
19923 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
19924 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
19925 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
19926 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
19927 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
19928 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19929 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
19930 ; SKIP-CACHE-INV-NEXT: s_endpgm
19932 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_seq_cst_ret_cmpxchg:
19933 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
19934 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
19935 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
19936 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
19937 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
19938 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19939 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
19940 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
19941 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19942 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
19943 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
19944 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
19945 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
19946 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19947 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
19948 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
19950 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_seq_cst_ret_cmpxchg:
19951 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
19952 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
19953 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
19954 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
19955 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
19956 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19957 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
19958 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
19959 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19960 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
19961 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
19962 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
19963 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
19964 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
19965 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
19966 ; GFX90A-TGSPLIT-NEXT: s_endpgm
19968 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_seq_cst_ret_cmpxchg:
19969 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
19970 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
19971 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
19972 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
19973 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
19974 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19975 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
19976 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
19977 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19978 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
19979 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
19980 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
19981 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
19982 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
19983 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
19984 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
19986 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_acq_rel_seq_cst_ret_cmpxchg:
19987 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
19988 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
19989 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
19990 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
19991 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
19992 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19993 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
19994 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
19995 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19996 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
19997 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
19998 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
19999 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
20000 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
20001 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
20002 ; GFX940-TGSPLIT-NEXT: s_endpgm
20004 ; GFX11-WGP-LABEL: flat_singlethread_one_as_acq_rel_seq_cst_ret_cmpxchg:
20005 ; GFX11-WGP: ; %bb.0: ; %entry
20006 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
20007 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
20008 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
20009 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
20010 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
20011 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
20012 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
20013 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
20014 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
20015 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
20016 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
20017 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
20018 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
20019 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
20020 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
20021 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
20022 ; GFX11-WGP-NEXT: s_endpgm
20024 ; GFX11-CU-LABEL: flat_singlethread_one_as_acq_rel_seq_cst_ret_cmpxchg:
20025 ; GFX11-CU: ; %bb.0: ; %entry
20026 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
20027 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
20028 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
20029 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
20030 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
20031 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
20032 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
20033 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
20034 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
20035 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
20036 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
20037 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
20038 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
20039 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
20040 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
20041 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
20042 ; GFX11-CU-NEXT: s_endpgm
20044 ; GFX12-WGP-LABEL: flat_singlethread_one_as_acq_rel_seq_cst_ret_cmpxchg:
20045 ; GFX12-WGP: ; %bb.0: ; %entry
20046 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
20047 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
20048 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
20049 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
20050 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
20051 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
20052 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
20053 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
20054 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
20055 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
20056 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
20057 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
20058 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
20059 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
20060 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
20061 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
20062 ; GFX12-WGP-NEXT: s_endpgm
20064 ; GFX12-CU-LABEL: flat_singlethread_one_as_acq_rel_seq_cst_ret_cmpxchg:
20065 ; GFX12-CU: ; %bb.0: ; %entry
20066 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
20067 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
20068 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
20069 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
20070 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
20071 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
20072 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
20073 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
20074 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
20075 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
20076 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
20077 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
20078 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
20079 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
20080 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
20081 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
20082 ; GFX12-CU-NEXT: s_endpgm
20083 ptr %out, i32 %in, i32 %old) {
20085 %gep = getelementptr i32, ptr %out, i32 4
20086 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") acq_rel seq_cst
20087 %val0 = extractvalue { i32, i1 } %val, 0
20088 store i32 %val0, ptr %out, align 4
20092 define amdgpu_kernel void @flat_singlethread_one_as_seq_cst_seq_cst_ret_cmpxchg(
20093 ; GFX7-LABEL: flat_singlethread_one_as_seq_cst_seq_cst_ret_cmpxchg:
20094 ; GFX7: ; %bb.0: ; %entry
20095 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
20096 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
20097 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
20098 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
20099 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
20100 ; GFX7-NEXT: s_mov_b32 s6, s4
20101 ; GFX7-NEXT: s_mov_b32 s7, s5
20102 ; GFX7-NEXT: s_mov_b32 s11, s12
20103 ; GFX7-NEXT: s_mov_b32 s10, s13
20104 ; GFX7-NEXT: s_add_u32 s6, s6, s11
20105 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
20106 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
20107 ; GFX7-NEXT: s_mov_b32 s7, s10
20108 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
20109 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
20110 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
20111 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
20112 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
20113 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
20114 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
20115 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
20116 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
20117 ; GFX7-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
20118 ; GFX7-NEXT: flat_store_dword v[0:1], v2
20119 ; GFX7-NEXT: s_endpgm
20121 ; GFX10-WGP-LABEL: flat_singlethread_one_as_seq_cst_seq_cst_ret_cmpxchg:
20122 ; GFX10-WGP: ; %bb.0: ; %entry
20123 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
20124 ; GFX10-WGP-NEXT: s_load_dword s9, s[6:7], 0x8
20125 ; GFX10-WGP-NEXT: s_load_dword s8, s[6:7], 0xc
20126 ; GFX10-WGP-NEXT: s_mov_b64 s[12:13], 16
20127 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
20128 ; GFX10-WGP-NEXT: s_mov_b32 s6, s4
20129 ; GFX10-WGP-NEXT: s_mov_b32 s7, s5
20130 ; GFX10-WGP-NEXT: s_mov_b32 s11, s12
20131 ; GFX10-WGP-NEXT: s_mov_b32 s10, s13
20132 ; GFX10-WGP-NEXT: s_add_u32 s6, s6, s11
20133 ; GFX10-WGP-NEXT: s_addc_u32 s10, s7, s10
20134 ; GFX10-WGP-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
20135 ; GFX10-WGP-NEXT: s_mov_b32 s7, s10
20136 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, s9
20137 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s8
20138 ; GFX10-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
20139 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, v0
20140 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s6
20141 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
20142 ; GFX10-WGP-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
20143 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, s4
20144 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s5
20145 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
20146 ; GFX10-WGP-NEXT: flat_store_dword v[0:1], v2
20147 ; GFX10-WGP-NEXT: s_endpgm
20149 ; GFX10-CU-LABEL: flat_singlethread_one_as_seq_cst_seq_cst_ret_cmpxchg:
20150 ; GFX10-CU: ; %bb.0: ; %entry
20151 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
20152 ; GFX10-CU-NEXT: s_load_dword s9, s[6:7], 0x8
20153 ; GFX10-CU-NEXT: s_load_dword s8, s[6:7], 0xc
20154 ; GFX10-CU-NEXT: s_mov_b64 s[12:13], 16
20155 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
20156 ; GFX10-CU-NEXT: s_mov_b32 s6, s4
20157 ; GFX10-CU-NEXT: s_mov_b32 s7, s5
20158 ; GFX10-CU-NEXT: s_mov_b32 s11, s12
20159 ; GFX10-CU-NEXT: s_mov_b32 s10, s13
20160 ; GFX10-CU-NEXT: s_add_u32 s6, s6, s11
20161 ; GFX10-CU-NEXT: s_addc_u32 s10, s7, s10
20162 ; GFX10-CU-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
20163 ; GFX10-CU-NEXT: s_mov_b32 s7, s10
20164 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, s9
20165 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s8
20166 ; GFX10-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
20167 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, v0
20168 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s6
20169 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
20170 ; GFX10-CU-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
20171 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, s4
20172 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s5
20173 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
20174 ; GFX10-CU-NEXT: flat_store_dword v[0:1], v2
20175 ; GFX10-CU-NEXT: s_endpgm
20177 ; SKIP-CACHE-INV-LABEL: flat_singlethread_one_as_seq_cst_seq_cst_ret_cmpxchg:
20178 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
20179 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
20180 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
20181 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
20182 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[8:9], 16
20183 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
20184 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s0
20185 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s1
20186 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
20187 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
20188 ; SKIP-CACHE-INV-NEXT: s_add_u32 s2, s2, s7
20189 ; SKIP-CACHE-INV-NEXT: s_addc_u32 s6, s3, s6
20190 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr2 killed $sgpr2 def $sgpr2_sgpr3
20191 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
20192 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s5
20193 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
20194 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
20195 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v3, v0
20196 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s2
20197 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s3
20198 ; SKIP-CACHE-INV-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
20199 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s0
20200 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, s1
20201 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
20202 ; SKIP-CACHE-INV-NEXT: flat_store_dword v[0:1], v2
20203 ; SKIP-CACHE-INV-NEXT: s_endpgm
20205 ; GFX90A-NOTTGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_seq_cst_ret_cmpxchg:
20206 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
20207 ; GFX90A-NOTTGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
20208 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
20209 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
20210 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
20211 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
20212 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
20213 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s6
20214 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
20215 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
20216 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
20217 ; GFX90A-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
20218 ; GFX90A-NOTTGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
20219 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
20220 ; GFX90A-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2
20221 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
20223 ; GFX90A-TGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_seq_cst_ret_cmpxchg:
20224 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
20225 ; GFX90A-TGSPLIT-NEXT: s_mov_b64 s[8:9], s[6:7]
20226 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
20227 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
20228 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
20229 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
20230 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
20231 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, s6
20232 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
20233 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
20234 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
20235 ; GFX90A-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
20236 ; GFX90A-TGSPLIT-NEXT: v_pk_mov_b32 v[0:1], s[4:5], s[4:5] op_sel:[0,1]
20237 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
20238 ; GFX90A-TGSPLIT-NEXT: flat_store_dword v[0:1], v2
20239 ; GFX90A-TGSPLIT-NEXT: s_endpgm
20241 ; GFX940-NOTTGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_seq_cst_ret_cmpxchg:
20242 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
20243 ; GFX940-NOTTGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
20244 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
20245 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
20246 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
20247 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
20248 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
20249 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, s2
20250 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
20251 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v0
20252 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
20253 ; GFX940-NOTTGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
20254 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
20255 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
20256 ; GFX940-NOTTGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
20257 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
20259 ; GFX940-TGSPLIT-LABEL: flat_singlethread_one_as_seq_cst_seq_cst_ret_cmpxchg:
20260 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
20261 ; GFX940-TGSPLIT-NEXT: s_mov_b64 s[4:5], s[2:3]
20262 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
20263 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
20264 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
20265 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
20266 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
20267 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, s2
20268 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
20269 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v0
20270 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
20271 ; GFX940-TGSPLIT-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 sc0
20272 ; GFX940-TGSPLIT-NEXT: v_mov_b64_e32 v[0:1], s[0:1]
20273 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
20274 ; GFX940-TGSPLIT-NEXT: flat_store_dword v[0:1], v2 sc0 sc1
20275 ; GFX940-TGSPLIT-NEXT: s_endpgm
20277 ; GFX11-WGP-LABEL: flat_singlethread_one_as_seq_cst_seq_cst_ret_cmpxchg:
20278 ; GFX11-WGP: ; %bb.0: ; %entry
20279 ; GFX11-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
20280 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
20281 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
20282 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
20283 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
20284 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, s3
20285 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s2
20286 ; GFX11-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
20287 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, v0
20288 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
20289 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
20290 ; GFX11-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
20291 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, s0
20292 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s1
20293 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
20294 ; GFX11-WGP-NEXT: flat_store_b32 v[0:1], v2
20295 ; GFX11-WGP-NEXT: s_endpgm
20297 ; GFX11-CU-LABEL: flat_singlethread_one_as_seq_cst_seq_cst_ret_cmpxchg:
20298 ; GFX11-CU: ; %bb.0: ; %entry
20299 ; GFX11-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
20300 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
20301 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
20302 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
20303 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
20304 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, s3
20305 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s2
20306 ; GFX11-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
20307 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, v0
20308 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
20309 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
20310 ; GFX11-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 glc
20311 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, s0
20312 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s1
20313 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
20314 ; GFX11-CU-NEXT: flat_store_b32 v[0:1], v2
20315 ; GFX11-CU-NEXT: s_endpgm
20317 ; GFX12-WGP-LABEL: flat_singlethread_one_as_seq_cst_seq_cst_ret_cmpxchg:
20318 ; GFX12-WGP: ; %bb.0: ; %entry
20319 ; GFX12-WGP-NEXT: s_mov_b64 s[4:5], s[2:3]
20320 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
20321 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
20322 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
20323 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
20324 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, s3
20325 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s2
20326 ; GFX12-WGP-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
20327 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, v0
20328 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
20329 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
20330 ; GFX12-WGP-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
20331 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, s0
20332 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s1
20333 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
20334 ; GFX12-WGP-NEXT: flat_store_b32 v[0:1], v2
20335 ; GFX12-WGP-NEXT: s_endpgm
20337 ; GFX12-CU-LABEL: flat_singlethread_one_as_seq_cst_seq_cst_ret_cmpxchg:
20338 ; GFX12-CU: ; %bb.0: ; %entry
20339 ; GFX12-CU-NEXT: s_mov_b64 s[4:5], s[2:3]
20340 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
20341 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
20342 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
20343 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
20344 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, s3
20345 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s2
20346 ; GFX12-CU-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
20347 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, v0
20348 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
20349 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
20350 ; GFX12-CU-NEXT: flat_atomic_cmpswap_b32 v2, v[0:1], v[2:3] offset:16 th:TH_ATOMIC_RETURN
20351 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, s0
20352 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s1
20353 ; GFX12-CU-NEXT: s_wait_loadcnt_dscnt 0x0
20354 ; GFX12-CU-NEXT: flat_store_b32 v[0:1], v2
20355 ; GFX12-CU-NEXT: s_endpgm
20356 ptr %out, i32 %in, i32 %old) {
20358 %gep = getelementptr i32, ptr %out, i32 4
20359 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("singlethread-one-as") seq_cst seq_cst
20360 %val0 = extractvalue { i32, i1 } %val, 0
20361 store i32 %val0, ptr %out, align 4