1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -O0 -mcpu=gfx600 < %s | FileCheck --check-prefixes=GFX6 %s
3 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -O0 -mcpu=gfx700 < %s | FileCheck --check-prefixes=GFX7 %s
4 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -O0 -mcpu=gfx1010 < %s | FileCheck --check-prefixes=GFX10-WGP %s
5 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -O0 -mcpu=gfx1010 -mattr=+cumode < %s | FileCheck --check-prefixes=GFX10-CU %s
6 ; RUN: llc -mtriple=amdgcn-amd-amdpal -O0 -mcpu=gfx700 -amdgcn-skip-cache-invalidations < %s | FileCheck --check-prefixes=SKIP-CACHE-INV %s
7 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -O0 -mcpu=gfx90a < %s | FileCheck -check-prefixes=GFX90A-NOTTGSPLIT %s
8 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -O0 -mcpu=gfx90a -mattr=+tgsplit < %s | FileCheck -check-prefixes=GFX90A-TGSPLIT %s
9 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -O0 -mcpu=gfx940 < %s | FileCheck -check-prefixes=GFX940-NOTTGSPLIT %s
10 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -O0 -mcpu=gfx940 -mattr=+tgsplit < %s | FileCheck -check-prefixes=GFX940-TGSPLIT %s
11 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -O0 -mcpu=gfx1100 < %s | FileCheck --check-prefixes=GFX11-WGP %s
12 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -O0 -mcpu=gfx1100 -mattr=+cumode < %s | FileCheck --check-prefixes=GFX11-CU %s
13 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -O0 -mcpu=gfx1200 < %s | FileCheck --check-prefixes=GFX12-WGP %s
14 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -O0 -mcpu=gfx1200 -mattr=+cumode < %s | FileCheck --check-prefixes=GFX12-CU %s
16 define amdgpu_kernel void @global_workgroup_unordered_load(
17 ; GFX6-LABEL: global_workgroup_unordered_load:
18 ; GFX6: ; %bb.0: ; %entry
19 ; GFX6-NEXT: s_mov_b64 s[4:5], s[8:9]
20 ; GFX6-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
21 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
22 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
23 ; GFX6-NEXT: s_mov_b32 s6, s9
24 ; GFX6-NEXT: ; kill: def $sgpr8 killed $sgpr8 killed $sgpr8_sgpr9
25 ; GFX6-NEXT: s_mov_b32 s12, 0x100f000
26 ; GFX6-NEXT: s_mov_b32 s13, -1
27 ; GFX6-NEXT: ; kill: def $sgpr8 killed $sgpr8 def $sgpr8_sgpr9_sgpr10_sgpr11
28 ; GFX6-NEXT: s_mov_b32 s9, s6
29 ; GFX6-NEXT: s_mov_b32 s10, s13
30 ; GFX6-NEXT: s_mov_b32 s11, s12
31 ; GFX6-NEXT: s_mov_b32 s14, s5
32 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
33 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
34 ; GFX6-NEXT: s_mov_b32 s5, s14
35 ; GFX6-NEXT: s_mov_b32 s6, s13
36 ; GFX6-NEXT: s_mov_b32 s7, s12
37 ; GFX6-NEXT: buffer_load_dword v0, off, s[8:11], 0
38 ; GFX6-NEXT: s_waitcnt vmcnt(0)
39 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
42 ; GFX7-LABEL: global_workgroup_unordered_load:
43 ; GFX7: ; %bb.0: ; %entry
44 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
45 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x2
46 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
47 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
48 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
49 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
50 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
51 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
52 ; GFX7-NEXT: s_waitcnt vmcnt(0)
53 ; GFX7-NEXT: flat_store_dword v[0:1], v2
56 ; GFX10-WGP-LABEL: global_workgroup_unordered_load:
57 ; GFX10-WGP: ; %bb.0: ; %entry
58 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
59 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
60 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
61 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
62 ; GFX10-WGP-NEXT: global_load_dword v1, v0, s[6:7]
63 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
64 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
65 ; GFX10-WGP-NEXT: s_endpgm
67 ; GFX10-CU-LABEL: global_workgroup_unordered_load:
68 ; GFX10-CU: ; %bb.0: ; %entry
69 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
70 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
71 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
72 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
73 ; GFX10-CU-NEXT: global_load_dword v1, v0, s[6:7]
74 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
75 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
76 ; GFX10-CU-NEXT: s_endpgm
78 ; SKIP-CACHE-INV-LABEL: global_workgroup_unordered_load:
79 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
80 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[4:5]
81 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
82 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
83 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
84 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s5
85 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
86 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, 0xf000
87 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s9, -1
88 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
89 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s2
90 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
91 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
92 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s10, s1
93 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
94 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
95 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s10
96 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s9
97 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s8
98 ; SKIP-CACHE-INV-NEXT: buffer_load_dword v0, off, s[4:7], 0
99 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
100 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
101 ; SKIP-CACHE-INV-NEXT: s_endpgm
103 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_unordered_load:
104 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
105 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
106 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
107 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
108 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
109 ; GFX90A-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[6:7]
110 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
111 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
112 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
114 ; GFX90A-TGSPLIT-LABEL: global_workgroup_unordered_load:
115 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
116 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
117 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
118 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
119 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
120 ; GFX90A-TGSPLIT-NEXT: global_load_dword v1, v0, s[6:7]
121 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
122 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
123 ; GFX90A-TGSPLIT-NEXT: s_endpgm
125 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_unordered_load:
126 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
127 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
128 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
129 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
130 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
131 ; GFX940-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[2:3]
132 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
133 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
134 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
136 ; GFX940-TGSPLIT-LABEL: global_workgroup_unordered_load:
137 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
138 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
139 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
140 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
141 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
142 ; GFX940-TGSPLIT-NEXT: global_load_dword v1, v0, s[2:3]
143 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
144 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
145 ; GFX940-TGSPLIT-NEXT: s_endpgm
147 ; GFX11-WGP-LABEL: global_workgroup_unordered_load:
148 ; GFX11-WGP: ; %bb.0: ; %entry
149 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
150 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
151 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
152 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
153 ; GFX11-WGP-NEXT: global_load_b32 v1, v0, s[2:3]
154 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
155 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
156 ; GFX11-WGP-NEXT: s_endpgm
158 ; GFX11-CU-LABEL: global_workgroup_unordered_load:
159 ; GFX11-CU: ; %bb.0: ; %entry
160 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
161 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
162 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
163 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
164 ; GFX11-CU-NEXT: global_load_b32 v1, v0, s[2:3]
165 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
166 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
167 ; GFX11-CU-NEXT: s_endpgm
169 ; GFX12-WGP-LABEL: global_workgroup_unordered_load:
170 ; GFX12-WGP: ; %bb.0: ; %entry
171 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
172 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
173 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
174 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
175 ; GFX12-WGP-NEXT: global_load_b32 v1, v0, s[2:3]
176 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
177 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
178 ; GFX12-WGP-NEXT: s_endpgm
180 ; GFX12-CU-LABEL: global_workgroup_unordered_load:
181 ; GFX12-CU: ; %bb.0: ; %entry
182 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
183 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
184 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
185 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
186 ; GFX12-CU-NEXT: global_load_b32 v1, v0, s[2:3]
187 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
188 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
189 ; GFX12-CU-NEXT: s_endpgm
190 ptr addrspace(1) %in, ptr addrspace(1) %out) {
192 %val = load atomic i32, ptr addrspace(1) %in syncscope("workgroup") unordered, align 4
193 store i32 %val, ptr addrspace(1) %out
197 define amdgpu_kernel void @global_workgroup_monotonic_load(
198 ; GFX6-LABEL: global_workgroup_monotonic_load:
199 ; GFX6: ; %bb.0: ; %entry
200 ; GFX6-NEXT: s_mov_b64 s[4:5], s[8:9]
201 ; GFX6-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
202 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
203 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
204 ; GFX6-NEXT: s_mov_b32 s6, s9
205 ; GFX6-NEXT: ; kill: def $sgpr8 killed $sgpr8 killed $sgpr8_sgpr9
206 ; GFX6-NEXT: s_mov_b32 s12, 0x100f000
207 ; GFX6-NEXT: s_mov_b32 s13, -1
208 ; GFX6-NEXT: ; kill: def $sgpr8 killed $sgpr8 def $sgpr8_sgpr9_sgpr10_sgpr11
209 ; GFX6-NEXT: s_mov_b32 s9, s6
210 ; GFX6-NEXT: s_mov_b32 s10, s13
211 ; GFX6-NEXT: s_mov_b32 s11, s12
212 ; GFX6-NEXT: s_mov_b32 s14, s5
213 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
214 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
215 ; GFX6-NEXT: s_mov_b32 s5, s14
216 ; GFX6-NEXT: s_mov_b32 s6, s13
217 ; GFX6-NEXT: s_mov_b32 s7, s12
218 ; GFX6-NEXT: buffer_load_dword v0, off, s[8:11], 0
219 ; GFX6-NEXT: s_waitcnt vmcnt(0)
220 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
221 ; GFX6-NEXT: s_endpgm
223 ; GFX7-LABEL: global_workgroup_monotonic_load:
224 ; GFX7: ; %bb.0: ; %entry
225 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
226 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x2
227 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
228 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
229 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
230 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
231 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
232 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
233 ; GFX7-NEXT: s_waitcnt vmcnt(0)
234 ; GFX7-NEXT: flat_store_dword v[0:1], v2
235 ; GFX7-NEXT: s_endpgm
237 ; GFX10-WGP-LABEL: global_workgroup_monotonic_load:
238 ; GFX10-WGP: ; %bb.0: ; %entry
239 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
240 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
241 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
242 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
243 ; GFX10-WGP-NEXT: global_load_dword v1, v0, s[6:7] glc
244 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
245 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
246 ; GFX10-WGP-NEXT: s_endpgm
248 ; GFX10-CU-LABEL: global_workgroup_monotonic_load:
249 ; GFX10-CU: ; %bb.0: ; %entry
250 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
251 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
252 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
253 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
254 ; GFX10-CU-NEXT: global_load_dword v1, v0, s[6:7]
255 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
256 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
257 ; GFX10-CU-NEXT: s_endpgm
259 ; SKIP-CACHE-INV-LABEL: global_workgroup_monotonic_load:
260 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
261 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[4:5]
262 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
263 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
264 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
265 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s5
266 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
267 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, 0xf000
268 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s9, -1
269 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
270 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s2
271 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
272 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
273 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s10, s1
274 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
275 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
276 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s10
277 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s9
278 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s8
279 ; SKIP-CACHE-INV-NEXT: buffer_load_dword v0, off, s[4:7], 0
280 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
281 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
282 ; SKIP-CACHE-INV-NEXT: s_endpgm
284 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_monotonic_load:
285 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
286 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
287 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
288 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
289 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
290 ; GFX90A-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[6:7]
291 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
292 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
293 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
295 ; GFX90A-TGSPLIT-LABEL: global_workgroup_monotonic_load:
296 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
297 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
298 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
299 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
300 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
301 ; GFX90A-TGSPLIT-NEXT: global_load_dword v1, v0, s[6:7] glc
302 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
303 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
304 ; GFX90A-TGSPLIT-NEXT: s_endpgm
306 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_monotonic_load:
307 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
308 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
309 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
310 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
311 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
312 ; GFX940-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[2:3] sc0
313 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
314 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
315 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
317 ; GFX940-TGSPLIT-LABEL: global_workgroup_monotonic_load:
318 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
319 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
320 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
321 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
322 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
323 ; GFX940-TGSPLIT-NEXT: global_load_dword v1, v0, s[2:3] sc0
324 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
325 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
326 ; GFX940-TGSPLIT-NEXT: s_endpgm
328 ; GFX11-WGP-LABEL: global_workgroup_monotonic_load:
329 ; GFX11-WGP: ; %bb.0: ; %entry
330 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
331 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
332 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
333 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
334 ; GFX11-WGP-NEXT: global_load_b32 v1, v0, s[2:3] glc
335 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
336 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
337 ; GFX11-WGP-NEXT: s_endpgm
339 ; GFX11-CU-LABEL: global_workgroup_monotonic_load:
340 ; GFX11-CU: ; %bb.0: ; %entry
341 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
342 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
343 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
344 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
345 ; GFX11-CU-NEXT: global_load_b32 v1, v0, s[2:3]
346 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
347 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
348 ; GFX11-CU-NEXT: s_endpgm
350 ; GFX12-WGP-LABEL: global_workgroup_monotonic_load:
351 ; GFX12-WGP: ; %bb.0: ; %entry
352 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
353 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
354 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
355 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
356 ; GFX12-WGP-NEXT: global_load_b32 v1, v0, s[2:3] scope:SCOPE_SE
357 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
358 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
359 ; GFX12-WGP-NEXT: s_endpgm
361 ; GFX12-CU-LABEL: global_workgroup_monotonic_load:
362 ; GFX12-CU: ; %bb.0: ; %entry
363 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
364 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
365 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
366 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
367 ; GFX12-CU-NEXT: global_load_b32 v1, v0, s[2:3]
368 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
369 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
370 ; GFX12-CU-NEXT: s_endpgm
371 ptr addrspace(1) %in, ptr addrspace(1) %out) {
373 %val = load atomic i32, ptr addrspace(1) %in syncscope("workgroup") monotonic, align 4
374 store i32 %val, ptr addrspace(1) %out
378 define amdgpu_kernel void @global_workgroup_acquire_load(
379 ; GFX6-LABEL: global_workgroup_acquire_load:
380 ; GFX6: ; %bb.0: ; %entry
381 ; GFX6-NEXT: s_mov_b64 s[4:5], s[8:9]
382 ; GFX6-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
383 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
384 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
385 ; GFX6-NEXT: s_mov_b32 s6, s9
386 ; GFX6-NEXT: ; kill: def $sgpr8 killed $sgpr8 killed $sgpr8_sgpr9
387 ; GFX6-NEXT: s_mov_b32 s12, 0x100f000
388 ; GFX6-NEXT: s_mov_b32 s13, -1
389 ; GFX6-NEXT: ; kill: def $sgpr8 killed $sgpr8 def $sgpr8_sgpr9_sgpr10_sgpr11
390 ; GFX6-NEXT: s_mov_b32 s9, s6
391 ; GFX6-NEXT: s_mov_b32 s10, s13
392 ; GFX6-NEXT: s_mov_b32 s11, s12
393 ; GFX6-NEXT: s_mov_b32 s14, s5
394 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
395 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
396 ; GFX6-NEXT: s_mov_b32 s5, s14
397 ; GFX6-NEXT: s_mov_b32 s6, s13
398 ; GFX6-NEXT: s_mov_b32 s7, s12
399 ; GFX6-NEXT: buffer_load_dword v0, off, s[8:11], 0
400 ; GFX6-NEXT: s_waitcnt vmcnt(0)
401 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
402 ; GFX6-NEXT: s_endpgm
404 ; GFX7-LABEL: global_workgroup_acquire_load:
405 ; GFX7: ; %bb.0: ; %entry
406 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
407 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x2
408 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
409 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
410 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
411 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
412 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
413 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
414 ; GFX7-NEXT: s_waitcnt vmcnt(0)
415 ; GFX7-NEXT: flat_store_dword v[0:1], v2
416 ; GFX7-NEXT: s_endpgm
418 ; GFX10-WGP-LABEL: global_workgroup_acquire_load:
419 ; GFX10-WGP: ; %bb.0: ; %entry
420 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
421 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
422 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
423 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
424 ; GFX10-WGP-NEXT: global_load_dword v1, v0, s[6:7] glc
425 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
426 ; GFX10-WGP-NEXT: buffer_gl0_inv
427 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
428 ; GFX10-WGP-NEXT: s_endpgm
430 ; GFX10-CU-LABEL: global_workgroup_acquire_load:
431 ; GFX10-CU: ; %bb.0: ; %entry
432 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
433 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
434 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
435 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
436 ; GFX10-CU-NEXT: global_load_dword v1, v0, s[6:7]
437 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
438 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
439 ; GFX10-CU-NEXT: s_endpgm
441 ; SKIP-CACHE-INV-LABEL: global_workgroup_acquire_load:
442 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
443 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[4:5]
444 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
445 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
446 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
447 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s5
448 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
449 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, 0xf000
450 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s9, -1
451 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
452 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s2
453 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
454 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
455 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s10, s1
456 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
457 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
458 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s10
459 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s9
460 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s8
461 ; SKIP-CACHE-INV-NEXT: buffer_load_dword v0, off, s[4:7], 0
462 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
463 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
464 ; SKIP-CACHE-INV-NEXT: s_endpgm
466 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acquire_load:
467 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
468 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
469 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
470 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
471 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
472 ; GFX90A-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[6:7]
473 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
474 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
475 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
477 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acquire_load:
478 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
479 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
480 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
481 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
482 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
483 ; GFX90A-TGSPLIT-NEXT: global_load_dword v1, v0, s[6:7] glc
484 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
485 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
486 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
487 ; GFX90A-TGSPLIT-NEXT: s_endpgm
489 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acquire_load:
490 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
491 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
492 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
493 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
494 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
495 ; GFX940-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[2:3] sc0
496 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
497 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
498 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
500 ; GFX940-TGSPLIT-LABEL: global_workgroup_acquire_load:
501 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
502 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
503 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
504 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
505 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
506 ; GFX940-TGSPLIT-NEXT: global_load_dword v1, v0, s[2:3] sc0
507 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
508 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
509 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
510 ; GFX940-TGSPLIT-NEXT: s_endpgm
512 ; GFX11-WGP-LABEL: global_workgroup_acquire_load:
513 ; GFX11-WGP: ; %bb.0: ; %entry
514 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
515 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
516 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
517 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
518 ; GFX11-WGP-NEXT: global_load_b32 v1, v0, s[2:3] glc
519 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
520 ; GFX11-WGP-NEXT: buffer_gl0_inv
521 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
522 ; GFX11-WGP-NEXT: s_endpgm
524 ; GFX11-CU-LABEL: global_workgroup_acquire_load:
525 ; GFX11-CU: ; %bb.0: ; %entry
526 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
527 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
528 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
529 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
530 ; GFX11-CU-NEXT: global_load_b32 v1, v0, s[2:3]
531 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
532 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
533 ; GFX11-CU-NEXT: s_endpgm
535 ; GFX12-WGP-LABEL: global_workgroup_acquire_load:
536 ; GFX12-WGP: ; %bb.0: ; %entry
537 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
538 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
539 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
540 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
541 ; GFX12-WGP-NEXT: global_load_b32 v1, v0, s[2:3] scope:SCOPE_SE
542 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
543 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
544 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
545 ; GFX12-WGP-NEXT: s_endpgm
547 ; GFX12-CU-LABEL: global_workgroup_acquire_load:
548 ; GFX12-CU: ; %bb.0: ; %entry
549 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
550 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
551 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
552 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
553 ; GFX12-CU-NEXT: global_load_b32 v1, v0, s[2:3]
554 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
555 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
556 ; GFX12-CU-NEXT: s_endpgm
557 ptr addrspace(1) %in, ptr addrspace(1) %out) {
559 %val = load atomic i32, ptr addrspace(1) %in syncscope("workgroup") acquire, align 4
560 store i32 %val, ptr addrspace(1) %out
564 define amdgpu_kernel void @global_workgroup_seq_cst_load(
565 ; GFX6-LABEL: global_workgroup_seq_cst_load:
566 ; GFX6: ; %bb.0: ; %entry
567 ; GFX6-NEXT: s_mov_b64 s[4:5], s[8:9]
568 ; GFX6-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
569 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
570 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
571 ; GFX6-NEXT: s_mov_b32 s6, s9
572 ; GFX6-NEXT: ; kill: def $sgpr8 killed $sgpr8 killed $sgpr8_sgpr9
573 ; GFX6-NEXT: s_mov_b32 s12, 0x100f000
574 ; GFX6-NEXT: s_mov_b32 s13, -1
575 ; GFX6-NEXT: ; kill: def $sgpr8 killed $sgpr8 def $sgpr8_sgpr9_sgpr10_sgpr11
576 ; GFX6-NEXT: s_mov_b32 s9, s6
577 ; GFX6-NEXT: s_mov_b32 s10, s13
578 ; GFX6-NEXT: s_mov_b32 s11, s12
579 ; GFX6-NEXT: s_mov_b32 s14, s5
580 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
581 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
582 ; GFX6-NEXT: s_mov_b32 s5, s14
583 ; GFX6-NEXT: s_mov_b32 s6, s13
584 ; GFX6-NEXT: s_mov_b32 s7, s12
585 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
586 ; GFX6-NEXT: buffer_load_dword v0, off, s[8:11], 0
587 ; GFX6-NEXT: s_waitcnt vmcnt(0)
588 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
589 ; GFX6-NEXT: s_endpgm
591 ; GFX7-LABEL: global_workgroup_seq_cst_load:
592 ; GFX7: ; %bb.0: ; %entry
593 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
594 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x2
595 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
596 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
597 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
598 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
599 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
600 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
601 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
602 ; GFX7-NEXT: s_waitcnt vmcnt(0)
603 ; GFX7-NEXT: flat_store_dword v[0:1], v2
604 ; GFX7-NEXT: s_endpgm
606 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_load:
607 ; GFX10-WGP: ; %bb.0: ; %entry
608 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
609 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
610 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
611 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
612 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
613 ; GFX10-WGP-NEXT: global_load_dword v1, v0, s[6:7] glc
614 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
615 ; GFX10-WGP-NEXT: buffer_gl0_inv
616 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
617 ; GFX10-WGP-NEXT: s_endpgm
619 ; GFX10-CU-LABEL: global_workgroup_seq_cst_load:
620 ; GFX10-CU: ; %bb.0: ; %entry
621 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
622 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
623 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
624 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
625 ; GFX10-CU-NEXT: global_load_dword v1, v0, s[6:7]
626 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
627 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
628 ; GFX10-CU-NEXT: s_endpgm
630 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_load:
631 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
632 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[4:5]
633 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
634 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
635 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
636 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s5
637 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
638 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, 0xf000
639 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s9, -1
640 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
641 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s2
642 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
643 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
644 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s10, s1
645 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
646 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
647 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s10
648 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s9
649 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s8
650 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
651 ; SKIP-CACHE-INV-NEXT: buffer_load_dword v0, off, s[4:7], 0
652 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
653 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
654 ; SKIP-CACHE-INV-NEXT: s_endpgm
656 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_load:
657 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
658 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
659 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
660 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
661 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
662 ; GFX90A-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[6:7]
663 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
664 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
665 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
667 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_load:
668 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
669 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
670 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
671 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
672 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
673 ; GFX90A-TGSPLIT-NEXT: global_load_dword v1, v0, s[6:7] glc
674 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
675 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
676 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
677 ; GFX90A-TGSPLIT-NEXT: s_endpgm
679 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_load:
680 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
681 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
682 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
683 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
684 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
685 ; GFX940-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[2:3] sc0
686 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
687 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
688 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
690 ; GFX940-TGSPLIT-LABEL: global_workgroup_seq_cst_load:
691 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
692 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
693 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
694 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
695 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
696 ; GFX940-TGSPLIT-NEXT: global_load_dword v1, v0, s[2:3] sc0
697 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
698 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
699 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
700 ; GFX940-TGSPLIT-NEXT: s_endpgm
702 ; GFX11-WGP-LABEL: global_workgroup_seq_cst_load:
703 ; GFX11-WGP: ; %bb.0: ; %entry
704 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
705 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
706 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
707 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
708 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
709 ; GFX11-WGP-NEXT: global_load_b32 v1, v0, s[2:3] glc
710 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
711 ; GFX11-WGP-NEXT: buffer_gl0_inv
712 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
713 ; GFX11-WGP-NEXT: s_endpgm
715 ; GFX11-CU-LABEL: global_workgroup_seq_cst_load:
716 ; GFX11-CU: ; %bb.0: ; %entry
717 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
718 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
719 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
720 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
721 ; GFX11-CU-NEXT: global_load_b32 v1, v0, s[2:3]
722 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
723 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
724 ; GFX11-CU-NEXT: s_endpgm
726 ; GFX12-WGP-LABEL: global_workgroup_seq_cst_load:
727 ; GFX12-WGP: ; %bb.0: ; %entry
728 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
729 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
730 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
731 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
732 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
733 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
734 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
735 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
736 ; GFX12-WGP-NEXT: global_load_b32 v1, v0, s[2:3] scope:SCOPE_SE
737 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
738 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
739 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
740 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
741 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
742 ; GFX12-WGP-NEXT: s_endpgm
744 ; GFX12-CU-LABEL: global_workgroup_seq_cst_load:
745 ; GFX12-CU: ; %bb.0: ; %entry
746 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
747 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
748 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
749 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
750 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
751 ; GFX12-CU-NEXT: global_load_b32 v1, v0, s[2:3]
752 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
753 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
754 ; GFX12-CU-NEXT: s_endpgm
755 ptr addrspace(1) %in, ptr addrspace(1) %out) {
757 %val = load atomic i32, ptr addrspace(1) %in syncscope("workgroup") seq_cst, align 4
758 store i32 %val, ptr addrspace(1) %out
762 define amdgpu_kernel void @global_workgroup_unordered_store(
763 ; GFX6-LABEL: global_workgroup_unordered_store:
764 ; GFX6: ; %bb.0: ; %entry
765 ; GFX6-NEXT: s_mov_b64 s[4:5], s[8:9]
766 ; GFX6-NEXT: s_load_dword s8, s[4:5], 0x0
767 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
768 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
769 ; GFX6-NEXT: s_mov_b32 s11, s5
770 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
771 ; GFX6-NEXT: s_mov_b32 s9, 0x100f000
772 ; GFX6-NEXT: s_mov_b32 s10, -1
773 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
774 ; GFX6-NEXT: s_mov_b32 s5, s11
775 ; GFX6-NEXT: s_mov_b32 s6, s10
776 ; GFX6-NEXT: s_mov_b32 s7, s9
777 ; GFX6-NEXT: v_mov_b32_e32 v0, s8
778 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
779 ; GFX6-NEXT: s_endpgm
781 ; GFX7-LABEL: global_workgroup_unordered_store:
782 ; GFX7: ; %bb.0: ; %entry
783 ; GFX7-NEXT: s_load_dword s4, s[8:9], 0x0
784 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x2
785 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
786 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
787 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
788 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
789 ; GFX7-NEXT: flat_store_dword v[0:1], v2
790 ; GFX7-NEXT: s_endpgm
792 ; GFX10-WGP-LABEL: global_workgroup_unordered_store:
793 ; GFX10-WGP: ; %bb.0: ; %entry
794 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0x0
795 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
796 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
797 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
798 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s6
799 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
800 ; GFX10-WGP-NEXT: s_endpgm
802 ; GFX10-CU-LABEL: global_workgroup_unordered_store:
803 ; GFX10-CU: ; %bb.0: ; %entry
804 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0x0
805 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
806 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
807 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
808 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s6
809 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
810 ; GFX10-CU-NEXT: s_endpgm
812 ; SKIP-CACHE-INV-LABEL: global_workgroup_unordered_store:
813 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
814 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[4:5]
815 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x0
816 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
817 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
818 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s1
819 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
820 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, 0xf000
821 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
822 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
823 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s7
824 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s6
825 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s5
826 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
827 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
828 ; SKIP-CACHE-INV-NEXT: s_endpgm
830 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_unordered_store:
831 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
832 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x0
833 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
834 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
835 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
836 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
837 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
838 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
840 ; GFX90A-TGSPLIT-LABEL: global_workgroup_unordered_store:
841 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
842 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x0
843 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
844 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
845 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
846 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
847 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
848 ; GFX90A-TGSPLIT-NEXT: s_endpgm
850 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_unordered_store:
851 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
852 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
853 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
854 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
855 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
856 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
857 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
858 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
860 ; GFX940-TGSPLIT-LABEL: global_workgroup_unordered_store:
861 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
862 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
863 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
864 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
865 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
866 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
867 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
868 ; GFX940-TGSPLIT-NEXT: s_endpgm
870 ; GFX11-WGP-LABEL: global_workgroup_unordered_store:
871 ; GFX11-WGP: ; %bb.0: ; %entry
872 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0x0
873 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
874 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
875 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
876 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s2
877 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
878 ; GFX11-WGP-NEXT: s_endpgm
880 ; GFX11-CU-LABEL: global_workgroup_unordered_store:
881 ; GFX11-CU: ; %bb.0: ; %entry
882 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0x0
883 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
884 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
885 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
886 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s2
887 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
888 ; GFX11-CU-NEXT: s_endpgm
890 ; GFX12-WGP-LABEL: global_workgroup_unordered_store:
891 ; GFX12-WGP: ; %bb.0: ; %entry
892 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0x0
893 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
894 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
895 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
896 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s2
897 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
898 ; GFX12-WGP-NEXT: s_endpgm
900 ; GFX12-CU-LABEL: global_workgroup_unordered_store:
901 ; GFX12-CU: ; %bb.0: ; %entry
902 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0x0
903 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
904 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
905 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
906 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s2
907 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
908 ; GFX12-CU-NEXT: s_endpgm
909 i32 %in, ptr addrspace(1) %out) {
911 store atomic i32 %in, ptr addrspace(1) %out syncscope("workgroup") unordered, align 4
915 define amdgpu_kernel void @global_workgroup_monotonic_store(
916 ; GFX6-LABEL: global_workgroup_monotonic_store:
917 ; GFX6: ; %bb.0: ; %entry
918 ; GFX6-NEXT: s_mov_b64 s[4:5], s[8:9]
919 ; GFX6-NEXT: s_load_dword s8, s[4:5], 0x0
920 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
921 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
922 ; GFX6-NEXT: s_mov_b32 s11, s5
923 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
924 ; GFX6-NEXT: s_mov_b32 s9, 0x100f000
925 ; GFX6-NEXT: s_mov_b32 s10, -1
926 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
927 ; GFX6-NEXT: s_mov_b32 s5, s11
928 ; GFX6-NEXT: s_mov_b32 s6, s10
929 ; GFX6-NEXT: s_mov_b32 s7, s9
930 ; GFX6-NEXT: v_mov_b32_e32 v0, s8
931 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
932 ; GFX6-NEXT: s_endpgm
934 ; GFX7-LABEL: global_workgroup_monotonic_store:
935 ; GFX7: ; %bb.0: ; %entry
936 ; GFX7-NEXT: s_load_dword s4, s[8:9], 0x0
937 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x2
938 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
939 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
940 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
941 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
942 ; GFX7-NEXT: flat_store_dword v[0:1], v2
943 ; GFX7-NEXT: s_endpgm
945 ; GFX10-WGP-LABEL: global_workgroup_monotonic_store:
946 ; GFX10-WGP: ; %bb.0: ; %entry
947 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0x0
948 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
949 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
950 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
951 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s6
952 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
953 ; GFX10-WGP-NEXT: s_endpgm
955 ; GFX10-CU-LABEL: global_workgroup_monotonic_store:
956 ; GFX10-CU: ; %bb.0: ; %entry
957 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0x0
958 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
959 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
960 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
961 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s6
962 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
963 ; GFX10-CU-NEXT: s_endpgm
965 ; SKIP-CACHE-INV-LABEL: global_workgroup_monotonic_store:
966 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
967 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[4:5]
968 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x0
969 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
970 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
971 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s1
972 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
973 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, 0xf000
974 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
975 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
976 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s7
977 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s6
978 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s5
979 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
980 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
981 ; SKIP-CACHE-INV-NEXT: s_endpgm
983 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_monotonic_store:
984 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
985 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x0
986 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
987 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
988 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
989 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
990 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
991 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
993 ; GFX90A-TGSPLIT-LABEL: global_workgroup_monotonic_store:
994 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
995 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x0
996 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
997 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
998 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
999 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
1000 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
1001 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1003 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_monotonic_store:
1004 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
1005 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
1006 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
1007 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1008 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1009 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1010 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
1011 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
1013 ; GFX940-TGSPLIT-LABEL: global_workgroup_monotonic_store:
1014 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
1015 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
1016 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
1017 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1018 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1019 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1020 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
1021 ; GFX940-TGSPLIT-NEXT: s_endpgm
1023 ; GFX11-WGP-LABEL: global_workgroup_monotonic_store:
1024 ; GFX11-WGP: ; %bb.0: ; %entry
1025 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0x0
1026 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
1027 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
1028 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1029 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s2
1030 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
1031 ; GFX11-WGP-NEXT: s_endpgm
1033 ; GFX11-CU-LABEL: global_workgroup_monotonic_store:
1034 ; GFX11-CU: ; %bb.0: ; %entry
1035 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0x0
1036 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
1037 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
1038 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1039 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s2
1040 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
1041 ; GFX11-CU-NEXT: s_endpgm
1043 ; GFX12-WGP-LABEL: global_workgroup_monotonic_store:
1044 ; GFX12-WGP: ; %bb.0: ; %entry
1045 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0x0
1046 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
1047 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
1048 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
1049 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s2
1050 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1] scope:SCOPE_SE
1051 ; GFX12-WGP-NEXT: s_endpgm
1053 ; GFX12-CU-LABEL: global_workgroup_monotonic_store:
1054 ; GFX12-CU: ; %bb.0: ; %entry
1055 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0x0
1056 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
1057 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
1058 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
1059 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s2
1060 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
1061 ; GFX12-CU-NEXT: s_endpgm
1062 i32 %in, ptr addrspace(1) %out) {
1064 store atomic i32 %in, ptr addrspace(1) %out syncscope("workgroup") monotonic, align 4
1068 define amdgpu_kernel void @global_workgroup_release_store(
1069 ; GFX6-LABEL: global_workgroup_release_store:
1070 ; GFX6: ; %bb.0: ; %entry
1071 ; GFX6-NEXT: s_mov_b64 s[4:5], s[8:9]
1072 ; GFX6-NEXT: s_load_dword s8, s[4:5], 0x0
1073 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
1074 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1075 ; GFX6-NEXT: s_mov_b32 s11, s5
1076 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
1077 ; GFX6-NEXT: s_mov_b32 s9, 0x100f000
1078 ; GFX6-NEXT: s_mov_b32 s10, -1
1079 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
1080 ; GFX6-NEXT: s_mov_b32 s5, s11
1081 ; GFX6-NEXT: s_mov_b32 s6, s10
1082 ; GFX6-NEXT: s_mov_b32 s7, s9
1083 ; GFX6-NEXT: v_mov_b32_e32 v0, s8
1084 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1085 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
1086 ; GFX6-NEXT: s_endpgm
1088 ; GFX7-LABEL: global_workgroup_release_store:
1089 ; GFX7: ; %bb.0: ; %entry
1090 ; GFX7-NEXT: s_load_dword s4, s[8:9], 0x0
1091 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x2
1092 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1093 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
1094 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
1095 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
1096 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1097 ; GFX7-NEXT: flat_store_dword v[0:1], v2
1098 ; GFX7-NEXT: s_endpgm
1100 ; GFX10-WGP-LABEL: global_workgroup_release_store:
1101 ; GFX10-WGP: ; %bb.0: ; %entry
1102 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0x0
1103 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
1104 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
1105 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1106 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s6
1107 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1108 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1109 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
1110 ; GFX10-WGP-NEXT: s_endpgm
1112 ; GFX10-CU-LABEL: global_workgroup_release_store:
1113 ; GFX10-CU: ; %bb.0: ; %entry
1114 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0x0
1115 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
1116 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
1117 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1118 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s6
1119 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1120 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
1121 ; GFX10-CU-NEXT: s_endpgm
1123 ; SKIP-CACHE-INV-LABEL: global_workgroup_release_store:
1124 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1125 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[4:5]
1126 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x0
1127 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
1128 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1129 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s1
1130 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
1131 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, 0xf000
1132 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
1133 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
1134 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s7
1135 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s6
1136 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s5
1137 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
1138 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1139 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
1140 ; SKIP-CACHE-INV-NEXT: s_endpgm
1142 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_release_store:
1143 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1144 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x0
1145 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
1146 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1147 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1148 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
1149 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1150 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
1151 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1153 ; GFX90A-TGSPLIT-LABEL: global_workgroup_release_store:
1154 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1155 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x0
1156 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
1157 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1158 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1159 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
1160 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1161 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
1162 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1164 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_release_store:
1165 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
1166 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
1167 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
1168 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1169 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1170 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1171 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1172 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
1173 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
1175 ; GFX940-TGSPLIT-LABEL: global_workgroup_release_store:
1176 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
1177 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
1178 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
1179 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1180 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1181 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1182 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1183 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
1184 ; GFX940-TGSPLIT-NEXT: s_endpgm
1186 ; GFX11-WGP-LABEL: global_workgroup_release_store:
1187 ; GFX11-WGP: ; %bb.0: ; %entry
1188 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0x0
1189 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
1190 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
1191 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1192 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s2
1193 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1194 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1195 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
1196 ; GFX11-WGP-NEXT: s_endpgm
1198 ; GFX11-CU-LABEL: global_workgroup_release_store:
1199 ; GFX11-CU: ; %bb.0: ; %entry
1200 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0x0
1201 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
1202 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
1203 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1204 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s2
1205 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1206 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
1207 ; GFX11-CU-NEXT: s_endpgm
1209 ; GFX12-WGP-LABEL: global_workgroup_release_store:
1210 ; GFX12-WGP: ; %bb.0: ; %entry
1211 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0x0
1212 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
1213 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
1214 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
1215 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s2
1216 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
1217 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
1218 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
1219 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
1220 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1] scope:SCOPE_SE
1221 ; GFX12-WGP-NEXT: s_endpgm
1223 ; GFX12-CU-LABEL: global_workgroup_release_store:
1224 ; GFX12-CU: ; %bb.0: ; %entry
1225 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0x0
1226 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
1227 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
1228 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
1229 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s2
1230 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
1231 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
1232 ; GFX12-CU-NEXT: s_endpgm
1233 i32 %in, ptr addrspace(1) %out) {
1235 store atomic i32 %in, ptr addrspace(1) %out syncscope("workgroup") release, align 4
1239 define amdgpu_kernel void @global_workgroup_seq_cst_store(
1240 ; GFX6-LABEL: global_workgroup_seq_cst_store:
1241 ; GFX6: ; %bb.0: ; %entry
1242 ; GFX6-NEXT: s_mov_b64 s[4:5], s[8:9]
1243 ; GFX6-NEXT: s_load_dword s8, s[4:5], 0x0
1244 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
1245 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1246 ; GFX6-NEXT: s_mov_b32 s11, s5
1247 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
1248 ; GFX6-NEXT: s_mov_b32 s9, 0x100f000
1249 ; GFX6-NEXT: s_mov_b32 s10, -1
1250 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
1251 ; GFX6-NEXT: s_mov_b32 s5, s11
1252 ; GFX6-NEXT: s_mov_b32 s6, s10
1253 ; GFX6-NEXT: s_mov_b32 s7, s9
1254 ; GFX6-NEXT: v_mov_b32_e32 v0, s8
1255 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1256 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
1257 ; GFX6-NEXT: s_endpgm
1259 ; GFX7-LABEL: global_workgroup_seq_cst_store:
1260 ; GFX7: ; %bb.0: ; %entry
1261 ; GFX7-NEXT: s_load_dword s4, s[8:9], 0x0
1262 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x2
1263 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1264 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
1265 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
1266 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
1267 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1268 ; GFX7-NEXT: flat_store_dword v[0:1], v2
1269 ; GFX7-NEXT: s_endpgm
1271 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_store:
1272 ; GFX10-WGP: ; %bb.0: ; %entry
1273 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0x0
1274 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
1275 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
1276 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1277 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s6
1278 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1279 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1280 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
1281 ; GFX10-WGP-NEXT: s_endpgm
1283 ; GFX10-CU-LABEL: global_workgroup_seq_cst_store:
1284 ; GFX10-CU: ; %bb.0: ; %entry
1285 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0x0
1286 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
1287 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
1288 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1289 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s6
1290 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1291 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
1292 ; GFX10-CU-NEXT: s_endpgm
1294 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_store:
1295 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1296 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[4:5]
1297 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x0
1298 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
1299 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1300 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s1
1301 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
1302 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, 0xf000
1303 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
1304 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
1305 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s7
1306 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s6
1307 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s5
1308 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
1309 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1310 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
1311 ; SKIP-CACHE-INV-NEXT: s_endpgm
1313 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_store:
1314 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1315 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x0
1316 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
1317 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1318 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1319 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
1320 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1321 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
1322 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1324 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_store:
1325 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1326 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x0
1327 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
1328 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1329 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1330 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
1331 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1332 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
1333 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1335 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_store:
1336 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
1337 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
1338 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
1339 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1340 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1341 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1342 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1343 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
1344 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
1346 ; GFX940-TGSPLIT-LABEL: global_workgroup_seq_cst_store:
1347 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
1348 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
1349 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
1350 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1351 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1352 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1353 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1354 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
1355 ; GFX940-TGSPLIT-NEXT: s_endpgm
1357 ; GFX11-WGP-LABEL: global_workgroup_seq_cst_store:
1358 ; GFX11-WGP: ; %bb.0: ; %entry
1359 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0x0
1360 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
1361 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
1362 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1363 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s2
1364 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1365 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1366 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
1367 ; GFX11-WGP-NEXT: s_endpgm
1369 ; GFX11-CU-LABEL: global_workgroup_seq_cst_store:
1370 ; GFX11-CU: ; %bb.0: ; %entry
1371 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0x0
1372 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
1373 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
1374 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1375 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s2
1376 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1377 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
1378 ; GFX11-CU-NEXT: s_endpgm
1380 ; GFX12-WGP-LABEL: global_workgroup_seq_cst_store:
1381 ; GFX12-WGP: ; %bb.0: ; %entry
1382 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0x0
1383 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
1384 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
1385 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
1386 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s2
1387 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
1388 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
1389 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
1390 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
1391 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1] scope:SCOPE_SE
1392 ; GFX12-WGP-NEXT: s_endpgm
1394 ; GFX12-CU-LABEL: global_workgroup_seq_cst_store:
1395 ; GFX12-CU: ; %bb.0: ; %entry
1396 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0x0
1397 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
1398 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
1399 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
1400 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s2
1401 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
1402 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
1403 ; GFX12-CU-NEXT: s_endpgm
1404 i32 %in, ptr addrspace(1) %out) {
1406 store atomic i32 %in, ptr addrspace(1) %out syncscope("workgroup") seq_cst, align 4
1410 define amdgpu_kernel void @global_workgroup_monotonic_atomicrmw(
1411 ; GFX6-LABEL: global_workgroup_monotonic_atomicrmw:
1412 ; GFX6: ; %bb.0: ; %entry
1413 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
1414 ; GFX6-NEXT: s_load_dword s8, s[8:9], 0x2
1415 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1416 ; GFX6-NEXT: s_mov_b32 s11, s5
1417 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
1418 ; GFX6-NEXT: s_mov_b32 s9, 0x100f000
1419 ; GFX6-NEXT: s_mov_b32 s10, -1
1420 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
1421 ; GFX6-NEXT: s_mov_b32 s5, s11
1422 ; GFX6-NEXT: s_mov_b32 s6, s10
1423 ; GFX6-NEXT: s_mov_b32 s7, s9
1424 ; GFX6-NEXT: v_mov_b32_e32 v0, s8
1425 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[4:7], 0
1426 ; GFX6-NEXT: s_endpgm
1428 ; GFX7-LABEL: global_workgroup_monotonic_atomicrmw:
1429 ; GFX7: ; %bb.0: ; %entry
1430 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
1431 ; GFX7-NEXT: s_load_dword s4, s[8:9], 0x2
1432 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1433 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
1434 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
1435 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
1436 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
1437 ; GFX7-NEXT: s_endpgm
1439 ; GFX10-WGP-LABEL: global_workgroup_monotonic_atomicrmw:
1440 ; GFX10-WGP: ; %bb.0: ; %entry
1441 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
1442 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
1443 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0x8
1444 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1445 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s6
1446 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[4:5]
1447 ; GFX10-WGP-NEXT: s_endpgm
1449 ; GFX10-CU-LABEL: global_workgroup_monotonic_atomicrmw:
1450 ; GFX10-CU: ; %bb.0: ; %entry
1451 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
1452 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
1453 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0x8
1454 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1455 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s6
1456 ; GFX10-CU-NEXT: global_atomic_swap v0, v1, s[4:5]
1457 ; GFX10-CU-NEXT: s_endpgm
1459 ; SKIP-CACHE-INV-LABEL: global_workgroup_monotonic_atomicrmw:
1460 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1461 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1462 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[4:5], 0x2
1463 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1464 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s1
1465 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
1466 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, 0xf000
1467 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
1468 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
1469 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s7
1470 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s6
1471 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s5
1472 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
1473 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
1474 ; SKIP-CACHE-INV-NEXT: s_endpgm
1476 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_monotonic_atomicrmw:
1477 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1478 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1479 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
1480 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
1481 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1482 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
1483 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[4:5]
1484 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1486 ; GFX90A-TGSPLIT-LABEL: global_workgroup_monotonic_atomicrmw:
1487 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1488 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1489 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
1490 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
1491 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1492 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
1493 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[4:5]
1494 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1496 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_monotonic_atomicrmw:
1497 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
1498 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1499 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1500 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1501 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1502 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1503 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
1504 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
1506 ; GFX940-TGSPLIT-LABEL: global_workgroup_monotonic_atomicrmw:
1507 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
1508 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1509 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1510 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1511 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1512 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1513 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
1514 ; GFX940-TGSPLIT-NEXT: s_endpgm
1516 ; GFX11-WGP-LABEL: global_workgroup_monotonic_atomicrmw:
1517 ; GFX11-WGP: ; %bb.0: ; %entry
1518 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
1519 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
1520 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
1521 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1522 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s2
1523 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
1524 ; GFX11-WGP-NEXT: s_endpgm
1526 ; GFX11-CU-LABEL: global_workgroup_monotonic_atomicrmw:
1527 ; GFX11-CU: ; %bb.0: ; %entry
1528 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
1529 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
1530 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
1531 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1532 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s2
1533 ; GFX11-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
1534 ; GFX11-CU-NEXT: s_endpgm
1536 ; GFX12-WGP-LABEL: global_workgroup_monotonic_atomicrmw:
1537 ; GFX12-WGP: ; %bb.0: ; %entry
1538 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
1539 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
1540 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
1541 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
1542 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s2
1543 ; GFX12-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1] scope:SCOPE_SE
1544 ; GFX12-WGP-NEXT: s_endpgm
1546 ; GFX12-CU-LABEL: global_workgroup_monotonic_atomicrmw:
1547 ; GFX12-CU: ; %bb.0: ; %entry
1548 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
1549 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
1550 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
1551 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
1552 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s2
1553 ; GFX12-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
1554 ; GFX12-CU-NEXT: s_endpgm
1555 ptr addrspace(1) %out, i32 %in) {
1557 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup") monotonic
1561 define amdgpu_kernel void @global_workgroup_acquire_atomicrmw(
1562 ; GFX6-LABEL: global_workgroup_acquire_atomicrmw:
1563 ; GFX6: ; %bb.0: ; %entry
1564 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
1565 ; GFX6-NEXT: s_load_dword s8, s[8:9], 0x2
1566 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1567 ; GFX6-NEXT: s_mov_b32 s11, s5
1568 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
1569 ; GFX6-NEXT: s_mov_b32 s9, 0x100f000
1570 ; GFX6-NEXT: s_mov_b32 s10, -1
1571 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
1572 ; GFX6-NEXT: s_mov_b32 s5, s11
1573 ; GFX6-NEXT: s_mov_b32 s6, s10
1574 ; GFX6-NEXT: s_mov_b32 s7, s9
1575 ; GFX6-NEXT: v_mov_b32_e32 v0, s8
1576 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[4:7], 0
1577 ; GFX6-NEXT: s_endpgm
1579 ; GFX7-LABEL: global_workgroup_acquire_atomicrmw:
1580 ; GFX7: ; %bb.0: ; %entry
1581 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
1582 ; GFX7-NEXT: s_load_dword s4, s[8:9], 0x2
1583 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1584 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
1585 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
1586 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
1587 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
1588 ; GFX7-NEXT: s_endpgm
1590 ; GFX10-WGP-LABEL: global_workgroup_acquire_atomicrmw:
1591 ; GFX10-WGP: ; %bb.0: ; %entry
1592 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
1593 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
1594 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0x8
1595 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1596 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s6
1597 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[4:5]
1598 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1599 ; GFX10-WGP-NEXT: buffer_gl0_inv
1600 ; GFX10-WGP-NEXT: s_endpgm
1602 ; GFX10-CU-LABEL: global_workgroup_acquire_atomicrmw:
1603 ; GFX10-CU: ; %bb.0: ; %entry
1604 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
1605 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
1606 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0x8
1607 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1608 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s6
1609 ; GFX10-CU-NEXT: global_atomic_swap v0, v1, s[4:5]
1610 ; GFX10-CU-NEXT: s_endpgm
1612 ; SKIP-CACHE-INV-LABEL: global_workgroup_acquire_atomicrmw:
1613 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1614 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1615 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[4:5], 0x2
1616 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1617 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s1
1618 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
1619 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, 0xf000
1620 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
1621 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
1622 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s7
1623 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s6
1624 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s5
1625 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
1626 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
1627 ; SKIP-CACHE-INV-NEXT: s_endpgm
1629 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acquire_atomicrmw:
1630 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1631 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1632 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
1633 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
1634 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1635 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
1636 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[4:5]
1637 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1639 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acquire_atomicrmw:
1640 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1641 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1642 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
1643 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
1644 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1645 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
1646 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[4:5]
1647 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1648 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
1649 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1651 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acquire_atomicrmw:
1652 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
1653 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1654 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1655 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1656 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1657 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1658 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
1659 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
1661 ; GFX940-TGSPLIT-LABEL: global_workgroup_acquire_atomicrmw:
1662 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
1663 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1664 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1665 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1666 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1667 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1668 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
1669 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1670 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
1671 ; GFX940-TGSPLIT-NEXT: s_endpgm
1673 ; GFX11-WGP-LABEL: global_workgroup_acquire_atomicrmw:
1674 ; GFX11-WGP: ; %bb.0: ; %entry
1675 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
1676 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
1677 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
1678 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1679 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s2
1680 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
1681 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1682 ; GFX11-WGP-NEXT: buffer_gl0_inv
1683 ; GFX11-WGP-NEXT: s_endpgm
1685 ; GFX11-CU-LABEL: global_workgroup_acquire_atomicrmw:
1686 ; GFX11-CU: ; %bb.0: ; %entry
1687 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
1688 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
1689 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
1690 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1691 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s2
1692 ; GFX11-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
1693 ; GFX11-CU-NEXT: s_endpgm
1695 ; GFX12-WGP-LABEL: global_workgroup_acquire_atomicrmw:
1696 ; GFX12-WGP: ; %bb.0: ; %entry
1697 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
1698 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
1699 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
1700 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
1701 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s2
1702 ; GFX12-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1] scope:SCOPE_SE
1703 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
1704 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
1705 ; GFX12-WGP-NEXT: s_endpgm
1707 ; GFX12-CU-LABEL: global_workgroup_acquire_atomicrmw:
1708 ; GFX12-CU: ; %bb.0: ; %entry
1709 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
1710 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
1711 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
1712 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
1713 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s2
1714 ; GFX12-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
1715 ; GFX12-CU-NEXT: s_endpgm
1716 ptr addrspace(1) %out, i32 %in) {
1718 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup") acquire
1722 define amdgpu_kernel void @global_workgroup_release_atomicrmw(
1723 ; GFX6-LABEL: global_workgroup_release_atomicrmw:
1724 ; GFX6: ; %bb.0: ; %entry
1725 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
1726 ; GFX6-NEXT: s_load_dword s8, s[8:9], 0x2
1727 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1728 ; GFX6-NEXT: s_mov_b32 s11, s5
1729 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
1730 ; GFX6-NEXT: s_mov_b32 s9, 0x100f000
1731 ; GFX6-NEXT: s_mov_b32 s10, -1
1732 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
1733 ; GFX6-NEXT: s_mov_b32 s5, s11
1734 ; GFX6-NEXT: s_mov_b32 s6, s10
1735 ; GFX6-NEXT: s_mov_b32 s7, s9
1736 ; GFX6-NEXT: v_mov_b32_e32 v0, s8
1737 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1738 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[4:7], 0
1739 ; GFX6-NEXT: s_endpgm
1741 ; GFX7-LABEL: global_workgroup_release_atomicrmw:
1742 ; GFX7: ; %bb.0: ; %entry
1743 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
1744 ; GFX7-NEXT: s_load_dword s4, s[8:9], 0x2
1745 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1746 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
1747 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
1748 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
1749 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1750 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
1751 ; GFX7-NEXT: s_endpgm
1753 ; GFX10-WGP-LABEL: global_workgroup_release_atomicrmw:
1754 ; GFX10-WGP: ; %bb.0: ; %entry
1755 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
1756 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
1757 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0x8
1758 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1759 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s6
1760 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1761 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1762 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[4:5]
1763 ; GFX10-WGP-NEXT: s_endpgm
1765 ; GFX10-CU-LABEL: global_workgroup_release_atomicrmw:
1766 ; GFX10-CU: ; %bb.0: ; %entry
1767 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
1768 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
1769 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0x8
1770 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1771 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s6
1772 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1773 ; GFX10-CU-NEXT: global_atomic_swap v0, v1, s[4:5]
1774 ; GFX10-CU-NEXT: s_endpgm
1776 ; SKIP-CACHE-INV-LABEL: global_workgroup_release_atomicrmw:
1777 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1778 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1779 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[4:5], 0x2
1780 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1781 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s1
1782 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
1783 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, 0xf000
1784 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
1785 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
1786 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s7
1787 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s6
1788 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s5
1789 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
1790 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1791 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
1792 ; SKIP-CACHE-INV-NEXT: s_endpgm
1794 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_release_atomicrmw:
1795 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1796 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1797 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
1798 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
1799 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1800 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
1801 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1802 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[4:5]
1803 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1805 ; GFX90A-TGSPLIT-LABEL: global_workgroup_release_atomicrmw:
1806 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1807 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1808 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
1809 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
1810 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1811 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
1812 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1813 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[4:5]
1814 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1816 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_release_atomicrmw:
1817 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
1818 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1819 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1820 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1821 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1822 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1823 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1824 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
1825 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
1827 ; GFX940-TGSPLIT-LABEL: global_workgroup_release_atomicrmw:
1828 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
1829 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1830 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1831 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1832 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1833 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1834 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1835 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
1836 ; GFX940-TGSPLIT-NEXT: s_endpgm
1838 ; GFX11-WGP-LABEL: global_workgroup_release_atomicrmw:
1839 ; GFX11-WGP: ; %bb.0: ; %entry
1840 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
1841 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
1842 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
1843 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
1844 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s2
1845 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1846 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1847 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
1848 ; GFX11-WGP-NEXT: s_endpgm
1850 ; GFX11-CU-LABEL: global_workgroup_release_atomicrmw:
1851 ; GFX11-CU: ; %bb.0: ; %entry
1852 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
1853 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
1854 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
1855 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1856 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s2
1857 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
1858 ; GFX11-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
1859 ; GFX11-CU-NEXT: s_endpgm
1861 ; GFX12-WGP-LABEL: global_workgroup_release_atomicrmw:
1862 ; GFX12-WGP: ; %bb.0: ; %entry
1863 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
1864 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
1865 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
1866 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
1867 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s2
1868 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
1869 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
1870 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
1871 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
1872 ; GFX12-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1] scope:SCOPE_SE
1873 ; GFX12-WGP-NEXT: s_endpgm
1875 ; GFX12-CU-LABEL: global_workgroup_release_atomicrmw:
1876 ; GFX12-CU: ; %bb.0: ; %entry
1877 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
1878 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
1879 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
1880 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
1881 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s2
1882 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
1883 ; GFX12-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
1884 ; GFX12-CU-NEXT: s_endpgm
1885 ptr addrspace(1) %out, i32 %in) {
1887 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup") release
1891 define amdgpu_kernel void @global_workgroup_acq_rel_atomicrmw(
1892 ; GFX6-LABEL: global_workgroup_acq_rel_atomicrmw:
1893 ; GFX6: ; %bb.0: ; %entry
1894 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
1895 ; GFX6-NEXT: s_load_dword s8, s[8:9], 0x2
1896 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1897 ; GFX6-NEXT: s_mov_b32 s11, s5
1898 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
1899 ; GFX6-NEXT: s_mov_b32 s9, 0x100f000
1900 ; GFX6-NEXT: s_mov_b32 s10, -1
1901 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
1902 ; GFX6-NEXT: s_mov_b32 s5, s11
1903 ; GFX6-NEXT: s_mov_b32 s6, s10
1904 ; GFX6-NEXT: s_mov_b32 s7, s9
1905 ; GFX6-NEXT: v_mov_b32_e32 v0, s8
1906 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
1907 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[4:7], 0
1908 ; GFX6-NEXT: s_endpgm
1910 ; GFX7-LABEL: global_workgroup_acq_rel_atomicrmw:
1911 ; GFX7: ; %bb.0: ; %entry
1912 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
1913 ; GFX7-NEXT: s_load_dword s4, s[8:9], 0x2
1914 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1915 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
1916 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
1917 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
1918 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
1919 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
1920 ; GFX7-NEXT: s_endpgm
1922 ; GFX10-WGP-LABEL: global_workgroup_acq_rel_atomicrmw:
1923 ; GFX10-WGP: ; %bb.0: ; %entry
1924 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
1925 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
1926 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0x8
1927 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
1928 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s6
1929 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1930 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1931 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[4:5]
1932 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
1933 ; GFX10-WGP-NEXT: buffer_gl0_inv
1934 ; GFX10-WGP-NEXT: s_endpgm
1936 ; GFX10-CU-LABEL: global_workgroup_acq_rel_atomicrmw:
1937 ; GFX10-CU: ; %bb.0: ; %entry
1938 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
1939 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
1940 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0x8
1941 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1942 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s6
1943 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
1944 ; GFX10-CU-NEXT: global_atomic_swap v0, v1, s[4:5]
1945 ; GFX10-CU-NEXT: s_endpgm
1947 ; SKIP-CACHE-INV-LABEL: global_workgroup_acq_rel_atomicrmw:
1948 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
1949 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1950 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[4:5], 0x2
1951 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1952 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s1
1953 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
1954 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, 0xf000
1955 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
1956 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
1957 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s7
1958 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s6
1959 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s5
1960 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
1961 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
1962 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
1963 ; SKIP-CACHE-INV-NEXT: s_endpgm
1965 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_atomicrmw:
1966 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
1967 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1968 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
1969 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
1970 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1971 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
1972 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1973 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[4:5]
1974 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
1976 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acq_rel_atomicrmw:
1977 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
1978 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1979 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
1980 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
1981 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1982 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
1983 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1984 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[4:5]
1985 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
1986 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
1987 ; GFX90A-TGSPLIT-NEXT: s_endpgm
1989 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_atomicrmw:
1990 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
1991 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
1992 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
1993 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
1994 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1995 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
1996 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
1997 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
1998 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
2000 ; GFX940-TGSPLIT-LABEL: global_workgroup_acq_rel_atomicrmw:
2001 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
2002 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2003 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2004 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
2005 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2006 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
2007 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2008 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
2009 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2010 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
2011 ; GFX940-TGSPLIT-NEXT: s_endpgm
2013 ; GFX11-WGP-LABEL: global_workgroup_acq_rel_atomicrmw:
2014 ; GFX11-WGP: ; %bb.0: ; %entry
2015 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
2016 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
2017 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
2018 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
2019 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s2
2020 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2021 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2022 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
2023 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2024 ; GFX11-WGP-NEXT: buffer_gl0_inv
2025 ; GFX11-WGP-NEXT: s_endpgm
2027 ; GFX11-CU-LABEL: global_workgroup_acq_rel_atomicrmw:
2028 ; GFX11-CU: ; %bb.0: ; %entry
2029 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
2030 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
2031 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
2032 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2033 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s2
2034 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2035 ; GFX11-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
2036 ; GFX11-CU-NEXT: s_endpgm
2038 ; GFX12-WGP-LABEL: global_workgroup_acq_rel_atomicrmw:
2039 ; GFX12-WGP: ; %bb.0: ; %entry
2040 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
2041 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
2042 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
2043 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
2044 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s2
2045 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
2046 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
2047 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
2048 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
2049 ; GFX12-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1] scope:SCOPE_SE
2050 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
2051 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
2052 ; GFX12-WGP-NEXT: s_endpgm
2054 ; GFX12-CU-LABEL: global_workgroup_acq_rel_atomicrmw:
2055 ; GFX12-CU: ; %bb.0: ; %entry
2056 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
2057 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
2058 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
2059 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
2060 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s2
2061 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
2062 ; GFX12-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
2063 ; GFX12-CU-NEXT: s_endpgm
2064 ptr addrspace(1) %out, i32 %in) {
2066 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup") acq_rel
2070 define amdgpu_kernel void @global_workgroup_seq_cst_atomicrmw(
2071 ; GFX6-LABEL: global_workgroup_seq_cst_atomicrmw:
2072 ; GFX6: ; %bb.0: ; %entry
2073 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2074 ; GFX6-NEXT: s_load_dword s8, s[8:9], 0x2
2075 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2076 ; GFX6-NEXT: s_mov_b32 s11, s5
2077 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
2078 ; GFX6-NEXT: s_mov_b32 s9, 0x100f000
2079 ; GFX6-NEXT: s_mov_b32 s10, -1
2080 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
2081 ; GFX6-NEXT: s_mov_b32 s5, s11
2082 ; GFX6-NEXT: s_mov_b32 s6, s10
2083 ; GFX6-NEXT: s_mov_b32 s7, s9
2084 ; GFX6-NEXT: v_mov_b32_e32 v0, s8
2085 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2086 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[4:7], 0
2087 ; GFX6-NEXT: s_endpgm
2089 ; GFX7-LABEL: global_workgroup_seq_cst_atomicrmw:
2090 ; GFX7: ; %bb.0: ; %entry
2091 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
2092 ; GFX7-NEXT: s_load_dword s4, s[8:9], 0x2
2093 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2094 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
2095 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
2096 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
2097 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2098 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
2099 ; GFX7-NEXT: s_endpgm
2101 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_atomicrmw:
2102 ; GFX10-WGP: ; %bb.0: ; %entry
2103 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
2104 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2105 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0x8
2106 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2107 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s6
2108 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2109 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2110 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[4:5]
2111 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2112 ; GFX10-WGP-NEXT: buffer_gl0_inv
2113 ; GFX10-WGP-NEXT: s_endpgm
2115 ; GFX10-CU-LABEL: global_workgroup_seq_cst_atomicrmw:
2116 ; GFX10-CU: ; %bb.0: ; %entry
2117 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
2118 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2119 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0x8
2120 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2121 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s6
2122 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2123 ; GFX10-CU-NEXT: global_atomic_swap v0, v1, s[4:5]
2124 ; GFX10-CU-NEXT: s_endpgm
2126 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_atomicrmw:
2127 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2128 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2129 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[4:5], 0x2
2130 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2131 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s1
2132 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
2133 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, 0xf000
2134 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
2135 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
2136 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s7
2137 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s6
2138 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s5
2139 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
2140 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2141 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
2142 ; SKIP-CACHE-INV-NEXT: s_endpgm
2144 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_atomicrmw:
2145 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2146 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2147 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2148 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
2149 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2150 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
2151 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2152 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[4:5]
2153 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2155 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_atomicrmw:
2156 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2157 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2158 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2159 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
2160 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2161 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
2162 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2163 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[4:5]
2164 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2165 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
2166 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2168 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_atomicrmw:
2169 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
2170 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2171 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2172 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
2173 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2174 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
2175 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2176 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
2177 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
2179 ; GFX940-TGSPLIT-LABEL: global_workgroup_seq_cst_atomicrmw:
2180 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
2181 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2182 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2183 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
2184 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2185 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
2186 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2187 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
2188 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2189 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
2190 ; GFX940-TGSPLIT-NEXT: s_endpgm
2192 ; GFX11-WGP-LABEL: global_workgroup_seq_cst_atomicrmw:
2193 ; GFX11-WGP: ; %bb.0: ; %entry
2194 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
2195 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
2196 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
2197 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
2198 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s2
2199 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2200 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2201 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
2202 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2203 ; GFX11-WGP-NEXT: buffer_gl0_inv
2204 ; GFX11-WGP-NEXT: s_endpgm
2206 ; GFX11-CU-LABEL: global_workgroup_seq_cst_atomicrmw:
2207 ; GFX11-CU: ; %bb.0: ; %entry
2208 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
2209 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
2210 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
2211 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2212 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s2
2213 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2214 ; GFX11-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
2215 ; GFX11-CU-NEXT: s_endpgm
2217 ; GFX12-WGP-LABEL: global_workgroup_seq_cst_atomicrmw:
2218 ; GFX12-WGP: ; %bb.0: ; %entry
2219 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
2220 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
2221 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
2222 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
2223 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s2
2224 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
2225 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
2226 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
2227 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
2228 ; GFX12-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1] scope:SCOPE_SE
2229 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
2230 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
2231 ; GFX12-WGP-NEXT: s_endpgm
2233 ; GFX12-CU-LABEL: global_workgroup_seq_cst_atomicrmw:
2234 ; GFX12-CU: ; %bb.0: ; %entry
2235 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
2236 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
2237 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
2238 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
2239 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s2
2240 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
2241 ; GFX12-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
2242 ; GFX12-CU-NEXT: s_endpgm
2243 ptr addrspace(1) %out, i32 %in) {
2245 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup") seq_cst
2249 define amdgpu_kernel void @global_workgroup_acquire_ret_atomicrmw(
2250 ; GFX6-LABEL: global_workgroup_acquire_ret_atomicrmw:
2251 ; GFX6: ; %bb.0: ; %entry
2252 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2253 ; GFX6-NEXT: s_load_dword s8, s[8:9], 0x2
2254 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2255 ; GFX6-NEXT: s_mov_b32 s11, s5
2256 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
2257 ; GFX6-NEXT: s_mov_b32 s9, 0x100f000
2258 ; GFX6-NEXT: s_mov_b32 s10, -1
2259 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
2260 ; GFX6-NEXT: s_mov_b32 s5, s11
2261 ; GFX6-NEXT: s_mov_b32 s6, s10
2262 ; GFX6-NEXT: s_mov_b32 s7, s9
2263 ; GFX6-NEXT: v_mov_b32_e32 v0, s8
2264 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[4:7], 0 glc
2265 ; GFX6-NEXT: s_waitcnt vmcnt(0)
2266 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
2267 ; GFX6-NEXT: s_endpgm
2269 ; GFX7-LABEL: global_workgroup_acquire_ret_atomicrmw:
2270 ; GFX7: ; %bb.0: ; %entry
2271 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2272 ; GFX7-NEXT: s_load_dword s6, s[8:9], 0x2
2273 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2274 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
2275 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
2276 ; GFX7-NEXT: v_mov_b32_e32 v2, s6
2277 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
2278 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
2279 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
2280 ; GFX7-NEXT: s_waitcnt vmcnt(0)
2281 ; GFX7-NEXT: flat_store_dword v[0:1], v2
2282 ; GFX7-NEXT: s_endpgm
2284 ; GFX10-WGP-LABEL: global_workgroup_acquire_ret_atomicrmw:
2285 ; GFX10-WGP: ; %bb.0: ; %entry
2286 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
2287 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2288 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0x8
2289 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2290 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s6
2291 ; GFX10-WGP-NEXT: global_atomic_swap v1, v0, v1, s[4:5] glc
2292 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
2293 ; GFX10-WGP-NEXT: buffer_gl0_inv
2294 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
2295 ; GFX10-WGP-NEXT: s_endpgm
2297 ; GFX10-CU-LABEL: global_workgroup_acquire_ret_atomicrmw:
2298 ; GFX10-CU: ; %bb.0: ; %entry
2299 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
2300 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2301 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0x8
2302 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2303 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s6
2304 ; GFX10-CU-NEXT: global_atomic_swap v1, v0, v1, s[4:5] glc
2305 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
2306 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
2307 ; GFX10-CU-NEXT: s_endpgm
2309 ; SKIP-CACHE-INV-LABEL: global_workgroup_acquire_ret_atomicrmw:
2310 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2311 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2312 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[4:5], 0x2
2313 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2314 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s1
2315 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
2316 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, 0xf000
2317 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
2318 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
2319 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s7
2320 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s6
2321 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s5
2322 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
2323 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0 glc
2324 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
2325 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
2326 ; SKIP-CACHE-INV-NEXT: s_endpgm
2328 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acquire_ret_atomicrmw:
2329 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2330 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2331 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2332 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
2333 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2334 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
2335 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[4:5] glc
2336 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
2337 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
2338 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2340 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acquire_ret_atomicrmw:
2341 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2342 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2343 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2344 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
2345 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2346 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
2347 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[4:5] glc
2348 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2349 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
2350 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
2351 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2353 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acquire_ret_atomicrmw:
2354 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
2355 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2356 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2357 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
2358 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2359 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
2360 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] sc0
2361 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
2362 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
2363 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
2365 ; GFX940-TGSPLIT-LABEL: global_workgroup_acquire_ret_atomicrmw:
2366 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
2367 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2368 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2369 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
2370 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2371 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
2372 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] sc0
2373 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2374 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
2375 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
2376 ; GFX940-TGSPLIT-NEXT: s_endpgm
2378 ; GFX11-WGP-LABEL: global_workgroup_acquire_ret_atomicrmw:
2379 ; GFX11-WGP: ; %bb.0: ; %entry
2380 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
2381 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
2382 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
2383 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
2384 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s2
2385 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] glc
2386 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
2387 ; GFX11-WGP-NEXT: buffer_gl0_inv
2388 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
2389 ; GFX11-WGP-NEXT: s_endpgm
2391 ; GFX11-CU-LABEL: global_workgroup_acquire_ret_atomicrmw:
2392 ; GFX11-CU: ; %bb.0: ; %entry
2393 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
2394 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
2395 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
2396 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2397 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s2
2398 ; GFX11-CU-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] glc
2399 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
2400 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
2401 ; GFX11-CU-NEXT: s_endpgm
2403 ; GFX12-WGP-LABEL: global_workgroup_acquire_ret_atomicrmw:
2404 ; GFX12-WGP: ; %bb.0: ; %entry
2405 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
2406 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
2407 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
2408 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
2409 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s2
2410 ; GFX12-WGP-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] th:TH_ATOMIC_RETURN scope:SCOPE_SE
2411 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
2412 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
2413 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
2414 ; GFX12-WGP-NEXT: s_endpgm
2416 ; GFX12-CU-LABEL: global_workgroup_acquire_ret_atomicrmw:
2417 ; GFX12-CU: ; %bb.0: ; %entry
2418 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
2419 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
2420 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
2421 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
2422 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s2
2423 ; GFX12-CU-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] th:TH_ATOMIC_RETURN
2424 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
2425 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
2426 ; GFX12-CU-NEXT: s_endpgm
2427 ptr addrspace(1) %out, i32 %in) {
2429 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup") acquire
2430 store i32 %val, ptr addrspace(1) %out, align 4
2434 define amdgpu_kernel void @global_workgroup_acq_rel_ret_atomicrmw(
2435 ; GFX6-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
2436 ; GFX6: ; %bb.0: ; %entry
2437 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2438 ; GFX6-NEXT: s_load_dword s8, s[8:9], 0x2
2439 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2440 ; GFX6-NEXT: s_mov_b32 s11, s5
2441 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
2442 ; GFX6-NEXT: s_mov_b32 s9, 0x100f000
2443 ; GFX6-NEXT: s_mov_b32 s10, -1
2444 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
2445 ; GFX6-NEXT: s_mov_b32 s5, s11
2446 ; GFX6-NEXT: s_mov_b32 s6, s10
2447 ; GFX6-NEXT: s_mov_b32 s7, s9
2448 ; GFX6-NEXT: v_mov_b32_e32 v0, s8
2449 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2450 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[4:7], 0 glc
2451 ; GFX6-NEXT: s_waitcnt vmcnt(0)
2452 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
2453 ; GFX6-NEXT: s_endpgm
2455 ; GFX7-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
2456 ; GFX7: ; %bb.0: ; %entry
2457 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2458 ; GFX7-NEXT: s_load_dword s6, s[8:9], 0x2
2459 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2460 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
2461 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
2462 ; GFX7-NEXT: v_mov_b32_e32 v2, s6
2463 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2464 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
2465 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
2466 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
2467 ; GFX7-NEXT: s_waitcnt vmcnt(0)
2468 ; GFX7-NEXT: flat_store_dword v[0:1], v2
2469 ; GFX7-NEXT: s_endpgm
2471 ; GFX10-WGP-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
2472 ; GFX10-WGP: ; %bb.0: ; %entry
2473 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
2474 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2475 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0x8
2476 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2477 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s6
2478 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2479 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2480 ; GFX10-WGP-NEXT: global_atomic_swap v1, v0, v1, s[4:5] glc
2481 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
2482 ; GFX10-WGP-NEXT: buffer_gl0_inv
2483 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
2484 ; GFX10-WGP-NEXT: s_endpgm
2486 ; GFX10-CU-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
2487 ; GFX10-CU: ; %bb.0: ; %entry
2488 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
2489 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2490 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0x8
2491 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2492 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s6
2493 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2494 ; GFX10-CU-NEXT: global_atomic_swap v1, v0, v1, s[4:5] glc
2495 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
2496 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
2497 ; GFX10-CU-NEXT: s_endpgm
2499 ; SKIP-CACHE-INV-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
2500 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2501 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2502 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[4:5], 0x2
2503 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2504 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s1
2505 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
2506 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, 0xf000
2507 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
2508 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
2509 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s7
2510 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s6
2511 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s5
2512 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
2513 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2514 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0 glc
2515 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
2516 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
2517 ; SKIP-CACHE-INV-NEXT: s_endpgm
2519 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
2520 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2521 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2522 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2523 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
2524 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2525 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
2526 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2527 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[4:5] glc
2528 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
2529 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
2530 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2532 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
2533 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2534 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2535 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2536 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
2537 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2538 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
2539 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2540 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[4:5] glc
2541 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2542 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
2543 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
2544 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2546 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
2547 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
2548 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2549 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2550 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
2551 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2552 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
2553 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2554 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] sc0
2555 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
2556 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
2557 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
2559 ; GFX940-TGSPLIT-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
2560 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
2561 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2562 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2563 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
2564 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2565 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
2566 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2567 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] sc0
2568 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2569 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
2570 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
2571 ; GFX940-TGSPLIT-NEXT: s_endpgm
2573 ; GFX11-WGP-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
2574 ; GFX11-WGP: ; %bb.0: ; %entry
2575 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
2576 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
2577 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
2578 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
2579 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s2
2580 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2581 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2582 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] glc
2583 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
2584 ; GFX11-WGP-NEXT: buffer_gl0_inv
2585 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
2586 ; GFX11-WGP-NEXT: s_endpgm
2588 ; GFX11-CU-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
2589 ; GFX11-CU: ; %bb.0: ; %entry
2590 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
2591 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
2592 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
2593 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2594 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s2
2595 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2596 ; GFX11-CU-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] glc
2597 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
2598 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
2599 ; GFX11-CU-NEXT: s_endpgm
2601 ; GFX12-WGP-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
2602 ; GFX12-WGP: ; %bb.0: ; %entry
2603 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
2604 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
2605 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
2606 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
2607 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s2
2608 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
2609 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
2610 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
2611 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
2612 ; GFX12-WGP-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] th:TH_ATOMIC_RETURN scope:SCOPE_SE
2613 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
2614 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
2615 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
2616 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
2617 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
2618 ; GFX12-WGP-NEXT: s_endpgm
2620 ; GFX12-CU-LABEL: global_workgroup_acq_rel_ret_atomicrmw:
2621 ; GFX12-CU: ; %bb.0: ; %entry
2622 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
2623 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
2624 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
2625 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
2626 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s2
2627 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
2628 ; GFX12-CU-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] th:TH_ATOMIC_RETURN
2629 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
2630 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
2631 ; GFX12-CU-NEXT: s_endpgm
2632 ptr addrspace(1) %out, i32 %in) {
2634 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup") acq_rel
2635 store i32 %val, ptr addrspace(1) %out, align 4
2639 define amdgpu_kernel void @global_workgroup_seq_cst_ret_atomicrmw(
2640 ; GFX6-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
2641 ; GFX6: ; %bb.0: ; %entry
2642 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2643 ; GFX6-NEXT: s_load_dword s8, s[8:9], 0x2
2644 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2645 ; GFX6-NEXT: s_mov_b32 s11, s5
2646 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
2647 ; GFX6-NEXT: s_mov_b32 s9, 0x100f000
2648 ; GFX6-NEXT: s_mov_b32 s10, -1
2649 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
2650 ; GFX6-NEXT: s_mov_b32 s5, s11
2651 ; GFX6-NEXT: s_mov_b32 s6, s10
2652 ; GFX6-NEXT: s_mov_b32 s7, s9
2653 ; GFX6-NEXT: v_mov_b32_e32 v0, s8
2654 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2655 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[4:7], 0 glc
2656 ; GFX6-NEXT: s_waitcnt vmcnt(0)
2657 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
2658 ; GFX6-NEXT: s_endpgm
2660 ; GFX7-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
2661 ; GFX7: ; %bb.0: ; %entry
2662 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2663 ; GFX7-NEXT: s_load_dword s6, s[8:9], 0x2
2664 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2665 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
2666 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
2667 ; GFX7-NEXT: v_mov_b32_e32 v2, s6
2668 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2669 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
2670 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
2671 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
2672 ; GFX7-NEXT: s_waitcnt vmcnt(0)
2673 ; GFX7-NEXT: flat_store_dword v[0:1], v2
2674 ; GFX7-NEXT: s_endpgm
2676 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
2677 ; GFX10-WGP: ; %bb.0: ; %entry
2678 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
2679 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2680 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0x8
2681 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2682 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s6
2683 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2684 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2685 ; GFX10-WGP-NEXT: global_atomic_swap v1, v0, v1, s[4:5] glc
2686 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
2687 ; GFX10-WGP-NEXT: buffer_gl0_inv
2688 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
2689 ; GFX10-WGP-NEXT: s_endpgm
2691 ; GFX10-CU-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
2692 ; GFX10-CU: ; %bb.0: ; %entry
2693 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
2694 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2695 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0x8
2696 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2697 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s6
2698 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2699 ; GFX10-CU-NEXT: global_atomic_swap v1, v0, v1, s[4:5] glc
2700 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
2701 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
2702 ; GFX10-CU-NEXT: s_endpgm
2704 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
2705 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2706 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2707 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[4:5], 0x2
2708 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2709 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s1
2710 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
2711 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, 0xf000
2712 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
2713 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
2714 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s7
2715 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s6
2716 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s5
2717 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
2718 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2719 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0 glc
2720 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
2721 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
2722 ; SKIP-CACHE-INV-NEXT: s_endpgm
2724 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
2725 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2726 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2727 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2728 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
2729 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2730 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
2731 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2732 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[4:5] glc
2733 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
2734 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
2735 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2737 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
2738 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2739 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2740 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2741 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
2742 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2743 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
2744 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2745 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[4:5] glc
2746 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2747 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
2748 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
2749 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2751 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
2752 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
2753 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2754 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2755 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
2756 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2757 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
2758 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2759 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] sc0
2760 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
2761 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
2762 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
2764 ; GFX940-TGSPLIT-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
2765 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
2766 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2767 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2768 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
2769 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2770 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
2771 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2772 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] sc0
2773 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
2774 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
2775 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
2776 ; GFX940-TGSPLIT-NEXT: s_endpgm
2778 ; GFX11-WGP-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
2779 ; GFX11-WGP: ; %bb.0: ; %entry
2780 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
2781 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
2782 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
2783 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
2784 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s2
2785 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
2786 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
2787 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] glc
2788 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
2789 ; GFX11-WGP-NEXT: buffer_gl0_inv
2790 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
2791 ; GFX11-WGP-NEXT: s_endpgm
2793 ; GFX11-CU-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
2794 ; GFX11-CU: ; %bb.0: ; %entry
2795 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
2796 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
2797 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
2798 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2799 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s2
2800 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
2801 ; GFX11-CU-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] glc
2802 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
2803 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
2804 ; GFX11-CU-NEXT: s_endpgm
2806 ; GFX12-WGP-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
2807 ; GFX12-WGP: ; %bb.0: ; %entry
2808 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
2809 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
2810 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
2811 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
2812 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s2
2813 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
2814 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
2815 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
2816 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
2817 ; GFX12-WGP-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] th:TH_ATOMIC_RETURN scope:SCOPE_SE
2818 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
2819 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
2820 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
2821 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
2822 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
2823 ; GFX12-WGP-NEXT: s_endpgm
2825 ; GFX12-CU-LABEL: global_workgroup_seq_cst_ret_atomicrmw:
2826 ; GFX12-CU: ; %bb.0: ; %entry
2827 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
2828 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
2829 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
2830 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
2831 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s2
2832 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
2833 ; GFX12-CU-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] th:TH_ATOMIC_RETURN
2834 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
2835 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
2836 ; GFX12-CU-NEXT: s_endpgm
2837 ptr addrspace(1) %out, i32 %in) {
2839 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup") seq_cst
2840 store i32 %val, ptr addrspace(1) %out, align 4
2844 define amdgpu_kernel void @global_workgroup_monotonic_monotonic_cmpxchg(
2845 ; GFX6-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
2846 ; GFX6: ; %bb.0: ; %entry
2847 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
2848 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
2849 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
2850 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
2851 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
2852 ; GFX6-NEXT: s_mov_b32 s12, s5
2853 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
2854 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
2855 ; GFX6-NEXT: s_mov_b32 s11, -1
2856 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
2857 ; GFX6-NEXT: s_mov_b32 s5, s12
2858 ; GFX6-NEXT: s_mov_b32 s6, s11
2859 ; GFX6-NEXT: s_mov_b32 s7, s10
2860 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
2861 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
2862 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
2863 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
2864 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
2865 ; GFX6-NEXT: s_endpgm
2867 ; GFX7-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
2868 ; GFX7: ; %bb.0: ; %entry
2869 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
2870 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
2871 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
2872 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
2873 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
2874 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
2875 ; GFX7-NEXT: s_mov_b32 s4, s8
2876 ; GFX7-NEXT: s_mov_b32 s5, s9
2877 ; GFX7-NEXT: s_mov_b32 s9, s10
2878 ; GFX7-NEXT: s_mov_b32 s8, s11
2879 ; GFX7-NEXT: s_add_u32 s4, s4, s9
2880 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
2881 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
2882 ; GFX7-NEXT: s_mov_b32 s5, s8
2883 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
2884 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
2885 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
2886 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
2887 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
2888 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
2889 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
2890 ; GFX7-NEXT: s_endpgm
2892 ; GFX10-WGP-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
2893 ; GFX10-WGP: ; %bb.0: ; %entry
2894 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
2895 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2896 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
2897 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
2898 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
2899 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
2900 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
2901 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
2902 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
2903 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
2904 ; GFX10-WGP-NEXT: s_endpgm
2906 ; GFX10-CU-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
2907 ; GFX10-CU: ; %bb.0: ; %entry
2908 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
2909 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2910 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
2911 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
2912 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
2913 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
2914 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
2915 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
2916 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
2917 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
2918 ; GFX10-CU-NEXT: s_endpgm
2920 ; SKIP-CACHE-INV-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
2921 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
2922 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
2923 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
2924 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
2925 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
2926 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
2927 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
2928 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
2929 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
2930 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
2931 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
2932 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
2933 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
2934 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
2935 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
2936 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
2937 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
2938 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
2939 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
2940 ; SKIP-CACHE-INV-NEXT: s_endpgm
2942 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
2943 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
2944 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2945 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2946 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
2947 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
2948 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2949 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
2950 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
2951 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
2952 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
2953 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
2954 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
2956 ; GFX90A-TGSPLIT-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
2957 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
2958 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2959 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
2960 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
2961 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
2962 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2963 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
2964 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
2965 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
2966 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
2967 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
2968 ; GFX90A-TGSPLIT-NEXT: s_endpgm
2970 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
2971 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
2972 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2973 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2974 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
2975 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
2976 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2977 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
2978 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
2979 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
2980 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
2981 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
2982 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
2984 ; GFX940-TGSPLIT-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
2985 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
2986 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
2987 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
2988 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
2989 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
2990 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
2991 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
2992 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
2993 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
2994 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
2995 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
2996 ; GFX940-TGSPLIT-NEXT: s_endpgm
2998 ; GFX11-WGP-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
2999 ; GFX11-WGP: ; %bb.0: ; %entry
3000 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
3001 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3002 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
3003 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
3004 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3005 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
3006 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
3007 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
3008 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
3009 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
3010 ; GFX11-WGP-NEXT: s_endpgm
3012 ; GFX11-CU-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
3013 ; GFX11-CU: ; %bb.0: ; %entry
3014 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
3015 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3016 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
3017 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
3018 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3019 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
3020 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
3021 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
3022 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
3023 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
3024 ; GFX11-CU-NEXT: s_endpgm
3026 ; GFX12-WGP-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
3027 ; GFX12-WGP: ; %bb.0: ; %entry
3028 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
3029 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3030 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
3031 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
3032 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
3033 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
3034 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
3035 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
3036 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
3037 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
3038 ; GFX12-WGP-NEXT: s_endpgm
3040 ; GFX12-CU-LABEL: global_workgroup_monotonic_monotonic_cmpxchg:
3041 ; GFX12-CU: ; %bb.0: ; %entry
3042 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
3043 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3044 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
3045 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
3046 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
3047 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
3048 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
3049 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
3050 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
3051 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
3052 ; GFX12-CU-NEXT: s_endpgm
3053 ptr addrspace(1) %out, i32 %in, i32 %old) {
3055 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
3056 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") monotonic monotonic
3060 define amdgpu_kernel void @global_workgroup_acquire_monotonic_cmpxchg(
3061 ; GFX6-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
3062 ; GFX6: ; %bb.0: ; %entry
3063 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
3064 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
3065 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
3066 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
3067 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3068 ; GFX6-NEXT: s_mov_b32 s12, s5
3069 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
3070 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
3071 ; GFX6-NEXT: s_mov_b32 s11, -1
3072 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
3073 ; GFX6-NEXT: s_mov_b32 s5, s12
3074 ; GFX6-NEXT: s_mov_b32 s6, s11
3075 ; GFX6-NEXT: s_mov_b32 s7, s10
3076 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
3077 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
3078 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
3079 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
3080 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
3081 ; GFX6-NEXT: s_endpgm
3083 ; GFX7-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
3084 ; GFX7: ; %bb.0: ; %entry
3085 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
3086 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
3087 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
3088 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
3089 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
3090 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3091 ; GFX7-NEXT: s_mov_b32 s4, s8
3092 ; GFX7-NEXT: s_mov_b32 s5, s9
3093 ; GFX7-NEXT: s_mov_b32 s9, s10
3094 ; GFX7-NEXT: s_mov_b32 s8, s11
3095 ; GFX7-NEXT: s_add_u32 s4, s4, s9
3096 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
3097 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
3098 ; GFX7-NEXT: s_mov_b32 s5, s8
3099 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
3100 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
3101 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3102 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
3103 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
3104 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
3105 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3106 ; GFX7-NEXT: s_endpgm
3108 ; GFX10-WGP-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
3109 ; GFX10-WGP: ; %bb.0: ; %entry
3110 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
3111 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
3112 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
3113 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
3114 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3115 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
3116 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
3117 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
3118 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
3119 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
3120 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3121 ; GFX10-WGP-NEXT: buffer_gl0_inv
3122 ; GFX10-WGP-NEXT: s_endpgm
3124 ; GFX10-CU-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
3125 ; GFX10-CU: ; %bb.0: ; %entry
3126 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
3127 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
3128 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
3129 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
3130 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3131 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
3132 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
3133 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
3134 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
3135 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
3136 ; GFX10-CU-NEXT: s_endpgm
3138 ; SKIP-CACHE-INV-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
3139 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3140 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
3141 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
3142 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
3143 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
3144 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3145 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
3146 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
3147 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
3148 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
3149 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
3150 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
3151 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
3152 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
3153 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
3154 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
3155 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
3156 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
3157 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
3158 ; SKIP-CACHE-INV-NEXT: s_endpgm
3160 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
3161 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3162 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
3163 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
3164 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
3165 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
3166 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3167 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
3168 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
3169 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3170 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
3171 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
3172 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3174 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
3175 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3176 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
3177 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
3178 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
3179 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
3180 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3181 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
3182 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
3183 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3184 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
3185 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
3186 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3187 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
3188 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3190 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
3191 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
3192 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
3193 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3194 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
3195 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
3196 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3197 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
3198 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
3199 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3200 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
3201 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
3202 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
3204 ; GFX940-TGSPLIT-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
3205 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
3206 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
3207 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3208 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
3209 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
3210 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3211 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
3212 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
3213 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3214 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
3215 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
3216 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3217 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
3218 ; GFX940-TGSPLIT-NEXT: s_endpgm
3220 ; GFX11-WGP-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
3221 ; GFX11-WGP: ; %bb.0: ; %entry
3222 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
3223 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3224 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
3225 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
3226 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3227 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
3228 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
3229 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
3230 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
3231 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
3232 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3233 ; GFX11-WGP-NEXT: buffer_gl0_inv
3234 ; GFX11-WGP-NEXT: s_endpgm
3236 ; GFX11-CU-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
3237 ; GFX11-CU: ; %bb.0: ; %entry
3238 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
3239 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3240 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
3241 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
3242 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3243 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
3244 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
3245 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
3246 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
3247 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
3248 ; GFX11-CU-NEXT: s_endpgm
3250 ; GFX12-WGP-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
3251 ; GFX12-WGP: ; %bb.0: ; %entry
3252 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
3253 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3254 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
3255 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
3256 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
3257 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
3258 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
3259 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
3260 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
3261 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
3262 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
3263 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
3264 ; GFX12-WGP-NEXT: s_endpgm
3266 ; GFX12-CU-LABEL: global_workgroup_acquire_monotonic_cmpxchg:
3267 ; GFX12-CU: ; %bb.0: ; %entry
3268 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
3269 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3270 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
3271 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
3272 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
3273 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
3274 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
3275 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
3276 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
3277 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
3278 ; GFX12-CU-NEXT: s_endpgm
3279 ptr addrspace(1) %out, i32 %in, i32 %old) {
3281 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
3282 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") acquire monotonic
3286 define amdgpu_kernel void @global_workgroup_release_monotonic_cmpxchg(
3287 ; GFX6-LABEL: global_workgroup_release_monotonic_cmpxchg:
3288 ; GFX6: ; %bb.0: ; %entry
3289 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
3290 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
3291 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
3292 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
3293 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3294 ; GFX6-NEXT: s_mov_b32 s12, s5
3295 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
3296 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
3297 ; GFX6-NEXT: s_mov_b32 s11, -1
3298 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
3299 ; GFX6-NEXT: s_mov_b32 s5, s12
3300 ; GFX6-NEXT: s_mov_b32 s6, s11
3301 ; GFX6-NEXT: s_mov_b32 s7, s10
3302 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
3303 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
3304 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
3305 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
3306 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3307 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
3308 ; GFX6-NEXT: s_endpgm
3310 ; GFX7-LABEL: global_workgroup_release_monotonic_cmpxchg:
3311 ; GFX7: ; %bb.0: ; %entry
3312 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
3313 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
3314 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
3315 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
3316 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
3317 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3318 ; GFX7-NEXT: s_mov_b32 s4, s8
3319 ; GFX7-NEXT: s_mov_b32 s5, s9
3320 ; GFX7-NEXT: s_mov_b32 s9, s10
3321 ; GFX7-NEXT: s_mov_b32 s8, s11
3322 ; GFX7-NEXT: s_add_u32 s4, s4, s9
3323 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
3324 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
3325 ; GFX7-NEXT: s_mov_b32 s5, s8
3326 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
3327 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
3328 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3329 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
3330 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
3331 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
3332 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3333 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3334 ; GFX7-NEXT: s_endpgm
3336 ; GFX10-WGP-LABEL: global_workgroup_release_monotonic_cmpxchg:
3337 ; GFX10-WGP: ; %bb.0: ; %entry
3338 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
3339 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
3340 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
3341 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
3342 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3343 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
3344 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
3345 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
3346 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
3347 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3348 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3349 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
3350 ; GFX10-WGP-NEXT: s_endpgm
3352 ; GFX10-CU-LABEL: global_workgroup_release_monotonic_cmpxchg:
3353 ; GFX10-CU: ; %bb.0: ; %entry
3354 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
3355 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
3356 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
3357 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
3358 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3359 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
3360 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
3361 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
3362 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
3363 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3364 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
3365 ; GFX10-CU-NEXT: s_endpgm
3367 ; SKIP-CACHE-INV-LABEL: global_workgroup_release_monotonic_cmpxchg:
3368 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3369 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
3370 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
3371 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
3372 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
3373 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3374 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
3375 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
3376 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
3377 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
3378 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
3379 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
3380 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
3381 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
3382 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
3383 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
3384 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
3385 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
3386 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3387 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
3388 ; SKIP-CACHE-INV-NEXT: s_endpgm
3390 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_release_monotonic_cmpxchg:
3391 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3392 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
3393 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
3394 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
3395 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
3396 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3397 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
3398 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
3399 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3400 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
3401 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3402 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
3403 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3405 ; GFX90A-TGSPLIT-LABEL: global_workgroup_release_monotonic_cmpxchg:
3406 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3407 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
3408 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
3409 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
3410 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
3411 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3412 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
3413 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
3414 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3415 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
3416 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3417 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
3418 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3420 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_release_monotonic_cmpxchg:
3421 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
3422 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
3423 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3424 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
3425 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
3426 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3427 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
3428 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
3429 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3430 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
3431 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3432 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
3433 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
3435 ; GFX940-TGSPLIT-LABEL: global_workgroup_release_monotonic_cmpxchg:
3436 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
3437 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
3438 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3439 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
3440 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
3441 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3442 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
3443 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
3444 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3445 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
3446 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3447 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
3448 ; GFX940-TGSPLIT-NEXT: s_endpgm
3450 ; GFX11-WGP-LABEL: global_workgroup_release_monotonic_cmpxchg:
3451 ; GFX11-WGP: ; %bb.0: ; %entry
3452 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
3453 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3454 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
3455 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
3456 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3457 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
3458 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
3459 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
3460 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
3461 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3462 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3463 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
3464 ; GFX11-WGP-NEXT: s_endpgm
3466 ; GFX11-CU-LABEL: global_workgroup_release_monotonic_cmpxchg:
3467 ; GFX11-CU: ; %bb.0: ; %entry
3468 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
3469 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3470 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
3471 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
3472 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3473 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
3474 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
3475 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
3476 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
3477 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3478 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
3479 ; GFX11-CU-NEXT: s_endpgm
3481 ; GFX12-WGP-LABEL: global_workgroup_release_monotonic_cmpxchg:
3482 ; GFX12-WGP: ; %bb.0: ; %entry
3483 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
3484 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3485 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
3486 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
3487 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
3488 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
3489 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
3490 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
3491 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
3492 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
3493 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
3494 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
3495 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
3496 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
3497 ; GFX12-WGP-NEXT: s_endpgm
3499 ; GFX12-CU-LABEL: global_workgroup_release_monotonic_cmpxchg:
3500 ; GFX12-CU: ; %bb.0: ; %entry
3501 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
3502 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3503 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
3504 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
3505 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
3506 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
3507 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
3508 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
3509 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
3510 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
3511 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
3512 ; GFX12-CU-NEXT: s_endpgm
3513 ptr addrspace(1) %out, i32 %in, i32 %old) {
3515 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
3516 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") release monotonic
3520 define amdgpu_kernel void @global_workgroup_acq_rel_monotonic_cmpxchg(
3521 ; GFX6-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
3522 ; GFX6: ; %bb.0: ; %entry
3523 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
3524 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
3525 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
3526 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
3527 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3528 ; GFX6-NEXT: s_mov_b32 s12, s5
3529 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
3530 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
3531 ; GFX6-NEXT: s_mov_b32 s11, -1
3532 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
3533 ; GFX6-NEXT: s_mov_b32 s5, s12
3534 ; GFX6-NEXT: s_mov_b32 s6, s11
3535 ; GFX6-NEXT: s_mov_b32 s7, s10
3536 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
3537 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
3538 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
3539 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
3540 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3541 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
3542 ; GFX6-NEXT: s_endpgm
3544 ; GFX7-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
3545 ; GFX7: ; %bb.0: ; %entry
3546 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
3547 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
3548 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
3549 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
3550 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
3551 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3552 ; GFX7-NEXT: s_mov_b32 s4, s8
3553 ; GFX7-NEXT: s_mov_b32 s5, s9
3554 ; GFX7-NEXT: s_mov_b32 s9, s10
3555 ; GFX7-NEXT: s_mov_b32 s8, s11
3556 ; GFX7-NEXT: s_add_u32 s4, s4, s9
3557 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
3558 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
3559 ; GFX7-NEXT: s_mov_b32 s5, s8
3560 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
3561 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
3562 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3563 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
3564 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
3565 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
3566 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3567 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3568 ; GFX7-NEXT: s_endpgm
3570 ; GFX10-WGP-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
3571 ; GFX10-WGP: ; %bb.0: ; %entry
3572 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
3573 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
3574 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
3575 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
3576 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3577 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
3578 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
3579 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
3580 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
3581 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3582 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3583 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
3584 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3585 ; GFX10-WGP-NEXT: buffer_gl0_inv
3586 ; GFX10-WGP-NEXT: s_endpgm
3588 ; GFX10-CU-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
3589 ; GFX10-CU: ; %bb.0: ; %entry
3590 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
3591 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
3592 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
3593 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
3594 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3595 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
3596 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
3597 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
3598 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
3599 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3600 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
3601 ; GFX10-CU-NEXT: s_endpgm
3603 ; SKIP-CACHE-INV-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
3604 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3605 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
3606 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
3607 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
3608 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
3609 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3610 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
3611 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
3612 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
3613 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
3614 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
3615 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
3616 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
3617 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
3618 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
3619 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
3620 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
3621 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
3622 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3623 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
3624 ; SKIP-CACHE-INV-NEXT: s_endpgm
3626 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
3627 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3628 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
3629 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
3630 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
3631 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
3632 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3633 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
3634 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
3635 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3636 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
3637 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3638 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
3639 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3641 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
3642 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3643 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
3644 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
3645 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
3646 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
3647 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3648 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
3649 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
3650 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3651 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
3652 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3653 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
3654 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3655 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
3656 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3658 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
3659 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
3660 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
3661 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3662 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
3663 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
3664 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3665 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
3666 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
3667 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3668 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
3669 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3670 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
3671 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
3673 ; GFX940-TGSPLIT-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
3674 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
3675 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
3676 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3677 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
3678 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
3679 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3680 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
3681 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
3682 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3683 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
3684 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3685 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
3686 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3687 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
3688 ; GFX940-TGSPLIT-NEXT: s_endpgm
3690 ; GFX11-WGP-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
3691 ; GFX11-WGP: ; %bb.0: ; %entry
3692 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
3693 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3694 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
3695 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
3696 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3697 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
3698 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
3699 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
3700 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
3701 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3702 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3703 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
3704 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3705 ; GFX11-WGP-NEXT: buffer_gl0_inv
3706 ; GFX11-WGP-NEXT: s_endpgm
3708 ; GFX11-CU-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
3709 ; GFX11-CU: ; %bb.0: ; %entry
3710 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
3711 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3712 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
3713 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
3714 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3715 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
3716 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
3717 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
3718 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
3719 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3720 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
3721 ; GFX11-CU-NEXT: s_endpgm
3723 ; GFX12-WGP-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
3724 ; GFX12-WGP: ; %bb.0: ; %entry
3725 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
3726 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3727 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
3728 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
3729 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
3730 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
3731 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
3732 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
3733 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
3734 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
3735 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
3736 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
3737 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
3738 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
3739 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
3740 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
3741 ; GFX12-WGP-NEXT: s_endpgm
3743 ; GFX12-CU-LABEL: global_workgroup_acq_rel_monotonic_cmpxchg:
3744 ; GFX12-CU: ; %bb.0: ; %entry
3745 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
3746 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3747 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
3748 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
3749 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
3750 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
3751 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
3752 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
3753 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
3754 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
3755 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
3756 ; GFX12-CU-NEXT: s_endpgm
3757 ptr addrspace(1) %out, i32 %in, i32 %old) {
3759 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
3760 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") acq_rel monotonic
3764 define amdgpu_kernel void @global_workgroup_seq_cst_monotonic_cmpxchg(
3765 ; GFX6-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
3766 ; GFX6: ; %bb.0: ; %entry
3767 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
3768 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
3769 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
3770 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
3771 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3772 ; GFX6-NEXT: s_mov_b32 s12, s5
3773 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
3774 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
3775 ; GFX6-NEXT: s_mov_b32 s11, -1
3776 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
3777 ; GFX6-NEXT: s_mov_b32 s5, s12
3778 ; GFX6-NEXT: s_mov_b32 s6, s11
3779 ; GFX6-NEXT: s_mov_b32 s7, s10
3780 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
3781 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
3782 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
3783 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
3784 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
3785 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
3786 ; GFX6-NEXT: s_endpgm
3788 ; GFX7-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
3789 ; GFX7: ; %bb.0: ; %entry
3790 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
3791 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
3792 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
3793 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
3794 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
3795 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3796 ; GFX7-NEXT: s_mov_b32 s4, s8
3797 ; GFX7-NEXT: s_mov_b32 s5, s9
3798 ; GFX7-NEXT: s_mov_b32 s9, s10
3799 ; GFX7-NEXT: s_mov_b32 s8, s11
3800 ; GFX7-NEXT: s_add_u32 s4, s4, s9
3801 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
3802 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
3803 ; GFX7-NEXT: s_mov_b32 s5, s8
3804 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
3805 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
3806 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3807 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
3808 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
3809 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
3810 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
3811 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
3812 ; GFX7-NEXT: s_endpgm
3814 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
3815 ; GFX10-WGP: ; %bb.0: ; %entry
3816 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
3817 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
3818 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
3819 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
3820 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
3821 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
3822 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
3823 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
3824 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
3825 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3826 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3827 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
3828 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3829 ; GFX10-WGP-NEXT: buffer_gl0_inv
3830 ; GFX10-WGP-NEXT: s_endpgm
3832 ; GFX10-CU-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
3833 ; GFX10-CU: ; %bb.0: ; %entry
3834 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
3835 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
3836 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
3837 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
3838 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3839 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
3840 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
3841 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
3842 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
3843 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
3844 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
3845 ; GFX10-CU-NEXT: s_endpgm
3847 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
3848 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
3849 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
3850 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
3851 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
3852 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
3853 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3854 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
3855 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
3856 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
3857 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
3858 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
3859 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
3860 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
3861 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
3862 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
3863 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
3864 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
3865 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
3866 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
3867 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
3868 ; SKIP-CACHE-INV-NEXT: s_endpgm
3870 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
3871 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
3872 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
3873 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
3874 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
3875 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
3876 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3877 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
3878 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
3879 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3880 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
3881 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3882 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
3883 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
3885 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
3886 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
3887 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
3888 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
3889 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
3890 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
3891 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3892 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
3893 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
3894 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3895 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
3896 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3897 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
3898 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3899 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
3900 ; GFX90A-TGSPLIT-NEXT: s_endpgm
3902 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
3903 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
3904 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
3905 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3906 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
3907 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
3908 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3909 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
3910 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
3911 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3912 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
3913 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3914 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
3915 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
3917 ; GFX940-TGSPLIT-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
3918 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
3919 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
3920 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
3921 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
3922 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
3923 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
3924 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
3925 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
3926 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
3927 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
3928 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3929 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
3930 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
3931 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
3932 ; GFX940-TGSPLIT-NEXT: s_endpgm
3934 ; GFX11-WGP-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
3935 ; GFX11-WGP: ; %bb.0: ; %entry
3936 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
3937 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3938 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
3939 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
3940 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
3941 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
3942 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
3943 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
3944 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
3945 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3946 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3947 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
3948 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
3949 ; GFX11-WGP-NEXT: buffer_gl0_inv
3950 ; GFX11-WGP-NEXT: s_endpgm
3952 ; GFX11-CU-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
3953 ; GFX11-CU: ; %bb.0: ; %entry
3954 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
3955 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3956 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
3957 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
3958 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3959 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
3960 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
3961 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
3962 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
3963 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
3964 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
3965 ; GFX11-CU-NEXT: s_endpgm
3967 ; GFX12-WGP-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
3968 ; GFX12-WGP: ; %bb.0: ; %entry
3969 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
3970 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3971 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
3972 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
3973 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
3974 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
3975 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
3976 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
3977 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
3978 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
3979 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
3980 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
3981 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
3982 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
3983 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
3984 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
3985 ; GFX12-WGP-NEXT: s_endpgm
3987 ; GFX12-CU-LABEL: global_workgroup_seq_cst_monotonic_cmpxchg:
3988 ; GFX12-CU: ; %bb.0: ; %entry
3989 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
3990 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
3991 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
3992 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
3993 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
3994 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
3995 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
3996 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
3997 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
3998 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
3999 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
4000 ; GFX12-CU-NEXT: s_endpgm
4001 ptr addrspace(1) %out, i32 %in, i32 %old) {
4003 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
4004 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") seq_cst monotonic
4008 define amdgpu_kernel void @global_workgroup_monotonic_acquire_cmpxchg(
4009 ; GFX6-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
4010 ; GFX6: ; %bb.0: ; %entry
4011 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
4012 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
4013 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
4014 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
4015 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4016 ; GFX6-NEXT: s_mov_b32 s12, s5
4017 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
4018 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
4019 ; GFX6-NEXT: s_mov_b32 s11, -1
4020 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
4021 ; GFX6-NEXT: s_mov_b32 s5, s12
4022 ; GFX6-NEXT: s_mov_b32 s6, s11
4023 ; GFX6-NEXT: s_mov_b32 s7, s10
4024 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
4025 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
4026 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
4027 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
4028 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
4029 ; GFX6-NEXT: s_endpgm
4031 ; GFX7-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
4032 ; GFX7: ; %bb.0: ; %entry
4033 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
4034 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
4035 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
4036 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
4037 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
4038 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4039 ; GFX7-NEXT: s_mov_b32 s4, s8
4040 ; GFX7-NEXT: s_mov_b32 s5, s9
4041 ; GFX7-NEXT: s_mov_b32 s9, s10
4042 ; GFX7-NEXT: s_mov_b32 s8, s11
4043 ; GFX7-NEXT: s_add_u32 s4, s4, s9
4044 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
4045 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
4046 ; GFX7-NEXT: s_mov_b32 s5, s8
4047 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
4048 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
4049 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4050 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
4051 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
4052 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
4053 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4054 ; GFX7-NEXT: s_endpgm
4056 ; GFX10-WGP-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
4057 ; GFX10-WGP: ; %bb.0: ; %entry
4058 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
4059 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
4060 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
4061 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
4062 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4063 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
4064 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
4065 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
4066 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
4067 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
4068 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4069 ; GFX10-WGP-NEXT: buffer_gl0_inv
4070 ; GFX10-WGP-NEXT: s_endpgm
4072 ; GFX10-CU-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
4073 ; GFX10-CU: ; %bb.0: ; %entry
4074 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
4075 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
4076 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
4077 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
4078 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4079 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
4080 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
4081 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
4082 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
4083 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
4084 ; GFX10-CU-NEXT: s_endpgm
4086 ; SKIP-CACHE-INV-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
4087 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4088 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
4089 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
4090 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
4091 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
4092 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4093 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
4094 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
4095 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
4096 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
4097 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
4098 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
4099 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
4100 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
4101 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
4102 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
4103 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
4104 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
4105 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
4106 ; SKIP-CACHE-INV-NEXT: s_endpgm
4108 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
4109 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4110 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
4111 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
4112 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
4113 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
4114 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4115 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
4116 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
4117 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4118 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
4119 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
4120 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4122 ; GFX90A-TGSPLIT-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
4123 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4124 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
4125 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
4126 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
4127 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
4128 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4129 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
4130 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
4131 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4132 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
4133 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
4134 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4135 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
4136 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4138 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
4139 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
4140 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
4141 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4142 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
4143 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
4144 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4145 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
4146 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
4147 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4148 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
4149 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
4150 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
4152 ; GFX940-TGSPLIT-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
4153 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
4154 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
4155 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4156 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
4157 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
4158 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4159 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
4160 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
4161 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4162 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
4163 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
4164 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4165 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
4166 ; GFX940-TGSPLIT-NEXT: s_endpgm
4168 ; GFX11-WGP-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
4169 ; GFX11-WGP: ; %bb.0: ; %entry
4170 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
4171 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4172 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
4173 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
4174 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
4175 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
4176 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
4177 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
4178 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
4179 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
4180 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4181 ; GFX11-WGP-NEXT: buffer_gl0_inv
4182 ; GFX11-WGP-NEXT: s_endpgm
4184 ; GFX11-CU-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
4185 ; GFX11-CU: ; %bb.0: ; %entry
4186 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
4187 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4188 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
4189 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
4190 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4191 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
4192 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
4193 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
4194 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
4195 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
4196 ; GFX11-CU-NEXT: s_endpgm
4198 ; GFX12-WGP-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
4199 ; GFX12-WGP: ; %bb.0: ; %entry
4200 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
4201 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4202 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
4203 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
4204 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
4205 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
4206 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
4207 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
4208 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
4209 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
4210 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
4211 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
4212 ; GFX12-WGP-NEXT: s_endpgm
4214 ; GFX12-CU-LABEL: global_workgroup_monotonic_acquire_cmpxchg:
4215 ; GFX12-CU: ; %bb.0: ; %entry
4216 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
4217 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4218 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
4219 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
4220 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
4221 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
4222 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
4223 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
4224 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
4225 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
4226 ; GFX12-CU-NEXT: s_endpgm
4227 ptr addrspace(1) %out, i32 %in, i32 %old) {
4229 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
4230 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") monotonic acquire
4234 define amdgpu_kernel void @global_workgroup_acquire_acquire_cmpxchg(
4235 ; GFX6-LABEL: global_workgroup_acquire_acquire_cmpxchg:
4236 ; GFX6: ; %bb.0: ; %entry
4237 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
4238 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
4239 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
4240 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
4241 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4242 ; GFX6-NEXT: s_mov_b32 s12, s5
4243 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
4244 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
4245 ; GFX6-NEXT: s_mov_b32 s11, -1
4246 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
4247 ; GFX6-NEXT: s_mov_b32 s5, s12
4248 ; GFX6-NEXT: s_mov_b32 s6, s11
4249 ; GFX6-NEXT: s_mov_b32 s7, s10
4250 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
4251 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
4252 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
4253 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
4254 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
4255 ; GFX6-NEXT: s_endpgm
4257 ; GFX7-LABEL: global_workgroup_acquire_acquire_cmpxchg:
4258 ; GFX7: ; %bb.0: ; %entry
4259 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
4260 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
4261 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
4262 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
4263 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
4264 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4265 ; GFX7-NEXT: s_mov_b32 s4, s8
4266 ; GFX7-NEXT: s_mov_b32 s5, s9
4267 ; GFX7-NEXT: s_mov_b32 s9, s10
4268 ; GFX7-NEXT: s_mov_b32 s8, s11
4269 ; GFX7-NEXT: s_add_u32 s4, s4, s9
4270 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
4271 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
4272 ; GFX7-NEXT: s_mov_b32 s5, s8
4273 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
4274 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
4275 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4276 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
4277 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
4278 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
4279 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4280 ; GFX7-NEXT: s_endpgm
4282 ; GFX10-WGP-LABEL: global_workgroup_acquire_acquire_cmpxchg:
4283 ; GFX10-WGP: ; %bb.0: ; %entry
4284 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
4285 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
4286 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
4287 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
4288 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4289 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
4290 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
4291 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
4292 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
4293 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
4294 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4295 ; GFX10-WGP-NEXT: buffer_gl0_inv
4296 ; GFX10-WGP-NEXT: s_endpgm
4298 ; GFX10-CU-LABEL: global_workgroup_acquire_acquire_cmpxchg:
4299 ; GFX10-CU: ; %bb.0: ; %entry
4300 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
4301 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
4302 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
4303 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
4304 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4305 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
4306 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
4307 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
4308 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
4309 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
4310 ; GFX10-CU-NEXT: s_endpgm
4312 ; SKIP-CACHE-INV-LABEL: global_workgroup_acquire_acquire_cmpxchg:
4313 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4314 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
4315 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
4316 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
4317 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
4318 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4319 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
4320 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
4321 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
4322 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
4323 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
4324 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
4325 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
4326 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
4327 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
4328 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
4329 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
4330 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
4331 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
4332 ; SKIP-CACHE-INV-NEXT: s_endpgm
4334 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acquire_acquire_cmpxchg:
4335 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4336 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
4337 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
4338 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
4339 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
4340 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4341 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
4342 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
4343 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4344 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
4345 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
4346 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4348 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acquire_acquire_cmpxchg:
4349 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4350 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
4351 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
4352 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
4353 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
4354 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4355 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
4356 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
4357 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4358 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
4359 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
4360 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4361 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
4362 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4364 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acquire_acquire_cmpxchg:
4365 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
4366 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
4367 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4368 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
4369 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
4370 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4371 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
4372 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
4373 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4374 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
4375 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
4376 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
4378 ; GFX940-TGSPLIT-LABEL: global_workgroup_acquire_acquire_cmpxchg:
4379 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
4380 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
4381 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4382 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
4383 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
4384 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4385 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
4386 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
4387 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4388 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
4389 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
4390 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4391 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
4392 ; GFX940-TGSPLIT-NEXT: s_endpgm
4394 ; GFX11-WGP-LABEL: global_workgroup_acquire_acquire_cmpxchg:
4395 ; GFX11-WGP: ; %bb.0: ; %entry
4396 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
4397 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4398 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
4399 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
4400 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
4401 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
4402 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
4403 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
4404 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
4405 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
4406 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4407 ; GFX11-WGP-NEXT: buffer_gl0_inv
4408 ; GFX11-WGP-NEXT: s_endpgm
4410 ; GFX11-CU-LABEL: global_workgroup_acquire_acquire_cmpxchg:
4411 ; GFX11-CU: ; %bb.0: ; %entry
4412 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
4413 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4414 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
4415 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
4416 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4417 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
4418 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
4419 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
4420 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
4421 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
4422 ; GFX11-CU-NEXT: s_endpgm
4424 ; GFX12-WGP-LABEL: global_workgroup_acquire_acquire_cmpxchg:
4425 ; GFX12-WGP: ; %bb.0: ; %entry
4426 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
4427 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4428 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
4429 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
4430 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
4431 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
4432 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
4433 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
4434 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
4435 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
4436 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
4437 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
4438 ; GFX12-WGP-NEXT: s_endpgm
4440 ; GFX12-CU-LABEL: global_workgroup_acquire_acquire_cmpxchg:
4441 ; GFX12-CU: ; %bb.0: ; %entry
4442 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
4443 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4444 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
4445 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
4446 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
4447 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
4448 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
4449 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
4450 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
4451 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
4452 ; GFX12-CU-NEXT: s_endpgm
4453 ptr addrspace(1) %out, i32 %in, i32 %old) {
4455 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
4456 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") acquire acquire
4460 define amdgpu_kernel void @global_workgroup_release_acquire_cmpxchg(
4461 ; GFX6-LABEL: global_workgroup_release_acquire_cmpxchg:
4462 ; GFX6: ; %bb.0: ; %entry
4463 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
4464 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
4465 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
4466 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
4467 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4468 ; GFX6-NEXT: s_mov_b32 s12, s5
4469 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
4470 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
4471 ; GFX6-NEXT: s_mov_b32 s11, -1
4472 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
4473 ; GFX6-NEXT: s_mov_b32 s5, s12
4474 ; GFX6-NEXT: s_mov_b32 s6, s11
4475 ; GFX6-NEXT: s_mov_b32 s7, s10
4476 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
4477 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
4478 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
4479 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
4480 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4481 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
4482 ; GFX6-NEXT: s_endpgm
4484 ; GFX7-LABEL: global_workgroup_release_acquire_cmpxchg:
4485 ; GFX7: ; %bb.0: ; %entry
4486 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
4487 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
4488 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
4489 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
4490 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
4491 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4492 ; GFX7-NEXT: s_mov_b32 s4, s8
4493 ; GFX7-NEXT: s_mov_b32 s5, s9
4494 ; GFX7-NEXT: s_mov_b32 s9, s10
4495 ; GFX7-NEXT: s_mov_b32 s8, s11
4496 ; GFX7-NEXT: s_add_u32 s4, s4, s9
4497 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
4498 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
4499 ; GFX7-NEXT: s_mov_b32 s5, s8
4500 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
4501 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
4502 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4503 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
4504 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
4505 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
4506 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4507 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4508 ; GFX7-NEXT: s_endpgm
4510 ; GFX10-WGP-LABEL: global_workgroup_release_acquire_cmpxchg:
4511 ; GFX10-WGP: ; %bb.0: ; %entry
4512 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
4513 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
4514 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
4515 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
4516 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4517 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
4518 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
4519 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
4520 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
4521 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4522 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4523 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
4524 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4525 ; GFX10-WGP-NEXT: buffer_gl0_inv
4526 ; GFX10-WGP-NEXT: s_endpgm
4528 ; GFX10-CU-LABEL: global_workgroup_release_acquire_cmpxchg:
4529 ; GFX10-CU: ; %bb.0: ; %entry
4530 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
4531 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
4532 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
4533 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
4534 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4535 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
4536 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
4537 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
4538 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
4539 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4540 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
4541 ; GFX10-CU-NEXT: s_endpgm
4543 ; SKIP-CACHE-INV-LABEL: global_workgroup_release_acquire_cmpxchg:
4544 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4545 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
4546 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
4547 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
4548 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
4549 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4550 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
4551 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
4552 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
4553 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
4554 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
4555 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
4556 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
4557 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
4558 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
4559 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
4560 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
4561 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
4562 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4563 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
4564 ; SKIP-CACHE-INV-NEXT: s_endpgm
4566 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_release_acquire_cmpxchg:
4567 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4568 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
4569 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
4570 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
4571 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
4572 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4573 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
4574 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
4575 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4576 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
4577 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4578 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
4579 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4581 ; GFX90A-TGSPLIT-LABEL: global_workgroup_release_acquire_cmpxchg:
4582 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4583 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
4584 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
4585 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
4586 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
4587 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4588 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
4589 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
4590 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4591 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
4592 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4593 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
4594 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4595 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
4596 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4598 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_release_acquire_cmpxchg:
4599 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
4600 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
4601 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4602 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
4603 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
4604 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4605 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
4606 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
4607 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4608 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
4609 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4610 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
4611 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
4613 ; GFX940-TGSPLIT-LABEL: global_workgroup_release_acquire_cmpxchg:
4614 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
4615 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
4616 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4617 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
4618 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
4619 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4620 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
4621 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
4622 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4623 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
4624 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4625 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
4626 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4627 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
4628 ; GFX940-TGSPLIT-NEXT: s_endpgm
4630 ; GFX11-WGP-LABEL: global_workgroup_release_acquire_cmpxchg:
4631 ; GFX11-WGP: ; %bb.0: ; %entry
4632 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
4633 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4634 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
4635 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
4636 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
4637 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
4638 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
4639 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
4640 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
4641 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4642 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4643 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
4644 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4645 ; GFX11-WGP-NEXT: buffer_gl0_inv
4646 ; GFX11-WGP-NEXT: s_endpgm
4648 ; GFX11-CU-LABEL: global_workgroup_release_acquire_cmpxchg:
4649 ; GFX11-CU: ; %bb.0: ; %entry
4650 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
4651 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4652 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
4653 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
4654 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4655 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
4656 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
4657 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
4658 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
4659 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4660 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
4661 ; GFX11-CU-NEXT: s_endpgm
4663 ; GFX12-WGP-LABEL: global_workgroup_release_acquire_cmpxchg:
4664 ; GFX12-WGP: ; %bb.0: ; %entry
4665 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
4666 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4667 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
4668 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
4669 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
4670 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
4671 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
4672 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
4673 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
4674 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
4675 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
4676 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
4677 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
4678 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
4679 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
4680 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
4681 ; GFX12-WGP-NEXT: s_endpgm
4683 ; GFX12-CU-LABEL: global_workgroup_release_acquire_cmpxchg:
4684 ; GFX12-CU: ; %bb.0: ; %entry
4685 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
4686 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4687 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
4688 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
4689 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
4690 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
4691 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
4692 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
4693 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
4694 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
4695 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
4696 ; GFX12-CU-NEXT: s_endpgm
4697 ptr addrspace(1) %out, i32 %in, i32 %old) {
4699 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
4700 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") release acquire
4704 define amdgpu_kernel void @global_workgroup_acq_rel_acquire_cmpxchg(
4705 ; GFX6-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
4706 ; GFX6: ; %bb.0: ; %entry
4707 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
4708 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
4709 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
4710 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
4711 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4712 ; GFX6-NEXT: s_mov_b32 s12, s5
4713 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
4714 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
4715 ; GFX6-NEXT: s_mov_b32 s11, -1
4716 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
4717 ; GFX6-NEXT: s_mov_b32 s5, s12
4718 ; GFX6-NEXT: s_mov_b32 s6, s11
4719 ; GFX6-NEXT: s_mov_b32 s7, s10
4720 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
4721 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
4722 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
4723 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
4724 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4725 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
4726 ; GFX6-NEXT: s_endpgm
4728 ; GFX7-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
4729 ; GFX7: ; %bb.0: ; %entry
4730 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
4731 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
4732 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
4733 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
4734 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
4735 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4736 ; GFX7-NEXT: s_mov_b32 s4, s8
4737 ; GFX7-NEXT: s_mov_b32 s5, s9
4738 ; GFX7-NEXT: s_mov_b32 s9, s10
4739 ; GFX7-NEXT: s_mov_b32 s8, s11
4740 ; GFX7-NEXT: s_add_u32 s4, s4, s9
4741 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
4742 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
4743 ; GFX7-NEXT: s_mov_b32 s5, s8
4744 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
4745 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
4746 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4747 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
4748 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
4749 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
4750 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4751 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4752 ; GFX7-NEXT: s_endpgm
4754 ; GFX10-WGP-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
4755 ; GFX10-WGP: ; %bb.0: ; %entry
4756 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
4757 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
4758 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
4759 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
4760 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
4761 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
4762 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
4763 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
4764 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
4765 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4766 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4767 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
4768 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4769 ; GFX10-WGP-NEXT: buffer_gl0_inv
4770 ; GFX10-WGP-NEXT: s_endpgm
4772 ; GFX10-CU-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
4773 ; GFX10-CU: ; %bb.0: ; %entry
4774 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
4775 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
4776 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
4777 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
4778 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4779 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
4780 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
4781 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
4782 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
4783 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
4784 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
4785 ; GFX10-CU-NEXT: s_endpgm
4787 ; SKIP-CACHE-INV-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
4788 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
4789 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
4790 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
4791 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
4792 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
4793 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4794 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
4795 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
4796 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
4797 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
4798 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
4799 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
4800 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
4801 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
4802 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
4803 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
4804 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
4805 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
4806 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
4807 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
4808 ; SKIP-CACHE-INV-NEXT: s_endpgm
4810 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
4811 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
4812 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
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 v1, s6
4819 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4820 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
4821 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4822 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
4823 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
4825 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
4826 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
4827 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
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 v1, s6
4834 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4835 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
4836 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4837 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
4838 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4839 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
4840 ; GFX90A-TGSPLIT-NEXT: s_endpgm
4842 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
4843 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
4844 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
4845 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4846 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
4847 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
4848 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4849 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
4850 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
4851 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4852 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
4853 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4854 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
4855 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
4857 ; GFX940-TGSPLIT-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
4858 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
4859 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
4860 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
4861 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
4862 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
4863 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
4864 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
4865 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
4866 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4867 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
4868 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4869 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
4870 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
4871 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
4872 ; GFX940-TGSPLIT-NEXT: s_endpgm
4874 ; GFX11-WGP-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
4875 ; GFX11-WGP: ; %bb.0: ; %entry
4876 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
4877 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4878 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
4879 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
4880 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
4881 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
4882 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
4883 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
4884 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
4885 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4886 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4887 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
4888 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
4889 ; GFX11-WGP-NEXT: buffer_gl0_inv
4890 ; GFX11-WGP-NEXT: s_endpgm
4892 ; GFX11-CU-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
4893 ; GFX11-CU: ; %bb.0: ; %entry
4894 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
4895 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4896 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
4897 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
4898 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4899 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
4900 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
4901 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
4902 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
4903 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
4904 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
4905 ; GFX11-CU-NEXT: s_endpgm
4907 ; GFX12-WGP-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
4908 ; GFX12-WGP: ; %bb.0: ; %entry
4909 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
4910 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4911 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
4912 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
4913 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
4914 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
4915 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
4916 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
4917 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
4918 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
4919 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
4920 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
4921 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
4922 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
4923 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
4924 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
4925 ; GFX12-WGP-NEXT: s_endpgm
4927 ; GFX12-CU-LABEL: global_workgroup_acq_rel_acquire_cmpxchg:
4928 ; GFX12-CU: ; %bb.0: ; %entry
4929 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
4930 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
4931 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
4932 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
4933 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
4934 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
4935 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
4936 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
4937 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
4938 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
4939 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
4940 ; GFX12-CU-NEXT: s_endpgm
4941 ptr addrspace(1) %out, i32 %in, i32 %old) {
4943 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
4944 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") acq_rel acquire
4948 define amdgpu_kernel void @global_workgroup_seq_cst_acquire_cmpxchg(
4949 ; GFX6-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
4950 ; GFX6: ; %bb.0: ; %entry
4951 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
4952 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
4953 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
4954 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
4955 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4956 ; GFX6-NEXT: s_mov_b32 s12, s5
4957 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
4958 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
4959 ; GFX6-NEXT: s_mov_b32 s11, -1
4960 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
4961 ; GFX6-NEXT: s_mov_b32 s5, s12
4962 ; GFX6-NEXT: s_mov_b32 s6, s11
4963 ; GFX6-NEXT: s_mov_b32 s7, s10
4964 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
4965 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
4966 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
4967 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
4968 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
4969 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
4970 ; GFX6-NEXT: s_endpgm
4972 ; GFX7-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
4973 ; GFX7: ; %bb.0: ; %entry
4974 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
4975 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
4976 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
4977 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
4978 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
4979 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4980 ; GFX7-NEXT: s_mov_b32 s4, s8
4981 ; GFX7-NEXT: s_mov_b32 s5, s9
4982 ; GFX7-NEXT: s_mov_b32 s9, s10
4983 ; GFX7-NEXT: s_mov_b32 s8, s11
4984 ; GFX7-NEXT: s_add_u32 s4, s4, s9
4985 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
4986 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
4987 ; GFX7-NEXT: s_mov_b32 s5, s8
4988 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
4989 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
4990 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
4991 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
4992 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
4993 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
4994 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
4995 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4996 ; GFX7-NEXT: s_endpgm
4998 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
4999 ; GFX10-WGP: ; %bb.0: ; %entry
5000 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
5001 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
5002 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
5003 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
5004 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5005 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
5006 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
5007 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
5008 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
5009 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5010 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5011 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
5012 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5013 ; GFX10-WGP-NEXT: buffer_gl0_inv
5014 ; GFX10-WGP-NEXT: s_endpgm
5016 ; GFX10-CU-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
5017 ; GFX10-CU: ; %bb.0: ; %entry
5018 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
5019 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
5020 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
5021 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
5022 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5023 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
5024 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
5025 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
5026 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
5027 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5028 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
5029 ; GFX10-CU-NEXT: s_endpgm
5031 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
5032 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5033 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
5034 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
5035 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
5036 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
5037 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5038 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
5039 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
5040 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
5041 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
5042 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
5043 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
5044 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
5045 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
5046 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
5047 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
5048 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
5049 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
5050 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5051 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
5052 ; SKIP-CACHE-INV-NEXT: s_endpgm
5054 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
5055 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5056 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5057 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
5058 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
5059 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
5060 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5061 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
5062 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
5063 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5064 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
5065 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5066 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
5067 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5069 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
5070 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5071 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5072 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
5073 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
5074 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
5075 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5076 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
5077 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
5078 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5079 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
5080 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5081 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
5082 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5083 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
5084 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5086 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
5087 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
5088 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5089 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5090 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
5091 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
5092 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5093 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
5094 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5095 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5096 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
5097 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5098 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
5099 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
5101 ; GFX940-TGSPLIT-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
5102 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
5103 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5104 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5105 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
5106 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
5107 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5108 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
5109 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5110 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5111 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
5112 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5113 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
5114 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5115 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
5116 ; GFX940-TGSPLIT-NEXT: s_endpgm
5118 ; GFX11-WGP-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
5119 ; GFX11-WGP: ; %bb.0: ; %entry
5120 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
5121 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5122 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
5123 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
5124 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
5125 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
5126 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
5127 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
5128 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
5129 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5130 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5131 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
5132 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5133 ; GFX11-WGP-NEXT: buffer_gl0_inv
5134 ; GFX11-WGP-NEXT: s_endpgm
5136 ; GFX11-CU-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
5137 ; GFX11-CU: ; %bb.0: ; %entry
5138 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
5139 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5140 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
5141 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
5142 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5143 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
5144 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
5145 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
5146 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
5147 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5148 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
5149 ; GFX11-CU-NEXT: s_endpgm
5151 ; GFX12-WGP-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
5152 ; GFX12-WGP: ; %bb.0: ; %entry
5153 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
5154 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5155 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
5156 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
5157 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
5158 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
5159 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
5160 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
5161 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
5162 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
5163 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
5164 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
5165 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
5166 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
5167 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
5168 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
5169 ; GFX12-WGP-NEXT: s_endpgm
5171 ; GFX12-CU-LABEL: global_workgroup_seq_cst_acquire_cmpxchg:
5172 ; GFX12-CU: ; %bb.0: ; %entry
5173 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
5174 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5175 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
5176 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
5177 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
5178 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
5179 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
5180 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
5181 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
5182 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
5183 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
5184 ; GFX12-CU-NEXT: s_endpgm
5185 ptr addrspace(1) %out, i32 %in, i32 %old) {
5187 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
5188 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") seq_cst acquire
5192 define amdgpu_kernel void @global_workgroup_monotonic_seq_cst_cmpxchg(
5193 ; GFX6-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
5194 ; GFX6: ; %bb.0: ; %entry
5195 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
5196 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
5197 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
5198 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
5199 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5200 ; GFX6-NEXT: s_mov_b32 s12, s5
5201 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
5202 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
5203 ; GFX6-NEXT: s_mov_b32 s11, -1
5204 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
5205 ; GFX6-NEXT: s_mov_b32 s5, s12
5206 ; GFX6-NEXT: s_mov_b32 s6, s11
5207 ; GFX6-NEXT: s_mov_b32 s7, s10
5208 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
5209 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
5210 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
5211 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
5212 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5213 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
5214 ; GFX6-NEXT: s_endpgm
5216 ; GFX7-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
5217 ; GFX7: ; %bb.0: ; %entry
5218 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
5219 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
5220 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
5221 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
5222 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
5223 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5224 ; GFX7-NEXT: s_mov_b32 s4, s8
5225 ; GFX7-NEXT: s_mov_b32 s5, s9
5226 ; GFX7-NEXT: s_mov_b32 s9, s10
5227 ; GFX7-NEXT: s_mov_b32 s8, s11
5228 ; GFX7-NEXT: s_add_u32 s4, s4, s9
5229 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
5230 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
5231 ; GFX7-NEXT: s_mov_b32 s5, s8
5232 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
5233 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
5234 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5235 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
5236 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
5237 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
5238 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5239 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
5240 ; GFX7-NEXT: s_endpgm
5242 ; GFX10-WGP-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
5243 ; GFX10-WGP: ; %bb.0: ; %entry
5244 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
5245 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
5246 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
5247 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
5248 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5249 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
5250 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
5251 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
5252 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
5253 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5254 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5255 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
5256 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5257 ; GFX10-WGP-NEXT: buffer_gl0_inv
5258 ; GFX10-WGP-NEXT: s_endpgm
5260 ; GFX10-CU-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
5261 ; GFX10-CU: ; %bb.0: ; %entry
5262 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
5263 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
5264 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
5265 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
5266 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5267 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
5268 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
5269 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
5270 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
5271 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5272 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
5273 ; GFX10-CU-NEXT: s_endpgm
5275 ; SKIP-CACHE-INV-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
5276 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5277 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
5278 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
5279 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
5280 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
5281 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5282 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
5283 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
5284 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
5285 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
5286 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
5287 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
5288 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
5289 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
5290 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
5291 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
5292 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
5293 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
5294 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5295 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
5296 ; SKIP-CACHE-INV-NEXT: s_endpgm
5298 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
5299 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5300 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5301 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
5302 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
5303 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
5304 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5305 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
5306 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
5307 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5308 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
5309 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5310 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
5311 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5313 ; GFX90A-TGSPLIT-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
5314 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5315 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5316 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
5317 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
5318 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
5319 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5320 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
5321 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
5322 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5323 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
5324 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5325 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
5326 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5327 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
5328 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5330 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
5331 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
5332 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5333 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5334 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
5335 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
5336 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5337 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
5338 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5339 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5340 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
5341 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5342 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
5343 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
5345 ; GFX940-TGSPLIT-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
5346 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
5347 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5348 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5349 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
5350 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
5351 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5352 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
5353 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5354 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5355 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
5356 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5357 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
5358 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5359 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
5360 ; GFX940-TGSPLIT-NEXT: s_endpgm
5362 ; GFX11-WGP-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
5363 ; GFX11-WGP: ; %bb.0: ; %entry
5364 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
5365 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5366 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
5367 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
5368 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
5369 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
5370 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
5371 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
5372 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
5373 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5374 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5375 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
5376 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5377 ; GFX11-WGP-NEXT: buffer_gl0_inv
5378 ; GFX11-WGP-NEXT: s_endpgm
5380 ; GFX11-CU-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
5381 ; GFX11-CU: ; %bb.0: ; %entry
5382 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
5383 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5384 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
5385 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
5386 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5387 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
5388 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
5389 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
5390 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
5391 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5392 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
5393 ; GFX11-CU-NEXT: s_endpgm
5395 ; GFX12-WGP-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
5396 ; GFX12-WGP: ; %bb.0: ; %entry
5397 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
5398 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5399 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
5400 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
5401 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
5402 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
5403 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
5404 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
5405 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
5406 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
5407 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
5408 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
5409 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
5410 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
5411 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
5412 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
5413 ; GFX12-WGP-NEXT: s_endpgm
5415 ; GFX12-CU-LABEL: global_workgroup_monotonic_seq_cst_cmpxchg:
5416 ; GFX12-CU: ; %bb.0: ; %entry
5417 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
5418 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5419 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
5420 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
5421 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
5422 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
5423 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
5424 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
5425 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
5426 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
5427 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
5428 ; GFX12-CU-NEXT: s_endpgm
5429 ptr addrspace(1) %out, i32 %in, i32 %old) {
5431 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
5432 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") monotonic seq_cst
5436 define amdgpu_kernel void @global_workgroup_acquire_seq_cst_cmpxchg(
5437 ; GFX6-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
5438 ; GFX6: ; %bb.0: ; %entry
5439 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
5440 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
5441 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
5442 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
5443 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5444 ; GFX6-NEXT: s_mov_b32 s12, s5
5445 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
5446 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
5447 ; GFX6-NEXT: s_mov_b32 s11, -1
5448 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
5449 ; GFX6-NEXT: s_mov_b32 s5, s12
5450 ; GFX6-NEXT: s_mov_b32 s6, s11
5451 ; GFX6-NEXT: s_mov_b32 s7, s10
5452 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
5453 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
5454 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
5455 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
5456 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5457 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
5458 ; GFX6-NEXT: s_endpgm
5460 ; GFX7-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
5461 ; GFX7: ; %bb.0: ; %entry
5462 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
5463 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
5464 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
5465 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
5466 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
5467 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5468 ; GFX7-NEXT: s_mov_b32 s4, s8
5469 ; GFX7-NEXT: s_mov_b32 s5, s9
5470 ; GFX7-NEXT: s_mov_b32 s9, s10
5471 ; GFX7-NEXT: s_mov_b32 s8, s11
5472 ; GFX7-NEXT: s_add_u32 s4, s4, s9
5473 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
5474 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
5475 ; GFX7-NEXT: s_mov_b32 s5, s8
5476 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
5477 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
5478 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5479 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
5480 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
5481 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
5482 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5483 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
5484 ; GFX7-NEXT: s_endpgm
5486 ; GFX10-WGP-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
5487 ; GFX10-WGP: ; %bb.0: ; %entry
5488 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
5489 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
5490 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
5491 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
5492 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5493 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
5494 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
5495 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
5496 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
5497 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5498 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5499 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
5500 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5501 ; GFX10-WGP-NEXT: buffer_gl0_inv
5502 ; GFX10-WGP-NEXT: s_endpgm
5504 ; GFX10-CU-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
5505 ; GFX10-CU: ; %bb.0: ; %entry
5506 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
5507 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
5508 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
5509 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
5510 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5511 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
5512 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
5513 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
5514 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
5515 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5516 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
5517 ; GFX10-CU-NEXT: s_endpgm
5519 ; SKIP-CACHE-INV-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
5520 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5521 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
5522 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
5523 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
5524 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
5525 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5526 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
5527 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
5528 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
5529 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
5530 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
5531 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
5532 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
5533 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
5534 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
5535 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
5536 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
5537 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
5538 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5539 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
5540 ; SKIP-CACHE-INV-NEXT: s_endpgm
5542 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
5543 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5544 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5545 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
5546 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
5547 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
5548 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5549 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
5550 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
5551 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5552 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
5553 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5554 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
5555 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5557 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
5558 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5559 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5560 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
5561 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
5562 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
5563 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5564 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
5565 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
5566 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5567 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
5568 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5569 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
5570 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5571 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
5572 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5574 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
5575 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
5576 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5577 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5578 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
5579 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
5580 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5581 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
5582 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5583 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5584 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
5585 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5586 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
5587 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
5589 ; GFX940-TGSPLIT-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
5590 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
5591 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5592 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5593 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
5594 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
5595 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5596 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
5597 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5598 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5599 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
5600 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5601 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
5602 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5603 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
5604 ; GFX940-TGSPLIT-NEXT: s_endpgm
5606 ; GFX11-WGP-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
5607 ; GFX11-WGP: ; %bb.0: ; %entry
5608 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
5609 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5610 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
5611 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
5612 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
5613 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
5614 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
5615 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
5616 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
5617 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5618 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5619 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
5620 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5621 ; GFX11-WGP-NEXT: buffer_gl0_inv
5622 ; GFX11-WGP-NEXT: s_endpgm
5624 ; GFX11-CU-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
5625 ; GFX11-CU: ; %bb.0: ; %entry
5626 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
5627 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5628 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
5629 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
5630 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5631 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
5632 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
5633 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
5634 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
5635 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5636 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
5637 ; GFX11-CU-NEXT: s_endpgm
5639 ; GFX12-WGP-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
5640 ; GFX12-WGP: ; %bb.0: ; %entry
5641 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
5642 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5643 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
5644 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
5645 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
5646 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
5647 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
5648 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
5649 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
5650 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
5651 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
5652 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
5653 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
5654 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
5655 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
5656 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
5657 ; GFX12-WGP-NEXT: s_endpgm
5659 ; GFX12-CU-LABEL: global_workgroup_acquire_seq_cst_cmpxchg:
5660 ; GFX12-CU: ; %bb.0: ; %entry
5661 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
5662 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5663 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
5664 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
5665 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
5666 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
5667 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
5668 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
5669 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
5670 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
5671 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
5672 ; GFX12-CU-NEXT: s_endpgm
5673 ptr addrspace(1) %out, i32 %in, i32 %old) {
5675 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
5676 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") acquire seq_cst
5680 define amdgpu_kernel void @global_workgroup_release_seq_cst_cmpxchg(
5681 ; GFX6-LABEL: global_workgroup_release_seq_cst_cmpxchg:
5682 ; GFX6: ; %bb.0: ; %entry
5683 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
5684 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
5685 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
5686 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
5687 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5688 ; GFX6-NEXT: s_mov_b32 s12, s5
5689 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
5690 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
5691 ; GFX6-NEXT: s_mov_b32 s11, -1
5692 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
5693 ; GFX6-NEXT: s_mov_b32 s5, s12
5694 ; GFX6-NEXT: s_mov_b32 s6, s11
5695 ; GFX6-NEXT: s_mov_b32 s7, s10
5696 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
5697 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
5698 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
5699 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
5700 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5701 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
5702 ; GFX6-NEXT: s_endpgm
5704 ; GFX7-LABEL: global_workgroup_release_seq_cst_cmpxchg:
5705 ; GFX7: ; %bb.0: ; %entry
5706 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
5707 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
5708 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
5709 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
5710 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
5711 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5712 ; GFX7-NEXT: s_mov_b32 s4, s8
5713 ; GFX7-NEXT: s_mov_b32 s5, s9
5714 ; GFX7-NEXT: s_mov_b32 s9, s10
5715 ; GFX7-NEXT: s_mov_b32 s8, s11
5716 ; GFX7-NEXT: s_add_u32 s4, s4, s9
5717 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
5718 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
5719 ; GFX7-NEXT: s_mov_b32 s5, s8
5720 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
5721 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
5722 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5723 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
5724 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
5725 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
5726 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5727 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
5728 ; GFX7-NEXT: s_endpgm
5730 ; GFX10-WGP-LABEL: global_workgroup_release_seq_cst_cmpxchg:
5731 ; GFX10-WGP: ; %bb.0: ; %entry
5732 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
5733 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
5734 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
5735 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
5736 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5737 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
5738 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
5739 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
5740 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
5741 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5742 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5743 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
5744 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5745 ; GFX10-WGP-NEXT: buffer_gl0_inv
5746 ; GFX10-WGP-NEXT: s_endpgm
5748 ; GFX10-CU-LABEL: global_workgroup_release_seq_cst_cmpxchg:
5749 ; GFX10-CU: ; %bb.0: ; %entry
5750 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
5751 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
5752 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
5753 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
5754 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5755 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
5756 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
5757 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
5758 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
5759 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5760 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
5761 ; GFX10-CU-NEXT: s_endpgm
5763 ; SKIP-CACHE-INV-LABEL: global_workgroup_release_seq_cst_cmpxchg:
5764 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
5765 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
5766 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
5767 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
5768 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
5769 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5770 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
5771 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
5772 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
5773 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
5774 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
5775 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
5776 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
5777 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
5778 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
5779 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
5780 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
5781 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
5782 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
5783 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
5784 ; SKIP-CACHE-INV-NEXT: s_endpgm
5786 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_release_seq_cst_cmpxchg:
5787 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
5788 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5789 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
5790 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
5791 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
5792 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5793 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
5794 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
5795 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5796 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
5797 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5798 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
5799 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
5801 ; GFX90A-TGSPLIT-LABEL: global_workgroup_release_seq_cst_cmpxchg:
5802 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
5803 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5804 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
5805 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
5806 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
5807 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5808 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
5809 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
5810 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5811 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
5812 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5813 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
5814 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5815 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
5816 ; GFX90A-TGSPLIT-NEXT: s_endpgm
5818 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_release_seq_cst_cmpxchg:
5819 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
5820 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5821 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5822 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
5823 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
5824 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5825 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
5826 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5827 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5828 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
5829 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5830 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
5831 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
5833 ; GFX940-TGSPLIT-LABEL: global_workgroup_release_seq_cst_cmpxchg:
5834 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
5835 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
5836 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
5837 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
5838 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
5839 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
5840 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
5841 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
5842 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5843 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
5844 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5845 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
5846 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
5847 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
5848 ; GFX940-TGSPLIT-NEXT: s_endpgm
5850 ; GFX11-WGP-LABEL: global_workgroup_release_seq_cst_cmpxchg:
5851 ; GFX11-WGP: ; %bb.0: ; %entry
5852 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
5853 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5854 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
5855 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
5856 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
5857 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
5858 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
5859 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
5860 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
5861 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5862 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5863 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
5864 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5865 ; GFX11-WGP-NEXT: buffer_gl0_inv
5866 ; GFX11-WGP-NEXT: s_endpgm
5868 ; GFX11-CU-LABEL: global_workgroup_release_seq_cst_cmpxchg:
5869 ; GFX11-CU: ; %bb.0: ; %entry
5870 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
5871 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5872 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
5873 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
5874 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5875 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
5876 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
5877 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
5878 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
5879 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
5880 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
5881 ; GFX11-CU-NEXT: s_endpgm
5883 ; GFX12-WGP-LABEL: global_workgroup_release_seq_cst_cmpxchg:
5884 ; GFX12-WGP: ; %bb.0: ; %entry
5885 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
5886 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5887 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
5888 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
5889 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
5890 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
5891 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
5892 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
5893 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
5894 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
5895 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
5896 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
5897 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
5898 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
5899 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
5900 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
5901 ; GFX12-WGP-NEXT: s_endpgm
5903 ; GFX12-CU-LABEL: global_workgroup_release_seq_cst_cmpxchg:
5904 ; GFX12-CU: ; %bb.0: ; %entry
5905 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
5906 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
5907 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
5908 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
5909 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
5910 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
5911 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
5912 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
5913 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
5914 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
5915 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
5916 ; GFX12-CU-NEXT: s_endpgm
5917 ptr addrspace(1) %out, i32 %in, i32 %old) {
5919 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
5920 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") release seq_cst
5924 define amdgpu_kernel void @global_workgroup_acq_rel_seq_cst_cmpxchg(
5925 ; GFX6-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
5926 ; GFX6: ; %bb.0: ; %entry
5927 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
5928 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
5929 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
5930 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
5931 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5932 ; GFX6-NEXT: s_mov_b32 s12, s5
5933 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
5934 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
5935 ; GFX6-NEXT: s_mov_b32 s11, -1
5936 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
5937 ; GFX6-NEXT: s_mov_b32 s5, s12
5938 ; GFX6-NEXT: s_mov_b32 s6, s11
5939 ; GFX6-NEXT: s_mov_b32 s7, s10
5940 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
5941 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
5942 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
5943 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
5944 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
5945 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
5946 ; GFX6-NEXT: s_endpgm
5948 ; GFX7-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
5949 ; GFX7: ; %bb.0: ; %entry
5950 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
5951 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
5952 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
5953 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
5954 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
5955 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5956 ; GFX7-NEXT: s_mov_b32 s4, s8
5957 ; GFX7-NEXT: s_mov_b32 s5, s9
5958 ; GFX7-NEXT: s_mov_b32 s9, s10
5959 ; GFX7-NEXT: s_mov_b32 s8, s11
5960 ; GFX7-NEXT: s_add_u32 s4, s4, s9
5961 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
5962 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
5963 ; GFX7-NEXT: s_mov_b32 s5, s8
5964 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
5965 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
5966 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
5967 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
5968 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
5969 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
5970 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
5971 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
5972 ; GFX7-NEXT: s_endpgm
5974 ; GFX10-WGP-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
5975 ; GFX10-WGP: ; %bb.0: ; %entry
5976 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
5977 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
5978 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
5979 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
5980 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
5981 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
5982 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
5983 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
5984 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
5985 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5986 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5987 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
5988 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
5989 ; GFX10-WGP-NEXT: buffer_gl0_inv
5990 ; GFX10-WGP-NEXT: s_endpgm
5992 ; GFX10-CU-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
5993 ; GFX10-CU: ; %bb.0: ; %entry
5994 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
5995 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
5996 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
5997 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
5998 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
5999 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
6000 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
6001 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
6002 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
6003 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6004 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
6005 ; GFX10-CU-NEXT: s_endpgm
6007 ; SKIP-CACHE-INV-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
6008 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6009 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
6010 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
6011 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
6012 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
6013 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6014 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
6015 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
6016 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
6017 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
6018 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
6019 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
6020 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
6021 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
6022 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
6023 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
6024 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
6025 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
6026 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6027 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
6028 ; SKIP-CACHE-INV-NEXT: s_endpgm
6030 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
6031 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6032 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
6033 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
6034 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
6035 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
6036 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6037 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
6038 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
6039 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6040 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
6041 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6042 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
6043 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6045 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
6046 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6047 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
6048 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
6049 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
6050 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
6051 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6052 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
6053 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
6054 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6055 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
6056 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6057 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
6058 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6059 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
6060 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6062 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
6063 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
6064 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
6065 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6066 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
6067 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
6068 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6069 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
6070 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
6071 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6072 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
6073 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6074 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
6075 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
6077 ; GFX940-TGSPLIT-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
6078 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
6079 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
6080 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6081 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
6082 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
6083 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6084 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
6085 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
6086 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6087 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
6088 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6089 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
6090 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6091 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
6092 ; GFX940-TGSPLIT-NEXT: s_endpgm
6094 ; GFX11-WGP-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
6095 ; GFX11-WGP: ; %bb.0: ; %entry
6096 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
6097 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6098 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
6099 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
6100 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
6101 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
6102 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
6103 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
6104 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
6105 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6106 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6107 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
6108 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6109 ; GFX11-WGP-NEXT: buffer_gl0_inv
6110 ; GFX11-WGP-NEXT: s_endpgm
6112 ; GFX11-CU-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
6113 ; GFX11-CU: ; %bb.0: ; %entry
6114 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
6115 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6116 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
6117 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
6118 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6119 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
6120 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
6121 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
6122 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
6123 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6124 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
6125 ; GFX11-CU-NEXT: s_endpgm
6127 ; GFX12-WGP-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
6128 ; GFX12-WGP: ; %bb.0: ; %entry
6129 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
6130 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6131 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
6132 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
6133 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
6134 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
6135 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
6136 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
6137 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
6138 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
6139 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
6140 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
6141 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
6142 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
6143 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
6144 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
6145 ; GFX12-WGP-NEXT: s_endpgm
6147 ; GFX12-CU-LABEL: global_workgroup_acq_rel_seq_cst_cmpxchg:
6148 ; GFX12-CU: ; %bb.0: ; %entry
6149 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
6150 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6151 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
6152 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
6153 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
6154 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
6155 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
6156 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
6157 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
6158 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
6159 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
6160 ; GFX12-CU-NEXT: s_endpgm
6161 ptr addrspace(1) %out, i32 %in, i32 %old) {
6163 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
6164 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") acq_rel seq_cst
6168 define amdgpu_kernel void @global_workgroup_seq_cst_seq_cst_cmpxchg(
6169 ; GFX6-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
6170 ; GFX6: ; %bb.0: ; %entry
6171 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
6172 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
6173 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
6174 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
6175 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6176 ; GFX6-NEXT: s_mov_b32 s12, s5
6177 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
6178 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
6179 ; GFX6-NEXT: s_mov_b32 s11, -1
6180 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
6181 ; GFX6-NEXT: s_mov_b32 s5, s12
6182 ; GFX6-NEXT: s_mov_b32 s6, s11
6183 ; GFX6-NEXT: s_mov_b32 s7, s10
6184 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
6185 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
6186 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
6187 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
6188 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6189 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
6190 ; GFX6-NEXT: s_endpgm
6192 ; GFX7-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
6193 ; GFX7: ; %bb.0: ; %entry
6194 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
6195 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
6196 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
6197 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
6198 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
6199 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6200 ; GFX7-NEXT: s_mov_b32 s4, s8
6201 ; GFX7-NEXT: s_mov_b32 s5, s9
6202 ; GFX7-NEXT: s_mov_b32 s9, s10
6203 ; GFX7-NEXT: s_mov_b32 s8, s11
6204 ; GFX7-NEXT: s_add_u32 s4, s4, s9
6205 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
6206 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
6207 ; GFX7-NEXT: s_mov_b32 s5, s8
6208 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
6209 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
6210 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6211 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
6212 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
6213 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
6214 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6215 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
6216 ; GFX7-NEXT: s_endpgm
6218 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
6219 ; GFX10-WGP: ; %bb.0: ; %entry
6220 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
6221 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
6222 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
6223 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
6224 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6225 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
6226 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
6227 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
6228 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
6229 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6230 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6231 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
6232 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6233 ; GFX10-WGP-NEXT: buffer_gl0_inv
6234 ; GFX10-WGP-NEXT: s_endpgm
6236 ; GFX10-CU-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
6237 ; GFX10-CU: ; %bb.0: ; %entry
6238 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
6239 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
6240 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
6241 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
6242 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6243 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
6244 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
6245 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
6246 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
6247 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6248 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
6249 ; GFX10-CU-NEXT: s_endpgm
6251 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
6252 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6253 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
6254 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
6255 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
6256 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
6257 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6258 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
6259 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
6260 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
6261 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
6262 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
6263 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
6264 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
6265 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
6266 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
6267 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
6268 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
6269 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
6270 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6271 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
6272 ; SKIP-CACHE-INV-NEXT: s_endpgm
6274 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
6275 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6276 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
6277 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
6278 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
6279 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
6280 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6281 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
6282 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
6283 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6284 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
6285 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6286 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
6287 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6289 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
6290 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6291 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
6292 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
6293 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
6294 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
6295 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6296 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
6297 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
6298 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6299 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
6300 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6301 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
6302 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6303 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
6304 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6306 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
6307 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
6308 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
6309 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6310 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
6311 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
6312 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6313 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
6314 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
6315 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6316 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
6317 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6318 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
6319 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
6321 ; GFX940-TGSPLIT-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
6322 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
6323 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
6324 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6325 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
6326 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
6327 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6328 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
6329 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
6330 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6331 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
6332 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6333 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
6334 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6335 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
6336 ; GFX940-TGSPLIT-NEXT: s_endpgm
6338 ; GFX11-WGP-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
6339 ; GFX11-WGP: ; %bb.0: ; %entry
6340 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
6341 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6342 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
6343 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
6344 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
6345 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
6346 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
6347 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
6348 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
6349 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6350 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6351 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
6352 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6353 ; GFX11-WGP-NEXT: buffer_gl0_inv
6354 ; GFX11-WGP-NEXT: s_endpgm
6356 ; GFX11-CU-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
6357 ; GFX11-CU: ; %bb.0: ; %entry
6358 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
6359 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6360 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
6361 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
6362 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6363 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
6364 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
6365 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
6366 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
6367 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6368 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
6369 ; GFX11-CU-NEXT: s_endpgm
6371 ; GFX12-WGP-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
6372 ; GFX12-WGP: ; %bb.0: ; %entry
6373 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
6374 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6375 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
6376 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
6377 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
6378 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
6379 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
6380 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
6381 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
6382 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
6383 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
6384 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
6385 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
6386 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
6387 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
6388 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
6389 ; GFX12-WGP-NEXT: s_endpgm
6391 ; GFX12-CU-LABEL: global_workgroup_seq_cst_seq_cst_cmpxchg:
6392 ; GFX12-CU: ; %bb.0: ; %entry
6393 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
6394 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6395 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
6396 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
6397 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
6398 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
6399 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
6400 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
6401 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
6402 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
6403 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
6404 ; GFX12-CU-NEXT: s_endpgm
6405 ptr addrspace(1) %out, i32 %in, i32 %old) {
6407 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
6408 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") seq_cst seq_cst
6412 define amdgpu_kernel void @global_workgroup_monotonic_monotonic_ret_cmpxchg(
6413 ; GFX6-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
6414 ; GFX6: ; %bb.0: ; %entry
6415 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
6416 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
6417 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
6418 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
6419 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6420 ; GFX6-NEXT: s_mov_b32 s12, s5
6421 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
6422 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
6423 ; GFX6-NEXT: s_mov_b32 s11, -1
6424 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
6425 ; GFX6-NEXT: s_mov_b32 s5, s12
6426 ; GFX6-NEXT: s_mov_b32 s6, s11
6427 ; GFX6-NEXT: s_mov_b32 s7, s10
6428 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
6429 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
6430 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
6431 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
6432 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
6433 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
6434 ; GFX6-NEXT: s_waitcnt vmcnt(0)
6435 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
6436 ; GFX6-NEXT: s_endpgm
6438 ; GFX7-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
6439 ; GFX7: ; %bb.0: ; %entry
6440 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
6441 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
6442 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
6443 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
6444 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
6445 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6446 ; GFX7-NEXT: s_mov_b32 s6, s4
6447 ; GFX7-NEXT: s_mov_b32 s7, s5
6448 ; GFX7-NEXT: s_mov_b32 s11, s12
6449 ; GFX7-NEXT: s_mov_b32 s10, s13
6450 ; GFX7-NEXT: s_add_u32 s6, s6, s11
6451 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
6452 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
6453 ; GFX7-NEXT: s_mov_b32 s7, s10
6454 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
6455 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
6456 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6457 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
6458 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
6459 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
6460 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
6461 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
6462 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
6463 ; GFX7-NEXT: s_waitcnt vmcnt(0)
6464 ; GFX7-NEXT: flat_store_dword v[0:1], v2
6465 ; GFX7-NEXT: s_endpgm
6467 ; GFX10-WGP-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
6468 ; GFX10-WGP: ; %bb.0: ; %entry
6469 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
6470 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
6471 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
6472 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
6473 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6474 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
6475 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
6476 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
6477 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
6478 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
6479 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
6480 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
6481 ; GFX10-WGP-NEXT: s_endpgm
6483 ; GFX10-CU-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
6484 ; GFX10-CU: ; %bb.0: ; %entry
6485 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
6486 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
6487 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
6488 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
6489 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6490 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
6491 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
6492 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
6493 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
6494 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
6495 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
6496 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
6497 ; GFX10-CU-NEXT: s_endpgm
6499 ; SKIP-CACHE-INV-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
6500 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6501 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
6502 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
6503 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
6504 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
6505 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6506 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
6507 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
6508 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
6509 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
6510 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
6511 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
6512 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
6513 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
6514 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
6515 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
6516 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
6517 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
6518 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
6519 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
6520 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
6521 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
6522 ; SKIP-CACHE-INV-NEXT: s_endpgm
6524 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
6525 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6526 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
6527 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
6528 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
6529 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
6530 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6531 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
6532 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
6533 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6534 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
6535 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
6536 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
6537 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
6538 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6540 ; GFX90A-TGSPLIT-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
6541 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6542 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
6543 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
6544 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
6545 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
6546 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6547 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
6548 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
6549 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6550 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
6551 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
6552 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6553 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
6554 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6556 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
6557 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
6558 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
6559 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6560 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
6561 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
6562 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6563 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
6564 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
6565 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6566 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
6567 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
6568 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
6569 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
6570 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
6572 ; GFX940-TGSPLIT-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
6573 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
6574 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
6575 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6576 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
6577 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
6578 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6579 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
6580 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
6581 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6582 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
6583 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
6584 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6585 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
6586 ; GFX940-TGSPLIT-NEXT: s_endpgm
6588 ; GFX11-WGP-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
6589 ; GFX11-WGP: ; %bb.0: ; %entry
6590 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
6591 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6592 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
6593 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
6594 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
6595 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
6596 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
6597 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
6598 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
6599 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
6600 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
6601 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
6602 ; GFX11-WGP-NEXT: s_endpgm
6604 ; GFX11-CU-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
6605 ; GFX11-CU: ; %bb.0: ; %entry
6606 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
6607 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6608 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
6609 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
6610 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6611 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
6612 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
6613 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
6614 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
6615 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
6616 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
6617 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
6618 ; GFX11-CU-NEXT: s_endpgm
6620 ; GFX12-WGP-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
6621 ; GFX12-WGP: ; %bb.0: ; %entry
6622 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
6623 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6624 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
6625 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
6626 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
6627 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
6628 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
6629 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
6630 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
6631 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
6632 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
6633 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
6634 ; GFX12-WGP-NEXT: s_endpgm
6636 ; GFX12-CU-LABEL: global_workgroup_monotonic_monotonic_ret_cmpxchg:
6637 ; GFX12-CU: ; %bb.0: ; %entry
6638 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
6639 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6640 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
6641 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
6642 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
6643 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
6644 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
6645 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
6646 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
6647 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
6648 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
6649 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
6650 ; GFX12-CU-NEXT: s_endpgm
6651 ptr addrspace(1) %out, i32 %in, i32 %old) {
6653 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
6654 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") monotonic monotonic
6655 %val0 = extractvalue { i32, i1 } %val, 0
6656 store i32 %val0, ptr addrspace(1) %out, align 4
6660 define amdgpu_kernel void @global_workgroup_acquire_monotonic_ret_cmpxchg(
6661 ; GFX6-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
6662 ; GFX6: ; %bb.0: ; %entry
6663 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
6664 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
6665 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
6666 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
6667 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6668 ; GFX6-NEXT: s_mov_b32 s12, s5
6669 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
6670 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
6671 ; GFX6-NEXT: s_mov_b32 s11, -1
6672 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
6673 ; GFX6-NEXT: s_mov_b32 s5, s12
6674 ; GFX6-NEXT: s_mov_b32 s6, s11
6675 ; GFX6-NEXT: s_mov_b32 s7, s10
6676 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
6677 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
6678 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
6679 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
6680 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
6681 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
6682 ; GFX6-NEXT: s_waitcnt vmcnt(0)
6683 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
6684 ; GFX6-NEXT: s_endpgm
6686 ; GFX7-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
6687 ; GFX7: ; %bb.0: ; %entry
6688 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
6689 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
6690 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
6691 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
6692 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
6693 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6694 ; GFX7-NEXT: s_mov_b32 s6, s4
6695 ; GFX7-NEXT: s_mov_b32 s7, s5
6696 ; GFX7-NEXT: s_mov_b32 s11, s12
6697 ; GFX7-NEXT: s_mov_b32 s10, s13
6698 ; GFX7-NEXT: s_add_u32 s6, s6, s11
6699 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
6700 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
6701 ; GFX7-NEXT: s_mov_b32 s7, s10
6702 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
6703 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
6704 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6705 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
6706 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
6707 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
6708 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
6709 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
6710 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
6711 ; GFX7-NEXT: s_waitcnt vmcnt(0)
6712 ; GFX7-NEXT: flat_store_dword v[0:1], v2
6713 ; GFX7-NEXT: s_endpgm
6715 ; GFX10-WGP-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
6716 ; GFX10-WGP: ; %bb.0: ; %entry
6717 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
6718 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
6719 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
6720 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
6721 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6722 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
6723 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
6724 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
6725 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
6726 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
6727 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
6728 ; GFX10-WGP-NEXT: buffer_gl0_inv
6729 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
6730 ; GFX10-WGP-NEXT: s_endpgm
6732 ; GFX10-CU-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
6733 ; GFX10-CU: ; %bb.0: ; %entry
6734 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
6735 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
6736 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
6737 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
6738 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6739 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
6740 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
6741 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
6742 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
6743 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
6744 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
6745 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
6746 ; GFX10-CU-NEXT: s_endpgm
6748 ; SKIP-CACHE-INV-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
6749 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
6750 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
6751 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
6752 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
6753 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
6754 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
6755 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
6756 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
6757 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
6758 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
6759 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
6760 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
6761 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
6762 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
6763 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
6764 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
6765 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
6766 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
6767 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
6768 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
6769 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
6770 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
6771 ; SKIP-CACHE-INV-NEXT: s_endpgm
6773 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
6774 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
6775 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
6776 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
6777 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
6778 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
6779 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6780 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
6781 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
6782 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6783 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
6784 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
6785 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
6786 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
6787 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
6789 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
6790 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
6791 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
6792 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
6793 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
6794 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
6795 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6796 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
6797 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
6798 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6799 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
6800 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
6801 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6802 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
6803 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
6804 ; GFX90A-TGSPLIT-NEXT: s_endpgm
6806 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
6807 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
6808 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
6809 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6810 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
6811 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
6812 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6813 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
6814 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
6815 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6816 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
6817 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
6818 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
6819 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
6820 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
6822 ; GFX940-TGSPLIT-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
6823 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
6824 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
6825 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
6826 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
6827 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
6828 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
6829 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
6830 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
6831 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6832 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
6833 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
6834 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
6835 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
6836 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
6837 ; GFX940-TGSPLIT-NEXT: s_endpgm
6839 ; GFX11-WGP-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
6840 ; GFX11-WGP: ; %bb.0: ; %entry
6841 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
6842 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6843 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
6844 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
6845 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
6846 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
6847 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
6848 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
6849 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
6850 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
6851 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
6852 ; GFX11-WGP-NEXT: buffer_gl0_inv
6853 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
6854 ; GFX11-WGP-NEXT: s_endpgm
6856 ; GFX11-CU-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
6857 ; GFX11-CU: ; %bb.0: ; %entry
6858 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
6859 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6860 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
6861 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
6862 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
6863 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
6864 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
6865 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
6866 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
6867 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
6868 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
6869 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
6870 ; GFX11-CU-NEXT: s_endpgm
6872 ; GFX12-WGP-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
6873 ; GFX12-WGP: ; %bb.0: ; %entry
6874 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
6875 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6876 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
6877 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
6878 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
6879 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
6880 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
6881 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
6882 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
6883 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
6884 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
6885 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
6886 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
6887 ; GFX12-WGP-NEXT: s_endpgm
6889 ; GFX12-CU-LABEL: global_workgroup_acquire_monotonic_ret_cmpxchg:
6890 ; GFX12-CU: ; %bb.0: ; %entry
6891 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
6892 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
6893 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
6894 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
6895 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
6896 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
6897 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
6898 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
6899 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
6900 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
6901 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
6902 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
6903 ; GFX12-CU-NEXT: s_endpgm
6904 ptr addrspace(1) %out, i32 %in, i32 %old) {
6906 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
6907 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") acquire monotonic
6908 %val0 = extractvalue { i32, i1 } %val, 0
6909 store i32 %val0, ptr addrspace(1) %out, align 4
6913 define amdgpu_kernel void @global_workgroup_release_monotonic_ret_cmpxchg(
6914 ; GFX6-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
6915 ; GFX6: ; %bb.0: ; %entry
6916 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
6917 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
6918 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
6919 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
6920 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6921 ; GFX6-NEXT: s_mov_b32 s12, s5
6922 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
6923 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
6924 ; GFX6-NEXT: s_mov_b32 s11, -1
6925 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
6926 ; GFX6-NEXT: s_mov_b32 s5, s12
6927 ; GFX6-NEXT: s_mov_b32 s6, s11
6928 ; GFX6-NEXT: s_mov_b32 s7, s10
6929 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
6930 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
6931 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
6932 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
6933 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
6934 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
6935 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
6936 ; GFX6-NEXT: s_waitcnt vmcnt(0)
6937 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
6938 ; GFX6-NEXT: s_endpgm
6940 ; GFX7-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
6941 ; GFX7: ; %bb.0: ; %entry
6942 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
6943 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
6944 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
6945 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
6946 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
6947 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6948 ; GFX7-NEXT: s_mov_b32 s6, s4
6949 ; GFX7-NEXT: s_mov_b32 s7, s5
6950 ; GFX7-NEXT: s_mov_b32 s11, s12
6951 ; GFX7-NEXT: s_mov_b32 s10, s13
6952 ; GFX7-NEXT: s_add_u32 s6, s6, s11
6953 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
6954 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
6955 ; GFX7-NEXT: s_mov_b32 s7, s10
6956 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
6957 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
6958 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
6959 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
6960 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
6961 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
6962 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
6963 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
6964 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
6965 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
6966 ; GFX7-NEXT: s_waitcnt vmcnt(0)
6967 ; GFX7-NEXT: flat_store_dword v[0:1], v2
6968 ; GFX7-NEXT: s_endpgm
6970 ; GFX10-WGP-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
6971 ; GFX10-WGP: ; %bb.0: ; %entry
6972 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
6973 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
6974 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
6975 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
6976 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
6977 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
6978 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
6979 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
6980 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
6981 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6982 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
6983 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
6984 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
6985 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
6986 ; GFX10-WGP-NEXT: s_endpgm
6988 ; GFX10-CU-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
6989 ; GFX10-CU: ; %bb.0: ; %entry
6990 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
6991 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
6992 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
6993 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
6994 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
6995 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
6996 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
6997 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
6998 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
6999 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7000 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
7001 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
7002 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
7003 ; GFX10-CU-NEXT: s_endpgm
7005 ; SKIP-CACHE-INV-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
7006 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7007 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
7008 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
7009 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
7010 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
7011 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7012 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
7013 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
7014 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
7015 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
7016 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
7017 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
7018 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
7019 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
7020 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
7021 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
7022 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
7023 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
7024 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7025 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
7026 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
7027 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
7028 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
7029 ; SKIP-CACHE-INV-NEXT: s_endpgm
7031 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
7032 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7033 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7034 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
7035 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
7036 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
7037 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7038 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
7039 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
7040 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7041 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
7042 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7043 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
7044 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
7045 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
7046 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7048 ; GFX90A-TGSPLIT-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
7049 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7050 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7051 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
7052 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
7053 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
7054 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7055 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
7056 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
7057 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7058 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
7059 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7060 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
7061 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7062 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
7063 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7065 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
7066 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
7067 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7068 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7069 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
7070 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
7071 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7072 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
7073 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
7074 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7075 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
7076 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7077 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
7078 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
7079 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
7080 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
7082 ; GFX940-TGSPLIT-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
7083 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
7084 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7085 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7086 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
7087 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
7088 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7089 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
7090 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
7091 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7092 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
7093 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7094 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
7095 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7096 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
7097 ; GFX940-TGSPLIT-NEXT: s_endpgm
7099 ; GFX11-WGP-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
7100 ; GFX11-WGP: ; %bb.0: ; %entry
7101 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
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 v1, s3
7107 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
7108 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
7109 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
7110 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7111 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7112 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
7113 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
7114 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
7115 ; GFX11-WGP-NEXT: s_endpgm
7117 ; GFX11-CU-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
7118 ; GFX11-CU: ; %bb.0: ; %entry
7119 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
7120 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7121 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
7122 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
7123 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
7124 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
7125 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
7126 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
7127 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
7128 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
7129 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
7130 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
7131 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
7132 ; GFX11-CU-NEXT: s_endpgm
7134 ; GFX12-WGP-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
7135 ; GFX12-WGP: ; %bb.0: ; %entry
7136 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
7137 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7138 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
7139 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
7140 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
7141 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
7142 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
7143 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
7144 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
7145 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
7146 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
7147 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
7148 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
7149 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
7150 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
7151 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
7152 ; GFX12-WGP-NEXT: s_endpgm
7154 ; GFX12-CU-LABEL: global_workgroup_release_monotonic_ret_cmpxchg:
7155 ; GFX12-CU: ; %bb.0: ; %entry
7156 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
7157 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7158 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
7159 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
7160 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
7161 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
7162 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
7163 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
7164 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
7165 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
7166 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
7167 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
7168 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
7169 ; GFX12-CU-NEXT: s_endpgm
7170 ptr addrspace(1) %out, i32 %in, i32 %old) {
7172 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
7173 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") release monotonic
7174 %val0 = extractvalue { i32, i1 } %val, 0
7175 store i32 %val0, ptr addrspace(1) %out, align 4
7179 define amdgpu_kernel void @global_workgroup_acq_rel_monotonic_ret_cmpxchg(
7180 ; GFX6-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
7181 ; GFX6: ; %bb.0: ; %entry
7182 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
7183 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
7184 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
7185 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
7186 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7187 ; GFX6-NEXT: s_mov_b32 s12, s5
7188 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
7189 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
7190 ; GFX6-NEXT: s_mov_b32 s11, -1
7191 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
7192 ; GFX6-NEXT: s_mov_b32 s5, s12
7193 ; GFX6-NEXT: s_mov_b32 s6, s11
7194 ; GFX6-NEXT: s_mov_b32 s7, s10
7195 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
7196 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
7197 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
7198 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
7199 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7200 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
7201 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
7202 ; GFX6-NEXT: s_waitcnt vmcnt(0)
7203 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
7204 ; GFX6-NEXT: s_endpgm
7206 ; GFX7-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
7207 ; GFX7: ; %bb.0: ; %entry
7208 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
7209 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
7210 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
7211 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
7212 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
7213 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7214 ; GFX7-NEXT: s_mov_b32 s6, s4
7215 ; GFX7-NEXT: s_mov_b32 s7, s5
7216 ; GFX7-NEXT: s_mov_b32 s11, s12
7217 ; GFX7-NEXT: s_mov_b32 s10, s13
7218 ; GFX7-NEXT: s_add_u32 s6, s6, s11
7219 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
7220 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
7221 ; GFX7-NEXT: s_mov_b32 s7, s10
7222 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
7223 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
7224 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7225 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
7226 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
7227 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
7228 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7229 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
7230 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
7231 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
7232 ; GFX7-NEXT: s_waitcnt vmcnt(0)
7233 ; GFX7-NEXT: flat_store_dword v[0:1], v2
7234 ; GFX7-NEXT: s_endpgm
7236 ; GFX10-WGP-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
7237 ; GFX10-WGP: ; %bb.0: ; %entry
7238 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
7239 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
7240 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
7241 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
7242 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7243 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
7244 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
7245 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
7246 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
7247 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7248 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7249 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
7250 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
7251 ; GFX10-WGP-NEXT: buffer_gl0_inv
7252 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
7253 ; GFX10-WGP-NEXT: s_endpgm
7255 ; GFX10-CU-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
7256 ; GFX10-CU: ; %bb.0: ; %entry
7257 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
7258 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
7259 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
7260 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
7261 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7262 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
7263 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
7264 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
7265 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
7266 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7267 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
7268 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
7269 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
7270 ; GFX10-CU-NEXT: s_endpgm
7272 ; SKIP-CACHE-INV-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
7273 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7274 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
7275 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
7276 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
7277 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
7278 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7279 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
7280 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
7281 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
7282 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
7283 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
7284 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
7285 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
7286 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
7287 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
7288 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
7289 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
7290 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
7291 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7292 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
7293 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
7294 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
7295 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
7296 ; SKIP-CACHE-INV-NEXT: s_endpgm
7298 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
7299 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7300 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7301 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
7302 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
7303 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
7304 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7305 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
7306 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
7307 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7308 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
7309 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7310 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
7311 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
7312 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
7313 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7315 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
7316 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7317 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7318 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
7319 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
7320 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
7321 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7322 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
7323 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
7324 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7325 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
7326 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7327 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
7328 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7329 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
7330 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
7331 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7333 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
7334 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
7335 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7336 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7337 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
7338 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
7339 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7340 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
7341 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
7342 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7343 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
7344 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7345 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
7346 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
7347 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
7348 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
7350 ; GFX940-TGSPLIT-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
7351 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
7352 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7353 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7354 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
7355 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
7356 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7357 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
7358 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
7359 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7360 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
7361 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7362 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
7363 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7364 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
7365 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
7366 ; GFX940-TGSPLIT-NEXT: s_endpgm
7368 ; GFX11-WGP-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
7369 ; GFX11-WGP: ; %bb.0: ; %entry
7370 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
7371 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7372 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
7373 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
7374 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
7375 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
7376 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
7377 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
7378 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
7379 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7380 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7381 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
7382 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
7383 ; GFX11-WGP-NEXT: buffer_gl0_inv
7384 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
7385 ; GFX11-WGP-NEXT: s_endpgm
7387 ; GFX11-CU-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
7388 ; GFX11-CU: ; %bb.0: ; %entry
7389 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
7390 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7391 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
7392 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
7393 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
7394 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
7395 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
7396 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
7397 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
7398 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
7399 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
7400 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
7401 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
7402 ; GFX11-CU-NEXT: s_endpgm
7404 ; GFX12-WGP-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
7405 ; GFX12-WGP: ; %bb.0: ; %entry
7406 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
7407 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7408 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
7409 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
7410 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
7411 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
7412 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
7413 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
7414 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
7415 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
7416 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
7417 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
7418 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
7419 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
7420 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
7421 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
7422 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
7423 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
7424 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
7425 ; GFX12-WGP-NEXT: s_endpgm
7427 ; GFX12-CU-LABEL: global_workgroup_acq_rel_monotonic_ret_cmpxchg:
7428 ; GFX12-CU: ; %bb.0: ; %entry
7429 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
7430 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7431 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
7432 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
7433 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
7434 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
7435 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
7436 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
7437 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
7438 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
7439 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
7440 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
7441 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
7442 ; GFX12-CU-NEXT: s_endpgm
7443 ptr addrspace(1) %out, i32 %in, i32 %old) {
7445 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
7446 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") acq_rel monotonic
7447 %val0 = extractvalue { i32, i1 } %val, 0
7448 store i32 %val0, ptr addrspace(1) %out, align 4
7452 define amdgpu_kernel void @global_workgroup_seq_cst_monotonic_ret_cmpxchg(
7453 ; GFX6-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
7454 ; GFX6: ; %bb.0: ; %entry
7455 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
7456 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
7457 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
7458 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
7459 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7460 ; GFX6-NEXT: s_mov_b32 s12, s5
7461 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
7462 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
7463 ; GFX6-NEXT: s_mov_b32 s11, -1
7464 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
7465 ; GFX6-NEXT: s_mov_b32 s5, s12
7466 ; GFX6-NEXT: s_mov_b32 s6, s11
7467 ; GFX6-NEXT: s_mov_b32 s7, s10
7468 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
7469 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
7470 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
7471 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
7472 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7473 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
7474 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
7475 ; GFX6-NEXT: s_waitcnt vmcnt(0)
7476 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
7477 ; GFX6-NEXT: s_endpgm
7479 ; GFX7-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
7480 ; GFX7: ; %bb.0: ; %entry
7481 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
7482 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
7483 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
7484 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
7485 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
7486 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7487 ; GFX7-NEXT: s_mov_b32 s6, s4
7488 ; GFX7-NEXT: s_mov_b32 s7, s5
7489 ; GFX7-NEXT: s_mov_b32 s11, s12
7490 ; GFX7-NEXT: s_mov_b32 s10, s13
7491 ; GFX7-NEXT: s_add_u32 s6, s6, s11
7492 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
7493 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
7494 ; GFX7-NEXT: s_mov_b32 s7, s10
7495 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
7496 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
7497 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7498 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
7499 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
7500 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
7501 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7502 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
7503 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
7504 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
7505 ; GFX7-NEXT: s_waitcnt vmcnt(0)
7506 ; GFX7-NEXT: flat_store_dword v[0:1], v2
7507 ; GFX7-NEXT: s_endpgm
7509 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
7510 ; GFX10-WGP: ; %bb.0: ; %entry
7511 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
7512 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
7513 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
7514 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
7515 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7516 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
7517 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
7518 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
7519 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
7520 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7521 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7522 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
7523 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
7524 ; GFX10-WGP-NEXT: buffer_gl0_inv
7525 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
7526 ; GFX10-WGP-NEXT: s_endpgm
7528 ; GFX10-CU-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
7529 ; GFX10-CU: ; %bb.0: ; %entry
7530 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
7531 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
7532 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
7533 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
7534 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7535 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
7536 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
7537 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
7538 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
7539 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7540 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
7541 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
7542 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
7543 ; GFX10-CU-NEXT: s_endpgm
7545 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
7546 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7547 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
7548 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
7549 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
7550 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
7551 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7552 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
7553 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
7554 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
7555 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
7556 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
7557 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
7558 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
7559 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
7560 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
7561 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
7562 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
7563 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
7564 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7565 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
7566 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
7567 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
7568 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
7569 ; SKIP-CACHE-INV-NEXT: s_endpgm
7571 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
7572 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7573 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7574 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
7575 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
7576 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
7577 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7578 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
7579 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
7580 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7581 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
7582 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7583 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
7584 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
7585 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
7586 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7588 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
7589 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7590 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7591 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
7592 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
7593 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
7594 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7595 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
7596 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
7597 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7598 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
7599 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7600 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
7601 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7602 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
7603 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
7604 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7606 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
7607 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
7608 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7609 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7610 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
7611 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
7612 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7613 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
7614 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
7615 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7616 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
7617 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7618 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
7619 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
7620 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
7621 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
7623 ; GFX940-TGSPLIT-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
7624 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
7625 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7626 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7627 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
7628 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
7629 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7630 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
7631 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
7632 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7633 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
7634 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7635 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
7636 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7637 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
7638 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
7639 ; GFX940-TGSPLIT-NEXT: s_endpgm
7641 ; GFX11-WGP-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
7642 ; GFX11-WGP: ; %bb.0: ; %entry
7643 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
7644 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7645 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
7646 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
7647 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
7648 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
7649 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
7650 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
7651 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
7652 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7653 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
7654 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
7655 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
7656 ; GFX11-WGP-NEXT: buffer_gl0_inv
7657 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
7658 ; GFX11-WGP-NEXT: s_endpgm
7660 ; GFX11-CU-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
7661 ; GFX11-CU: ; %bb.0: ; %entry
7662 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
7663 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7664 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
7665 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
7666 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
7667 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
7668 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
7669 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
7670 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
7671 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
7672 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
7673 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
7674 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
7675 ; GFX11-CU-NEXT: s_endpgm
7677 ; GFX12-WGP-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
7678 ; GFX12-WGP: ; %bb.0: ; %entry
7679 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
7680 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7681 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
7682 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
7683 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
7684 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
7685 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
7686 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
7687 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
7688 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
7689 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
7690 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
7691 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
7692 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
7693 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
7694 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
7695 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
7696 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
7697 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
7698 ; GFX12-WGP-NEXT: s_endpgm
7700 ; GFX12-CU-LABEL: global_workgroup_seq_cst_monotonic_ret_cmpxchg:
7701 ; GFX12-CU: ; %bb.0: ; %entry
7702 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
7703 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7704 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
7705 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
7706 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
7707 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
7708 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
7709 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
7710 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
7711 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
7712 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
7713 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
7714 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
7715 ; GFX12-CU-NEXT: s_endpgm
7716 ptr addrspace(1) %out, i32 %in, i32 %old) {
7718 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
7719 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") seq_cst monotonic
7720 %val0 = extractvalue { i32, i1 } %val, 0
7721 store i32 %val0, ptr addrspace(1) %out, align 4
7725 define amdgpu_kernel void @global_workgroup_monotonic_acquire_ret_cmpxchg(
7726 ; GFX6-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
7727 ; GFX6: ; %bb.0: ; %entry
7728 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
7729 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
7730 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
7731 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
7732 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7733 ; GFX6-NEXT: s_mov_b32 s12, s5
7734 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
7735 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
7736 ; GFX6-NEXT: s_mov_b32 s11, -1
7737 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
7738 ; GFX6-NEXT: s_mov_b32 s5, s12
7739 ; GFX6-NEXT: s_mov_b32 s6, s11
7740 ; GFX6-NEXT: s_mov_b32 s7, s10
7741 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
7742 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
7743 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
7744 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
7745 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
7746 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
7747 ; GFX6-NEXT: s_waitcnt vmcnt(0)
7748 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
7749 ; GFX6-NEXT: s_endpgm
7751 ; GFX7-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
7752 ; GFX7: ; %bb.0: ; %entry
7753 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
7754 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
7755 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
7756 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
7757 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
7758 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
7759 ; GFX7-NEXT: s_mov_b32 s6, s4
7760 ; GFX7-NEXT: s_mov_b32 s7, s5
7761 ; GFX7-NEXT: s_mov_b32 s11, s12
7762 ; GFX7-NEXT: s_mov_b32 s10, s13
7763 ; GFX7-NEXT: s_add_u32 s6, s6, s11
7764 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
7765 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
7766 ; GFX7-NEXT: s_mov_b32 s7, s10
7767 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
7768 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
7769 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7770 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
7771 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
7772 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
7773 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
7774 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
7775 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
7776 ; GFX7-NEXT: s_waitcnt vmcnt(0)
7777 ; GFX7-NEXT: flat_store_dword v[0:1], v2
7778 ; GFX7-NEXT: s_endpgm
7780 ; GFX10-WGP-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
7781 ; GFX10-WGP: ; %bb.0: ; %entry
7782 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
7783 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
7784 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
7785 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
7786 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
7787 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
7788 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
7789 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
7790 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
7791 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
7792 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
7793 ; GFX10-WGP-NEXT: buffer_gl0_inv
7794 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
7795 ; GFX10-WGP-NEXT: s_endpgm
7797 ; GFX10-CU-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
7798 ; GFX10-CU: ; %bb.0: ; %entry
7799 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
7800 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
7801 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
7802 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
7803 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
7804 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
7805 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
7806 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
7807 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
7808 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
7809 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
7810 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
7811 ; GFX10-CU-NEXT: s_endpgm
7813 ; SKIP-CACHE-INV-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
7814 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
7815 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
7816 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
7817 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
7818 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
7819 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
7820 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
7821 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
7822 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
7823 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
7824 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
7825 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
7826 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
7827 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
7828 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
7829 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
7830 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
7831 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
7832 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
7833 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
7834 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
7835 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
7836 ; SKIP-CACHE-INV-NEXT: s_endpgm
7838 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
7839 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
7840 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7841 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
7842 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
7843 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
7844 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7845 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
7846 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
7847 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7848 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
7849 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
7850 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
7851 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
7852 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
7854 ; GFX90A-TGSPLIT-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
7855 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
7856 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7857 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
7858 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
7859 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
7860 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7861 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
7862 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
7863 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7864 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
7865 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
7866 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7867 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
7868 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
7869 ; GFX90A-TGSPLIT-NEXT: s_endpgm
7871 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
7872 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
7873 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7874 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7875 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
7876 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
7877 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7878 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
7879 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
7880 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7881 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
7882 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
7883 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
7884 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
7885 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
7887 ; GFX940-TGSPLIT-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
7888 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
7889 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
7890 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
7891 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
7892 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
7893 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
7894 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
7895 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
7896 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
7897 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
7898 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
7899 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
7900 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
7901 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
7902 ; GFX940-TGSPLIT-NEXT: s_endpgm
7904 ; GFX11-WGP-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
7905 ; GFX11-WGP: ; %bb.0: ; %entry
7906 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
7907 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7908 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
7909 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
7910 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
7911 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
7912 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
7913 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
7914 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
7915 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
7916 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
7917 ; GFX11-WGP-NEXT: buffer_gl0_inv
7918 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
7919 ; GFX11-WGP-NEXT: s_endpgm
7921 ; GFX11-CU-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
7922 ; GFX11-CU: ; %bb.0: ; %entry
7923 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
7924 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7925 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
7926 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
7927 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
7928 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
7929 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
7930 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
7931 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
7932 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
7933 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
7934 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
7935 ; GFX11-CU-NEXT: s_endpgm
7937 ; GFX12-WGP-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
7938 ; GFX12-WGP: ; %bb.0: ; %entry
7939 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
7940 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7941 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
7942 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
7943 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
7944 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
7945 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
7946 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
7947 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
7948 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
7949 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
7950 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
7951 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
7952 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
7953 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
7954 ; GFX12-WGP-NEXT: s_endpgm
7956 ; GFX12-CU-LABEL: global_workgroup_monotonic_acquire_ret_cmpxchg:
7957 ; GFX12-CU: ; %bb.0: ; %entry
7958 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
7959 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
7960 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
7961 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
7962 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
7963 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
7964 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
7965 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
7966 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
7967 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
7968 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
7969 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
7970 ; GFX12-CU-NEXT: s_endpgm
7971 ptr addrspace(1) %out, i32 %in, i32 %old) {
7973 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
7974 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") monotonic acquire
7975 %val0 = extractvalue { i32, i1 } %val, 0
7976 store i32 %val0, ptr addrspace(1) %out, align 4
7980 define amdgpu_kernel void @global_workgroup_acquire_acquire_ret_cmpxchg(
7981 ; GFX6-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
7982 ; GFX6: ; %bb.0: ; %entry
7983 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
7984 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
7985 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
7986 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
7987 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
7988 ; GFX6-NEXT: s_mov_b32 s12, s5
7989 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
7990 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
7991 ; GFX6-NEXT: s_mov_b32 s11, -1
7992 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
7993 ; GFX6-NEXT: s_mov_b32 s5, s12
7994 ; GFX6-NEXT: s_mov_b32 s6, s11
7995 ; GFX6-NEXT: s_mov_b32 s7, s10
7996 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
7997 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
7998 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
7999 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
8000 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
8001 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
8002 ; GFX6-NEXT: s_waitcnt vmcnt(0)
8003 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
8004 ; GFX6-NEXT: s_endpgm
8006 ; GFX7-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
8007 ; GFX7: ; %bb.0: ; %entry
8008 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
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)
8032 ; GFX7-NEXT: flat_store_dword v[0:1], v2
8033 ; GFX7-NEXT: s_endpgm
8035 ; GFX10-WGP-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
8036 ; GFX10-WGP: ; %bb.0: ; %entry
8037 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
8038 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
8039 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
8040 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
8041 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8042 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
8043 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
8044 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
8045 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
8046 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
8047 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8048 ; GFX10-WGP-NEXT: buffer_gl0_inv
8049 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
8050 ; GFX10-WGP-NEXT: s_endpgm
8052 ; GFX10-CU-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
8053 ; GFX10-CU: ; %bb.0: ; %entry
8054 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
8055 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
8056 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
8057 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
8058 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8059 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
8060 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
8061 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
8062 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
8063 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
8064 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
8065 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
8066 ; GFX10-CU-NEXT: s_endpgm
8068 ; SKIP-CACHE-INV-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
8069 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8070 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
8071 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
8072 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
8073 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
8074 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8075 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
8076 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
8077 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
8078 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
8079 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
8080 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
8081 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
8082 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
8083 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
8084 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
8085 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
8086 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
8087 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
8088 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
8089 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
8090 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
8091 ; SKIP-CACHE-INV-NEXT: s_endpgm
8093 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
8094 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8095 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8096 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
8097 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
8098 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
8099 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8100 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
8101 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
8102 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8103 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
8104 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
8105 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
8106 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
8107 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8109 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
8110 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8111 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8112 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
8113 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
8114 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
8115 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8116 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
8117 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
8118 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8119 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
8120 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
8121 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8122 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
8123 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
8124 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8126 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
8127 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
8128 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8129 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8130 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
8131 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
8132 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8133 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
8134 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
8135 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8136 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
8137 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
8138 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
8139 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
8140 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
8142 ; GFX940-TGSPLIT-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
8143 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
8144 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8145 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8146 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
8147 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
8148 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8149 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
8150 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
8151 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8152 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
8153 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
8154 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8155 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
8156 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
8157 ; GFX940-TGSPLIT-NEXT: s_endpgm
8159 ; GFX11-WGP-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
8160 ; GFX11-WGP: ; %bb.0: ; %entry
8161 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
8162 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
8163 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
8164 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
8165 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
8166 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
8167 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
8168 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
8169 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
8170 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
8171 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
8172 ; GFX11-WGP-NEXT: buffer_gl0_inv
8173 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
8174 ; GFX11-WGP-NEXT: s_endpgm
8176 ; GFX11-CU-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
8177 ; GFX11-CU: ; %bb.0: ; %entry
8178 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
8179 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
8180 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
8181 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
8182 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
8183 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
8184 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
8185 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
8186 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
8187 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
8188 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
8189 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
8190 ; GFX11-CU-NEXT: s_endpgm
8192 ; GFX12-WGP-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
8193 ; GFX12-WGP: ; %bb.0: ; %entry
8194 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
8195 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
8196 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
8197 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
8198 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
8199 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
8200 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
8201 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
8202 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
8203 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
8204 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
8205 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
8206 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
8207 ; GFX12-WGP-NEXT: s_endpgm
8209 ; GFX12-CU-LABEL: global_workgroup_acquire_acquire_ret_cmpxchg:
8210 ; GFX12-CU: ; %bb.0: ; %entry
8211 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
8212 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
8213 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
8214 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
8215 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
8216 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
8217 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
8218 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
8219 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
8220 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
8221 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
8222 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
8223 ; GFX12-CU-NEXT: s_endpgm
8224 ptr addrspace(1) %out, i32 %in, i32 %old) {
8226 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
8227 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") acquire acquire
8228 %val0 = extractvalue { i32, i1 } %val, 0
8229 store i32 %val0, ptr addrspace(1) %out, align 4
8233 define amdgpu_kernel void @global_workgroup_release_acquire_ret_cmpxchg(
8234 ; GFX6-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
8235 ; GFX6: ; %bb.0: ; %entry
8236 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
8237 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
8238 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
8239 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
8240 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8241 ; GFX6-NEXT: s_mov_b32 s12, s5
8242 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
8243 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
8244 ; GFX6-NEXT: s_mov_b32 s11, -1
8245 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
8246 ; GFX6-NEXT: s_mov_b32 s5, s12
8247 ; GFX6-NEXT: s_mov_b32 s6, s11
8248 ; GFX6-NEXT: s_mov_b32 s7, s10
8249 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
8250 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
8251 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
8252 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
8253 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8254 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
8255 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
8256 ; GFX6-NEXT: s_waitcnt vmcnt(0)
8257 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
8258 ; GFX6-NEXT: s_endpgm
8260 ; GFX7-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
8261 ; GFX7: ; %bb.0: ; %entry
8262 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
8263 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
8264 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
8265 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
8266 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
8267 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8268 ; GFX7-NEXT: s_mov_b32 s6, s4
8269 ; GFX7-NEXT: s_mov_b32 s7, s5
8270 ; GFX7-NEXT: s_mov_b32 s11, s12
8271 ; GFX7-NEXT: s_mov_b32 s10, s13
8272 ; GFX7-NEXT: s_add_u32 s6, s6, s11
8273 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
8274 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
8275 ; GFX7-NEXT: s_mov_b32 s7, s10
8276 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
8277 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
8278 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8279 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
8280 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
8281 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
8282 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8283 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8284 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
8285 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
8286 ; GFX7-NEXT: s_waitcnt vmcnt(0)
8287 ; GFX7-NEXT: flat_store_dword v[0:1], v2
8288 ; GFX7-NEXT: s_endpgm
8290 ; GFX10-WGP-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
8291 ; GFX10-WGP: ; %bb.0: ; %entry
8292 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
8293 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
8294 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
8295 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
8296 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8297 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
8298 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
8299 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
8300 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
8301 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8302 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8303 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
8304 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8305 ; GFX10-WGP-NEXT: buffer_gl0_inv
8306 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
8307 ; GFX10-WGP-NEXT: s_endpgm
8309 ; GFX10-CU-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
8310 ; GFX10-CU: ; %bb.0: ; %entry
8311 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
8312 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
8313 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
8314 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
8315 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8316 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
8317 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
8318 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
8319 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
8320 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8321 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
8322 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
8323 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
8324 ; GFX10-CU-NEXT: s_endpgm
8326 ; SKIP-CACHE-INV-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
8327 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8328 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
8329 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
8330 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
8331 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
8332 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8333 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
8334 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
8335 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
8336 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
8337 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
8338 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
8339 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
8340 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
8341 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
8342 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
8343 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
8344 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
8345 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8346 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
8347 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
8348 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
8349 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
8350 ; SKIP-CACHE-INV-NEXT: s_endpgm
8352 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
8353 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8354 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8355 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
8356 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
8357 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
8358 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8359 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
8360 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
8361 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8362 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
8363 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8364 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
8365 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
8366 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
8367 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8369 ; GFX90A-TGSPLIT-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
8370 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8371 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8372 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
8373 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
8374 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
8375 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8376 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
8377 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
8378 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8379 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
8380 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8381 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
8382 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8383 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
8384 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
8385 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8387 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
8388 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
8389 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8390 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8391 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
8392 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
8393 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8394 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
8395 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
8396 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8397 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
8398 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8399 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
8400 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
8401 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
8402 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
8404 ; GFX940-TGSPLIT-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
8405 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
8406 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8407 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8408 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
8409 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
8410 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8411 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
8412 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
8413 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8414 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
8415 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8416 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
8417 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8418 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
8419 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
8420 ; GFX940-TGSPLIT-NEXT: s_endpgm
8422 ; GFX11-WGP-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
8423 ; GFX11-WGP: ; %bb.0: ; %entry
8424 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
8425 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
8426 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
8427 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
8428 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
8429 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
8430 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
8431 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
8432 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
8433 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8434 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8435 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
8436 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
8437 ; GFX11-WGP-NEXT: buffer_gl0_inv
8438 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
8439 ; GFX11-WGP-NEXT: s_endpgm
8441 ; GFX11-CU-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
8442 ; GFX11-CU: ; %bb.0: ; %entry
8443 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
8444 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
8445 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
8446 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
8447 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
8448 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
8449 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
8450 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
8451 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
8452 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
8453 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
8454 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
8455 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
8456 ; GFX11-CU-NEXT: s_endpgm
8458 ; GFX12-WGP-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
8459 ; GFX12-WGP: ; %bb.0: ; %entry
8460 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
8461 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
8462 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
8463 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
8464 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
8465 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
8466 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
8467 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
8468 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
8469 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
8470 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
8471 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
8472 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
8473 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
8474 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
8475 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
8476 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
8477 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
8478 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
8479 ; GFX12-WGP-NEXT: s_endpgm
8481 ; GFX12-CU-LABEL: global_workgroup_release_acquire_ret_cmpxchg:
8482 ; GFX12-CU: ; %bb.0: ; %entry
8483 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
8484 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
8485 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
8486 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
8487 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
8488 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
8489 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
8490 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
8491 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
8492 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
8493 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
8494 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
8495 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
8496 ; GFX12-CU-NEXT: s_endpgm
8497 ptr addrspace(1) %out, i32 %in, i32 %old) {
8499 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
8500 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") release acquire
8501 %val0 = extractvalue { i32, i1 } %val, 0
8502 store i32 %val0, ptr addrspace(1) %out, align 4
8506 define amdgpu_kernel void @global_workgroup_acq_rel_acquire_ret_cmpxchg(
8507 ; GFX6-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
8508 ; GFX6: ; %bb.0: ; %entry
8509 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
8510 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
8511 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
8512 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
8513 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8514 ; GFX6-NEXT: s_mov_b32 s12, s5
8515 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
8516 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
8517 ; GFX6-NEXT: s_mov_b32 s11, -1
8518 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
8519 ; GFX6-NEXT: s_mov_b32 s5, s12
8520 ; GFX6-NEXT: s_mov_b32 s6, s11
8521 ; GFX6-NEXT: s_mov_b32 s7, s10
8522 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
8523 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
8524 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
8525 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
8526 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8527 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
8528 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
8529 ; GFX6-NEXT: s_waitcnt vmcnt(0)
8530 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
8531 ; GFX6-NEXT: s_endpgm
8533 ; GFX7-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
8534 ; GFX7: ; %bb.0: ; %entry
8535 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
8536 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
8537 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
8538 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
8539 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
8540 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8541 ; GFX7-NEXT: s_mov_b32 s6, s4
8542 ; GFX7-NEXT: s_mov_b32 s7, s5
8543 ; GFX7-NEXT: s_mov_b32 s11, s12
8544 ; GFX7-NEXT: s_mov_b32 s10, s13
8545 ; GFX7-NEXT: s_add_u32 s6, s6, s11
8546 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
8547 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
8548 ; GFX7-NEXT: s_mov_b32 s7, s10
8549 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
8550 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
8551 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8552 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
8553 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
8554 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
8555 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8556 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8557 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
8558 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
8559 ; GFX7-NEXT: s_waitcnt vmcnt(0)
8560 ; GFX7-NEXT: flat_store_dword v[0:1], v2
8561 ; GFX7-NEXT: s_endpgm
8563 ; GFX10-WGP-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
8564 ; GFX10-WGP: ; %bb.0: ; %entry
8565 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
8566 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
8567 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
8568 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
8569 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8570 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
8571 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
8572 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
8573 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
8574 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8575 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8576 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
8577 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8578 ; GFX10-WGP-NEXT: buffer_gl0_inv
8579 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
8580 ; GFX10-WGP-NEXT: s_endpgm
8582 ; GFX10-CU-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
8583 ; GFX10-CU: ; %bb.0: ; %entry
8584 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
8585 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
8586 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
8587 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
8588 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8589 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
8590 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
8591 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
8592 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
8593 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8594 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
8595 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
8596 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
8597 ; GFX10-CU-NEXT: s_endpgm
8599 ; SKIP-CACHE-INV-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
8600 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8601 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
8602 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
8603 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
8604 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
8605 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8606 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
8607 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
8608 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
8609 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
8610 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
8611 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
8612 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
8613 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
8614 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
8615 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
8616 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
8617 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
8618 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8619 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
8620 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
8621 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
8622 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
8623 ; SKIP-CACHE-INV-NEXT: s_endpgm
8625 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
8626 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8627 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8628 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
8629 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
8630 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
8631 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8632 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
8633 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
8634 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8635 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
8636 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8637 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
8638 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
8639 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
8640 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8642 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
8643 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8644 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8645 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
8646 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
8647 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
8648 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8649 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
8650 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
8651 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8652 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
8653 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8654 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
8655 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8656 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
8657 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
8658 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8660 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
8661 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
8662 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8663 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8664 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
8665 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
8666 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8667 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
8668 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
8669 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8670 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
8671 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8672 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
8673 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
8674 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
8675 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
8677 ; GFX940-TGSPLIT-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
8678 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
8679 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8680 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8681 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
8682 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
8683 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8684 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
8685 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
8686 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8687 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
8688 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8689 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
8690 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8691 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
8692 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
8693 ; GFX940-TGSPLIT-NEXT: s_endpgm
8695 ; GFX11-WGP-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
8696 ; GFX11-WGP: ; %bb.0: ; %entry
8697 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
8698 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
8699 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
8700 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
8701 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
8702 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
8703 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
8704 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
8705 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
8706 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8707 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8708 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
8709 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
8710 ; GFX11-WGP-NEXT: buffer_gl0_inv
8711 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
8712 ; GFX11-WGP-NEXT: s_endpgm
8714 ; GFX11-CU-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
8715 ; GFX11-CU: ; %bb.0: ; %entry
8716 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
8717 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
8718 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
8719 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
8720 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
8721 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
8722 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
8723 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
8724 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
8725 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
8726 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
8727 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
8728 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
8729 ; GFX11-CU-NEXT: s_endpgm
8731 ; GFX12-WGP-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
8732 ; GFX12-WGP: ; %bb.0: ; %entry
8733 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
8734 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
8735 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
8736 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
8737 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
8738 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
8739 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
8740 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
8741 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
8742 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
8743 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
8744 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
8745 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
8746 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
8747 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
8748 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
8749 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
8750 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
8751 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
8752 ; GFX12-WGP-NEXT: s_endpgm
8754 ; GFX12-CU-LABEL: global_workgroup_acq_rel_acquire_ret_cmpxchg:
8755 ; GFX12-CU: ; %bb.0: ; %entry
8756 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
8757 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
8758 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
8759 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
8760 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
8761 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
8762 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
8763 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
8764 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
8765 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
8766 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
8767 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
8768 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
8769 ; GFX12-CU-NEXT: s_endpgm
8770 ptr addrspace(1) %out, i32 %in, i32 %old) {
8772 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
8773 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") acq_rel acquire
8774 %val0 = extractvalue { i32, i1 } %val, 0
8775 store i32 %val0, ptr addrspace(1) %out, align 4
8779 define amdgpu_kernel void @global_workgroup_seq_cst_acquire_ret_cmpxchg(
8780 ; GFX6-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
8781 ; GFX6: ; %bb.0: ; %entry
8782 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
8783 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
8784 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
8785 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
8786 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8787 ; GFX6-NEXT: s_mov_b32 s12, s5
8788 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
8789 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
8790 ; GFX6-NEXT: s_mov_b32 s11, -1
8791 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
8792 ; GFX6-NEXT: s_mov_b32 s5, s12
8793 ; GFX6-NEXT: s_mov_b32 s6, s11
8794 ; GFX6-NEXT: s_mov_b32 s7, s10
8795 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
8796 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
8797 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
8798 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
8799 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
8800 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
8801 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
8802 ; GFX6-NEXT: s_waitcnt vmcnt(0)
8803 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
8804 ; GFX6-NEXT: s_endpgm
8806 ; GFX7-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
8807 ; GFX7: ; %bb.0: ; %entry
8808 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
8809 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
8810 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
8811 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
8812 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
8813 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8814 ; GFX7-NEXT: s_mov_b32 s6, s4
8815 ; GFX7-NEXT: s_mov_b32 s7, s5
8816 ; GFX7-NEXT: s_mov_b32 s11, s12
8817 ; GFX7-NEXT: s_mov_b32 s10, s13
8818 ; GFX7-NEXT: s_add_u32 s6, s6, s11
8819 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
8820 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
8821 ; GFX7-NEXT: s_mov_b32 s7, s10
8822 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
8823 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
8824 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8825 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
8826 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
8827 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
8828 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
8829 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
8830 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
8831 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
8832 ; GFX7-NEXT: s_waitcnt vmcnt(0)
8833 ; GFX7-NEXT: flat_store_dword v[0:1], v2
8834 ; GFX7-NEXT: s_endpgm
8836 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
8837 ; GFX10-WGP: ; %bb.0: ; %entry
8838 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
8839 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
8840 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
8841 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
8842 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
8843 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
8844 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
8845 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
8846 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
8847 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8848 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8849 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
8850 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
8851 ; GFX10-WGP-NEXT: buffer_gl0_inv
8852 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
8853 ; GFX10-WGP-NEXT: s_endpgm
8855 ; GFX10-CU-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
8856 ; GFX10-CU: ; %bb.0: ; %entry
8857 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
8858 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
8859 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
8860 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
8861 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8862 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
8863 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
8864 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
8865 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
8866 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
8867 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
8868 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
8869 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
8870 ; GFX10-CU-NEXT: s_endpgm
8872 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
8873 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
8874 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
8875 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
8876 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
8877 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
8878 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8879 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
8880 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
8881 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
8882 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
8883 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
8884 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
8885 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
8886 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
8887 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
8888 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
8889 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
8890 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
8891 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
8892 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
8893 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
8894 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
8895 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
8896 ; SKIP-CACHE-INV-NEXT: s_endpgm
8898 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
8899 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
8900 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8901 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
8902 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
8903 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
8904 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8905 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
8906 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
8907 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8908 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
8909 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8910 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
8911 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
8912 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
8913 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
8915 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
8916 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
8917 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8918 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
8919 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
8920 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
8921 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8922 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
8923 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
8924 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8925 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
8926 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8927 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
8928 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8929 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
8930 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
8931 ; GFX90A-TGSPLIT-NEXT: s_endpgm
8933 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
8934 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
8935 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8936 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8937 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
8938 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
8939 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8940 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
8941 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
8942 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8943 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
8944 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8945 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
8946 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
8947 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
8948 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
8950 ; GFX940-TGSPLIT-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
8951 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
8952 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
8953 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
8954 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
8955 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
8956 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
8957 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
8958 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
8959 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
8960 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
8961 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8962 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
8963 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
8964 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
8965 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
8966 ; GFX940-TGSPLIT-NEXT: s_endpgm
8968 ; GFX11-WGP-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
8969 ; GFX11-WGP: ; %bb.0: ; %entry
8970 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
8971 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
8972 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
8973 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
8974 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
8975 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
8976 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
8977 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
8978 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
8979 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8980 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
8981 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
8982 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
8983 ; GFX11-WGP-NEXT: buffer_gl0_inv
8984 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
8985 ; GFX11-WGP-NEXT: s_endpgm
8987 ; GFX11-CU-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
8988 ; GFX11-CU: ; %bb.0: ; %entry
8989 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
8990 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
8991 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
8992 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
8993 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
8994 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
8995 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
8996 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
8997 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
8998 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
8999 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
9000 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
9001 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
9002 ; GFX11-CU-NEXT: s_endpgm
9004 ; GFX12-WGP-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
9005 ; GFX12-WGP: ; %bb.0: ; %entry
9006 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
9007 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9008 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
9009 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
9010 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
9011 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
9012 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
9013 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
9014 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
9015 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
9016 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
9017 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
9018 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
9019 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
9020 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
9021 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
9022 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
9023 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
9024 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
9025 ; GFX12-WGP-NEXT: s_endpgm
9027 ; GFX12-CU-LABEL: global_workgroup_seq_cst_acquire_ret_cmpxchg:
9028 ; GFX12-CU: ; %bb.0: ; %entry
9029 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
9030 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9031 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
9032 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
9033 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
9034 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
9035 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
9036 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
9037 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
9038 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
9039 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
9040 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
9041 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
9042 ; GFX12-CU-NEXT: s_endpgm
9043 ptr addrspace(1) %out, i32 %in, i32 %old) {
9045 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
9046 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") seq_cst acquire
9047 %val0 = extractvalue { i32, i1 } %val, 0
9048 store i32 %val0, ptr addrspace(1) %out, align 4
9052 define amdgpu_kernel void @global_workgroup_monotonic_seq_cst_ret_cmpxchg(
9053 ; GFX6-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
9054 ; GFX6: ; %bb.0: ; %entry
9055 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
9056 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
9057 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
9058 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
9059 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
9060 ; GFX6-NEXT: s_mov_b32 s12, s5
9061 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
9062 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
9063 ; GFX6-NEXT: s_mov_b32 s11, -1
9064 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
9065 ; GFX6-NEXT: s_mov_b32 s5, s12
9066 ; GFX6-NEXT: s_mov_b32 s6, s11
9067 ; GFX6-NEXT: s_mov_b32 s7, s10
9068 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
9069 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
9070 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
9071 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
9072 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
9073 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
9074 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
9075 ; GFX6-NEXT: s_waitcnt vmcnt(0)
9076 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
9077 ; GFX6-NEXT: s_endpgm
9079 ; GFX7-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
9080 ; GFX7: ; %bb.0: ; %entry
9081 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
9082 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
9083 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
9084 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
9085 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
9086 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
9087 ; GFX7-NEXT: s_mov_b32 s6, s4
9088 ; GFX7-NEXT: s_mov_b32 s7, s5
9089 ; GFX7-NEXT: s_mov_b32 s11, s12
9090 ; GFX7-NEXT: s_mov_b32 s10, s13
9091 ; GFX7-NEXT: s_add_u32 s6, s6, s11
9092 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
9093 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
9094 ; GFX7-NEXT: s_mov_b32 s7, s10
9095 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
9096 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
9097 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9098 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
9099 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
9100 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
9101 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
9102 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9103 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
9104 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
9105 ; GFX7-NEXT: s_waitcnt vmcnt(0)
9106 ; GFX7-NEXT: flat_store_dword v[0:1], v2
9107 ; GFX7-NEXT: s_endpgm
9109 ; GFX10-WGP-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
9110 ; GFX10-WGP: ; %bb.0: ; %entry
9111 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
9112 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
9113 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
9114 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
9115 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
9116 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
9117 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
9118 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
9119 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
9120 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9121 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9122 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
9123 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
9124 ; GFX10-WGP-NEXT: buffer_gl0_inv
9125 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
9126 ; GFX10-WGP-NEXT: s_endpgm
9128 ; GFX10-CU-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
9129 ; GFX10-CU: ; %bb.0: ; %entry
9130 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
9131 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
9132 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
9133 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
9134 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9135 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
9136 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
9137 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
9138 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
9139 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9140 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
9141 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
9142 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
9143 ; GFX10-CU-NEXT: s_endpgm
9145 ; SKIP-CACHE-INV-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
9146 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
9147 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
9148 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
9149 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
9150 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
9151 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9152 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
9153 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
9154 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
9155 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
9156 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
9157 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
9158 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
9159 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
9160 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
9161 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
9162 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
9163 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
9164 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9165 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
9166 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
9167 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
9168 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
9169 ; SKIP-CACHE-INV-NEXT: s_endpgm
9171 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
9172 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
9173 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
9174 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
9175 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
9176 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
9177 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9178 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
9179 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
9180 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9181 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
9182 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9183 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
9184 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
9185 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
9186 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
9188 ; GFX90A-TGSPLIT-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
9189 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
9190 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
9191 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
9192 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
9193 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
9194 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9195 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
9196 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
9197 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9198 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
9199 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9200 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
9201 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9202 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
9203 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
9204 ; GFX90A-TGSPLIT-NEXT: s_endpgm
9206 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
9207 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
9208 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
9209 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
9210 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
9211 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
9212 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9213 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
9214 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
9215 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9216 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
9217 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9218 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
9219 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
9220 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
9221 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
9223 ; GFX940-TGSPLIT-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
9224 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
9225 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
9226 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
9227 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
9228 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
9229 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9230 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
9231 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
9232 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9233 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
9234 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9235 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
9236 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9237 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
9238 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
9239 ; GFX940-TGSPLIT-NEXT: s_endpgm
9241 ; GFX11-WGP-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
9242 ; GFX11-WGP: ; %bb.0: ; %entry
9243 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
9244 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9245 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
9246 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
9247 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
9248 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
9249 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
9250 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
9251 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
9252 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9253 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9254 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
9255 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
9256 ; GFX11-WGP-NEXT: buffer_gl0_inv
9257 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
9258 ; GFX11-WGP-NEXT: s_endpgm
9260 ; GFX11-CU-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
9261 ; GFX11-CU: ; %bb.0: ; %entry
9262 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
9263 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9264 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
9265 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
9266 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
9267 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
9268 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
9269 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
9270 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
9271 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
9272 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
9273 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
9274 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
9275 ; GFX11-CU-NEXT: s_endpgm
9277 ; GFX12-WGP-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
9278 ; GFX12-WGP: ; %bb.0: ; %entry
9279 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
9280 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9281 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
9282 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
9283 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
9284 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
9285 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
9286 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
9287 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
9288 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
9289 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
9290 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
9291 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
9292 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
9293 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
9294 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
9295 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
9296 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
9297 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
9298 ; GFX12-WGP-NEXT: s_endpgm
9300 ; GFX12-CU-LABEL: global_workgroup_monotonic_seq_cst_ret_cmpxchg:
9301 ; GFX12-CU: ; %bb.0: ; %entry
9302 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
9303 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9304 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
9305 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
9306 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
9307 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
9308 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
9309 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
9310 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
9311 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
9312 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
9313 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
9314 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
9315 ; GFX12-CU-NEXT: s_endpgm
9316 ptr addrspace(1) %out, i32 %in, i32 %old) {
9318 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
9319 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") monotonic seq_cst
9320 %val0 = extractvalue { i32, i1 } %val, 0
9321 store i32 %val0, ptr addrspace(1) %out, align 4
9325 define amdgpu_kernel void @global_workgroup_acquire_seq_cst_ret_cmpxchg(
9326 ; GFX6-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
9327 ; GFX6: ; %bb.0: ; %entry
9328 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
9329 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
9330 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
9331 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
9332 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
9333 ; GFX6-NEXT: s_mov_b32 s12, s5
9334 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
9335 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
9336 ; GFX6-NEXT: s_mov_b32 s11, -1
9337 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
9338 ; GFX6-NEXT: s_mov_b32 s5, s12
9339 ; GFX6-NEXT: s_mov_b32 s6, s11
9340 ; GFX6-NEXT: s_mov_b32 s7, s10
9341 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
9342 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
9343 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
9344 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
9345 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
9346 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
9347 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
9348 ; GFX6-NEXT: s_waitcnt vmcnt(0)
9349 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
9350 ; GFX6-NEXT: s_endpgm
9352 ; GFX7-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
9353 ; GFX7: ; %bb.0: ; %entry
9354 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
9355 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
9356 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
9357 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
9358 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
9359 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
9360 ; GFX7-NEXT: s_mov_b32 s6, s4
9361 ; GFX7-NEXT: s_mov_b32 s7, s5
9362 ; GFX7-NEXT: s_mov_b32 s11, s12
9363 ; GFX7-NEXT: s_mov_b32 s10, s13
9364 ; GFX7-NEXT: s_add_u32 s6, s6, s11
9365 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
9366 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
9367 ; GFX7-NEXT: s_mov_b32 s7, s10
9368 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
9369 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
9370 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9371 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
9372 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
9373 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
9374 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
9375 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9376 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
9377 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
9378 ; GFX7-NEXT: s_waitcnt vmcnt(0)
9379 ; GFX7-NEXT: flat_store_dword v[0:1], v2
9380 ; GFX7-NEXT: s_endpgm
9382 ; GFX10-WGP-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
9383 ; GFX10-WGP: ; %bb.0: ; %entry
9384 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
9385 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
9386 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
9387 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
9388 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
9389 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
9390 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
9391 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
9392 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
9393 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9394 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9395 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
9396 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
9397 ; GFX10-WGP-NEXT: buffer_gl0_inv
9398 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
9399 ; GFX10-WGP-NEXT: s_endpgm
9401 ; GFX10-CU-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
9402 ; GFX10-CU: ; %bb.0: ; %entry
9403 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
9404 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
9405 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
9406 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
9407 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9408 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
9409 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
9410 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
9411 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
9412 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9413 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
9414 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
9415 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
9416 ; GFX10-CU-NEXT: s_endpgm
9418 ; SKIP-CACHE-INV-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
9419 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
9420 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
9421 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
9422 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
9423 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
9424 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9425 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
9426 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
9427 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
9428 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
9429 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
9430 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
9431 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
9432 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
9433 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
9434 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
9435 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
9436 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
9437 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9438 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
9439 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
9440 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
9441 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
9442 ; SKIP-CACHE-INV-NEXT: s_endpgm
9444 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
9445 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
9446 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
9447 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
9448 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
9449 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
9450 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9451 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
9452 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
9453 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9454 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
9455 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9456 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
9457 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
9458 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
9459 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
9461 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
9462 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
9463 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
9464 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
9465 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
9466 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
9467 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9468 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
9469 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
9470 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9471 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
9472 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9473 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
9474 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9475 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
9476 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
9477 ; GFX90A-TGSPLIT-NEXT: s_endpgm
9479 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
9480 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
9481 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
9482 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
9483 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
9484 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
9485 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9486 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
9487 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
9488 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9489 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
9490 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9491 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
9492 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
9493 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
9494 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
9496 ; GFX940-TGSPLIT-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
9497 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
9498 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
9499 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
9500 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
9501 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
9502 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9503 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
9504 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
9505 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9506 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
9507 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9508 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
9509 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9510 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
9511 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
9512 ; GFX940-TGSPLIT-NEXT: s_endpgm
9514 ; GFX11-WGP-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
9515 ; GFX11-WGP: ; %bb.0: ; %entry
9516 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
9517 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9518 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
9519 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
9520 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
9521 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
9522 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
9523 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
9524 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
9525 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9526 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9527 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
9528 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
9529 ; GFX11-WGP-NEXT: buffer_gl0_inv
9530 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
9531 ; GFX11-WGP-NEXT: s_endpgm
9533 ; GFX11-CU-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
9534 ; GFX11-CU: ; %bb.0: ; %entry
9535 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
9536 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9537 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
9538 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
9539 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
9540 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
9541 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
9542 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
9543 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
9544 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
9545 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
9546 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
9547 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
9548 ; GFX11-CU-NEXT: s_endpgm
9550 ; GFX12-WGP-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
9551 ; GFX12-WGP: ; %bb.0: ; %entry
9552 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
9553 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9554 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
9555 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
9556 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
9557 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
9558 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
9559 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
9560 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
9561 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
9562 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
9563 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
9564 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
9565 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
9566 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
9567 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
9568 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
9569 ; GFX12-WGP-NEXT: s_endpgm
9571 ; GFX12-CU-LABEL: global_workgroup_acquire_seq_cst_ret_cmpxchg:
9572 ; GFX12-CU: ; %bb.0: ; %entry
9573 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
9574 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9575 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
9576 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
9577 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
9578 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
9579 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
9580 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
9581 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
9582 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
9583 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
9584 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
9585 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
9586 ; GFX12-CU-NEXT: s_endpgm
9587 ptr addrspace(1) %out, i32 %in, i32 %old) {
9589 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
9590 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") acquire seq_cst
9591 %val0 = extractvalue { i32, i1 } %val, 0
9592 store i32 %val0, ptr addrspace(1) %out, align 4
9596 define amdgpu_kernel void @global_workgroup_release_seq_cst_ret_cmpxchg(
9597 ; GFX6-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
9598 ; GFX6: ; %bb.0: ; %entry
9599 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
9600 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
9601 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
9602 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
9603 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
9604 ; GFX6-NEXT: s_mov_b32 s12, s5
9605 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
9606 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
9607 ; GFX6-NEXT: s_mov_b32 s11, -1
9608 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
9609 ; GFX6-NEXT: s_mov_b32 s5, s12
9610 ; GFX6-NEXT: s_mov_b32 s6, s11
9611 ; GFX6-NEXT: s_mov_b32 s7, s10
9612 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
9613 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
9614 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
9615 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
9616 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
9617 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
9618 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
9619 ; GFX6-NEXT: s_waitcnt vmcnt(0)
9620 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
9621 ; GFX6-NEXT: s_endpgm
9623 ; GFX7-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
9624 ; GFX7: ; %bb.0: ; %entry
9625 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
9626 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
9627 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
9628 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
9629 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
9630 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
9631 ; GFX7-NEXT: s_mov_b32 s6, s4
9632 ; GFX7-NEXT: s_mov_b32 s7, s5
9633 ; GFX7-NEXT: s_mov_b32 s11, s12
9634 ; GFX7-NEXT: s_mov_b32 s10, s13
9635 ; GFX7-NEXT: s_add_u32 s6, s6, s11
9636 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
9637 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
9638 ; GFX7-NEXT: s_mov_b32 s7, s10
9639 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
9640 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
9641 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9642 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
9643 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
9644 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
9645 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
9646 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9647 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
9648 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
9649 ; GFX7-NEXT: s_waitcnt vmcnt(0)
9650 ; GFX7-NEXT: flat_store_dword v[0:1], v2
9651 ; GFX7-NEXT: s_endpgm
9653 ; GFX10-WGP-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
9654 ; GFX10-WGP: ; %bb.0: ; %entry
9655 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
9656 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
9657 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
9658 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
9659 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
9660 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
9661 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
9662 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
9663 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
9664 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9665 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9666 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
9667 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
9668 ; GFX10-WGP-NEXT: buffer_gl0_inv
9669 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
9670 ; GFX10-WGP-NEXT: s_endpgm
9672 ; GFX10-CU-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
9673 ; GFX10-CU: ; %bb.0: ; %entry
9674 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
9675 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
9676 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
9677 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
9678 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9679 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
9680 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
9681 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
9682 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
9683 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9684 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
9685 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
9686 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
9687 ; GFX10-CU-NEXT: s_endpgm
9689 ; SKIP-CACHE-INV-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
9690 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
9691 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
9692 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
9693 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
9694 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
9695 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9696 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
9697 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
9698 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
9699 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
9700 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
9701 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
9702 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
9703 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
9704 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
9705 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
9706 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
9707 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
9708 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9709 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
9710 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
9711 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
9712 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
9713 ; SKIP-CACHE-INV-NEXT: s_endpgm
9715 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
9716 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
9717 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
9718 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
9719 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
9720 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
9721 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9722 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
9723 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
9724 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9725 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
9726 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9727 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
9728 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
9729 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
9730 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
9732 ; GFX90A-TGSPLIT-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
9733 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
9734 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
9735 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
9736 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
9737 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
9738 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9739 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
9740 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
9741 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9742 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
9743 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9744 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
9745 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9746 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
9747 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
9748 ; GFX90A-TGSPLIT-NEXT: s_endpgm
9750 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
9751 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
9752 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
9753 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
9754 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
9755 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
9756 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9757 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
9758 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
9759 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9760 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
9761 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9762 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
9763 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
9764 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
9765 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
9767 ; GFX940-TGSPLIT-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
9768 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
9769 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
9770 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
9771 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
9772 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
9773 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9774 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
9775 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
9776 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9777 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
9778 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9779 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
9780 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
9781 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
9782 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
9783 ; GFX940-TGSPLIT-NEXT: s_endpgm
9785 ; GFX11-WGP-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
9786 ; GFX11-WGP: ; %bb.0: ; %entry
9787 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
9788 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9789 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
9790 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
9791 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
9792 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
9793 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
9794 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
9795 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
9796 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9797 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9798 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
9799 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
9800 ; GFX11-WGP-NEXT: buffer_gl0_inv
9801 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
9802 ; GFX11-WGP-NEXT: s_endpgm
9804 ; GFX11-CU-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
9805 ; GFX11-CU: ; %bb.0: ; %entry
9806 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
9807 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9808 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
9809 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
9810 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
9811 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
9812 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
9813 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
9814 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
9815 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
9816 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
9817 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
9818 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
9819 ; GFX11-CU-NEXT: s_endpgm
9821 ; GFX12-WGP-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
9822 ; GFX12-WGP: ; %bb.0: ; %entry
9823 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
9824 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9825 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
9826 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
9827 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
9828 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
9829 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
9830 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
9831 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
9832 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
9833 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
9834 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
9835 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
9836 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
9837 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
9838 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
9839 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
9840 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
9841 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
9842 ; GFX12-WGP-NEXT: s_endpgm
9844 ; GFX12-CU-LABEL: global_workgroup_release_seq_cst_ret_cmpxchg:
9845 ; GFX12-CU: ; %bb.0: ; %entry
9846 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
9847 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
9848 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
9849 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
9850 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
9851 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
9852 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
9853 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
9854 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
9855 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
9856 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
9857 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
9858 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
9859 ; GFX12-CU-NEXT: s_endpgm
9860 ptr addrspace(1) %out, i32 %in, i32 %old) {
9862 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
9863 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") release seq_cst
9864 %val0 = extractvalue { i32, i1 } %val, 0
9865 store i32 %val0, ptr addrspace(1) %out, align 4
9869 define amdgpu_kernel void @global_workgroup_acq_rel_seq_cst_ret_cmpxchg(
9870 ; GFX6-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
9871 ; GFX6: ; %bb.0: ; %entry
9872 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
9873 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
9874 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
9875 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
9876 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
9877 ; GFX6-NEXT: s_mov_b32 s12, s5
9878 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
9879 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
9880 ; GFX6-NEXT: s_mov_b32 s11, -1
9881 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
9882 ; GFX6-NEXT: s_mov_b32 s5, s12
9883 ; GFX6-NEXT: s_mov_b32 s6, s11
9884 ; GFX6-NEXT: s_mov_b32 s7, s10
9885 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
9886 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
9887 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
9888 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
9889 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
9890 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
9891 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
9892 ; GFX6-NEXT: s_waitcnt vmcnt(0)
9893 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
9894 ; GFX6-NEXT: s_endpgm
9896 ; GFX7-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
9897 ; GFX7: ; %bb.0: ; %entry
9898 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
9899 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
9900 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
9901 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
9902 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
9903 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
9904 ; GFX7-NEXT: s_mov_b32 s6, s4
9905 ; GFX7-NEXT: s_mov_b32 s7, s5
9906 ; GFX7-NEXT: s_mov_b32 s11, s12
9907 ; GFX7-NEXT: s_mov_b32 s10, s13
9908 ; GFX7-NEXT: s_add_u32 s6, s6, s11
9909 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
9910 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
9911 ; GFX7-NEXT: s_mov_b32 s7, s10
9912 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
9913 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
9914 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9915 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
9916 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
9917 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
9918 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
9919 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
9920 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
9921 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
9922 ; GFX7-NEXT: s_waitcnt vmcnt(0)
9923 ; GFX7-NEXT: flat_store_dword v[0:1], v2
9924 ; GFX7-NEXT: s_endpgm
9926 ; GFX10-WGP-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
9927 ; GFX10-WGP: ; %bb.0: ; %entry
9928 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
9929 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
9930 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
9931 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
9932 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
9933 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
9934 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
9935 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
9936 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
9937 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
9938 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
9939 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
9940 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
9941 ; GFX10-WGP-NEXT: buffer_gl0_inv
9942 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
9943 ; GFX10-WGP-NEXT: s_endpgm
9945 ; GFX10-CU-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
9946 ; GFX10-CU: ; %bb.0: ; %entry
9947 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
9948 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
9949 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
9950 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
9951 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9952 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
9953 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
9954 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
9955 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
9956 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
9957 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
9958 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
9959 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
9960 ; GFX10-CU-NEXT: s_endpgm
9962 ; SKIP-CACHE-INV-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
9963 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
9964 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
9965 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
9966 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
9967 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
9968 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9969 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
9970 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
9971 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
9972 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
9973 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
9974 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
9975 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
9976 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
9977 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
9978 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
9979 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
9980 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
9981 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
9982 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
9983 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
9984 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
9985 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
9986 ; SKIP-CACHE-INV-NEXT: s_endpgm
9988 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
9989 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
9990 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
9991 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
9992 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
9993 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
9994 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
9995 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
9996 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
9997 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
9998 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
9999 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10000 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
10001 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
10002 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
10003 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
10005 ; GFX90A-TGSPLIT-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
10006 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
10007 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
10008 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
10009 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
10010 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
10011 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10012 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
10013 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
10014 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
10015 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
10016 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10017 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
10018 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10019 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
10020 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
10021 ; GFX90A-TGSPLIT-NEXT: s_endpgm
10023 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
10024 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
10025 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
10026 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
10027 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
10028 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
10029 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10030 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
10031 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
10032 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
10033 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
10034 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10035 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
10036 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
10037 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
10038 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
10040 ; GFX940-TGSPLIT-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
10041 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
10042 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
10043 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
10044 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
10045 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
10046 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10047 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
10048 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
10049 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
10050 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
10051 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10052 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
10053 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10054 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
10055 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
10056 ; GFX940-TGSPLIT-NEXT: s_endpgm
10058 ; GFX11-WGP-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
10059 ; GFX11-WGP: ; %bb.0: ; %entry
10060 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
10061 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
10062 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
10063 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
10064 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10065 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
10066 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
10067 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
10068 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
10069 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10070 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10071 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
10072 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
10073 ; GFX11-WGP-NEXT: buffer_gl0_inv
10074 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
10075 ; GFX11-WGP-NEXT: s_endpgm
10077 ; GFX11-CU-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
10078 ; GFX11-CU: ; %bb.0: ; %entry
10079 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
10080 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
10081 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
10082 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
10083 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
10084 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
10085 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
10086 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
10087 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
10088 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
10089 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
10090 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
10091 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
10092 ; GFX11-CU-NEXT: s_endpgm
10094 ; GFX12-WGP-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
10095 ; GFX12-WGP: ; %bb.0: ; %entry
10096 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
10097 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
10098 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
10099 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
10100 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
10101 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
10102 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
10103 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
10104 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
10105 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
10106 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
10107 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
10108 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
10109 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
10110 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
10111 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
10112 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
10113 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
10114 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
10115 ; GFX12-WGP-NEXT: s_endpgm
10117 ; GFX12-CU-LABEL: global_workgroup_acq_rel_seq_cst_ret_cmpxchg:
10118 ; GFX12-CU: ; %bb.0: ; %entry
10119 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
10120 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
10121 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
10122 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
10123 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
10124 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
10125 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
10126 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
10127 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
10128 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
10129 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
10130 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
10131 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
10132 ; GFX12-CU-NEXT: s_endpgm
10133 ptr addrspace(1) %out, i32 %in, i32 %old) {
10135 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
10136 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") acq_rel seq_cst
10137 %val0 = extractvalue { i32, i1 } %val, 0
10138 store i32 %val0, ptr addrspace(1) %out, align 4
10142 define amdgpu_kernel void @global_workgroup_seq_cst_seq_cst_ret_cmpxchg(
10143 ; GFX6-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
10144 ; GFX6: ; %bb.0: ; %entry
10145 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
10146 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
10147 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
10148 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
10149 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
10150 ; GFX6-NEXT: s_mov_b32 s12, s5
10151 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
10152 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
10153 ; GFX6-NEXT: s_mov_b32 s11, -1
10154 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
10155 ; GFX6-NEXT: s_mov_b32 s5, s12
10156 ; GFX6-NEXT: s_mov_b32 s6, s11
10157 ; GFX6-NEXT: s_mov_b32 s7, s10
10158 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
10159 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
10160 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
10161 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
10162 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
10163 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
10164 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
10165 ; GFX6-NEXT: s_waitcnt vmcnt(0)
10166 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
10167 ; GFX6-NEXT: s_endpgm
10169 ; GFX7-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
10170 ; GFX7: ; %bb.0: ; %entry
10171 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
10172 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
10173 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
10174 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
10175 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
10176 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
10177 ; GFX7-NEXT: s_mov_b32 s6, s4
10178 ; GFX7-NEXT: s_mov_b32 s7, s5
10179 ; GFX7-NEXT: s_mov_b32 s11, s12
10180 ; GFX7-NEXT: s_mov_b32 s10, s13
10181 ; GFX7-NEXT: s_add_u32 s6, s6, s11
10182 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
10183 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
10184 ; GFX7-NEXT: s_mov_b32 s7, s10
10185 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
10186 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
10187 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
10188 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
10189 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
10190 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
10191 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
10192 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
10193 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
10194 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
10195 ; GFX7-NEXT: s_waitcnt vmcnt(0)
10196 ; GFX7-NEXT: flat_store_dword v[0:1], v2
10197 ; GFX7-NEXT: s_endpgm
10199 ; GFX10-WGP-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
10200 ; GFX10-WGP: ; %bb.0: ; %entry
10201 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
10202 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
10203 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
10204 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
10205 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
10206 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
10207 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
10208 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
10209 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
10210 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10211 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10212 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
10213 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
10214 ; GFX10-WGP-NEXT: buffer_gl0_inv
10215 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
10216 ; GFX10-WGP-NEXT: s_endpgm
10218 ; GFX10-CU-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
10219 ; GFX10-CU: ; %bb.0: ; %entry
10220 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
10221 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
10222 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
10223 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
10224 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
10225 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
10226 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
10227 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
10228 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
10229 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
10230 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
10231 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
10232 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
10233 ; GFX10-CU-NEXT: s_endpgm
10235 ; SKIP-CACHE-INV-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
10236 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
10237 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
10238 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
10239 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
10240 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
10241 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
10242 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
10243 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
10244 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
10245 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
10246 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
10247 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
10248 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
10249 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
10250 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
10251 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
10252 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
10253 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
10254 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
10255 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
10256 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
10257 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
10258 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
10259 ; SKIP-CACHE-INV-NEXT: s_endpgm
10261 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
10262 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
10263 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
10264 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
10265 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
10266 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
10267 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10268 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
10269 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
10270 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
10271 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
10272 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10273 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
10274 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
10275 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
10276 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
10278 ; GFX90A-TGSPLIT-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
10279 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
10280 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
10281 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
10282 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
10283 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
10284 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10285 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
10286 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
10287 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
10288 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
10289 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10290 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
10291 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10292 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
10293 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
10294 ; GFX90A-TGSPLIT-NEXT: s_endpgm
10296 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
10297 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
10298 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
10299 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
10300 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
10301 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
10302 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10303 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
10304 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
10305 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
10306 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
10307 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10308 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
10309 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
10310 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
10311 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
10313 ; GFX940-TGSPLIT-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
10314 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
10315 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
10316 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
10317 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
10318 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
10319 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10320 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
10321 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
10322 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
10323 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
10324 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10325 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
10326 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10327 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
10328 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
10329 ; GFX940-TGSPLIT-NEXT: s_endpgm
10331 ; GFX11-WGP-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
10332 ; GFX11-WGP: ; %bb.0: ; %entry
10333 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
10334 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
10335 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
10336 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
10337 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10338 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
10339 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
10340 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
10341 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
10342 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
10343 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
10344 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
10345 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
10346 ; GFX11-WGP-NEXT: buffer_gl0_inv
10347 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
10348 ; GFX11-WGP-NEXT: s_endpgm
10350 ; GFX11-CU-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
10351 ; GFX11-CU: ; %bb.0: ; %entry
10352 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
10353 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
10354 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
10355 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
10356 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
10357 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
10358 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
10359 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
10360 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
10361 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
10362 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
10363 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
10364 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
10365 ; GFX11-CU-NEXT: s_endpgm
10367 ; GFX12-WGP-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
10368 ; GFX12-WGP: ; %bb.0: ; %entry
10369 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
10370 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
10371 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
10372 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
10373 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
10374 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
10375 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
10376 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
10377 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
10378 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
10379 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
10380 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
10381 ; GFX12-WGP-NEXT: s_wait_loadcnt_dscnt 0x0
10382 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
10383 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
10384 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
10385 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
10386 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
10387 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
10388 ; GFX12-WGP-NEXT: s_endpgm
10390 ; GFX12-CU-LABEL: global_workgroup_seq_cst_seq_cst_ret_cmpxchg:
10391 ; GFX12-CU: ; %bb.0: ; %entry
10392 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
10393 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
10394 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
10395 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
10396 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
10397 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
10398 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
10399 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
10400 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
10401 ; GFX12-CU-NEXT: s_wait_dscnt 0x0
10402 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
10403 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
10404 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
10405 ; GFX12-CU-NEXT: s_endpgm
10406 ptr addrspace(1) %out, i32 %in, i32 %old) {
10408 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
10409 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup") seq_cst seq_cst
10410 %val0 = extractvalue { i32, i1 } %val, 0
10411 store i32 %val0, ptr addrspace(1) %out, align 4
10415 define amdgpu_kernel void @global_workgroup_one_as_unordered_load(
10416 ; GFX6-LABEL: global_workgroup_one_as_unordered_load:
10417 ; GFX6: ; %bb.0: ; %entry
10418 ; GFX6-NEXT: s_mov_b64 s[4:5], s[8:9]
10419 ; GFX6-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
10420 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
10421 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
10422 ; GFX6-NEXT: s_mov_b32 s6, s9
10423 ; GFX6-NEXT: ; kill: def $sgpr8 killed $sgpr8 killed $sgpr8_sgpr9
10424 ; GFX6-NEXT: s_mov_b32 s12, 0x100f000
10425 ; GFX6-NEXT: s_mov_b32 s13, -1
10426 ; GFX6-NEXT: ; kill: def $sgpr8 killed $sgpr8 def $sgpr8_sgpr9_sgpr10_sgpr11
10427 ; GFX6-NEXT: s_mov_b32 s9, s6
10428 ; GFX6-NEXT: s_mov_b32 s10, s13
10429 ; GFX6-NEXT: s_mov_b32 s11, s12
10430 ; GFX6-NEXT: s_mov_b32 s14, s5
10431 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
10432 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
10433 ; GFX6-NEXT: s_mov_b32 s5, s14
10434 ; GFX6-NEXT: s_mov_b32 s6, s13
10435 ; GFX6-NEXT: s_mov_b32 s7, s12
10436 ; GFX6-NEXT: buffer_load_dword v0, off, s[8:11], 0
10437 ; GFX6-NEXT: s_waitcnt vmcnt(0)
10438 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
10439 ; GFX6-NEXT: s_endpgm
10441 ; GFX7-LABEL: global_workgroup_one_as_unordered_load:
10442 ; GFX7: ; %bb.0: ; %entry
10443 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
10444 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x2
10445 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
10446 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
10447 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
10448 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
10449 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
10450 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
10451 ; GFX7-NEXT: s_waitcnt vmcnt(0)
10452 ; GFX7-NEXT: flat_store_dword v[0:1], v2
10453 ; GFX7-NEXT: s_endpgm
10455 ; GFX10-WGP-LABEL: global_workgroup_one_as_unordered_load:
10456 ; GFX10-WGP: ; %bb.0: ; %entry
10457 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
10458 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
10459 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
10460 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
10461 ; GFX10-WGP-NEXT: global_load_dword v1, v0, s[6:7]
10462 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
10463 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
10464 ; GFX10-WGP-NEXT: s_endpgm
10466 ; GFX10-CU-LABEL: global_workgroup_one_as_unordered_load:
10467 ; GFX10-CU: ; %bb.0: ; %entry
10468 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
10469 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
10470 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
10471 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
10472 ; GFX10-CU-NEXT: global_load_dword v1, v0, s[6:7]
10473 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
10474 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
10475 ; GFX10-CU-NEXT: s_endpgm
10477 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_unordered_load:
10478 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
10479 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[4:5]
10480 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
10481 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
10482 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
10483 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s5
10484 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
10485 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, 0xf000
10486 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s9, -1
10487 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
10488 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s2
10489 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
10490 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
10491 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s10, s1
10492 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
10493 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
10494 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s10
10495 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s9
10496 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s8
10497 ; SKIP-CACHE-INV-NEXT: buffer_load_dword v0, off, s[4:7], 0
10498 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
10499 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
10500 ; SKIP-CACHE-INV-NEXT: s_endpgm
10502 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_unordered_load:
10503 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
10504 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
10505 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
10506 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
10507 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10508 ; GFX90A-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[6:7]
10509 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
10510 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
10511 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
10513 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_unordered_load:
10514 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
10515 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
10516 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
10517 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
10518 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10519 ; GFX90A-TGSPLIT-NEXT: global_load_dword v1, v0, s[6:7]
10520 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10521 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
10522 ; GFX90A-TGSPLIT-NEXT: s_endpgm
10524 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_unordered_load:
10525 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
10526 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
10527 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
10528 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
10529 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10530 ; GFX940-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[2:3]
10531 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
10532 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
10533 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
10535 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_unordered_load:
10536 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
10537 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
10538 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
10539 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
10540 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10541 ; GFX940-TGSPLIT-NEXT: global_load_dword v1, v0, s[2:3]
10542 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10543 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
10544 ; GFX940-TGSPLIT-NEXT: s_endpgm
10546 ; GFX11-WGP-LABEL: global_workgroup_one_as_unordered_load:
10547 ; GFX11-WGP: ; %bb.0: ; %entry
10548 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
10549 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
10550 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
10551 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10552 ; GFX11-WGP-NEXT: global_load_b32 v1, v0, s[2:3]
10553 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
10554 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
10555 ; GFX11-WGP-NEXT: s_endpgm
10557 ; GFX11-CU-LABEL: global_workgroup_one_as_unordered_load:
10558 ; GFX11-CU: ; %bb.0: ; %entry
10559 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
10560 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
10561 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
10562 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
10563 ; GFX11-CU-NEXT: global_load_b32 v1, v0, s[2:3]
10564 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
10565 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
10566 ; GFX11-CU-NEXT: s_endpgm
10568 ; GFX12-WGP-LABEL: global_workgroup_one_as_unordered_load:
10569 ; GFX12-WGP: ; %bb.0: ; %entry
10570 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
10571 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
10572 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
10573 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
10574 ; GFX12-WGP-NEXT: global_load_b32 v1, v0, s[2:3]
10575 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
10576 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
10577 ; GFX12-WGP-NEXT: s_endpgm
10579 ; GFX12-CU-LABEL: global_workgroup_one_as_unordered_load:
10580 ; GFX12-CU: ; %bb.0: ; %entry
10581 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
10582 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
10583 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
10584 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
10585 ; GFX12-CU-NEXT: global_load_b32 v1, v0, s[2:3]
10586 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
10587 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
10588 ; GFX12-CU-NEXT: s_endpgm
10589 ptr addrspace(1) %in, ptr addrspace(1) %out) {
10591 %val = load atomic i32, ptr addrspace(1) %in syncscope("workgroup-one-as") unordered, align 4
10592 store i32 %val, ptr addrspace(1) %out
10596 define amdgpu_kernel void @global_workgroup_one_as_monotonic_load(
10597 ; GFX6-LABEL: global_workgroup_one_as_monotonic_load:
10598 ; GFX6: ; %bb.0: ; %entry
10599 ; GFX6-NEXT: s_mov_b64 s[4:5], s[8:9]
10600 ; GFX6-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
10601 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
10602 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
10603 ; GFX6-NEXT: s_mov_b32 s6, s9
10604 ; GFX6-NEXT: ; kill: def $sgpr8 killed $sgpr8 killed $sgpr8_sgpr9
10605 ; GFX6-NEXT: s_mov_b32 s12, 0x100f000
10606 ; GFX6-NEXT: s_mov_b32 s13, -1
10607 ; GFX6-NEXT: ; kill: def $sgpr8 killed $sgpr8 def $sgpr8_sgpr9_sgpr10_sgpr11
10608 ; GFX6-NEXT: s_mov_b32 s9, s6
10609 ; GFX6-NEXT: s_mov_b32 s10, s13
10610 ; GFX6-NEXT: s_mov_b32 s11, s12
10611 ; GFX6-NEXT: s_mov_b32 s14, s5
10612 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
10613 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
10614 ; GFX6-NEXT: s_mov_b32 s5, s14
10615 ; GFX6-NEXT: s_mov_b32 s6, s13
10616 ; GFX6-NEXT: s_mov_b32 s7, s12
10617 ; GFX6-NEXT: buffer_load_dword v0, off, s[8:11], 0
10618 ; GFX6-NEXT: s_waitcnt vmcnt(0)
10619 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
10620 ; GFX6-NEXT: s_endpgm
10622 ; GFX7-LABEL: global_workgroup_one_as_monotonic_load:
10623 ; GFX7: ; %bb.0: ; %entry
10624 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
10625 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x2
10626 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
10627 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
10628 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
10629 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
10630 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
10631 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
10632 ; GFX7-NEXT: s_waitcnt vmcnt(0)
10633 ; GFX7-NEXT: flat_store_dword v[0:1], v2
10634 ; GFX7-NEXT: s_endpgm
10636 ; GFX10-WGP-LABEL: global_workgroup_one_as_monotonic_load:
10637 ; GFX10-WGP: ; %bb.0: ; %entry
10638 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
10639 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
10640 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
10641 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
10642 ; GFX10-WGP-NEXT: global_load_dword v1, v0, s[6:7] glc
10643 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
10644 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
10645 ; GFX10-WGP-NEXT: s_endpgm
10647 ; GFX10-CU-LABEL: global_workgroup_one_as_monotonic_load:
10648 ; GFX10-CU: ; %bb.0: ; %entry
10649 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
10650 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
10651 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
10652 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
10653 ; GFX10-CU-NEXT: global_load_dword v1, v0, s[6:7]
10654 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
10655 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
10656 ; GFX10-CU-NEXT: s_endpgm
10658 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_monotonic_load:
10659 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
10660 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[4:5]
10661 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
10662 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
10663 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
10664 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s5
10665 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
10666 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, 0xf000
10667 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s9, -1
10668 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
10669 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s2
10670 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
10671 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
10672 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s10, s1
10673 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
10674 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
10675 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s10
10676 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s9
10677 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s8
10678 ; SKIP-CACHE-INV-NEXT: buffer_load_dword v0, off, s[4:7], 0
10679 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
10680 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
10681 ; SKIP-CACHE-INV-NEXT: s_endpgm
10683 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_load:
10684 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
10685 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
10686 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
10687 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
10688 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10689 ; GFX90A-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[6:7]
10690 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
10691 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
10692 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
10694 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_load:
10695 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
10696 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
10697 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
10698 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
10699 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10700 ; GFX90A-TGSPLIT-NEXT: global_load_dword v1, v0, s[6:7] glc
10701 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10702 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
10703 ; GFX90A-TGSPLIT-NEXT: s_endpgm
10705 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_load:
10706 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
10707 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
10708 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
10709 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
10710 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10711 ; GFX940-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[2:3] sc0
10712 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
10713 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
10714 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
10716 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_load:
10717 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
10718 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
10719 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
10720 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
10721 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10722 ; GFX940-TGSPLIT-NEXT: global_load_dword v1, v0, s[2:3] sc0
10723 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10724 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
10725 ; GFX940-TGSPLIT-NEXT: s_endpgm
10727 ; GFX11-WGP-LABEL: global_workgroup_one_as_monotonic_load:
10728 ; GFX11-WGP: ; %bb.0: ; %entry
10729 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
10730 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
10731 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
10732 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10733 ; GFX11-WGP-NEXT: global_load_b32 v1, v0, s[2:3] glc
10734 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
10735 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
10736 ; GFX11-WGP-NEXT: s_endpgm
10738 ; GFX11-CU-LABEL: global_workgroup_one_as_monotonic_load:
10739 ; GFX11-CU: ; %bb.0: ; %entry
10740 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
10741 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
10742 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
10743 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
10744 ; GFX11-CU-NEXT: global_load_b32 v1, v0, s[2:3]
10745 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
10746 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
10747 ; GFX11-CU-NEXT: s_endpgm
10749 ; GFX12-WGP-LABEL: global_workgroup_one_as_monotonic_load:
10750 ; GFX12-WGP: ; %bb.0: ; %entry
10751 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
10752 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
10753 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
10754 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
10755 ; GFX12-WGP-NEXT: global_load_b32 v1, v0, s[2:3] scope:SCOPE_SE
10756 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
10757 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
10758 ; GFX12-WGP-NEXT: s_endpgm
10760 ; GFX12-CU-LABEL: global_workgroup_one_as_monotonic_load:
10761 ; GFX12-CU: ; %bb.0: ; %entry
10762 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
10763 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
10764 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
10765 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
10766 ; GFX12-CU-NEXT: global_load_b32 v1, v0, s[2:3]
10767 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
10768 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
10769 ; GFX12-CU-NEXT: s_endpgm
10770 ptr addrspace(1) %in, ptr addrspace(1) %out) {
10772 %val = load atomic i32, ptr addrspace(1) %in syncscope("workgroup-one-as") monotonic, align 4
10773 store i32 %val, ptr addrspace(1) %out
10777 define amdgpu_kernel void @global_workgroup_one_as_acquire_load(
10778 ; GFX6-LABEL: global_workgroup_one_as_acquire_load:
10779 ; GFX6: ; %bb.0: ; %entry
10780 ; GFX6-NEXT: s_mov_b64 s[4:5], s[8:9]
10781 ; GFX6-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
10782 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
10783 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
10784 ; GFX6-NEXT: s_mov_b32 s6, s9
10785 ; GFX6-NEXT: ; kill: def $sgpr8 killed $sgpr8 killed $sgpr8_sgpr9
10786 ; GFX6-NEXT: s_mov_b32 s12, 0x100f000
10787 ; GFX6-NEXT: s_mov_b32 s13, -1
10788 ; GFX6-NEXT: ; kill: def $sgpr8 killed $sgpr8 def $sgpr8_sgpr9_sgpr10_sgpr11
10789 ; GFX6-NEXT: s_mov_b32 s9, s6
10790 ; GFX6-NEXT: s_mov_b32 s10, s13
10791 ; GFX6-NEXT: s_mov_b32 s11, s12
10792 ; GFX6-NEXT: s_mov_b32 s14, s5
10793 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
10794 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
10795 ; GFX6-NEXT: s_mov_b32 s5, s14
10796 ; GFX6-NEXT: s_mov_b32 s6, s13
10797 ; GFX6-NEXT: s_mov_b32 s7, s12
10798 ; GFX6-NEXT: buffer_load_dword v0, off, s[8:11], 0
10799 ; GFX6-NEXT: s_waitcnt vmcnt(0)
10800 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
10801 ; GFX6-NEXT: s_endpgm
10803 ; GFX7-LABEL: global_workgroup_one_as_acquire_load:
10804 ; GFX7: ; %bb.0: ; %entry
10805 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
10806 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x2
10807 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
10808 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
10809 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
10810 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
10811 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
10812 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
10813 ; GFX7-NEXT: s_waitcnt vmcnt(0)
10814 ; GFX7-NEXT: flat_store_dword v[0:1], v2
10815 ; GFX7-NEXT: s_endpgm
10817 ; GFX10-WGP-LABEL: global_workgroup_one_as_acquire_load:
10818 ; GFX10-WGP: ; %bb.0: ; %entry
10819 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
10820 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
10821 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
10822 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
10823 ; GFX10-WGP-NEXT: global_load_dword v1, v0, s[6:7] glc
10824 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
10825 ; GFX10-WGP-NEXT: buffer_gl0_inv
10826 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
10827 ; GFX10-WGP-NEXT: s_endpgm
10829 ; GFX10-CU-LABEL: global_workgroup_one_as_acquire_load:
10830 ; GFX10-CU: ; %bb.0: ; %entry
10831 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
10832 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
10833 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
10834 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
10835 ; GFX10-CU-NEXT: global_load_dword v1, v0, s[6:7]
10836 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
10837 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
10838 ; GFX10-CU-NEXT: s_endpgm
10840 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acquire_load:
10841 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
10842 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[4:5]
10843 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
10844 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
10845 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
10846 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s5
10847 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
10848 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, 0xf000
10849 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s9, -1
10850 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
10851 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s2
10852 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
10853 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
10854 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s10, s1
10855 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
10856 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
10857 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s10
10858 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s9
10859 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s8
10860 ; SKIP-CACHE-INV-NEXT: buffer_load_dword v0, off, s[4:7], 0
10861 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
10862 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
10863 ; SKIP-CACHE-INV-NEXT: s_endpgm
10865 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_load:
10866 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
10867 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
10868 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
10869 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
10870 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10871 ; GFX90A-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[6:7]
10872 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
10873 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
10874 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
10876 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acquire_load:
10877 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
10878 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
10879 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
10880 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
10881 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10882 ; GFX90A-TGSPLIT-NEXT: global_load_dword v1, v0, s[6:7] glc
10883 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10884 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
10885 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
10886 ; GFX90A-TGSPLIT-NEXT: s_endpgm
10888 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_load:
10889 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
10890 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
10891 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
10892 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
10893 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10894 ; GFX940-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[2:3] sc0
10895 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
10896 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
10897 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
10899 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acquire_load:
10900 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
10901 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
10902 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
10903 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
10904 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
10905 ; GFX940-TGSPLIT-NEXT: global_load_dword v1, v0, s[2:3] sc0
10906 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
10907 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
10908 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
10909 ; GFX940-TGSPLIT-NEXT: s_endpgm
10911 ; GFX11-WGP-LABEL: global_workgroup_one_as_acquire_load:
10912 ; GFX11-WGP: ; %bb.0: ; %entry
10913 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
10914 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
10915 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
10916 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
10917 ; GFX11-WGP-NEXT: global_load_b32 v1, v0, s[2:3] glc
10918 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
10919 ; GFX11-WGP-NEXT: buffer_gl0_inv
10920 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
10921 ; GFX11-WGP-NEXT: s_endpgm
10923 ; GFX11-CU-LABEL: global_workgroup_one_as_acquire_load:
10924 ; GFX11-CU: ; %bb.0: ; %entry
10925 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
10926 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
10927 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
10928 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
10929 ; GFX11-CU-NEXT: global_load_b32 v1, v0, s[2:3]
10930 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
10931 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
10932 ; GFX11-CU-NEXT: s_endpgm
10934 ; GFX12-WGP-LABEL: global_workgroup_one_as_acquire_load:
10935 ; GFX12-WGP: ; %bb.0: ; %entry
10936 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
10937 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
10938 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
10939 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
10940 ; GFX12-WGP-NEXT: global_load_b32 v1, v0, s[2:3] scope:SCOPE_SE
10941 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
10942 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
10943 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
10944 ; GFX12-WGP-NEXT: s_endpgm
10946 ; GFX12-CU-LABEL: global_workgroup_one_as_acquire_load:
10947 ; GFX12-CU: ; %bb.0: ; %entry
10948 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
10949 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
10950 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
10951 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
10952 ; GFX12-CU-NEXT: global_load_b32 v1, v0, s[2:3]
10953 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
10954 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
10955 ; GFX12-CU-NEXT: s_endpgm
10956 ptr addrspace(1) %in, ptr addrspace(1) %out) {
10958 %val = load atomic i32, ptr addrspace(1) %in syncscope("workgroup-one-as") acquire, align 4
10959 store i32 %val, ptr addrspace(1) %out
10963 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_load(
10964 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_load:
10965 ; GFX6: ; %bb.0: ; %entry
10966 ; GFX6-NEXT: s_mov_b64 s[4:5], s[8:9]
10967 ; GFX6-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
10968 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
10969 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
10970 ; GFX6-NEXT: s_mov_b32 s6, s9
10971 ; GFX6-NEXT: ; kill: def $sgpr8 killed $sgpr8 killed $sgpr8_sgpr9
10972 ; GFX6-NEXT: s_mov_b32 s12, 0x100f000
10973 ; GFX6-NEXT: s_mov_b32 s13, -1
10974 ; GFX6-NEXT: ; kill: def $sgpr8 killed $sgpr8 def $sgpr8_sgpr9_sgpr10_sgpr11
10975 ; GFX6-NEXT: s_mov_b32 s9, s6
10976 ; GFX6-NEXT: s_mov_b32 s10, s13
10977 ; GFX6-NEXT: s_mov_b32 s11, s12
10978 ; GFX6-NEXT: s_mov_b32 s14, s5
10979 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
10980 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
10981 ; GFX6-NEXT: s_mov_b32 s5, s14
10982 ; GFX6-NEXT: s_mov_b32 s6, s13
10983 ; GFX6-NEXT: s_mov_b32 s7, s12
10984 ; GFX6-NEXT: buffer_load_dword v0, off, s[8:11], 0
10985 ; GFX6-NEXT: s_waitcnt vmcnt(0)
10986 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
10987 ; GFX6-NEXT: s_endpgm
10989 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_load:
10990 ; GFX7: ; %bb.0: ; %entry
10991 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
10992 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x2
10993 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
10994 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
10995 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
10996 ; GFX7-NEXT: flat_load_dword v2, v[0:1]
10997 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
10998 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
10999 ; GFX7-NEXT: s_waitcnt vmcnt(0)
11000 ; GFX7-NEXT: flat_store_dword v[0:1], v2
11001 ; GFX7-NEXT: s_endpgm
11003 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_load:
11004 ; GFX10-WGP: ; %bb.0: ; %entry
11005 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
11006 ; GFX10-WGP-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
11007 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
11008 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11009 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
11010 ; GFX10-WGP-NEXT: global_load_dword v1, v0, s[6:7] glc
11011 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
11012 ; GFX10-WGP-NEXT: buffer_gl0_inv
11013 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
11014 ; GFX10-WGP-NEXT: s_endpgm
11016 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_load:
11017 ; GFX10-CU: ; %bb.0: ; %entry
11018 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
11019 ; GFX10-CU-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
11020 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
11021 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
11022 ; GFX10-CU-NEXT: global_load_dword v1, v0, s[6:7]
11023 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
11024 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
11025 ; GFX10-CU-NEXT: s_endpgm
11027 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_load:
11028 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
11029 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[4:5]
11030 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x0
11031 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
11032 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
11033 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s5
11034 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
11035 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, 0xf000
11036 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s9, -1
11037 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
11038 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, s2
11039 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, s9
11040 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s8
11041 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s10, s1
11042 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
11043 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
11044 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s10
11045 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s9
11046 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s8
11047 ; SKIP-CACHE-INV-NEXT: buffer_load_dword v0, off, s[4:7], 0
11048 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
11049 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
11050 ; SKIP-CACHE-INV-NEXT: s_endpgm
11052 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_load:
11053 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
11054 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
11055 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
11056 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
11057 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11058 ; GFX90A-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[6:7]
11059 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
11060 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
11061 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
11063 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_load:
11064 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
11065 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
11066 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
11067 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
11068 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11069 ; GFX90A-TGSPLIT-NEXT: global_load_dword v1, v0, s[6:7] glc
11070 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11071 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
11072 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
11073 ; GFX90A-TGSPLIT-NEXT: s_endpgm
11075 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_load:
11076 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
11077 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
11078 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
11079 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
11080 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11081 ; GFX940-NOTTGSPLIT-NEXT: global_load_dword v1, v0, s[2:3] sc0
11082 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
11083 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
11084 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
11086 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_load:
11087 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
11088 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
11089 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[2:3], s[4:5], 0x0
11090 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
11091 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11092 ; GFX940-TGSPLIT-NEXT: global_load_dword v1, v0, s[2:3] sc0
11093 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11094 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
11095 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
11096 ; GFX940-TGSPLIT-NEXT: s_endpgm
11098 ; GFX11-WGP-LABEL: global_workgroup_one_as_seq_cst_load:
11099 ; GFX11-WGP: ; %bb.0: ; %entry
11100 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
11101 ; GFX11-WGP-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
11102 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
11103 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
11104 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
11105 ; GFX11-WGP-NEXT: global_load_b32 v1, v0, s[2:3] glc
11106 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
11107 ; GFX11-WGP-NEXT: buffer_gl0_inv
11108 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
11109 ; GFX11-WGP-NEXT: s_endpgm
11111 ; GFX11-CU-LABEL: global_workgroup_one_as_seq_cst_load:
11112 ; GFX11-CU: ; %bb.0: ; %entry
11113 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
11114 ; GFX11-CU-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
11115 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
11116 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
11117 ; GFX11-CU-NEXT: global_load_b32 v1, v0, s[2:3]
11118 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
11119 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
11120 ; GFX11-CU-NEXT: s_endpgm
11122 ; GFX12-WGP-LABEL: global_workgroup_one_as_seq_cst_load:
11123 ; GFX12-WGP: ; %bb.0: ; %entry
11124 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
11125 ; GFX12-WGP-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
11126 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
11127 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
11128 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
11129 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
11130 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
11131 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
11132 ; GFX12-WGP-NEXT: global_load_b32 v1, v0, s[2:3] scope:SCOPE_SE
11133 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
11134 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
11135 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
11136 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
11137 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
11138 ; GFX12-WGP-NEXT: s_endpgm
11140 ; GFX12-CU-LABEL: global_workgroup_one_as_seq_cst_load:
11141 ; GFX12-CU: ; %bb.0: ; %entry
11142 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
11143 ; GFX12-CU-NEXT: s_load_b64 s[2:3], s[4:5], 0x0
11144 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
11145 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
11146 ; GFX12-CU-NEXT: global_load_b32 v1, v0, s[2:3]
11147 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
11148 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
11149 ; GFX12-CU-NEXT: s_endpgm
11150 ptr addrspace(1) %in, ptr addrspace(1) %out) {
11152 %val = load atomic i32, ptr addrspace(1) %in syncscope("workgroup-one-as") seq_cst, align 4
11153 store i32 %val, ptr addrspace(1) %out
11157 define amdgpu_kernel void @global_workgroup_one_as_unordered_store(
11158 ; GFX6-LABEL: global_workgroup_one_as_unordered_store:
11159 ; GFX6: ; %bb.0: ; %entry
11160 ; GFX6-NEXT: s_mov_b64 s[4:5], s[8:9]
11161 ; GFX6-NEXT: s_load_dword s8, s[4:5], 0x0
11162 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
11163 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
11164 ; GFX6-NEXT: s_mov_b32 s11, s5
11165 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
11166 ; GFX6-NEXT: s_mov_b32 s9, 0x100f000
11167 ; GFX6-NEXT: s_mov_b32 s10, -1
11168 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
11169 ; GFX6-NEXT: s_mov_b32 s5, s11
11170 ; GFX6-NEXT: s_mov_b32 s6, s10
11171 ; GFX6-NEXT: s_mov_b32 s7, s9
11172 ; GFX6-NEXT: v_mov_b32_e32 v0, s8
11173 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
11174 ; GFX6-NEXT: s_endpgm
11176 ; GFX7-LABEL: global_workgroup_one_as_unordered_store:
11177 ; GFX7: ; %bb.0: ; %entry
11178 ; GFX7-NEXT: s_load_dword s4, s[8:9], 0x0
11179 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x2
11180 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
11181 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
11182 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
11183 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
11184 ; GFX7-NEXT: flat_store_dword v[0:1], v2
11185 ; GFX7-NEXT: s_endpgm
11187 ; GFX10-WGP-LABEL: global_workgroup_one_as_unordered_store:
11188 ; GFX10-WGP: ; %bb.0: ; %entry
11189 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0x0
11190 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
11191 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
11192 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11193 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s6
11194 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
11195 ; GFX10-WGP-NEXT: s_endpgm
11197 ; GFX10-CU-LABEL: global_workgroup_one_as_unordered_store:
11198 ; GFX10-CU: ; %bb.0: ; %entry
11199 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0x0
11200 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
11201 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
11202 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
11203 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s6
11204 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
11205 ; GFX10-CU-NEXT: s_endpgm
11207 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_unordered_store:
11208 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
11209 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[4:5]
11210 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x0
11211 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
11212 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
11213 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s1
11214 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
11215 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, 0xf000
11216 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
11217 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
11218 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s7
11219 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s6
11220 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s5
11221 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
11222 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
11223 ; SKIP-CACHE-INV-NEXT: s_endpgm
11225 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_unordered_store:
11226 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
11227 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x0
11228 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
11229 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
11230 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11231 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
11232 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
11233 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
11235 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_unordered_store:
11236 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
11237 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x0
11238 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
11239 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
11240 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11241 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
11242 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
11243 ; GFX90A-TGSPLIT-NEXT: s_endpgm
11245 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_unordered_store:
11246 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
11247 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
11248 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
11249 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
11250 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11251 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
11252 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
11253 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
11255 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_unordered_store:
11256 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
11257 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
11258 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
11259 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
11260 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11261 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
11262 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
11263 ; GFX940-TGSPLIT-NEXT: s_endpgm
11265 ; GFX11-WGP-LABEL: global_workgroup_one_as_unordered_store:
11266 ; GFX11-WGP: ; %bb.0: ; %entry
11267 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0x0
11268 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
11269 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
11270 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11271 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s2
11272 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
11273 ; GFX11-WGP-NEXT: s_endpgm
11275 ; GFX11-CU-LABEL: global_workgroup_one_as_unordered_store:
11276 ; GFX11-CU: ; %bb.0: ; %entry
11277 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0x0
11278 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
11279 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
11280 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
11281 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s2
11282 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
11283 ; GFX11-CU-NEXT: s_endpgm
11285 ; GFX12-WGP-LABEL: global_workgroup_one_as_unordered_store:
11286 ; GFX12-WGP: ; %bb.0: ; %entry
11287 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0x0
11288 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
11289 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
11290 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
11291 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s2
11292 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
11293 ; GFX12-WGP-NEXT: s_endpgm
11295 ; GFX12-CU-LABEL: global_workgroup_one_as_unordered_store:
11296 ; GFX12-CU: ; %bb.0: ; %entry
11297 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0x0
11298 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
11299 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
11300 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
11301 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s2
11302 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
11303 ; GFX12-CU-NEXT: s_endpgm
11304 i32 %in, ptr addrspace(1) %out) {
11306 store atomic i32 %in, ptr addrspace(1) %out syncscope("workgroup-one-as") unordered, align 4
11310 define amdgpu_kernel void @global_workgroup_one_as_monotonic_store(
11311 ; GFX6-LABEL: global_workgroup_one_as_monotonic_store:
11312 ; GFX6: ; %bb.0: ; %entry
11313 ; GFX6-NEXT: s_mov_b64 s[4:5], s[8:9]
11314 ; GFX6-NEXT: s_load_dword s8, s[4:5], 0x0
11315 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
11316 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
11317 ; GFX6-NEXT: s_mov_b32 s11, s5
11318 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
11319 ; GFX6-NEXT: s_mov_b32 s9, 0x100f000
11320 ; GFX6-NEXT: s_mov_b32 s10, -1
11321 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
11322 ; GFX6-NEXT: s_mov_b32 s5, s11
11323 ; GFX6-NEXT: s_mov_b32 s6, s10
11324 ; GFX6-NEXT: s_mov_b32 s7, s9
11325 ; GFX6-NEXT: v_mov_b32_e32 v0, s8
11326 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
11327 ; GFX6-NEXT: s_endpgm
11329 ; GFX7-LABEL: global_workgroup_one_as_monotonic_store:
11330 ; GFX7: ; %bb.0: ; %entry
11331 ; GFX7-NEXT: s_load_dword s4, s[8:9], 0x0
11332 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x2
11333 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
11334 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
11335 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
11336 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
11337 ; GFX7-NEXT: flat_store_dword v[0:1], v2
11338 ; GFX7-NEXT: s_endpgm
11340 ; GFX10-WGP-LABEL: global_workgroup_one_as_monotonic_store:
11341 ; GFX10-WGP: ; %bb.0: ; %entry
11342 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0x0
11343 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
11344 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
11345 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11346 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s6
11347 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
11348 ; GFX10-WGP-NEXT: s_endpgm
11350 ; GFX10-CU-LABEL: global_workgroup_one_as_monotonic_store:
11351 ; GFX10-CU: ; %bb.0: ; %entry
11352 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0x0
11353 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
11354 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
11355 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
11356 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s6
11357 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
11358 ; GFX10-CU-NEXT: s_endpgm
11360 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_monotonic_store:
11361 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
11362 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[4:5]
11363 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x0
11364 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
11365 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
11366 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s1
11367 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
11368 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, 0xf000
11369 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
11370 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
11371 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s7
11372 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s6
11373 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s5
11374 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
11375 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
11376 ; SKIP-CACHE-INV-NEXT: s_endpgm
11378 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_store:
11379 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
11380 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x0
11381 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
11382 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
11383 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11384 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
11385 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
11386 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
11388 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_store:
11389 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
11390 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x0
11391 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
11392 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
11393 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11394 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
11395 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
11396 ; GFX90A-TGSPLIT-NEXT: s_endpgm
11398 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_store:
11399 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
11400 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
11401 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
11402 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
11403 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11404 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
11405 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
11406 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
11408 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_store:
11409 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
11410 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
11411 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
11412 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
11413 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11414 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
11415 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
11416 ; GFX940-TGSPLIT-NEXT: s_endpgm
11418 ; GFX11-WGP-LABEL: global_workgroup_one_as_monotonic_store:
11419 ; GFX11-WGP: ; %bb.0: ; %entry
11420 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0x0
11421 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
11422 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
11423 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11424 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s2
11425 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
11426 ; GFX11-WGP-NEXT: s_endpgm
11428 ; GFX11-CU-LABEL: global_workgroup_one_as_monotonic_store:
11429 ; GFX11-CU: ; %bb.0: ; %entry
11430 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0x0
11431 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
11432 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
11433 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
11434 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s2
11435 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
11436 ; GFX11-CU-NEXT: s_endpgm
11438 ; GFX12-WGP-LABEL: global_workgroup_one_as_monotonic_store:
11439 ; GFX12-WGP: ; %bb.0: ; %entry
11440 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0x0
11441 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
11442 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
11443 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
11444 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s2
11445 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1] scope:SCOPE_SE
11446 ; GFX12-WGP-NEXT: s_endpgm
11448 ; GFX12-CU-LABEL: global_workgroup_one_as_monotonic_store:
11449 ; GFX12-CU: ; %bb.0: ; %entry
11450 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0x0
11451 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
11452 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
11453 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
11454 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s2
11455 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
11456 ; GFX12-CU-NEXT: s_endpgm
11457 i32 %in, ptr addrspace(1) %out) {
11459 store atomic i32 %in, ptr addrspace(1) %out syncscope("workgroup-one-as") monotonic, align 4
11463 define amdgpu_kernel void @global_workgroup_one_as_release_store(
11464 ; GFX6-LABEL: global_workgroup_one_as_release_store:
11465 ; GFX6: ; %bb.0: ; %entry
11466 ; GFX6-NEXT: s_mov_b64 s[4:5], s[8:9]
11467 ; GFX6-NEXT: s_load_dword s8, s[4:5], 0x0
11468 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
11469 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
11470 ; GFX6-NEXT: s_mov_b32 s11, s5
11471 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
11472 ; GFX6-NEXT: s_mov_b32 s9, 0x100f000
11473 ; GFX6-NEXT: s_mov_b32 s10, -1
11474 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
11475 ; GFX6-NEXT: s_mov_b32 s5, s11
11476 ; GFX6-NEXT: s_mov_b32 s6, s10
11477 ; GFX6-NEXT: s_mov_b32 s7, s9
11478 ; GFX6-NEXT: v_mov_b32_e32 v0, s8
11479 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
11480 ; GFX6-NEXT: s_endpgm
11482 ; GFX7-LABEL: global_workgroup_one_as_release_store:
11483 ; GFX7: ; %bb.0: ; %entry
11484 ; GFX7-NEXT: s_load_dword s4, s[8:9], 0x0
11485 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x2
11486 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
11487 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
11488 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
11489 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
11490 ; GFX7-NEXT: flat_store_dword v[0:1], v2
11491 ; GFX7-NEXT: s_endpgm
11493 ; GFX10-WGP-LABEL: global_workgroup_one_as_release_store:
11494 ; GFX10-WGP: ; %bb.0: ; %entry
11495 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0x0
11496 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
11497 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
11498 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11499 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s6
11500 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
11501 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
11502 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
11503 ; GFX10-WGP-NEXT: s_endpgm
11505 ; GFX10-CU-LABEL: global_workgroup_one_as_release_store:
11506 ; GFX10-CU: ; %bb.0: ; %entry
11507 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0x0
11508 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
11509 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
11510 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
11511 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s6
11512 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
11513 ; GFX10-CU-NEXT: s_endpgm
11515 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_release_store:
11516 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
11517 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[4:5]
11518 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x0
11519 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
11520 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
11521 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s1
11522 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
11523 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, 0xf000
11524 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
11525 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
11526 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s7
11527 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s6
11528 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s5
11529 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
11530 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
11531 ; SKIP-CACHE-INV-NEXT: s_endpgm
11533 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_store:
11534 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
11535 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x0
11536 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
11537 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
11538 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11539 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
11540 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
11541 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
11543 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_release_store:
11544 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
11545 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x0
11546 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
11547 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
11548 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11549 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
11550 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11551 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
11552 ; GFX90A-TGSPLIT-NEXT: s_endpgm
11554 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_store:
11555 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
11556 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
11557 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
11558 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
11559 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11560 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
11561 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
11562 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
11564 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_release_store:
11565 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
11566 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
11567 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
11568 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
11569 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11570 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
11571 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11572 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
11573 ; GFX940-TGSPLIT-NEXT: s_endpgm
11575 ; GFX11-WGP-LABEL: global_workgroup_one_as_release_store:
11576 ; GFX11-WGP: ; %bb.0: ; %entry
11577 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0x0
11578 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
11579 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
11580 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11581 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s2
11582 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
11583 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
11584 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
11585 ; GFX11-WGP-NEXT: s_endpgm
11587 ; GFX11-CU-LABEL: global_workgroup_one_as_release_store:
11588 ; GFX11-CU: ; %bb.0: ; %entry
11589 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0x0
11590 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
11591 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
11592 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
11593 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s2
11594 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
11595 ; GFX11-CU-NEXT: s_endpgm
11597 ; GFX12-WGP-LABEL: global_workgroup_one_as_release_store:
11598 ; GFX12-WGP: ; %bb.0: ; %entry
11599 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0x0
11600 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
11601 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
11602 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
11603 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s2
11604 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
11605 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
11606 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
11607 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
11608 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1] scope:SCOPE_SE
11609 ; GFX12-WGP-NEXT: s_endpgm
11611 ; GFX12-CU-LABEL: global_workgroup_one_as_release_store:
11612 ; GFX12-CU: ; %bb.0: ; %entry
11613 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0x0
11614 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
11615 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
11616 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
11617 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s2
11618 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
11619 ; GFX12-CU-NEXT: s_endpgm
11620 i32 %in, ptr addrspace(1) %out) {
11622 store atomic i32 %in, ptr addrspace(1) %out syncscope("workgroup-one-as") release, align 4
11626 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_store(
11627 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_store:
11628 ; GFX6: ; %bb.0: ; %entry
11629 ; GFX6-NEXT: s_mov_b64 s[4:5], s[8:9]
11630 ; GFX6-NEXT: s_load_dword s8, s[4:5], 0x0
11631 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x2
11632 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
11633 ; GFX6-NEXT: s_mov_b32 s11, s5
11634 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
11635 ; GFX6-NEXT: s_mov_b32 s9, 0x100f000
11636 ; GFX6-NEXT: s_mov_b32 s10, -1
11637 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
11638 ; GFX6-NEXT: s_mov_b32 s5, s11
11639 ; GFX6-NEXT: s_mov_b32 s6, s10
11640 ; GFX6-NEXT: s_mov_b32 s7, s9
11641 ; GFX6-NEXT: v_mov_b32_e32 v0, s8
11642 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
11643 ; GFX6-NEXT: s_endpgm
11645 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_store:
11646 ; GFX7: ; %bb.0: ; %entry
11647 ; GFX7-NEXT: s_load_dword s4, s[8:9], 0x0
11648 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x2
11649 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
11650 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
11651 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
11652 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
11653 ; GFX7-NEXT: flat_store_dword v[0:1], v2
11654 ; GFX7-NEXT: s_endpgm
11656 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_store:
11657 ; GFX10-WGP: ; %bb.0: ; %entry
11658 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0x0
11659 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
11660 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
11661 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11662 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s6
11663 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
11664 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
11665 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
11666 ; GFX10-WGP-NEXT: s_endpgm
11668 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_store:
11669 ; GFX10-CU: ; %bb.0: ; %entry
11670 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0x0
11671 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
11672 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
11673 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
11674 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s6
11675 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
11676 ; GFX10-CU-NEXT: s_endpgm
11678 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_store:
11679 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
11680 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[0:1], s[4:5]
11681 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[0:1], 0x0
11682 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2
11683 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
11684 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s1
11685 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
11686 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, 0xf000
11687 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
11688 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
11689 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s7
11690 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s6
11691 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s5
11692 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
11693 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
11694 ; SKIP-CACHE-INV-NEXT: s_endpgm
11696 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_store:
11697 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
11698 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x0
11699 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
11700 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
11701 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11702 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
11703 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
11704 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
11706 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_store:
11707 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
11708 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x0
11709 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x8
11710 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
11711 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11712 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
11713 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11714 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
11715 ; GFX90A-TGSPLIT-NEXT: s_endpgm
11717 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_store:
11718 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
11719 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
11720 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
11721 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
11722 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11723 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
11724 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
11725 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
11727 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_store:
11728 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
11729 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x0
11730 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x8
11731 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
11732 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11733 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
11734 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
11735 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
11736 ; GFX940-TGSPLIT-NEXT: s_endpgm
11738 ; GFX11-WGP-LABEL: global_workgroup_one_as_seq_cst_store:
11739 ; GFX11-WGP: ; %bb.0: ; %entry
11740 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0x0
11741 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
11742 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
11743 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11744 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s2
11745 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
11746 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
11747 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
11748 ; GFX11-WGP-NEXT: s_endpgm
11750 ; GFX11-CU-LABEL: global_workgroup_one_as_seq_cst_store:
11751 ; GFX11-CU: ; %bb.0: ; %entry
11752 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0x0
11753 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
11754 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
11755 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
11756 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s2
11757 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
11758 ; GFX11-CU-NEXT: s_endpgm
11760 ; GFX12-WGP-LABEL: global_workgroup_one_as_seq_cst_store:
11761 ; GFX12-WGP: ; %bb.0: ; %entry
11762 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0x0
11763 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
11764 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
11765 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
11766 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s2
11767 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
11768 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
11769 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
11770 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
11771 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1] scope:SCOPE_SE
11772 ; GFX12-WGP-NEXT: s_endpgm
11774 ; GFX12-CU-LABEL: global_workgroup_one_as_seq_cst_store:
11775 ; GFX12-CU: ; %bb.0: ; %entry
11776 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0x0
11777 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x8
11778 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
11779 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
11780 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s2
11781 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
11782 ; GFX12-CU-NEXT: s_endpgm
11783 i32 %in, ptr addrspace(1) %out) {
11785 store atomic i32 %in, ptr addrspace(1) %out syncscope("workgroup-one-as") seq_cst, align 4
11789 define amdgpu_kernel void @global_workgroup_one_as_monotonic_atomicrmw(
11790 ; GFX6-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
11791 ; GFX6: ; %bb.0: ; %entry
11792 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
11793 ; GFX6-NEXT: s_load_dword s8, s[8:9], 0x2
11794 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
11795 ; GFX6-NEXT: s_mov_b32 s11, s5
11796 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
11797 ; GFX6-NEXT: s_mov_b32 s9, 0x100f000
11798 ; GFX6-NEXT: s_mov_b32 s10, -1
11799 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
11800 ; GFX6-NEXT: s_mov_b32 s5, s11
11801 ; GFX6-NEXT: s_mov_b32 s6, s10
11802 ; GFX6-NEXT: s_mov_b32 s7, s9
11803 ; GFX6-NEXT: v_mov_b32_e32 v0, s8
11804 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[4:7], 0
11805 ; GFX6-NEXT: s_endpgm
11807 ; GFX7-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
11808 ; GFX7: ; %bb.0: ; %entry
11809 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
11810 ; GFX7-NEXT: s_load_dword s4, s[8:9], 0x2
11811 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
11812 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
11813 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
11814 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
11815 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
11816 ; GFX7-NEXT: s_endpgm
11818 ; GFX10-WGP-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
11819 ; GFX10-WGP: ; %bb.0: ; %entry
11820 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
11821 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
11822 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0x8
11823 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11824 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s6
11825 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[4:5]
11826 ; GFX10-WGP-NEXT: s_endpgm
11828 ; GFX10-CU-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
11829 ; GFX10-CU: ; %bb.0: ; %entry
11830 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
11831 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
11832 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0x8
11833 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
11834 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s6
11835 ; GFX10-CU-NEXT: global_atomic_swap v0, v1, s[4:5]
11836 ; GFX10-CU-NEXT: s_endpgm
11838 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
11839 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
11840 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
11841 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[4:5], 0x2
11842 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
11843 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s1
11844 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
11845 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, 0xf000
11846 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
11847 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
11848 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s7
11849 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s6
11850 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s5
11851 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
11852 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
11853 ; SKIP-CACHE-INV-NEXT: s_endpgm
11855 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
11856 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
11857 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
11858 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
11859 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
11860 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11861 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
11862 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[4:5]
11863 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
11865 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
11866 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
11867 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
11868 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
11869 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
11870 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11871 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
11872 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[4:5]
11873 ; GFX90A-TGSPLIT-NEXT: s_endpgm
11875 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
11876 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
11877 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
11878 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
11879 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
11880 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11881 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
11882 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
11883 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
11885 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
11886 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
11887 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
11888 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
11889 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
11890 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
11891 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
11892 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
11893 ; GFX940-TGSPLIT-NEXT: s_endpgm
11895 ; GFX11-WGP-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
11896 ; GFX11-WGP: ; %bb.0: ; %entry
11897 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
11898 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
11899 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
11900 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
11901 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s2
11902 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
11903 ; GFX11-WGP-NEXT: s_endpgm
11905 ; GFX11-CU-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
11906 ; GFX11-CU: ; %bb.0: ; %entry
11907 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
11908 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
11909 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
11910 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
11911 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s2
11912 ; GFX11-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
11913 ; GFX11-CU-NEXT: s_endpgm
11915 ; GFX12-WGP-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
11916 ; GFX12-WGP: ; %bb.0: ; %entry
11917 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
11918 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
11919 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
11920 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
11921 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s2
11922 ; GFX12-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1] scope:SCOPE_SE
11923 ; GFX12-WGP-NEXT: s_endpgm
11925 ; GFX12-CU-LABEL: global_workgroup_one_as_monotonic_atomicrmw:
11926 ; GFX12-CU: ; %bb.0: ; %entry
11927 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
11928 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
11929 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
11930 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
11931 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s2
11932 ; GFX12-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
11933 ; GFX12-CU-NEXT: s_endpgm
11934 ptr addrspace(1) %out, i32 %in) {
11936 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup-one-as") monotonic
11940 define amdgpu_kernel void @global_workgroup_one_as_acquire_atomicrmw(
11941 ; GFX6-LABEL: global_workgroup_one_as_acquire_atomicrmw:
11942 ; GFX6: ; %bb.0: ; %entry
11943 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
11944 ; GFX6-NEXT: s_load_dword s8, s[8:9], 0x2
11945 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
11946 ; GFX6-NEXT: s_mov_b32 s11, s5
11947 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
11948 ; GFX6-NEXT: s_mov_b32 s9, 0x100f000
11949 ; GFX6-NEXT: s_mov_b32 s10, -1
11950 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
11951 ; GFX6-NEXT: s_mov_b32 s5, s11
11952 ; GFX6-NEXT: s_mov_b32 s6, s10
11953 ; GFX6-NEXT: s_mov_b32 s7, s9
11954 ; GFX6-NEXT: v_mov_b32_e32 v0, s8
11955 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[4:7], 0
11956 ; GFX6-NEXT: s_endpgm
11958 ; GFX7-LABEL: global_workgroup_one_as_acquire_atomicrmw:
11959 ; GFX7: ; %bb.0: ; %entry
11960 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
11961 ; GFX7-NEXT: s_load_dword s4, s[8:9], 0x2
11962 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
11963 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
11964 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
11965 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
11966 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
11967 ; GFX7-NEXT: s_endpgm
11969 ; GFX10-WGP-LABEL: global_workgroup_one_as_acquire_atomicrmw:
11970 ; GFX10-WGP: ; %bb.0: ; %entry
11971 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
11972 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
11973 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0x8
11974 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
11975 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s6
11976 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[4:5]
11977 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
11978 ; GFX10-WGP-NEXT: buffer_gl0_inv
11979 ; GFX10-WGP-NEXT: s_endpgm
11981 ; GFX10-CU-LABEL: global_workgroup_one_as_acquire_atomicrmw:
11982 ; GFX10-CU: ; %bb.0: ; %entry
11983 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
11984 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
11985 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0x8
11986 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
11987 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s6
11988 ; GFX10-CU-NEXT: global_atomic_swap v0, v1, s[4:5]
11989 ; GFX10-CU-NEXT: s_endpgm
11991 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acquire_atomicrmw:
11992 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
11993 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
11994 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[4:5], 0x2
11995 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
11996 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s1
11997 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
11998 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, 0xf000
11999 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
12000 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
12001 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s7
12002 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s6
12003 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s5
12004 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
12005 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
12006 ; SKIP-CACHE-INV-NEXT: s_endpgm
12008 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_atomicrmw:
12009 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
12010 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
12011 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12012 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
12013 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12014 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
12015 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[4:5]
12016 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
12018 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acquire_atomicrmw:
12019 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
12020 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
12021 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12022 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
12023 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12024 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
12025 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[4:5]
12026 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12027 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
12028 ; GFX90A-TGSPLIT-NEXT: s_endpgm
12030 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_atomicrmw:
12031 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
12032 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
12033 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
12034 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
12035 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12036 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
12037 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
12038 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
12040 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acquire_atomicrmw:
12041 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
12042 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
12043 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
12044 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
12045 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12046 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
12047 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
12048 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12049 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
12050 ; GFX940-TGSPLIT-NEXT: s_endpgm
12052 ; GFX11-WGP-LABEL: global_workgroup_one_as_acquire_atomicrmw:
12053 ; GFX11-WGP: ; %bb.0: ; %entry
12054 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
12055 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
12056 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
12057 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
12058 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s2
12059 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
12060 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
12061 ; GFX11-WGP-NEXT: buffer_gl0_inv
12062 ; GFX11-WGP-NEXT: s_endpgm
12064 ; GFX11-CU-LABEL: global_workgroup_one_as_acquire_atomicrmw:
12065 ; GFX11-CU: ; %bb.0: ; %entry
12066 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
12067 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
12068 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
12069 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
12070 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s2
12071 ; GFX11-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
12072 ; GFX11-CU-NEXT: s_endpgm
12074 ; GFX12-WGP-LABEL: global_workgroup_one_as_acquire_atomicrmw:
12075 ; GFX12-WGP: ; %bb.0: ; %entry
12076 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
12077 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
12078 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
12079 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
12080 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s2
12081 ; GFX12-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1] scope:SCOPE_SE
12082 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
12083 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
12084 ; GFX12-WGP-NEXT: s_endpgm
12086 ; GFX12-CU-LABEL: global_workgroup_one_as_acquire_atomicrmw:
12087 ; GFX12-CU: ; %bb.0: ; %entry
12088 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
12089 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
12090 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
12091 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
12092 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s2
12093 ; GFX12-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
12094 ; GFX12-CU-NEXT: s_endpgm
12095 ptr addrspace(1) %out, i32 %in) {
12097 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup-one-as") acquire
12101 define amdgpu_kernel void @global_workgroup_one_as_release_atomicrmw(
12102 ; GFX6-LABEL: global_workgroup_one_as_release_atomicrmw:
12103 ; GFX6: ; %bb.0: ; %entry
12104 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12105 ; GFX6-NEXT: s_load_dword s8, s[8:9], 0x2
12106 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
12107 ; GFX6-NEXT: s_mov_b32 s11, s5
12108 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
12109 ; GFX6-NEXT: s_mov_b32 s9, 0x100f000
12110 ; GFX6-NEXT: s_mov_b32 s10, -1
12111 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
12112 ; GFX6-NEXT: s_mov_b32 s5, s11
12113 ; GFX6-NEXT: s_mov_b32 s6, s10
12114 ; GFX6-NEXT: s_mov_b32 s7, s9
12115 ; GFX6-NEXT: v_mov_b32_e32 v0, s8
12116 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[4:7], 0
12117 ; GFX6-NEXT: s_endpgm
12119 ; GFX7-LABEL: global_workgroup_one_as_release_atomicrmw:
12120 ; GFX7: ; %bb.0: ; %entry
12121 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
12122 ; GFX7-NEXT: s_load_dword s4, s[8:9], 0x2
12123 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
12124 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
12125 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
12126 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
12127 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
12128 ; GFX7-NEXT: s_endpgm
12130 ; GFX10-WGP-LABEL: global_workgroup_one_as_release_atomicrmw:
12131 ; GFX10-WGP: ; %bb.0: ; %entry
12132 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
12133 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12134 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0x8
12135 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
12136 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s6
12137 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
12138 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
12139 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[4:5]
12140 ; GFX10-WGP-NEXT: s_endpgm
12142 ; GFX10-CU-LABEL: global_workgroup_one_as_release_atomicrmw:
12143 ; GFX10-CU: ; %bb.0: ; %entry
12144 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
12145 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12146 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0x8
12147 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
12148 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s6
12149 ; GFX10-CU-NEXT: global_atomic_swap v0, v1, s[4:5]
12150 ; GFX10-CU-NEXT: s_endpgm
12152 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_release_atomicrmw:
12153 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
12154 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
12155 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[4:5], 0x2
12156 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
12157 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s1
12158 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
12159 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, 0xf000
12160 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
12161 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
12162 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s7
12163 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s6
12164 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s5
12165 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
12166 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
12167 ; SKIP-CACHE-INV-NEXT: s_endpgm
12169 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_atomicrmw:
12170 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
12171 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
12172 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12173 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
12174 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12175 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
12176 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[4:5]
12177 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
12179 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_release_atomicrmw:
12180 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
12181 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
12182 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12183 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
12184 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12185 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
12186 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12187 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[4:5]
12188 ; GFX90A-TGSPLIT-NEXT: s_endpgm
12190 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_atomicrmw:
12191 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
12192 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
12193 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
12194 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
12195 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12196 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
12197 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
12198 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
12200 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_release_atomicrmw:
12201 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
12202 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
12203 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
12204 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
12205 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12206 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
12207 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12208 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
12209 ; GFX940-TGSPLIT-NEXT: s_endpgm
12211 ; GFX11-WGP-LABEL: global_workgroup_one_as_release_atomicrmw:
12212 ; GFX11-WGP: ; %bb.0: ; %entry
12213 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
12214 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
12215 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
12216 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
12217 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s2
12218 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
12219 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
12220 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
12221 ; GFX11-WGP-NEXT: s_endpgm
12223 ; GFX11-CU-LABEL: global_workgroup_one_as_release_atomicrmw:
12224 ; GFX11-CU: ; %bb.0: ; %entry
12225 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
12226 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
12227 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
12228 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
12229 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s2
12230 ; GFX11-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
12231 ; GFX11-CU-NEXT: s_endpgm
12233 ; GFX12-WGP-LABEL: global_workgroup_one_as_release_atomicrmw:
12234 ; GFX12-WGP: ; %bb.0: ; %entry
12235 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
12236 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
12237 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
12238 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
12239 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s2
12240 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
12241 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
12242 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
12243 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
12244 ; GFX12-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1] scope:SCOPE_SE
12245 ; GFX12-WGP-NEXT: s_endpgm
12247 ; GFX12-CU-LABEL: global_workgroup_one_as_release_atomicrmw:
12248 ; GFX12-CU: ; %bb.0: ; %entry
12249 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
12250 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
12251 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
12252 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
12253 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s2
12254 ; GFX12-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
12255 ; GFX12-CU-NEXT: s_endpgm
12256 ptr addrspace(1) %out, i32 %in) {
12258 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup-one-as") release
12262 define amdgpu_kernel void @global_workgroup_one_as_acq_rel_atomicrmw(
12263 ; GFX6-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
12264 ; GFX6: ; %bb.0: ; %entry
12265 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12266 ; GFX6-NEXT: s_load_dword s8, s[8:9], 0x2
12267 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
12268 ; GFX6-NEXT: s_mov_b32 s11, s5
12269 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
12270 ; GFX6-NEXT: s_mov_b32 s9, 0x100f000
12271 ; GFX6-NEXT: s_mov_b32 s10, -1
12272 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
12273 ; GFX6-NEXT: s_mov_b32 s5, s11
12274 ; GFX6-NEXT: s_mov_b32 s6, s10
12275 ; GFX6-NEXT: s_mov_b32 s7, s9
12276 ; GFX6-NEXT: v_mov_b32_e32 v0, s8
12277 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[4:7], 0
12278 ; GFX6-NEXT: s_endpgm
12280 ; GFX7-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
12281 ; GFX7: ; %bb.0: ; %entry
12282 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
12283 ; GFX7-NEXT: s_load_dword s4, s[8:9], 0x2
12284 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
12285 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
12286 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
12287 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
12288 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
12289 ; GFX7-NEXT: s_endpgm
12291 ; GFX10-WGP-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
12292 ; GFX10-WGP: ; %bb.0: ; %entry
12293 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
12294 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12295 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0x8
12296 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
12297 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s6
12298 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
12299 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
12300 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[4:5]
12301 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
12302 ; GFX10-WGP-NEXT: buffer_gl0_inv
12303 ; GFX10-WGP-NEXT: s_endpgm
12305 ; GFX10-CU-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
12306 ; GFX10-CU: ; %bb.0: ; %entry
12307 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
12308 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12309 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0x8
12310 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
12311 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s6
12312 ; GFX10-CU-NEXT: global_atomic_swap v0, v1, s[4:5]
12313 ; GFX10-CU-NEXT: s_endpgm
12315 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
12316 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
12317 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
12318 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[4:5], 0x2
12319 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
12320 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s1
12321 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
12322 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, 0xf000
12323 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
12324 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
12325 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s7
12326 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s6
12327 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s5
12328 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
12329 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
12330 ; SKIP-CACHE-INV-NEXT: s_endpgm
12332 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
12333 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
12334 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
12335 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12336 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
12337 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12338 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
12339 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[4:5]
12340 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
12342 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
12343 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
12344 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
12345 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12346 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
12347 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12348 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
12349 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12350 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[4:5]
12351 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12352 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
12353 ; GFX90A-TGSPLIT-NEXT: s_endpgm
12355 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
12356 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
12357 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
12358 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
12359 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
12360 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12361 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
12362 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
12363 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
12365 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
12366 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
12367 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
12368 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
12369 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
12370 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12371 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
12372 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12373 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
12374 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12375 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
12376 ; GFX940-TGSPLIT-NEXT: s_endpgm
12378 ; GFX11-WGP-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
12379 ; GFX11-WGP: ; %bb.0: ; %entry
12380 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
12381 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
12382 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
12383 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
12384 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s2
12385 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
12386 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
12387 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
12388 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
12389 ; GFX11-WGP-NEXT: buffer_gl0_inv
12390 ; GFX11-WGP-NEXT: s_endpgm
12392 ; GFX11-CU-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
12393 ; GFX11-CU: ; %bb.0: ; %entry
12394 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
12395 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
12396 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
12397 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
12398 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s2
12399 ; GFX11-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
12400 ; GFX11-CU-NEXT: s_endpgm
12402 ; GFX12-WGP-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
12403 ; GFX12-WGP: ; %bb.0: ; %entry
12404 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
12405 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
12406 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
12407 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
12408 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s2
12409 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
12410 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
12411 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
12412 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
12413 ; GFX12-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1] scope:SCOPE_SE
12414 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
12415 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
12416 ; GFX12-WGP-NEXT: s_endpgm
12418 ; GFX12-CU-LABEL: global_workgroup_one_as_acq_rel_atomicrmw:
12419 ; GFX12-CU: ; %bb.0: ; %entry
12420 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
12421 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
12422 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
12423 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
12424 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s2
12425 ; GFX12-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
12426 ; GFX12-CU-NEXT: s_endpgm
12427 ptr addrspace(1) %out, i32 %in) {
12429 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup-one-as") acq_rel
12433 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_atomicrmw(
12434 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
12435 ; GFX6: ; %bb.0: ; %entry
12436 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12437 ; GFX6-NEXT: s_load_dword s8, s[8:9], 0x2
12438 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
12439 ; GFX6-NEXT: s_mov_b32 s11, s5
12440 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
12441 ; GFX6-NEXT: s_mov_b32 s9, 0x100f000
12442 ; GFX6-NEXT: s_mov_b32 s10, -1
12443 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
12444 ; GFX6-NEXT: s_mov_b32 s5, s11
12445 ; GFX6-NEXT: s_mov_b32 s6, s10
12446 ; GFX6-NEXT: s_mov_b32 s7, s9
12447 ; GFX6-NEXT: v_mov_b32_e32 v0, s8
12448 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[4:7], 0
12449 ; GFX6-NEXT: s_endpgm
12451 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
12452 ; GFX7: ; %bb.0: ; %entry
12453 ; GFX7-NEXT: s_load_dwordx2 s[6:7], s[8:9], 0x0
12454 ; GFX7-NEXT: s_load_dword s4, s[8:9], 0x2
12455 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
12456 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
12457 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
12458 ; GFX7-NEXT: v_mov_b32_e32 v2, s4
12459 ; GFX7-NEXT: flat_atomic_swap v[0:1], v2
12460 ; GFX7-NEXT: s_endpgm
12462 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
12463 ; GFX10-WGP: ; %bb.0: ; %entry
12464 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
12465 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12466 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0x8
12467 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
12468 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s6
12469 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
12470 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
12471 ; GFX10-WGP-NEXT: global_atomic_swap v0, v1, s[4:5]
12472 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
12473 ; GFX10-WGP-NEXT: buffer_gl0_inv
12474 ; GFX10-WGP-NEXT: s_endpgm
12476 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
12477 ; GFX10-CU: ; %bb.0: ; %entry
12478 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
12479 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12480 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0x8
12481 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
12482 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s6
12483 ; GFX10-CU-NEXT: global_atomic_swap v0, v1, s[4:5]
12484 ; GFX10-CU-NEXT: s_endpgm
12486 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
12487 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
12488 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
12489 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[4:5], 0x2
12490 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
12491 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s1
12492 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
12493 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, 0xf000
12494 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
12495 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
12496 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s7
12497 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s6
12498 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s5
12499 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
12500 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0
12501 ; SKIP-CACHE-INV-NEXT: s_endpgm
12503 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
12504 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
12505 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
12506 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12507 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
12508 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12509 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
12510 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[4:5]
12511 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
12513 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
12514 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
12515 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
12516 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12517 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
12518 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12519 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
12520 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12521 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[4:5]
12522 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12523 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
12524 ; GFX90A-TGSPLIT-NEXT: s_endpgm
12526 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
12527 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
12528 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
12529 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
12530 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
12531 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12532 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
12533 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
12534 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
12536 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
12537 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
12538 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
12539 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
12540 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
12541 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12542 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
12543 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12544 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v0, v1, s[0:1]
12545 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12546 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
12547 ; GFX940-TGSPLIT-NEXT: s_endpgm
12549 ; GFX11-WGP-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
12550 ; GFX11-WGP: ; %bb.0: ; %entry
12551 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
12552 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
12553 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
12554 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
12555 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s2
12556 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
12557 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
12558 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
12559 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
12560 ; GFX11-WGP-NEXT: buffer_gl0_inv
12561 ; GFX11-WGP-NEXT: s_endpgm
12563 ; GFX11-CU-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
12564 ; GFX11-CU: ; %bb.0: ; %entry
12565 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
12566 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
12567 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
12568 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
12569 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s2
12570 ; GFX11-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
12571 ; GFX11-CU-NEXT: s_endpgm
12573 ; GFX12-WGP-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
12574 ; GFX12-WGP: ; %bb.0: ; %entry
12575 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
12576 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
12577 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
12578 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
12579 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s2
12580 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
12581 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
12582 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
12583 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
12584 ; GFX12-WGP-NEXT: global_atomic_swap_b32 v0, v1, s[0:1] scope:SCOPE_SE
12585 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
12586 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
12587 ; GFX12-WGP-NEXT: s_endpgm
12589 ; GFX12-CU-LABEL: global_workgroup_one_as_seq_cst_atomicrmw:
12590 ; GFX12-CU: ; %bb.0: ; %entry
12591 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
12592 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
12593 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
12594 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
12595 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s2
12596 ; GFX12-CU-NEXT: global_atomic_swap_b32 v0, v1, s[0:1]
12597 ; GFX12-CU-NEXT: s_endpgm
12598 ptr addrspace(1) %out, i32 %in) {
12600 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup-one-as") seq_cst
12604 define amdgpu_kernel void @global_workgroup_one_as_acquire_ret_atomicrmw(
12605 ; GFX6-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
12606 ; GFX6: ; %bb.0: ; %entry
12607 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12608 ; GFX6-NEXT: s_load_dword s8, s[8:9], 0x2
12609 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
12610 ; GFX6-NEXT: s_mov_b32 s11, s5
12611 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
12612 ; GFX6-NEXT: s_mov_b32 s9, 0x100f000
12613 ; GFX6-NEXT: s_mov_b32 s10, -1
12614 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
12615 ; GFX6-NEXT: s_mov_b32 s5, s11
12616 ; GFX6-NEXT: s_mov_b32 s6, s10
12617 ; GFX6-NEXT: s_mov_b32 s7, s9
12618 ; GFX6-NEXT: v_mov_b32_e32 v0, s8
12619 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[4:7], 0 glc
12620 ; GFX6-NEXT: s_waitcnt vmcnt(0)
12621 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
12622 ; GFX6-NEXT: s_endpgm
12624 ; GFX7-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
12625 ; GFX7: ; %bb.0: ; %entry
12626 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12627 ; GFX7-NEXT: s_load_dword s6, s[8:9], 0x2
12628 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
12629 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
12630 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
12631 ; GFX7-NEXT: v_mov_b32_e32 v2, s6
12632 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
12633 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
12634 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
12635 ; GFX7-NEXT: s_waitcnt vmcnt(0)
12636 ; GFX7-NEXT: flat_store_dword v[0:1], v2
12637 ; GFX7-NEXT: s_endpgm
12639 ; GFX10-WGP-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
12640 ; GFX10-WGP: ; %bb.0: ; %entry
12641 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
12642 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12643 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0x8
12644 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
12645 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s6
12646 ; GFX10-WGP-NEXT: global_atomic_swap v1, v0, v1, s[4:5] glc
12647 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
12648 ; GFX10-WGP-NEXT: buffer_gl0_inv
12649 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
12650 ; GFX10-WGP-NEXT: s_endpgm
12652 ; GFX10-CU-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
12653 ; GFX10-CU: ; %bb.0: ; %entry
12654 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
12655 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12656 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0x8
12657 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
12658 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s6
12659 ; GFX10-CU-NEXT: global_atomic_swap v1, v0, v1, s[4:5] glc
12660 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
12661 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
12662 ; GFX10-CU-NEXT: s_endpgm
12664 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
12665 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
12666 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
12667 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[4:5], 0x2
12668 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
12669 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s1
12670 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
12671 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, 0xf000
12672 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
12673 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
12674 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s7
12675 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s6
12676 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s5
12677 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
12678 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0 glc
12679 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
12680 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
12681 ; SKIP-CACHE-INV-NEXT: s_endpgm
12683 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
12684 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
12685 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
12686 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12687 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
12688 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12689 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
12690 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[4:5] glc
12691 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
12692 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
12693 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
12695 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
12696 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
12697 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
12698 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12699 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
12700 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12701 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
12702 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[4:5] glc
12703 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12704 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
12705 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
12706 ; GFX90A-TGSPLIT-NEXT: s_endpgm
12708 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
12709 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
12710 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
12711 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
12712 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
12713 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12714 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
12715 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] sc0
12716 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
12717 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
12718 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
12720 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
12721 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
12722 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
12723 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
12724 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
12725 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12726 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
12727 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] sc0
12728 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12729 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
12730 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
12731 ; GFX940-TGSPLIT-NEXT: s_endpgm
12733 ; GFX11-WGP-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
12734 ; GFX11-WGP: ; %bb.0: ; %entry
12735 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
12736 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
12737 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
12738 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
12739 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s2
12740 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] glc
12741 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
12742 ; GFX11-WGP-NEXT: buffer_gl0_inv
12743 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
12744 ; GFX11-WGP-NEXT: s_endpgm
12746 ; GFX11-CU-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
12747 ; GFX11-CU: ; %bb.0: ; %entry
12748 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
12749 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
12750 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
12751 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
12752 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s2
12753 ; GFX11-CU-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] glc
12754 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
12755 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
12756 ; GFX11-CU-NEXT: s_endpgm
12758 ; GFX12-WGP-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
12759 ; GFX12-WGP: ; %bb.0: ; %entry
12760 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
12761 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
12762 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
12763 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
12764 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s2
12765 ; GFX12-WGP-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] th:TH_ATOMIC_RETURN scope:SCOPE_SE
12766 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
12767 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
12768 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
12769 ; GFX12-WGP-NEXT: s_endpgm
12771 ; GFX12-CU-LABEL: global_workgroup_one_as_acquire_ret_atomicrmw:
12772 ; GFX12-CU: ; %bb.0: ; %entry
12773 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
12774 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
12775 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
12776 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
12777 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s2
12778 ; GFX12-CU-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] th:TH_ATOMIC_RETURN
12779 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
12780 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
12781 ; GFX12-CU-NEXT: s_endpgm
12782 ptr addrspace(1) %out, i32 %in) {
12784 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup-one-as") acquire
12785 store i32 %val, ptr addrspace(1) %out, align 4
12789 define amdgpu_kernel void @global_workgroup_one_as_acq_rel_ret_atomicrmw(
12790 ; GFX6-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
12791 ; GFX6: ; %bb.0: ; %entry
12792 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12793 ; GFX6-NEXT: s_load_dword s8, s[8:9], 0x2
12794 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
12795 ; GFX6-NEXT: s_mov_b32 s11, s5
12796 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
12797 ; GFX6-NEXT: s_mov_b32 s9, 0x100f000
12798 ; GFX6-NEXT: s_mov_b32 s10, -1
12799 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
12800 ; GFX6-NEXT: s_mov_b32 s5, s11
12801 ; GFX6-NEXT: s_mov_b32 s6, s10
12802 ; GFX6-NEXT: s_mov_b32 s7, s9
12803 ; GFX6-NEXT: v_mov_b32_e32 v0, s8
12804 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[4:7], 0 glc
12805 ; GFX6-NEXT: s_waitcnt vmcnt(0)
12806 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
12807 ; GFX6-NEXT: s_endpgm
12809 ; GFX7-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
12810 ; GFX7: ; %bb.0: ; %entry
12811 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12812 ; GFX7-NEXT: s_load_dword s6, s[8:9], 0x2
12813 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
12814 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
12815 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
12816 ; GFX7-NEXT: v_mov_b32_e32 v2, s6
12817 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
12818 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
12819 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
12820 ; GFX7-NEXT: s_waitcnt vmcnt(0)
12821 ; GFX7-NEXT: flat_store_dword v[0:1], v2
12822 ; GFX7-NEXT: s_endpgm
12824 ; GFX10-WGP-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
12825 ; GFX10-WGP: ; %bb.0: ; %entry
12826 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
12827 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12828 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0x8
12829 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
12830 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s6
12831 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
12832 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
12833 ; GFX10-WGP-NEXT: global_atomic_swap v1, v0, v1, s[4:5] glc
12834 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
12835 ; GFX10-WGP-NEXT: buffer_gl0_inv
12836 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
12837 ; GFX10-WGP-NEXT: s_endpgm
12839 ; GFX10-CU-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
12840 ; GFX10-CU: ; %bb.0: ; %entry
12841 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
12842 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12843 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0x8
12844 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
12845 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s6
12846 ; GFX10-CU-NEXT: global_atomic_swap v1, v0, v1, s[4:5] glc
12847 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
12848 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
12849 ; GFX10-CU-NEXT: s_endpgm
12851 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
12852 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
12853 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
12854 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[4:5], 0x2
12855 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
12856 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s1
12857 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
12858 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, 0xf000
12859 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
12860 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
12861 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s7
12862 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s6
12863 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s5
12864 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
12865 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0 glc
12866 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
12867 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
12868 ; SKIP-CACHE-INV-NEXT: s_endpgm
12870 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
12871 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
12872 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
12873 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12874 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
12875 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12876 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
12877 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[4:5] glc
12878 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
12879 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
12880 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
12882 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
12883 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
12884 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
12885 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12886 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
12887 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12888 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
12889 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12890 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[4:5] glc
12891 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12892 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
12893 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
12894 ; GFX90A-TGSPLIT-NEXT: s_endpgm
12896 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
12897 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
12898 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
12899 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
12900 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
12901 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12902 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
12903 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] sc0
12904 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
12905 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
12906 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
12908 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
12909 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
12910 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
12911 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
12912 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
12913 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
12914 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
12915 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12916 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] sc0
12917 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
12918 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
12919 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
12920 ; GFX940-TGSPLIT-NEXT: s_endpgm
12922 ; GFX11-WGP-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
12923 ; GFX11-WGP: ; %bb.0: ; %entry
12924 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
12925 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
12926 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
12927 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
12928 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s2
12929 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
12930 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
12931 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] glc
12932 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
12933 ; GFX11-WGP-NEXT: buffer_gl0_inv
12934 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
12935 ; GFX11-WGP-NEXT: s_endpgm
12937 ; GFX11-CU-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
12938 ; GFX11-CU: ; %bb.0: ; %entry
12939 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
12940 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
12941 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
12942 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
12943 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s2
12944 ; GFX11-CU-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] glc
12945 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
12946 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
12947 ; GFX11-CU-NEXT: s_endpgm
12949 ; GFX12-WGP-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
12950 ; GFX12-WGP: ; %bb.0: ; %entry
12951 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
12952 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
12953 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
12954 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
12955 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s2
12956 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
12957 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
12958 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
12959 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
12960 ; GFX12-WGP-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] th:TH_ATOMIC_RETURN scope:SCOPE_SE
12961 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
12962 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
12963 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
12964 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
12965 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
12966 ; GFX12-WGP-NEXT: s_endpgm
12968 ; GFX12-CU-LABEL: global_workgroup_one_as_acq_rel_ret_atomicrmw:
12969 ; GFX12-CU: ; %bb.0: ; %entry
12970 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
12971 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
12972 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
12973 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
12974 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s2
12975 ; GFX12-CU-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] th:TH_ATOMIC_RETURN
12976 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
12977 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
12978 ; GFX12-CU-NEXT: s_endpgm
12979 ptr addrspace(1) %out, i32 %in) {
12981 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup-one-as") acq_rel
12982 store i32 %val, ptr addrspace(1) %out, align 4
12986 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_ret_atomicrmw(
12987 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
12988 ; GFX6: ; %bb.0: ; %entry
12989 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
12990 ; GFX6-NEXT: s_load_dword s8, s[8:9], 0x2
12991 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
12992 ; GFX6-NEXT: s_mov_b32 s11, s5
12993 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
12994 ; GFX6-NEXT: s_mov_b32 s9, 0x100f000
12995 ; GFX6-NEXT: s_mov_b32 s10, -1
12996 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
12997 ; GFX6-NEXT: s_mov_b32 s5, s11
12998 ; GFX6-NEXT: s_mov_b32 s6, s10
12999 ; GFX6-NEXT: s_mov_b32 s7, s9
13000 ; GFX6-NEXT: v_mov_b32_e32 v0, s8
13001 ; GFX6-NEXT: buffer_atomic_swap v0, off, s[4:7], 0 glc
13002 ; GFX6-NEXT: s_waitcnt vmcnt(0)
13003 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
13004 ; GFX6-NEXT: s_endpgm
13006 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
13007 ; GFX7: ; %bb.0: ; %entry
13008 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13009 ; GFX7-NEXT: s_load_dword s6, s[8:9], 0x2
13010 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
13011 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
13012 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
13013 ; GFX7-NEXT: v_mov_b32_e32 v2, s6
13014 ; GFX7-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
13015 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
13016 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
13017 ; GFX7-NEXT: s_waitcnt vmcnt(0)
13018 ; GFX7-NEXT: flat_store_dword v[0:1], v2
13019 ; GFX7-NEXT: s_endpgm
13021 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
13022 ; GFX10-WGP: ; %bb.0: ; %entry
13023 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
13024 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13025 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0x8
13026 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
13027 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s6
13028 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
13029 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
13030 ; GFX10-WGP-NEXT: global_atomic_swap v1, v0, v1, s[4:5] glc
13031 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
13032 ; GFX10-WGP-NEXT: buffer_gl0_inv
13033 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
13034 ; GFX10-WGP-NEXT: s_endpgm
13036 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
13037 ; GFX10-CU: ; %bb.0: ; %entry
13038 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
13039 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13040 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0x8
13041 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
13042 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s6
13043 ; GFX10-CU-NEXT: global_atomic_swap v1, v0, v1, s[4:5] glc
13044 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
13045 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
13046 ; GFX10-CU-NEXT: s_endpgm
13048 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
13049 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
13050 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
13051 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[4:5], 0x2
13052 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
13053 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, s1
13054 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
13055 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s5, 0xf000
13056 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, -1
13057 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
13058 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s7
13059 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s6
13060 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s5
13061 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s4
13062 ; SKIP-CACHE-INV-NEXT: buffer_atomic_swap v0, off, s[0:3], 0 glc
13063 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
13064 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
13065 ; SKIP-CACHE-INV-NEXT: s_endpgm
13067 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
13068 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
13069 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
13070 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13071 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
13072 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13073 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
13074 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[4:5] glc
13075 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
13076 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
13077 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
13079 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
13080 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
13081 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
13082 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13083 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0x8
13084 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13085 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
13086 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
13087 ; GFX90A-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[4:5] glc
13088 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
13089 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
13090 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
13091 ; GFX90A-TGSPLIT-NEXT: s_endpgm
13093 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
13094 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
13095 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
13096 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
13097 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
13098 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13099 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
13100 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] sc0
13101 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
13102 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
13103 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
13105 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
13106 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
13107 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
13108 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
13109 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0x8
13110 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13111 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
13112 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
13113 ; GFX940-TGSPLIT-NEXT: global_atomic_swap v1, v0, v1, s[0:1] sc0
13114 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
13115 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
13116 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
13117 ; GFX940-TGSPLIT-NEXT: s_endpgm
13119 ; GFX11-WGP-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
13120 ; GFX11-WGP: ; %bb.0: ; %entry
13121 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
13122 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13123 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
13124 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
13125 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s2
13126 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
13127 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
13128 ; GFX11-WGP-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] glc
13129 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
13130 ; GFX11-WGP-NEXT: buffer_gl0_inv
13131 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
13132 ; GFX11-WGP-NEXT: s_endpgm
13134 ; GFX11-CU-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
13135 ; GFX11-CU: ; %bb.0: ; %entry
13136 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
13137 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13138 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
13139 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
13140 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s2
13141 ; GFX11-CU-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] glc
13142 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
13143 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
13144 ; GFX11-CU-NEXT: s_endpgm
13146 ; GFX12-WGP-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
13147 ; GFX12-WGP: ; %bb.0: ; %entry
13148 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
13149 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13150 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0x8
13151 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
13152 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s2
13153 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
13154 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
13155 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
13156 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
13157 ; GFX12-WGP-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] th:TH_ATOMIC_RETURN scope:SCOPE_SE
13158 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
13159 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
13160 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
13161 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
13162 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
13163 ; GFX12-WGP-NEXT: s_endpgm
13165 ; GFX12-CU-LABEL: global_workgroup_one_as_seq_cst_ret_atomicrmw:
13166 ; GFX12-CU: ; %bb.0: ; %entry
13167 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
13168 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13169 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0x8
13170 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
13171 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s2
13172 ; GFX12-CU-NEXT: global_atomic_swap_b32 v1, v0, v1, s[0:1] th:TH_ATOMIC_RETURN
13173 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
13174 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
13175 ; GFX12-CU-NEXT: s_endpgm
13176 ptr addrspace(1) %out, i32 %in) {
13178 %val = atomicrmw volatile xchg ptr addrspace(1) %out, i32 %in syncscope("workgroup-one-as") seq_cst
13179 store i32 %val, ptr addrspace(1) %out, align 4
13183 define amdgpu_kernel void @global_workgroup_one_as_monotonic_monotonic_cmpxchg(
13184 ; GFX6-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
13185 ; GFX6: ; %bb.0: ; %entry
13186 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
13187 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
13188 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
13189 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
13190 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
13191 ; GFX6-NEXT: s_mov_b32 s12, s5
13192 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
13193 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
13194 ; GFX6-NEXT: s_mov_b32 s11, -1
13195 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
13196 ; GFX6-NEXT: s_mov_b32 s5, s12
13197 ; GFX6-NEXT: s_mov_b32 s6, s11
13198 ; GFX6-NEXT: s_mov_b32 s7, s10
13199 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
13200 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
13201 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
13202 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
13203 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
13204 ; GFX6-NEXT: s_endpgm
13206 ; GFX7-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
13207 ; GFX7: ; %bb.0: ; %entry
13208 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
13209 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
13210 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
13211 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
13212 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
13213 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
13214 ; GFX7-NEXT: s_mov_b32 s4, s8
13215 ; GFX7-NEXT: s_mov_b32 s5, s9
13216 ; GFX7-NEXT: s_mov_b32 s9, s10
13217 ; GFX7-NEXT: s_mov_b32 s8, s11
13218 ; GFX7-NEXT: s_add_u32 s4, s4, s9
13219 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
13220 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
13221 ; GFX7-NEXT: s_mov_b32 s5, s8
13222 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
13223 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
13224 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13225 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
13226 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
13227 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
13228 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
13229 ; GFX7-NEXT: s_endpgm
13231 ; GFX10-WGP-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
13232 ; GFX10-WGP: ; %bb.0: ; %entry
13233 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
13234 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13235 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
13236 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
13237 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
13238 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
13239 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
13240 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
13241 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
13242 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
13243 ; GFX10-WGP-NEXT: s_endpgm
13245 ; GFX10-CU-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
13246 ; GFX10-CU: ; %bb.0: ; %entry
13247 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
13248 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13249 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
13250 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
13251 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
13252 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
13253 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
13254 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
13255 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
13256 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
13257 ; GFX10-CU-NEXT: s_endpgm
13259 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
13260 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
13261 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
13262 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
13263 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
13264 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
13265 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
13266 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
13267 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
13268 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
13269 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
13270 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
13271 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
13272 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
13273 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
13274 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
13275 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
13276 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
13277 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
13278 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
13279 ; SKIP-CACHE-INV-NEXT: s_endpgm
13281 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
13282 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
13283 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
13284 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13285 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
13286 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
13287 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13288 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
13289 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
13290 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13291 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
13292 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
13293 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
13295 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
13296 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
13297 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
13298 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13299 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
13300 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
13301 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13302 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
13303 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
13304 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13305 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
13306 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
13307 ; GFX90A-TGSPLIT-NEXT: s_endpgm
13309 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
13310 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
13311 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
13312 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
13313 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
13314 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
13315 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13316 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
13317 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
13318 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13319 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
13320 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
13321 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
13323 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
13324 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
13325 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
13326 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
13327 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
13328 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
13329 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13330 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
13331 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
13332 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13333 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
13334 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
13335 ; GFX940-TGSPLIT-NEXT: s_endpgm
13337 ; GFX11-WGP-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
13338 ; GFX11-WGP: ; %bb.0: ; %entry
13339 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
13340 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13341 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
13342 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
13343 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
13344 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
13345 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
13346 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
13347 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
13348 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
13349 ; GFX11-WGP-NEXT: s_endpgm
13351 ; GFX11-CU-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
13352 ; GFX11-CU: ; %bb.0: ; %entry
13353 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
13354 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13355 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
13356 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
13357 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
13358 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
13359 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
13360 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
13361 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
13362 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
13363 ; GFX11-CU-NEXT: s_endpgm
13365 ; GFX12-WGP-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
13366 ; GFX12-WGP: ; %bb.0: ; %entry
13367 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
13368 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13369 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
13370 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
13371 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
13372 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
13373 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
13374 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
13375 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
13376 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
13377 ; GFX12-WGP-NEXT: s_endpgm
13379 ; GFX12-CU-LABEL: global_workgroup_one_as_monotonic_monotonic_cmpxchg:
13380 ; GFX12-CU: ; %bb.0: ; %entry
13381 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
13382 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13383 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
13384 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
13385 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
13386 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
13387 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
13388 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
13389 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
13390 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
13391 ; GFX12-CU-NEXT: s_endpgm
13392 ptr addrspace(1) %out, i32 %in, i32 %old) {
13394 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
13395 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") monotonic monotonic
13399 define amdgpu_kernel void @global_workgroup_one_as_acquire_monotonic_cmpxchg(
13400 ; GFX6-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
13401 ; GFX6: ; %bb.0: ; %entry
13402 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
13403 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
13404 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
13405 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
13406 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
13407 ; GFX6-NEXT: s_mov_b32 s12, s5
13408 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
13409 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
13410 ; GFX6-NEXT: s_mov_b32 s11, -1
13411 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
13412 ; GFX6-NEXT: s_mov_b32 s5, s12
13413 ; GFX6-NEXT: s_mov_b32 s6, s11
13414 ; GFX6-NEXT: s_mov_b32 s7, s10
13415 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
13416 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
13417 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
13418 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
13419 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
13420 ; GFX6-NEXT: s_endpgm
13422 ; GFX7-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
13423 ; GFX7: ; %bb.0: ; %entry
13424 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
13425 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
13426 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
13427 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
13428 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
13429 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
13430 ; GFX7-NEXT: s_mov_b32 s4, s8
13431 ; GFX7-NEXT: s_mov_b32 s5, s9
13432 ; GFX7-NEXT: s_mov_b32 s9, s10
13433 ; GFX7-NEXT: s_mov_b32 s8, s11
13434 ; GFX7-NEXT: s_add_u32 s4, s4, s9
13435 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
13436 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
13437 ; GFX7-NEXT: s_mov_b32 s5, s8
13438 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
13439 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
13440 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13441 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
13442 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
13443 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
13444 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
13445 ; GFX7-NEXT: s_endpgm
13447 ; GFX10-WGP-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
13448 ; GFX10-WGP: ; %bb.0: ; %entry
13449 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
13450 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13451 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
13452 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
13453 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
13454 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
13455 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
13456 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
13457 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
13458 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
13459 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
13460 ; GFX10-WGP-NEXT: buffer_gl0_inv
13461 ; GFX10-WGP-NEXT: s_endpgm
13463 ; GFX10-CU-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
13464 ; GFX10-CU: ; %bb.0: ; %entry
13465 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
13466 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13467 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
13468 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
13469 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
13470 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
13471 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
13472 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
13473 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
13474 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
13475 ; GFX10-CU-NEXT: s_endpgm
13477 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
13478 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
13479 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
13480 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
13481 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
13482 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
13483 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
13484 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
13485 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
13486 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
13487 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
13488 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
13489 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
13490 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
13491 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
13492 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
13493 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
13494 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
13495 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
13496 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
13497 ; SKIP-CACHE-INV-NEXT: s_endpgm
13499 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
13500 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
13501 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
13502 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13503 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
13504 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
13505 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13506 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
13507 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
13508 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13509 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
13510 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
13511 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
13513 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
13514 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
13515 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
13516 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13517 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
13518 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
13519 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13520 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
13521 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
13522 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13523 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
13524 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
13525 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
13526 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
13527 ; GFX90A-TGSPLIT-NEXT: s_endpgm
13529 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
13530 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
13531 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
13532 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
13533 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
13534 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
13535 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13536 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
13537 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
13538 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13539 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
13540 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
13541 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
13543 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
13544 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
13545 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
13546 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
13547 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
13548 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
13549 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13550 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
13551 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
13552 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13553 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
13554 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
13555 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
13556 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
13557 ; GFX940-TGSPLIT-NEXT: s_endpgm
13559 ; GFX11-WGP-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
13560 ; GFX11-WGP: ; %bb.0: ; %entry
13561 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
13562 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13563 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
13564 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
13565 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
13566 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
13567 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
13568 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
13569 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
13570 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
13571 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
13572 ; GFX11-WGP-NEXT: buffer_gl0_inv
13573 ; GFX11-WGP-NEXT: s_endpgm
13575 ; GFX11-CU-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
13576 ; GFX11-CU: ; %bb.0: ; %entry
13577 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
13578 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13579 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
13580 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
13581 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
13582 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
13583 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
13584 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
13585 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
13586 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
13587 ; GFX11-CU-NEXT: s_endpgm
13589 ; GFX12-WGP-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
13590 ; GFX12-WGP: ; %bb.0: ; %entry
13591 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
13592 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13593 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
13594 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
13595 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
13596 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
13597 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
13598 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
13599 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
13600 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
13601 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
13602 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
13603 ; GFX12-WGP-NEXT: s_endpgm
13605 ; GFX12-CU-LABEL: global_workgroup_one_as_acquire_monotonic_cmpxchg:
13606 ; GFX12-CU: ; %bb.0: ; %entry
13607 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
13608 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13609 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
13610 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
13611 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
13612 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
13613 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
13614 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
13615 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
13616 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
13617 ; GFX12-CU-NEXT: s_endpgm
13618 ptr addrspace(1) %out, i32 %in, i32 %old) {
13620 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
13621 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acquire monotonic
13625 define amdgpu_kernel void @global_workgroup_one_as_release_monotonic_cmpxchg(
13626 ; GFX6-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
13627 ; GFX6: ; %bb.0: ; %entry
13628 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
13629 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
13630 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
13631 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
13632 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
13633 ; GFX6-NEXT: s_mov_b32 s12, s5
13634 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
13635 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
13636 ; GFX6-NEXT: s_mov_b32 s11, -1
13637 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
13638 ; GFX6-NEXT: s_mov_b32 s5, s12
13639 ; GFX6-NEXT: s_mov_b32 s6, s11
13640 ; GFX6-NEXT: s_mov_b32 s7, s10
13641 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
13642 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
13643 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
13644 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
13645 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
13646 ; GFX6-NEXT: s_endpgm
13648 ; GFX7-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
13649 ; GFX7: ; %bb.0: ; %entry
13650 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
13651 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
13652 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
13653 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
13654 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
13655 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
13656 ; GFX7-NEXT: s_mov_b32 s4, s8
13657 ; GFX7-NEXT: s_mov_b32 s5, s9
13658 ; GFX7-NEXT: s_mov_b32 s9, s10
13659 ; GFX7-NEXT: s_mov_b32 s8, s11
13660 ; GFX7-NEXT: s_add_u32 s4, s4, s9
13661 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
13662 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
13663 ; GFX7-NEXT: s_mov_b32 s5, s8
13664 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
13665 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
13666 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13667 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
13668 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
13669 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
13670 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
13671 ; GFX7-NEXT: s_endpgm
13673 ; GFX10-WGP-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
13674 ; GFX10-WGP: ; %bb.0: ; %entry
13675 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
13676 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13677 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
13678 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
13679 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
13680 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
13681 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
13682 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
13683 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
13684 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
13685 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
13686 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
13687 ; GFX10-WGP-NEXT: s_endpgm
13689 ; GFX10-CU-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
13690 ; GFX10-CU: ; %bb.0: ; %entry
13691 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
13692 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13693 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
13694 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
13695 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
13696 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
13697 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
13698 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
13699 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
13700 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
13701 ; GFX10-CU-NEXT: s_endpgm
13703 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
13704 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
13705 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
13706 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
13707 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
13708 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
13709 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
13710 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
13711 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
13712 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
13713 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
13714 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
13715 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
13716 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
13717 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
13718 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
13719 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
13720 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
13721 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
13722 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
13723 ; SKIP-CACHE-INV-NEXT: s_endpgm
13725 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
13726 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
13727 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
13728 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13729 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
13730 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
13731 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13732 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
13733 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
13734 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13735 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
13736 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
13737 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
13739 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
13740 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
13741 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
13742 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13743 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
13744 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
13745 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13746 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
13747 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
13748 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13749 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
13750 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
13751 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
13752 ; GFX90A-TGSPLIT-NEXT: s_endpgm
13754 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
13755 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
13756 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
13757 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
13758 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
13759 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
13760 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13761 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
13762 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
13763 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13764 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
13765 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
13766 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
13768 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
13769 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
13770 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
13771 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
13772 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
13773 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
13774 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13775 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
13776 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
13777 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13778 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
13779 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
13780 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
13781 ; GFX940-TGSPLIT-NEXT: s_endpgm
13783 ; GFX11-WGP-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
13784 ; GFX11-WGP: ; %bb.0: ; %entry
13785 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
13786 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13787 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
13788 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
13789 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
13790 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
13791 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
13792 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
13793 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
13794 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
13795 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
13796 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
13797 ; GFX11-WGP-NEXT: s_endpgm
13799 ; GFX11-CU-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
13800 ; GFX11-CU: ; %bb.0: ; %entry
13801 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
13802 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13803 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
13804 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
13805 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
13806 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
13807 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
13808 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
13809 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
13810 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
13811 ; GFX11-CU-NEXT: s_endpgm
13813 ; GFX12-WGP-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
13814 ; GFX12-WGP: ; %bb.0: ; %entry
13815 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
13816 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13817 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
13818 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
13819 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
13820 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
13821 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
13822 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
13823 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
13824 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
13825 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
13826 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
13827 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
13828 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
13829 ; GFX12-WGP-NEXT: s_endpgm
13831 ; GFX12-CU-LABEL: global_workgroup_one_as_release_monotonic_cmpxchg:
13832 ; GFX12-CU: ; %bb.0: ; %entry
13833 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
13834 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
13835 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
13836 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
13837 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
13838 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
13839 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
13840 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
13841 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
13842 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
13843 ; GFX12-CU-NEXT: s_endpgm
13844 ptr addrspace(1) %out, i32 %in, i32 %old) {
13846 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
13847 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") release monotonic
13851 define amdgpu_kernel void @global_workgroup_one_as_acq_rel_monotonic_cmpxchg(
13852 ; GFX6-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
13853 ; GFX6: ; %bb.0: ; %entry
13854 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
13855 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
13856 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
13857 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
13858 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
13859 ; GFX6-NEXT: s_mov_b32 s12, s5
13860 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
13861 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
13862 ; GFX6-NEXT: s_mov_b32 s11, -1
13863 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
13864 ; GFX6-NEXT: s_mov_b32 s5, s12
13865 ; GFX6-NEXT: s_mov_b32 s6, s11
13866 ; GFX6-NEXT: s_mov_b32 s7, s10
13867 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
13868 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
13869 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
13870 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
13871 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
13872 ; GFX6-NEXT: s_endpgm
13874 ; GFX7-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
13875 ; GFX7: ; %bb.0: ; %entry
13876 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
13877 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
13878 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
13879 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
13880 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
13881 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
13882 ; GFX7-NEXT: s_mov_b32 s4, s8
13883 ; GFX7-NEXT: s_mov_b32 s5, s9
13884 ; GFX7-NEXT: s_mov_b32 s9, s10
13885 ; GFX7-NEXT: s_mov_b32 s8, s11
13886 ; GFX7-NEXT: s_add_u32 s4, s4, s9
13887 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
13888 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
13889 ; GFX7-NEXT: s_mov_b32 s5, s8
13890 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
13891 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
13892 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13893 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
13894 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
13895 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
13896 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
13897 ; GFX7-NEXT: s_endpgm
13899 ; GFX10-WGP-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
13900 ; GFX10-WGP: ; %bb.0: ; %entry
13901 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
13902 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13903 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
13904 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
13905 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
13906 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
13907 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
13908 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
13909 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
13910 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
13911 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
13912 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
13913 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
13914 ; GFX10-WGP-NEXT: buffer_gl0_inv
13915 ; GFX10-WGP-NEXT: s_endpgm
13917 ; GFX10-CU-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
13918 ; GFX10-CU: ; %bb.0: ; %entry
13919 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
13920 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13921 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
13922 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
13923 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
13924 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
13925 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
13926 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
13927 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
13928 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
13929 ; GFX10-CU-NEXT: s_endpgm
13931 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
13932 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
13933 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
13934 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
13935 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
13936 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
13937 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
13938 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
13939 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
13940 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
13941 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
13942 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
13943 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
13944 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
13945 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
13946 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
13947 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
13948 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
13949 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
13950 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
13951 ; SKIP-CACHE-INV-NEXT: s_endpgm
13953 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
13954 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
13955 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
13956 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13957 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
13958 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
13959 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13960 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
13961 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
13962 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13963 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
13964 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
13965 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
13967 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
13968 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
13969 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
13970 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
13971 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
13972 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
13973 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13974 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
13975 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
13976 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13977 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
13978 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
13979 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
13980 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
13981 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
13982 ; GFX90A-TGSPLIT-NEXT: s_endpgm
13984 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
13985 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
13986 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
13987 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
13988 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
13989 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
13990 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
13991 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
13992 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
13993 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
13994 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
13995 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
13996 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
13998 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
13999 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
14000 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
14001 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
14002 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
14003 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
14004 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14005 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
14006 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
14007 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14008 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
14009 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
14010 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
14011 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
14012 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
14013 ; GFX940-TGSPLIT-NEXT: s_endpgm
14015 ; GFX11-WGP-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
14016 ; GFX11-WGP: ; %bb.0: ; %entry
14017 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
14018 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14019 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
14020 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
14021 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
14022 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
14023 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
14024 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
14025 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
14026 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
14027 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
14028 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
14029 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
14030 ; GFX11-WGP-NEXT: buffer_gl0_inv
14031 ; GFX11-WGP-NEXT: s_endpgm
14033 ; GFX11-CU-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
14034 ; GFX11-CU: ; %bb.0: ; %entry
14035 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
14036 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14037 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
14038 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
14039 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
14040 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
14041 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
14042 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
14043 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
14044 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
14045 ; GFX11-CU-NEXT: s_endpgm
14047 ; GFX12-WGP-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
14048 ; GFX12-WGP: ; %bb.0: ; %entry
14049 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
14050 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14051 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
14052 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
14053 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
14054 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
14055 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
14056 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
14057 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
14058 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
14059 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
14060 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
14061 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
14062 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
14063 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
14064 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
14065 ; GFX12-WGP-NEXT: s_endpgm
14067 ; GFX12-CU-LABEL: global_workgroup_one_as_acq_rel_monotonic_cmpxchg:
14068 ; GFX12-CU: ; %bb.0: ; %entry
14069 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
14070 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14071 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
14072 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
14073 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
14074 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
14075 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
14076 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
14077 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
14078 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
14079 ; GFX12-CU-NEXT: s_endpgm
14080 ptr addrspace(1) %out, i32 %in, i32 %old) {
14082 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
14083 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acq_rel monotonic
14087 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_monotonic_cmpxchg(
14088 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
14089 ; GFX6: ; %bb.0: ; %entry
14090 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
14091 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
14092 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
14093 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
14094 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
14095 ; GFX6-NEXT: s_mov_b32 s12, s5
14096 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
14097 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
14098 ; GFX6-NEXT: s_mov_b32 s11, -1
14099 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
14100 ; GFX6-NEXT: s_mov_b32 s5, s12
14101 ; GFX6-NEXT: s_mov_b32 s6, s11
14102 ; GFX6-NEXT: s_mov_b32 s7, s10
14103 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
14104 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
14105 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
14106 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
14107 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
14108 ; GFX6-NEXT: s_endpgm
14110 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
14111 ; GFX7: ; %bb.0: ; %entry
14112 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
14113 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
14114 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
14115 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
14116 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
14117 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
14118 ; GFX7-NEXT: s_mov_b32 s4, s8
14119 ; GFX7-NEXT: s_mov_b32 s5, s9
14120 ; GFX7-NEXT: s_mov_b32 s9, s10
14121 ; GFX7-NEXT: s_mov_b32 s8, s11
14122 ; GFX7-NEXT: s_add_u32 s4, s4, s9
14123 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
14124 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
14125 ; GFX7-NEXT: s_mov_b32 s5, s8
14126 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
14127 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
14128 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14129 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
14130 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
14131 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
14132 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
14133 ; GFX7-NEXT: s_endpgm
14135 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
14136 ; GFX10-WGP: ; %bb.0: ; %entry
14137 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
14138 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
14139 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
14140 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
14141 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
14142 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
14143 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
14144 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
14145 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
14146 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
14147 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
14148 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
14149 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
14150 ; GFX10-WGP-NEXT: buffer_gl0_inv
14151 ; GFX10-WGP-NEXT: s_endpgm
14153 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
14154 ; GFX10-CU: ; %bb.0: ; %entry
14155 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
14156 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
14157 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
14158 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
14159 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
14160 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
14161 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
14162 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
14163 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
14164 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
14165 ; GFX10-CU-NEXT: s_endpgm
14167 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
14168 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
14169 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
14170 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
14171 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
14172 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
14173 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
14174 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
14175 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
14176 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
14177 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
14178 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
14179 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
14180 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
14181 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
14182 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
14183 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
14184 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
14185 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
14186 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
14187 ; SKIP-CACHE-INV-NEXT: s_endpgm
14189 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
14190 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
14191 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
14192 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
14193 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
14194 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
14195 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14196 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
14197 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
14198 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14199 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
14200 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
14201 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
14203 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
14204 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
14205 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
14206 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
14207 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
14208 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
14209 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14210 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
14211 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
14212 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14213 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
14214 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
14215 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
14216 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
14217 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
14218 ; GFX90A-TGSPLIT-NEXT: s_endpgm
14220 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
14221 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
14222 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
14223 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
14224 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
14225 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
14226 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14227 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
14228 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
14229 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14230 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
14231 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
14232 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
14234 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
14235 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
14236 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
14237 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
14238 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
14239 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
14240 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14241 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
14242 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
14243 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14244 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
14245 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
14246 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
14247 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
14248 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
14249 ; GFX940-TGSPLIT-NEXT: s_endpgm
14251 ; GFX11-WGP-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
14252 ; GFX11-WGP: ; %bb.0: ; %entry
14253 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
14254 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14255 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
14256 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
14257 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
14258 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
14259 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
14260 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
14261 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
14262 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
14263 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
14264 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
14265 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
14266 ; GFX11-WGP-NEXT: buffer_gl0_inv
14267 ; GFX11-WGP-NEXT: s_endpgm
14269 ; GFX11-CU-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
14270 ; GFX11-CU: ; %bb.0: ; %entry
14271 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
14272 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14273 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
14274 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
14275 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
14276 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
14277 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
14278 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
14279 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
14280 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
14281 ; GFX11-CU-NEXT: s_endpgm
14283 ; GFX12-WGP-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
14284 ; GFX12-WGP: ; %bb.0: ; %entry
14285 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
14286 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14287 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
14288 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
14289 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
14290 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
14291 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
14292 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
14293 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
14294 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
14295 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
14296 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
14297 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
14298 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
14299 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
14300 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
14301 ; GFX12-WGP-NEXT: s_endpgm
14303 ; GFX12-CU-LABEL: global_workgroup_one_as_seq_cst_monotonic_cmpxchg:
14304 ; GFX12-CU: ; %bb.0: ; %entry
14305 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
14306 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14307 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
14308 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
14309 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
14310 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
14311 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
14312 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
14313 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
14314 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
14315 ; GFX12-CU-NEXT: s_endpgm
14316 ptr addrspace(1) %out, i32 %in, i32 %old) {
14318 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
14319 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") seq_cst monotonic
14323 define amdgpu_kernel void @global_workgroup_one_as_monotonic_acquire_cmpxchg(
14324 ; GFX6-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
14325 ; GFX6: ; %bb.0: ; %entry
14326 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
14327 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
14328 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
14329 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
14330 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
14331 ; GFX6-NEXT: s_mov_b32 s12, s5
14332 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
14333 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
14334 ; GFX6-NEXT: s_mov_b32 s11, -1
14335 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
14336 ; GFX6-NEXT: s_mov_b32 s5, s12
14337 ; GFX6-NEXT: s_mov_b32 s6, s11
14338 ; GFX6-NEXT: s_mov_b32 s7, s10
14339 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
14340 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
14341 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
14342 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
14343 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
14344 ; GFX6-NEXT: s_endpgm
14346 ; GFX7-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
14347 ; GFX7: ; %bb.0: ; %entry
14348 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
14349 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
14350 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
14351 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
14352 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
14353 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
14354 ; GFX7-NEXT: s_mov_b32 s4, s8
14355 ; GFX7-NEXT: s_mov_b32 s5, s9
14356 ; GFX7-NEXT: s_mov_b32 s9, s10
14357 ; GFX7-NEXT: s_mov_b32 s8, s11
14358 ; GFX7-NEXT: s_add_u32 s4, s4, s9
14359 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
14360 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
14361 ; GFX7-NEXT: s_mov_b32 s5, s8
14362 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
14363 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
14364 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14365 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
14366 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
14367 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
14368 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
14369 ; GFX7-NEXT: s_endpgm
14371 ; GFX10-WGP-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
14372 ; GFX10-WGP: ; %bb.0: ; %entry
14373 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
14374 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
14375 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
14376 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
14377 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
14378 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
14379 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
14380 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
14381 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
14382 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
14383 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
14384 ; GFX10-WGP-NEXT: buffer_gl0_inv
14385 ; GFX10-WGP-NEXT: s_endpgm
14387 ; GFX10-CU-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
14388 ; GFX10-CU: ; %bb.0: ; %entry
14389 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
14390 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
14391 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
14392 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
14393 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
14394 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
14395 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
14396 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
14397 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
14398 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
14399 ; GFX10-CU-NEXT: s_endpgm
14401 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
14402 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
14403 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
14404 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
14405 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
14406 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
14407 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
14408 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
14409 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
14410 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
14411 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
14412 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
14413 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
14414 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
14415 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
14416 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
14417 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
14418 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
14419 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
14420 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
14421 ; SKIP-CACHE-INV-NEXT: s_endpgm
14423 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
14424 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
14425 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
14426 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
14427 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
14428 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
14429 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14430 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
14431 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
14432 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14433 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
14434 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
14435 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
14437 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
14438 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
14439 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
14440 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
14441 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
14442 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
14443 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14444 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
14445 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
14446 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14447 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
14448 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
14449 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
14450 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
14451 ; GFX90A-TGSPLIT-NEXT: s_endpgm
14453 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
14454 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
14455 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
14456 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
14457 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
14458 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
14459 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14460 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
14461 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
14462 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14463 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
14464 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
14465 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
14467 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
14468 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
14469 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
14470 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
14471 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
14472 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
14473 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14474 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
14475 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
14476 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14477 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
14478 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
14479 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
14480 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
14481 ; GFX940-TGSPLIT-NEXT: s_endpgm
14483 ; GFX11-WGP-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
14484 ; GFX11-WGP: ; %bb.0: ; %entry
14485 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
14486 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14487 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
14488 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
14489 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
14490 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
14491 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
14492 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
14493 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
14494 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
14495 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
14496 ; GFX11-WGP-NEXT: buffer_gl0_inv
14497 ; GFX11-WGP-NEXT: s_endpgm
14499 ; GFX11-CU-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
14500 ; GFX11-CU: ; %bb.0: ; %entry
14501 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
14502 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14503 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
14504 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
14505 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
14506 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
14507 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
14508 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
14509 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
14510 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
14511 ; GFX11-CU-NEXT: s_endpgm
14513 ; GFX12-WGP-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
14514 ; GFX12-WGP: ; %bb.0: ; %entry
14515 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
14516 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14517 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
14518 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
14519 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
14520 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
14521 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
14522 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
14523 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
14524 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
14525 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
14526 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
14527 ; GFX12-WGP-NEXT: s_endpgm
14529 ; GFX12-CU-LABEL: global_workgroup_one_as_monotonic_acquire_cmpxchg:
14530 ; GFX12-CU: ; %bb.0: ; %entry
14531 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
14532 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14533 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
14534 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
14535 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
14536 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
14537 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
14538 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
14539 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
14540 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
14541 ; GFX12-CU-NEXT: s_endpgm
14542 ptr addrspace(1) %out, i32 %in, i32 %old) {
14544 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
14545 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") monotonic acquire
14549 define amdgpu_kernel void @global_workgroup_one_as_acquire_acquire_cmpxchg(
14550 ; GFX6-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
14551 ; GFX6: ; %bb.0: ; %entry
14552 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
14553 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
14554 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
14555 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
14556 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
14557 ; GFX6-NEXT: s_mov_b32 s12, s5
14558 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
14559 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
14560 ; GFX6-NEXT: s_mov_b32 s11, -1
14561 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
14562 ; GFX6-NEXT: s_mov_b32 s5, s12
14563 ; GFX6-NEXT: s_mov_b32 s6, s11
14564 ; GFX6-NEXT: s_mov_b32 s7, s10
14565 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
14566 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
14567 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
14568 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
14569 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
14570 ; GFX6-NEXT: s_endpgm
14572 ; GFX7-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
14573 ; GFX7: ; %bb.0: ; %entry
14574 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
14575 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
14576 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
14577 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
14578 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
14579 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
14580 ; GFX7-NEXT: s_mov_b32 s4, s8
14581 ; GFX7-NEXT: s_mov_b32 s5, s9
14582 ; GFX7-NEXT: s_mov_b32 s9, s10
14583 ; GFX7-NEXT: s_mov_b32 s8, s11
14584 ; GFX7-NEXT: s_add_u32 s4, s4, s9
14585 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
14586 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
14587 ; GFX7-NEXT: s_mov_b32 s5, s8
14588 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
14589 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
14590 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14591 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
14592 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
14593 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
14594 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
14595 ; GFX7-NEXT: s_endpgm
14597 ; GFX10-WGP-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
14598 ; GFX10-WGP: ; %bb.0: ; %entry
14599 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
14600 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
14601 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
14602 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
14603 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
14604 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
14605 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
14606 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
14607 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
14608 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
14609 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
14610 ; GFX10-WGP-NEXT: buffer_gl0_inv
14611 ; GFX10-WGP-NEXT: s_endpgm
14613 ; GFX10-CU-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
14614 ; GFX10-CU: ; %bb.0: ; %entry
14615 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
14616 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
14617 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
14618 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
14619 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
14620 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
14621 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
14622 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
14623 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
14624 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
14625 ; GFX10-CU-NEXT: s_endpgm
14627 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
14628 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
14629 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
14630 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
14631 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
14632 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
14633 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
14634 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
14635 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
14636 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
14637 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
14638 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
14639 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
14640 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
14641 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
14642 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
14643 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
14644 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
14645 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
14646 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
14647 ; SKIP-CACHE-INV-NEXT: s_endpgm
14649 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
14650 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
14651 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
14652 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
14653 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
14654 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
14655 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14656 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
14657 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
14658 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14659 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
14660 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
14661 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
14663 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
14664 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
14665 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
14666 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
14667 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
14668 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
14669 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14670 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
14671 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
14672 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14673 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
14674 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
14675 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
14676 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
14677 ; GFX90A-TGSPLIT-NEXT: s_endpgm
14679 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
14680 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
14681 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
14682 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
14683 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
14684 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
14685 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14686 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
14687 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
14688 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14689 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
14690 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
14691 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
14693 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
14694 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
14695 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
14696 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
14697 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
14698 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
14699 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14700 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
14701 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
14702 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14703 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
14704 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
14705 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
14706 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
14707 ; GFX940-TGSPLIT-NEXT: s_endpgm
14709 ; GFX11-WGP-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
14710 ; GFX11-WGP: ; %bb.0: ; %entry
14711 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
14712 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14713 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
14714 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
14715 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
14716 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
14717 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
14718 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
14719 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
14720 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
14721 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
14722 ; GFX11-WGP-NEXT: buffer_gl0_inv
14723 ; GFX11-WGP-NEXT: s_endpgm
14725 ; GFX11-CU-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
14726 ; GFX11-CU: ; %bb.0: ; %entry
14727 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
14728 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14729 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
14730 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
14731 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
14732 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
14733 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
14734 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
14735 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
14736 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
14737 ; GFX11-CU-NEXT: s_endpgm
14739 ; GFX12-WGP-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
14740 ; GFX12-WGP: ; %bb.0: ; %entry
14741 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
14742 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14743 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
14744 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
14745 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
14746 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
14747 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
14748 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
14749 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
14750 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
14751 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
14752 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
14753 ; GFX12-WGP-NEXT: s_endpgm
14755 ; GFX12-CU-LABEL: global_workgroup_one_as_acquire_acquire_cmpxchg:
14756 ; GFX12-CU: ; %bb.0: ; %entry
14757 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
14758 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14759 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
14760 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
14761 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
14762 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
14763 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
14764 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
14765 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
14766 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
14767 ; GFX12-CU-NEXT: s_endpgm
14768 ptr addrspace(1) %out, i32 %in, i32 %old) {
14770 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
14771 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acquire acquire
14775 define amdgpu_kernel void @global_workgroup_one_as_release_acquire_cmpxchg(
14776 ; GFX6-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
14777 ; GFX6: ; %bb.0: ; %entry
14778 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
14779 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
14780 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
14781 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
14782 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
14783 ; GFX6-NEXT: s_mov_b32 s12, s5
14784 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
14785 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
14786 ; GFX6-NEXT: s_mov_b32 s11, -1
14787 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
14788 ; GFX6-NEXT: s_mov_b32 s5, s12
14789 ; GFX6-NEXT: s_mov_b32 s6, s11
14790 ; GFX6-NEXT: s_mov_b32 s7, s10
14791 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
14792 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
14793 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
14794 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
14795 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
14796 ; GFX6-NEXT: s_endpgm
14798 ; GFX7-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
14799 ; GFX7: ; %bb.0: ; %entry
14800 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
14801 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
14802 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
14803 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
14804 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
14805 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
14806 ; GFX7-NEXT: s_mov_b32 s4, s8
14807 ; GFX7-NEXT: s_mov_b32 s5, s9
14808 ; GFX7-NEXT: s_mov_b32 s9, s10
14809 ; GFX7-NEXT: s_mov_b32 s8, s11
14810 ; GFX7-NEXT: s_add_u32 s4, s4, s9
14811 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
14812 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
14813 ; GFX7-NEXT: s_mov_b32 s5, s8
14814 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
14815 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
14816 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14817 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
14818 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
14819 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
14820 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
14821 ; GFX7-NEXT: s_endpgm
14823 ; GFX10-WGP-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
14824 ; GFX10-WGP: ; %bb.0: ; %entry
14825 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
14826 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
14827 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
14828 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
14829 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
14830 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
14831 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
14832 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
14833 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
14834 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
14835 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
14836 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
14837 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
14838 ; GFX10-WGP-NEXT: buffer_gl0_inv
14839 ; GFX10-WGP-NEXT: s_endpgm
14841 ; GFX10-CU-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
14842 ; GFX10-CU: ; %bb.0: ; %entry
14843 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
14844 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
14845 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
14846 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
14847 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
14848 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
14849 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
14850 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
14851 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
14852 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
14853 ; GFX10-CU-NEXT: s_endpgm
14855 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
14856 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
14857 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
14858 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
14859 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
14860 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
14861 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
14862 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
14863 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
14864 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
14865 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
14866 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
14867 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
14868 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
14869 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
14870 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
14871 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
14872 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
14873 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
14874 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
14875 ; SKIP-CACHE-INV-NEXT: s_endpgm
14877 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
14878 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
14879 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
14880 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
14881 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
14882 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
14883 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14884 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
14885 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
14886 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14887 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
14888 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
14889 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
14891 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
14892 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
14893 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
14894 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
14895 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
14896 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
14897 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14898 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
14899 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
14900 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14901 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
14902 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
14903 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
14904 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
14905 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
14906 ; GFX90A-TGSPLIT-NEXT: s_endpgm
14908 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
14909 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
14910 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
14911 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
14912 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
14913 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
14914 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14915 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
14916 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
14917 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14918 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
14919 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
14920 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
14922 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
14923 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
14924 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
14925 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
14926 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
14927 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
14928 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
14929 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
14930 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
14931 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
14932 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
14933 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
14934 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
14935 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
14936 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
14937 ; GFX940-TGSPLIT-NEXT: s_endpgm
14939 ; GFX11-WGP-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
14940 ; GFX11-WGP: ; %bb.0: ; %entry
14941 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
14942 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14943 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
14944 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
14945 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
14946 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
14947 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
14948 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
14949 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
14950 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
14951 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
14952 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
14953 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
14954 ; GFX11-WGP-NEXT: buffer_gl0_inv
14955 ; GFX11-WGP-NEXT: s_endpgm
14957 ; GFX11-CU-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
14958 ; GFX11-CU: ; %bb.0: ; %entry
14959 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
14960 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14961 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
14962 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
14963 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
14964 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
14965 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
14966 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
14967 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
14968 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
14969 ; GFX11-CU-NEXT: s_endpgm
14971 ; GFX12-WGP-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
14972 ; GFX12-WGP: ; %bb.0: ; %entry
14973 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
14974 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14975 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
14976 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
14977 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
14978 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
14979 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
14980 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
14981 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
14982 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
14983 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
14984 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
14985 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
14986 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
14987 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
14988 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
14989 ; GFX12-WGP-NEXT: s_endpgm
14991 ; GFX12-CU-LABEL: global_workgroup_one_as_release_acquire_cmpxchg:
14992 ; GFX12-CU: ; %bb.0: ; %entry
14993 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
14994 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
14995 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
14996 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
14997 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
14998 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
14999 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
15000 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
15001 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
15002 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
15003 ; GFX12-CU-NEXT: s_endpgm
15004 ptr addrspace(1) %out, i32 %in, i32 %old) {
15006 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
15007 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") release acquire
15011 define amdgpu_kernel void @global_workgroup_one_as_acq_rel_acquire_cmpxchg(
15012 ; GFX6-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
15013 ; GFX6: ; %bb.0: ; %entry
15014 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
15015 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
15016 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
15017 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
15018 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
15019 ; GFX6-NEXT: s_mov_b32 s12, s5
15020 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
15021 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
15022 ; GFX6-NEXT: s_mov_b32 s11, -1
15023 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
15024 ; GFX6-NEXT: s_mov_b32 s5, s12
15025 ; GFX6-NEXT: s_mov_b32 s6, s11
15026 ; GFX6-NEXT: s_mov_b32 s7, s10
15027 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
15028 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
15029 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
15030 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
15031 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
15032 ; GFX6-NEXT: s_endpgm
15034 ; GFX7-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
15035 ; GFX7: ; %bb.0: ; %entry
15036 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
15037 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
15038 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
15039 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
15040 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
15041 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
15042 ; GFX7-NEXT: s_mov_b32 s4, s8
15043 ; GFX7-NEXT: s_mov_b32 s5, s9
15044 ; GFX7-NEXT: s_mov_b32 s9, s10
15045 ; GFX7-NEXT: s_mov_b32 s8, s11
15046 ; GFX7-NEXT: s_add_u32 s4, s4, s9
15047 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
15048 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
15049 ; GFX7-NEXT: s_mov_b32 s5, s8
15050 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
15051 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
15052 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15053 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
15054 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
15055 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
15056 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
15057 ; GFX7-NEXT: s_endpgm
15059 ; GFX10-WGP-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
15060 ; GFX10-WGP: ; %bb.0: ; %entry
15061 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
15062 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
15063 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
15064 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
15065 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
15066 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
15067 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
15068 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
15069 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
15070 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
15071 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
15072 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
15073 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
15074 ; GFX10-WGP-NEXT: buffer_gl0_inv
15075 ; GFX10-WGP-NEXT: s_endpgm
15077 ; GFX10-CU-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
15078 ; GFX10-CU: ; %bb.0: ; %entry
15079 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
15080 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
15081 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
15082 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
15083 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
15084 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
15085 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
15086 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
15087 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
15088 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
15089 ; GFX10-CU-NEXT: s_endpgm
15091 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
15092 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
15093 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
15094 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
15095 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
15096 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
15097 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
15098 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
15099 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
15100 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
15101 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
15102 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
15103 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
15104 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
15105 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
15106 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
15107 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
15108 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
15109 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
15110 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
15111 ; SKIP-CACHE-INV-NEXT: s_endpgm
15113 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
15114 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
15115 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
15116 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
15117 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
15118 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
15119 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15120 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
15121 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
15122 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15123 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
15124 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
15125 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
15127 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
15128 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
15129 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
15130 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
15131 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
15132 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
15133 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15134 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
15135 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
15136 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15137 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
15138 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
15139 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
15140 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
15141 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
15142 ; GFX90A-TGSPLIT-NEXT: s_endpgm
15144 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
15145 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
15146 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
15147 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
15148 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
15149 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
15150 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15151 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
15152 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
15153 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15154 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
15155 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
15156 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
15158 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
15159 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
15160 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
15161 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
15162 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
15163 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
15164 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15165 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
15166 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
15167 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15168 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
15169 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
15170 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
15171 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
15172 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
15173 ; GFX940-TGSPLIT-NEXT: s_endpgm
15175 ; GFX11-WGP-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
15176 ; GFX11-WGP: ; %bb.0: ; %entry
15177 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
15178 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15179 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
15180 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
15181 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
15182 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
15183 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
15184 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
15185 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
15186 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
15187 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
15188 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
15189 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
15190 ; GFX11-WGP-NEXT: buffer_gl0_inv
15191 ; GFX11-WGP-NEXT: s_endpgm
15193 ; GFX11-CU-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
15194 ; GFX11-CU: ; %bb.0: ; %entry
15195 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
15196 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15197 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
15198 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
15199 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
15200 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
15201 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
15202 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
15203 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
15204 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
15205 ; GFX11-CU-NEXT: s_endpgm
15207 ; GFX12-WGP-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
15208 ; GFX12-WGP: ; %bb.0: ; %entry
15209 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
15210 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15211 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
15212 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
15213 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
15214 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
15215 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
15216 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
15217 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
15218 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
15219 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
15220 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
15221 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
15222 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
15223 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
15224 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
15225 ; GFX12-WGP-NEXT: s_endpgm
15227 ; GFX12-CU-LABEL: global_workgroup_one_as_acq_rel_acquire_cmpxchg:
15228 ; GFX12-CU: ; %bb.0: ; %entry
15229 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
15230 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15231 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
15232 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
15233 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
15234 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
15235 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
15236 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
15237 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
15238 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
15239 ; GFX12-CU-NEXT: s_endpgm
15240 ptr addrspace(1) %out, i32 %in, i32 %old) {
15242 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
15243 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acq_rel acquire
15247 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_acquire_cmpxchg(
15248 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
15249 ; GFX6: ; %bb.0: ; %entry
15250 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
15251 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
15252 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
15253 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
15254 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
15255 ; GFX6-NEXT: s_mov_b32 s12, s5
15256 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
15257 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
15258 ; GFX6-NEXT: s_mov_b32 s11, -1
15259 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
15260 ; GFX6-NEXT: s_mov_b32 s5, s12
15261 ; GFX6-NEXT: s_mov_b32 s6, s11
15262 ; GFX6-NEXT: s_mov_b32 s7, s10
15263 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
15264 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
15265 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
15266 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
15267 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
15268 ; GFX6-NEXT: s_endpgm
15270 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
15271 ; GFX7: ; %bb.0: ; %entry
15272 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
15273 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
15274 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
15275 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
15276 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
15277 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
15278 ; GFX7-NEXT: s_mov_b32 s4, s8
15279 ; GFX7-NEXT: s_mov_b32 s5, s9
15280 ; GFX7-NEXT: s_mov_b32 s9, s10
15281 ; GFX7-NEXT: s_mov_b32 s8, s11
15282 ; GFX7-NEXT: s_add_u32 s4, s4, s9
15283 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
15284 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
15285 ; GFX7-NEXT: s_mov_b32 s5, s8
15286 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
15287 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
15288 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15289 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
15290 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
15291 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
15292 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
15293 ; GFX7-NEXT: s_endpgm
15295 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
15296 ; GFX10-WGP: ; %bb.0: ; %entry
15297 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
15298 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
15299 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
15300 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
15301 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
15302 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
15303 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
15304 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
15305 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
15306 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
15307 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
15308 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
15309 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
15310 ; GFX10-WGP-NEXT: buffer_gl0_inv
15311 ; GFX10-WGP-NEXT: s_endpgm
15313 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
15314 ; GFX10-CU: ; %bb.0: ; %entry
15315 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
15316 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
15317 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
15318 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
15319 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
15320 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
15321 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
15322 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
15323 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
15324 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
15325 ; GFX10-CU-NEXT: s_endpgm
15327 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
15328 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
15329 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
15330 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
15331 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
15332 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
15333 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
15334 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
15335 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
15336 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
15337 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
15338 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
15339 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
15340 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
15341 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
15342 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
15343 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
15344 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
15345 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
15346 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
15347 ; SKIP-CACHE-INV-NEXT: s_endpgm
15349 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
15350 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
15351 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
15352 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
15353 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
15354 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
15355 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15356 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
15357 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
15358 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15359 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
15360 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
15361 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
15363 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
15364 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
15365 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
15366 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
15367 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
15368 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
15369 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15370 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
15371 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
15372 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15373 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
15374 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
15375 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
15376 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
15377 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
15378 ; GFX90A-TGSPLIT-NEXT: s_endpgm
15380 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
15381 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
15382 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
15383 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
15384 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
15385 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
15386 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15387 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
15388 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
15389 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15390 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
15391 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
15392 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
15394 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
15395 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
15396 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
15397 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
15398 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
15399 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
15400 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15401 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
15402 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
15403 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15404 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
15405 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
15406 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
15407 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
15408 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
15409 ; GFX940-TGSPLIT-NEXT: s_endpgm
15411 ; GFX11-WGP-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
15412 ; GFX11-WGP: ; %bb.0: ; %entry
15413 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
15414 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15415 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
15416 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
15417 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
15418 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
15419 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
15420 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
15421 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
15422 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
15423 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
15424 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
15425 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
15426 ; GFX11-WGP-NEXT: buffer_gl0_inv
15427 ; GFX11-WGP-NEXT: s_endpgm
15429 ; GFX11-CU-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
15430 ; GFX11-CU: ; %bb.0: ; %entry
15431 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
15432 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15433 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
15434 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
15435 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
15436 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
15437 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
15438 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
15439 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
15440 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
15441 ; GFX11-CU-NEXT: s_endpgm
15443 ; GFX12-WGP-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
15444 ; GFX12-WGP: ; %bb.0: ; %entry
15445 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
15446 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15447 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
15448 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
15449 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
15450 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
15451 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
15452 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
15453 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
15454 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
15455 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
15456 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
15457 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
15458 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
15459 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
15460 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
15461 ; GFX12-WGP-NEXT: s_endpgm
15463 ; GFX12-CU-LABEL: global_workgroup_one_as_seq_cst_acquire_cmpxchg:
15464 ; GFX12-CU: ; %bb.0: ; %entry
15465 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
15466 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15467 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
15468 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
15469 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
15470 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
15471 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
15472 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
15473 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
15474 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
15475 ; GFX12-CU-NEXT: s_endpgm
15476 ptr addrspace(1) %out, i32 %in, i32 %old) {
15478 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
15479 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") seq_cst acquire
15483 define amdgpu_kernel void @global_workgroup_one_as_monotonic_seq_cst_cmpxchg(
15484 ; GFX6-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
15485 ; GFX6: ; %bb.0: ; %entry
15486 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
15487 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
15488 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
15489 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
15490 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
15491 ; GFX6-NEXT: s_mov_b32 s12, s5
15492 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
15493 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
15494 ; GFX6-NEXT: s_mov_b32 s11, -1
15495 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
15496 ; GFX6-NEXT: s_mov_b32 s5, s12
15497 ; GFX6-NEXT: s_mov_b32 s6, s11
15498 ; GFX6-NEXT: s_mov_b32 s7, s10
15499 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
15500 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
15501 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
15502 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
15503 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
15504 ; GFX6-NEXT: s_endpgm
15506 ; GFX7-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
15507 ; GFX7: ; %bb.0: ; %entry
15508 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
15509 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
15510 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
15511 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
15512 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
15513 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
15514 ; GFX7-NEXT: s_mov_b32 s4, s8
15515 ; GFX7-NEXT: s_mov_b32 s5, s9
15516 ; GFX7-NEXT: s_mov_b32 s9, s10
15517 ; GFX7-NEXT: s_mov_b32 s8, s11
15518 ; GFX7-NEXT: s_add_u32 s4, s4, s9
15519 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
15520 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
15521 ; GFX7-NEXT: s_mov_b32 s5, s8
15522 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
15523 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
15524 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15525 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
15526 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
15527 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
15528 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
15529 ; GFX7-NEXT: s_endpgm
15531 ; GFX10-WGP-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
15532 ; GFX10-WGP: ; %bb.0: ; %entry
15533 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
15534 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
15535 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
15536 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
15537 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
15538 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
15539 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
15540 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
15541 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
15542 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
15543 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
15544 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
15545 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
15546 ; GFX10-WGP-NEXT: buffer_gl0_inv
15547 ; GFX10-WGP-NEXT: s_endpgm
15549 ; GFX10-CU-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
15550 ; GFX10-CU: ; %bb.0: ; %entry
15551 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
15552 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
15553 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
15554 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
15555 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
15556 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
15557 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
15558 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
15559 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
15560 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
15561 ; GFX10-CU-NEXT: s_endpgm
15563 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
15564 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
15565 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
15566 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
15567 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
15568 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
15569 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
15570 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
15571 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
15572 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
15573 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
15574 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
15575 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
15576 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
15577 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
15578 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
15579 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
15580 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
15581 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
15582 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
15583 ; SKIP-CACHE-INV-NEXT: s_endpgm
15585 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
15586 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
15587 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
15588 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
15589 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
15590 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
15591 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15592 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
15593 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
15594 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15595 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
15596 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
15597 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
15599 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
15600 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
15601 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
15602 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
15603 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
15604 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
15605 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15606 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
15607 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
15608 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15609 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
15610 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
15611 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
15612 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
15613 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
15614 ; GFX90A-TGSPLIT-NEXT: s_endpgm
15616 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
15617 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
15618 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
15619 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
15620 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
15621 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
15622 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15623 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
15624 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
15625 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15626 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
15627 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
15628 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
15630 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
15631 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
15632 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
15633 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
15634 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
15635 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
15636 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15637 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
15638 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
15639 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15640 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
15641 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
15642 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
15643 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
15644 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
15645 ; GFX940-TGSPLIT-NEXT: s_endpgm
15647 ; GFX11-WGP-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
15648 ; GFX11-WGP: ; %bb.0: ; %entry
15649 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
15650 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15651 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
15652 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
15653 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
15654 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
15655 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
15656 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
15657 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
15658 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
15659 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
15660 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
15661 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
15662 ; GFX11-WGP-NEXT: buffer_gl0_inv
15663 ; GFX11-WGP-NEXT: s_endpgm
15665 ; GFX11-CU-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
15666 ; GFX11-CU: ; %bb.0: ; %entry
15667 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
15668 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15669 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
15670 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
15671 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
15672 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
15673 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
15674 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
15675 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
15676 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
15677 ; GFX11-CU-NEXT: s_endpgm
15679 ; GFX12-WGP-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
15680 ; GFX12-WGP: ; %bb.0: ; %entry
15681 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
15682 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15683 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
15684 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
15685 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
15686 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
15687 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
15688 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
15689 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
15690 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
15691 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
15692 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
15693 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
15694 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
15695 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
15696 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
15697 ; GFX12-WGP-NEXT: s_endpgm
15699 ; GFX12-CU-LABEL: global_workgroup_one_as_monotonic_seq_cst_cmpxchg:
15700 ; GFX12-CU: ; %bb.0: ; %entry
15701 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
15702 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15703 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
15704 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
15705 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
15706 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
15707 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
15708 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
15709 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
15710 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
15711 ; GFX12-CU-NEXT: s_endpgm
15712 ptr addrspace(1) %out, i32 %in, i32 %old) {
15714 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
15715 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") monotonic seq_cst
15719 define amdgpu_kernel void @global_workgroup_one_as_acquire_seq_cst_cmpxchg(
15720 ; GFX6-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
15721 ; GFX6: ; %bb.0: ; %entry
15722 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
15723 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
15724 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
15725 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
15726 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
15727 ; GFX6-NEXT: s_mov_b32 s12, s5
15728 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
15729 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
15730 ; GFX6-NEXT: s_mov_b32 s11, -1
15731 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
15732 ; GFX6-NEXT: s_mov_b32 s5, s12
15733 ; GFX6-NEXT: s_mov_b32 s6, s11
15734 ; GFX6-NEXT: s_mov_b32 s7, s10
15735 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
15736 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
15737 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
15738 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
15739 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
15740 ; GFX6-NEXT: s_endpgm
15742 ; GFX7-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
15743 ; GFX7: ; %bb.0: ; %entry
15744 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
15745 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
15746 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
15747 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
15748 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
15749 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
15750 ; GFX7-NEXT: s_mov_b32 s4, s8
15751 ; GFX7-NEXT: s_mov_b32 s5, s9
15752 ; GFX7-NEXT: s_mov_b32 s9, s10
15753 ; GFX7-NEXT: s_mov_b32 s8, s11
15754 ; GFX7-NEXT: s_add_u32 s4, s4, s9
15755 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
15756 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
15757 ; GFX7-NEXT: s_mov_b32 s5, s8
15758 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
15759 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
15760 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15761 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
15762 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
15763 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
15764 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
15765 ; GFX7-NEXT: s_endpgm
15767 ; GFX10-WGP-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
15768 ; GFX10-WGP: ; %bb.0: ; %entry
15769 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
15770 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
15771 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
15772 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
15773 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
15774 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
15775 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
15776 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
15777 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
15778 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
15779 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
15780 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
15781 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
15782 ; GFX10-WGP-NEXT: buffer_gl0_inv
15783 ; GFX10-WGP-NEXT: s_endpgm
15785 ; GFX10-CU-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
15786 ; GFX10-CU: ; %bb.0: ; %entry
15787 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
15788 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
15789 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
15790 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
15791 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
15792 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
15793 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
15794 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
15795 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
15796 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
15797 ; GFX10-CU-NEXT: s_endpgm
15799 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
15800 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
15801 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
15802 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
15803 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
15804 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
15805 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
15806 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
15807 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
15808 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
15809 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
15810 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
15811 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
15812 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
15813 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
15814 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
15815 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
15816 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
15817 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
15818 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
15819 ; SKIP-CACHE-INV-NEXT: s_endpgm
15821 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
15822 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
15823 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
15824 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
15825 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
15826 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
15827 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15828 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
15829 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
15830 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15831 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
15832 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
15833 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
15835 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
15836 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
15837 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
15838 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
15839 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
15840 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
15841 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15842 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
15843 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
15844 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15845 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
15846 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
15847 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
15848 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
15849 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
15850 ; GFX90A-TGSPLIT-NEXT: s_endpgm
15852 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
15853 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
15854 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
15855 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
15856 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
15857 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
15858 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15859 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
15860 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
15861 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15862 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
15863 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
15864 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
15866 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
15867 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
15868 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
15869 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
15870 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
15871 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
15872 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
15873 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
15874 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
15875 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15876 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
15877 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
15878 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
15879 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
15880 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
15881 ; GFX940-TGSPLIT-NEXT: s_endpgm
15883 ; GFX11-WGP-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
15884 ; GFX11-WGP: ; %bb.0: ; %entry
15885 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
15886 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15887 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
15888 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
15889 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
15890 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
15891 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
15892 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
15893 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
15894 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
15895 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
15896 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
15897 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
15898 ; GFX11-WGP-NEXT: buffer_gl0_inv
15899 ; GFX11-WGP-NEXT: s_endpgm
15901 ; GFX11-CU-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
15902 ; GFX11-CU: ; %bb.0: ; %entry
15903 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
15904 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15905 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
15906 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
15907 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
15908 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
15909 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
15910 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
15911 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
15912 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
15913 ; GFX11-CU-NEXT: s_endpgm
15915 ; GFX12-WGP-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
15916 ; GFX12-WGP: ; %bb.0: ; %entry
15917 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
15918 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15919 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
15920 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
15921 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
15922 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
15923 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
15924 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
15925 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
15926 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
15927 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
15928 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
15929 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
15930 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
15931 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
15932 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
15933 ; GFX12-WGP-NEXT: s_endpgm
15935 ; GFX12-CU-LABEL: global_workgroup_one_as_acquire_seq_cst_cmpxchg:
15936 ; GFX12-CU: ; %bb.0: ; %entry
15937 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
15938 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
15939 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
15940 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
15941 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
15942 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
15943 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
15944 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
15945 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
15946 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
15947 ; GFX12-CU-NEXT: s_endpgm
15948 ptr addrspace(1) %out, i32 %in, i32 %old) {
15950 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
15951 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acquire seq_cst
15955 define amdgpu_kernel void @global_workgroup_one_as_release_seq_cst_cmpxchg(
15956 ; GFX6-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
15957 ; GFX6: ; %bb.0: ; %entry
15958 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
15959 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
15960 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
15961 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
15962 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
15963 ; GFX6-NEXT: s_mov_b32 s12, s5
15964 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
15965 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
15966 ; GFX6-NEXT: s_mov_b32 s11, -1
15967 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
15968 ; GFX6-NEXT: s_mov_b32 s5, s12
15969 ; GFX6-NEXT: s_mov_b32 s6, s11
15970 ; GFX6-NEXT: s_mov_b32 s7, s10
15971 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
15972 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
15973 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
15974 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
15975 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
15976 ; GFX6-NEXT: s_endpgm
15978 ; GFX7-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
15979 ; GFX7: ; %bb.0: ; %entry
15980 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
15981 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
15982 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
15983 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
15984 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
15985 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
15986 ; GFX7-NEXT: s_mov_b32 s4, s8
15987 ; GFX7-NEXT: s_mov_b32 s5, s9
15988 ; GFX7-NEXT: s_mov_b32 s9, s10
15989 ; GFX7-NEXT: s_mov_b32 s8, s11
15990 ; GFX7-NEXT: s_add_u32 s4, s4, s9
15991 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
15992 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
15993 ; GFX7-NEXT: s_mov_b32 s5, s8
15994 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
15995 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
15996 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
15997 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
15998 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
15999 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
16000 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
16001 ; GFX7-NEXT: s_endpgm
16003 ; GFX10-WGP-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
16004 ; GFX10-WGP: ; %bb.0: ; %entry
16005 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
16006 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
16007 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
16008 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
16009 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
16010 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
16011 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
16012 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
16013 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
16014 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
16015 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
16016 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
16017 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
16018 ; GFX10-WGP-NEXT: buffer_gl0_inv
16019 ; GFX10-WGP-NEXT: s_endpgm
16021 ; GFX10-CU-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
16022 ; GFX10-CU: ; %bb.0: ; %entry
16023 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
16024 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
16025 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
16026 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
16027 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
16028 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
16029 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
16030 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
16031 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
16032 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
16033 ; GFX10-CU-NEXT: s_endpgm
16035 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
16036 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
16037 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
16038 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
16039 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
16040 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
16041 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
16042 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
16043 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
16044 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
16045 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
16046 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
16047 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
16048 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
16049 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
16050 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
16051 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
16052 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
16053 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
16054 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
16055 ; SKIP-CACHE-INV-NEXT: s_endpgm
16057 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
16058 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
16059 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
16060 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
16061 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
16062 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
16063 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16064 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
16065 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
16066 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16067 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
16068 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
16069 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
16071 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
16072 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
16073 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
16074 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
16075 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
16076 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
16077 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16078 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
16079 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
16080 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16081 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
16082 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
16083 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
16084 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
16085 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
16086 ; GFX90A-TGSPLIT-NEXT: s_endpgm
16088 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
16089 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
16090 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
16091 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
16092 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
16093 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
16094 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16095 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
16096 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
16097 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16098 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
16099 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
16100 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
16102 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
16103 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
16104 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
16105 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
16106 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
16107 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
16108 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16109 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
16110 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
16111 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16112 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
16113 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
16114 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
16115 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
16116 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
16117 ; GFX940-TGSPLIT-NEXT: s_endpgm
16119 ; GFX11-WGP-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
16120 ; GFX11-WGP: ; %bb.0: ; %entry
16121 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
16122 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16123 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
16124 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
16125 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
16126 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
16127 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
16128 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
16129 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
16130 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
16131 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
16132 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
16133 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
16134 ; GFX11-WGP-NEXT: buffer_gl0_inv
16135 ; GFX11-WGP-NEXT: s_endpgm
16137 ; GFX11-CU-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
16138 ; GFX11-CU: ; %bb.0: ; %entry
16139 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
16140 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16141 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
16142 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
16143 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
16144 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
16145 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
16146 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
16147 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
16148 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
16149 ; GFX11-CU-NEXT: s_endpgm
16151 ; GFX12-WGP-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
16152 ; GFX12-WGP: ; %bb.0: ; %entry
16153 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
16154 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16155 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
16156 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
16157 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
16158 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
16159 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
16160 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
16161 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
16162 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
16163 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
16164 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
16165 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
16166 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
16167 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
16168 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
16169 ; GFX12-WGP-NEXT: s_endpgm
16171 ; GFX12-CU-LABEL: global_workgroup_one_as_release_seq_cst_cmpxchg:
16172 ; GFX12-CU: ; %bb.0: ; %entry
16173 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
16174 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16175 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
16176 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
16177 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
16178 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
16179 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
16180 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
16181 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
16182 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
16183 ; GFX12-CU-NEXT: s_endpgm
16184 ptr addrspace(1) %out, i32 %in, i32 %old) {
16186 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
16187 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") release seq_cst
16191 define amdgpu_kernel void @global_workgroup_one_as_acq_rel_seq_cst_cmpxchg(
16192 ; GFX6-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
16193 ; GFX6: ; %bb.0: ; %entry
16194 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
16195 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
16196 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
16197 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
16198 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
16199 ; GFX6-NEXT: s_mov_b32 s12, s5
16200 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
16201 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
16202 ; GFX6-NEXT: s_mov_b32 s11, -1
16203 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
16204 ; GFX6-NEXT: s_mov_b32 s5, s12
16205 ; GFX6-NEXT: s_mov_b32 s6, s11
16206 ; GFX6-NEXT: s_mov_b32 s7, s10
16207 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
16208 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
16209 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
16210 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
16211 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
16212 ; GFX6-NEXT: s_endpgm
16214 ; GFX7-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
16215 ; GFX7: ; %bb.0: ; %entry
16216 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
16217 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
16218 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
16219 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
16220 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
16221 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
16222 ; GFX7-NEXT: s_mov_b32 s4, s8
16223 ; GFX7-NEXT: s_mov_b32 s5, s9
16224 ; GFX7-NEXT: s_mov_b32 s9, s10
16225 ; GFX7-NEXT: s_mov_b32 s8, s11
16226 ; GFX7-NEXT: s_add_u32 s4, s4, s9
16227 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
16228 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
16229 ; GFX7-NEXT: s_mov_b32 s5, s8
16230 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
16231 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
16232 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16233 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
16234 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
16235 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
16236 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
16237 ; GFX7-NEXT: s_endpgm
16239 ; GFX10-WGP-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
16240 ; GFX10-WGP: ; %bb.0: ; %entry
16241 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
16242 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
16243 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
16244 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
16245 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
16246 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
16247 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
16248 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
16249 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
16250 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
16251 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
16252 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
16253 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
16254 ; GFX10-WGP-NEXT: buffer_gl0_inv
16255 ; GFX10-WGP-NEXT: s_endpgm
16257 ; GFX10-CU-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
16258 ; GFX10-CU: ; %bb.0: ; %entry
16259 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
16260 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
16261 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
16262 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
16263 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
16264 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
16265 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
16266 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
16267 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
16268 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
16269 ; GFX10-CU-NEXT: s_endpgm
16271 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
16272 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
16273 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
16274 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
16275 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
16276 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
16277 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
16278 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
16279 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
16280 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
16281 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
16282 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
16283 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
16284 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
16285 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
16286 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
16287 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
16288 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
16289 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
16290 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
16291 ; SKIP-CACHE-INV-NEXT: s_endpgm
16293 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
16294 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
16295 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
16296 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
16297 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
16298 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
16299 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16300 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
16301 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
16302 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16303 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
16304 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
16305 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
16307 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
16308 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
16309 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
16310 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
16311 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
16312 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
16313 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16314 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
16315 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
16316 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16317 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
16318 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
16319 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
16320 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
16321 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
16322 ; GFX90A-TGSPLIT-NEXT: s_endpgm
16324 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
16325 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
16326 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
16327 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
16328 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
16329 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
16330 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16331 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
16332 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
16333 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16334 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
16335 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
16336 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
16338 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
16339 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
16340 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
16341 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
16342 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
16343 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
16344 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16345 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
16346 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
16347 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16348 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
16349 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
16350 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
16351 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
16352 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
16353 ; GFX940-TGSPLIT-NEXT: s_endpgm
16355 ; GFX11-WGP-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
16356 ; GFX11-WGP: ; %bb.0: ; %entry
16357 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
16358 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16359 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
16360 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
16361 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
16362 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
16363 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
16364 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
16365 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
16366 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
16367 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
16368 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
16369 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
16370 ; GFX11-WGP-NEXT: buffer_gl0_inv
16371 ; GFX11-WGP-NEXT: s_endpgm
16373 ; GFX11-CU-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
16374 ; GFX11-CU: ; %bb.0: ; %entry
16375 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
16376 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16377 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
16378 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
16379 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
16380 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
16381 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
16382 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
16383 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
16384 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
16385 ; GFX11-CU-NEXT: s_endpgm
16387 ; GFX12-WGP-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
16388 ; GFX12-WGP: ; %bb.0: ; %entry
16389 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
16390 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16391 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
16392 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
16393 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
16394 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
16395 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
16396 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
16397 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
16398 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
16399 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
16400 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
16401 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
16402 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
16403 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
16404 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
16405 ; GFX12-WGP-NEXT: s_endpgm
16407 ; GFX12-CU-LABEL: global_workgroup_one_as_acq_rel_seq_cst_cmpxchg:
16408 ; GFX12-CU: ; %bb.0: ; %entry
16409 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
16410 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16411 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
16412 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
16413 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
16414 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
16415 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
16416 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
16417 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
16418 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
16419 ; GFX12-CU-NEXT: s_endpgm
16420 ptr addrspace(1) %out, i32 %in, i32 %old) {
16422 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
16423 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acq_rel seq_cst
16427 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_seq_cst_cmpxchg(
16428 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
16429 ; GFX6: ; %bb.0: ; %entry
16430 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
16431 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
16432 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
16433 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
16434 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
16435 ; GFX6-NEXT: s_mov_b32 s12, s5
16436 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
16437 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
16438 ; GFX6-NEXT: s_mov_b32 s11, -1
16439 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
16440 ; GFX6-NEXT: s_mov_b32 s5, s12
16441 ; GFX6-NEXT: s_mov_b32 s6, s11
16442 ; GFX6-NEXT: s_mov_b32 s7, s10
16443 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
16444 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
16445 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
16446 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
16447 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16
16448 ; GFX6-NEXT: s_endpgm
16450 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
16451 ; GFX7: ; %bb.0: ; %entry
16452 ; GFX7-NEXT: s_mov_b64 s[4:5], s[8:9]
16453 ; GFX7-NEXT: s_load_dwordx2 s[8:9], s[4:5], 0x0
16454 ; GFX7-NEXT: s_load_dword s7, s[4:5], 0x2
16455 ; GFX7-NEXT: s_load_dword s6, s[4:5], 0x3
16456 ; GFX7-NEXT: s_mov_b64 s[10:11], 16
16457 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
16458 ; GFX7-NEXT: s_mov_b32 s4, s8
16459 ; GFX7-NEXT: s_mov_b32 s5, s9
16460 ; GFX7-NEXT: s_mov_b32 s9, s10
16461 ; GFX7-NEXT: s_mov_b32 s8, s11
16462 ; GFX7-NEXT: s_add_u32 s4, s4, s9
16463 ; GFX7-NEXT: s_addc_u32 s8, s5, s8
16464 ; GFX7-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5
16465 ; GFX7-NEXT: s_mov_b32 s5, s8
16466 ; GFX7-NEXT: v_mov_b32_e32 v2, s7
16467 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
16468 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16469 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
16470 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
16471 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
16472 ; GFX7-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
16473 ; GFX7-NEXT: s_endpgm
16475 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
16476 ; GFX10-WGP: ; %bb.0: ; %entry
16477 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
16478 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
16479 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
16480 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
16481 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
16482 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
16483 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
16484 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
16485 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
16486 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
16487 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
16488 ; GFX10-WGP-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
16489 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
16490 ; GFX10-WGP-NEXT: buffer_gl0_inv
16491 ; GFX10-WGP-NEXT: s_endpgm
16493 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
16494 ; GFX10-CU: ; %bb.0: ; %entry
16495 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
16496 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
16497 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
16498 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
16499 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
16500 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
16501 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
16502 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
16503 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
16504 ; GFX10-CU-NEXT: global_atomic_cmpswap v0, v[1:2], s[4:5] offset:16
16505 ; GFX10-CU-NEXT: s_endpgm
16507 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
16508 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
16509 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
16510 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
16511 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
16512 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
16513 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
16514 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
16515 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
16516 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
16517 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
16518 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
16519 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
16520 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
16521 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
16522 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
16523 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
16524 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
16525 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
16526 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16
16527 ; SKIP-CACHE-INV-NEXT: s_endpgm
16529 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
16530 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
16531 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
16532 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
16533 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
16534 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
16535 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16536 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
16537 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
16538 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16539 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
16540 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
16541 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
16543 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
16544 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
16545 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
16546 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
16547 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
16548 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
16549 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16550 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
16551 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
16552 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16553 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
16554 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
16555 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[4:5] offset:16
16556 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
16557 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
16558 ; GFX90A-TGSPLIT-NEXT: s_endpgm
16560 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
16561 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
16562 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
16563 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
16564 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
16565 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
16566 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16567 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
16568 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
16569 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16570 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
16571 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
16572 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
16574 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
16575 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
16576 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
16577 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
16578 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
16579 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
16580 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16581 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
16582 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
16583 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16584 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
16585 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
16586 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v0, v[2:3], s[0:1] offset:16
16587 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
16588 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
16589 ; GFX940-TGSPLIT-NEXT: s_endpgm
16591 ; GFX11-WGP-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
16592 ; GFX11-WGP: ; %bb.0: ; %entry
16593 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
16594 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16595 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
16596 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
16597 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
16598 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
16599 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
16600 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
16601 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
16602 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
16603 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
16604 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
16605 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
16606 ; GFX11-WGP-NEXT: buffer_gl0_inv
16607 ; GFX11-WGP-NEXT: s_endpgm
16609 ; GFX11-CU-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
16610 ; GFX11-CU: ; %bb.0: ; %entry
16611 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
16612 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16613 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
16614 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
16615 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
16616 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
16617 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
16618 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
16619 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
16620 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
16621 ; GFX11-CU-NEXT: s_endpgm
16623 ; GFX12-WGP-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
16624 ; GFX12-WGP: ; %bb.0: ; %entry
16625 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
16626 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16627 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
16628 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
16629 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
16630 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
16631 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
16632 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
16633 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
16634 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
16635 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
16636 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
16637 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
16638 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16 scope:SCOPE_SE
16639 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
16640 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
16641 ; GFX12-WGP-NEXT: s_endpgm
16643 ; GFX12-CU-LABEL: global_workgroup_one_as_seq_cst_seq_cst_cmpxchg:
16644 ; GFX12-CU: ; %bb.0: ; %entry
16645 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
16646 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16647 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
16648 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
16649 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
16650 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
16651 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
16652 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
16653 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
16654 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v0, v[1:2], s[0:1] offset:16
16655 ; GFX12-CU-NEXT: s_endpgm
16656 ptr addrspace(1) %out, i32 %in, i32 %old) {
16658 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
16659 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") seq_cst seq_cst
16663 define amdgpu_kernel void @global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg(
16664 ; GFX6-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
16665 ; GFX6: ; %bb.0: ; %entry
16666 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
16667 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
16668 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
16669 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
16670 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
16671 ; GFX6-NEXT: s_mov_b32 s12, s5
16672 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
16673 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
16674 ; GFX6-NEXT: s_mov_b32 s11, -1
16675 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
16676 ; GFX6-NEXT: s_mov_b32 s5, s12
16677 ; GFX6-NEXT: s_mov_b32 s6, s11
16678 ; GFX6-NEXT: s_mov_b32 s7, s10
16679 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
16680 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
16681 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
16682 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
16683 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
16684 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
16685 ; GFX6-NEXT: s_waitcnt vmcnt(0)
16686 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
16687 ; GFX6-NEXT: s_endpgm
16689 ; GFX7-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
16690 ; GFX7: ; %bb.0: ; %entry
16691 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
16692 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
16693 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
16694 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
16695 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
16696 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
16697 ; GFX7-NEXT: s_mov_b32 s6, s4
16698 ; GFX7-NEXT: s_mov_b32 s7, s5
16699 ; GFX7-NEXT: s_mov_b32 s11, s12
16700 ; GFX7-NEXT: s_mov_b32 s10, s13
16701 ; GFX7-NEXT: s_add_u32 s6, s6, s11
16702 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
16703 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
16704 ; GFX7-NEXT: s_mov_b32 s7, s10
16705 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
16706 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
16707 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16708 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
16709 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
16710 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
16711 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
16712 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
16713 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
16714 ; GFX7-NEXT: s_waitcnt vmcnt(0)
16715 ; GFX7-NEXT: flat_store_dword v[0:1], v2
16716 ; GFX7-NEXT: s_endpgm
16718 ; GFX10-WGP-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
16719 ; GFX10-WGP: ; %bb.0: ; %entry
16720 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
16721 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
16722 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
16723 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
16724 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
16725 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
16726 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
16727 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
16728 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
16729 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
16730 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
16731 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
16732 ; GFX10-WGP-NEXT: s_endpgm
16734 ; GFX10-CU-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
16735 ; GFX10-CU: ; %bb.0: ; %entry
16736 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
16737 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
16738 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
16739 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
16740 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
16741 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
16742 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
16743 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
16744 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
16745 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
16746 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
16747 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
16748 ; GFX10-CU-NEXT: s_endpgm
16750 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
16751 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
16752 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
16753 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
16754 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
16755 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
16756 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
16757 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
16758 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
16759 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
16760 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
16761 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
16762 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
16763 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
16764 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
16765 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
16766 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
16767 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
16768 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
16769 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
16770 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
16771 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
16772 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
16773 ; SKIP-CACHE-INV-NEXT: s_endpgm
16775 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
16776 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
16777 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
16778 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
16779 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
16780 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
16781 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16782 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
16783 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
16784 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16785 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
16786 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
16787 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
16788 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
16789 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
16791 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
16792 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
16793 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
16794 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
16795 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
16796 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
16797 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16798 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
16799 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
16800 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16801 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
16802 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
16803 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
16804 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
16805 ; GFX90A-TGSPLIT-NEXT: s_endpgm
16807 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
16808 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
16809 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
16810 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
16811 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
16812 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
16813 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16814 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
16815 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
16816 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16817 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
16818 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
16819 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
16820 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
16821 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
16823 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
16824 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
16825 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
16826 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
16827 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
16828 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
16829 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
16830 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
16831 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
16832 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16833 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
16834 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
16835 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
16836 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
16837 ; GFX940-TGSPLIT-NEXT: s_endpgm
16839 ; GFX11-WGP-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
16840 ; GFX11-WGP: ; %bb.0: ; %entry
16841 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
16842 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16843 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
16844 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
16845 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
16846 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
16847 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
16848 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
16849 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
16850 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
16851 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
16852 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
16853 ; GFX11-WGP-NEXT: s_endpgm
16855 ; GFX11-CU-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
16856 ; GFX11-CU: ; %bb.0: ; %entry
16857 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
16858 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16859 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
16860 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
16861 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
16862 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
16863 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
16864 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
16865 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
16866 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
16867 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
16868 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
16869 ; GFX11-CU-NEXT: s_endpgm
16871 ; GFX12-WGP-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
16872 ; GFX12-WGP: ; %bb.0: ; %entry
16873 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
16874 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16875 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
16876 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
16877 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
16878 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
16879 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
16880 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
16881 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
16882 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
16883 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
16884 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
16885 ; GFX12-WGP-NEXT: s_endpgm
16887 ; GFX12-CU-LABEL: global_workgroup_one_as_monotonic_monotonic_ret_cmpxchg:
16888 ; GFX12-CU: ; %bb.0: ; %entry
16889 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
16890 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
16891 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
16892 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
16893 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
16894 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
16895 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
16896 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
16897 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
16898 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
16899 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
16900 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
16901 ; GFX12-CU-NEXT: s_endpgm
16902 ptr addrspace(1) %out, i32 %in, i32 %old) {
16904 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
16905 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") monotonic monotonic
16906 %val0 = extractvalue { i32, i1 } %val, 0
16907 store i32 %val0, ptr addrspace(1) %out, align 4
16911 define amdgpu_kernel void @global_workgroup_one_as_acquire_monotonic_ret_cmpxchg(
16912 ; GFX6-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
16913 ; GFX6: ; %bb.0: ; %entry
16914 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
16915 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
16916 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
16917 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
16918 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
16919 ; GFX6-NEXT: s_mov_b32 s12, s5
16920 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
16921 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
16922 ; GFX6-NEXT: s_mov_b32 s11, -1
16923 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
16924 ; GFX6-NEXT: s_mov_b32 s5, s12
16925 ; GFX6-NEXT: s_mov_b32 s6, s11
16926 ; GFX6-NEXT: s_mov_b32 s7, s10
16927 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
16928 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
16929 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
16930 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
16931 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
16932 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
16933 ; GFX6-NEXT: s_waitcnt vmcnt(0)
16934 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
16935 ; GFX6-NEXT: s_endpgm
16937 ; GFX7-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
16938 ; GFX7: ; %bb.0: ; %entry
16939 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
16940 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
16941 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
16942 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
16943 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
16944 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
16945 ; GFX7-NEXT: s_mov_b32 s6, s4
16946 ; GFX7-NEXT: s_mov_b32 s7, s5
16947 ; GFX7-NEXT: s_mov_b32 s11, s12
16948 ; GFX7-NEXT: s_mov_b32 s10, s13
16949 ; GFX7-NEXT: s_add_u32 s6, s6, s11
16950 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
16951 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
16952 ; GFX7-NEXT: s_mov_b32 s7, s10
16953 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
16954 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
16955 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
16956 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
16957 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
16958 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
16959 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
16960 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
16961 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
16962 ; GFX7-NEXT: s_waitcnt vmcnt(0)
16963 ; GFX7-NEXT: flat_store_dword v[0:1], v2
16964 ; GFX7-NEXT: s_endpgm
16966 ; GFX10-WGP-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
16967 ; GFX10-WGP: ; %bb.0: ; %entry
16968 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
16969 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
16970 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
16971 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
16972 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
16973 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
16974 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
16975 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
16976 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
16977 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
16978 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
16979 ; GFX10-WGP-NEXT: buffer_gl0_inv
16980 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
16981 ; GFX10-WGP-NEXT: s_endpgm
16983 ; GFX10-CU-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
16984 ; GFX10-CU: ; %bb.0: ; %entry
16985 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
16986 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
16987 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
16988 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
16989 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
16990 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
16991 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
16992 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
16993 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
16994 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
16995 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
16996 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
16997 ; GFX10-CU-NEXT: s_endpgm
16999 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
17000 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
17001 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
17002 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
17003 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
17004 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
17005 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
17006 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
17007 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
17008 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
17009 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
17010 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
17011 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
17012 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
17013 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
17014 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
17015 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
17016 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
17017 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
17018 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
17019 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
17020 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
17021 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
17022 ; SKIP-CACHE-INV-NEXT: s_endpgm
17024 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
17025 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
17026 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
17027 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
17028 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
17029 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
17030 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
17031 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
17032 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
17033 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17034 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
17035 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
17036 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
17037 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
17038 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
17040 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
17041 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
17042 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
17043 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
17044 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
17045 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
17046 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
17047 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
17048 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
17049 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17050 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
17051 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
17052 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
17053 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
17054 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
17055 ; GFX90A-TGSPLIT-NEXT: s_endpgm
17057 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
17058 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
17059 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
17060 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
17061 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
17062 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
17063 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
17064 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
17065 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
17066 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17067 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
17068 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
17069 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
17070 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
17071 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
17073 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
17074 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
17075 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
17076 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
17077 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
17078 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
17079 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
17080 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
17081 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
17082 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17083 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
17084 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
17085 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
17086 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
17087 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
17088 ; GFX940-TGSPLIT-NEXT: s_endpgm
17090 ; GFX11-WGP-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
17091 ; GFX11-WGP: ; %bb.0: ; %entry
17092 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
17093 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17094 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
17095 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
17096 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
17097 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
17098 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
17099 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
17100 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
17101 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
17102 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
17103 ; GFX11-WGP-NEXT: buffer_gl0_inv
17104 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
17105 ; GFX11-WGP-NEXT: s_endpgm
17107 ; GFX11-CU-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
17108 ; GFX11-CU: ; %bb.0: ; %entry
17109 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
17110 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17111 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
17112 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
17113 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
17114 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
17115 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
17116 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
17117 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
17118 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
17119 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
17120 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
17121 ; GFX11-CU-NEXT: s_endpgm
17123 ; GFX12-WGP-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
17124 ; GFX12-WGP: ; %bb.0: ; %entry
17125 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
17126 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17127 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
17128 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
17129 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
17130 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
17131 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
17132 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
17133 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
17134 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
17135 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
17136 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
17137 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
17138 ; GFX12-WGP-NEXT: s_endpgm
17140 ; GFX12-CU-LABEL: global_workgroup_one_as_acquire_monotonic_ret_cmpxchg:
17141 ; GFX12-CU: ; %bb.0: ; %entry
17142 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
17143 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17144 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
17145 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
17146 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
17147 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
17148 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
17149 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
17150 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
17151 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
17152 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
17153 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
17154 ; GFX12-CU-NEXT: s_endpgm
17155 ptr addrspace(1) %out, i32 %in, i32 %old) {
17157 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
17158 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acquire monotonic
17159 %val0 = extractvalue { i32, i1 } %val, 0
17160 store i32 %val0, ptr addrspace(1) %out, align 4
17164 define amdgpu_kernel void @global_workgroup_one_as_release_monotonic_ret_cmpxchg(
17165 ; GFX6-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
17166 ; GFX6: ; %bb.0: ; %entry
17167 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
17168 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
17169 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
17170 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
17171 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
17172 ; GFX6-NEXT: s_mov_b32 s12, s5
17173 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
17174 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
17175 ; GFX6-NEXT: s_mov_b32 s11, -1
17176 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
17177 ; GFX6-NEXT: s_mov_b32 s5, s12
17178 ; GFX6-NEXT: s_mov_b32 s6, s11
17179 ; GFX6-NEXT: s_mov_b32 s7, s10
17180 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
17181 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
17182 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
17183 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
17184 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
17185 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
17186 ; GFX6-NEXT: s_waitcnt vmcnt(0)
17187 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
17188 ; GFX6-NEXT: s_endpgm
17190 ; GFX7-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
17191 ; GFX7: ; %bb.0: ; %entry
17192 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
17193 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
17194 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
17195 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
17196 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
17197 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
17198 ; GFX7-NEXT: s_mov_b32 s6, s4
17199 ; GFX7-NEXT: s_mov_b32 s7, s5
17200 ; GFX7-NEXT: s_mov_b32 s11, s12
17201 ; GFX7-NEXT: s_mov_b32 s10, s13
17202 ; GFX7-NEXT: s_add_u32 s6, s6, s11
17203 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
17204 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
17205 ; GFX7-NEXT: s_mov_b32 s7, s10
17206 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
17207 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
17208 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17209 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
17210 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
17211 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
17212 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
17213 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
17214 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
17215 ; GFX7-NEXT: s_waitcnt vmcnt(0)
17216 ; GFX7-NEXT: flat_store_dword v[0:1], v2
17217 ; GFX7-NEXT: s_endpgm
17219 ; GFX10-WGP-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
17220 ; GFX10-WGP: ; %bb.0: ; %entry
17221 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
17222 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
17223 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
17224 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
17225 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
17226 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
17227 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
17228 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
17229 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
17230 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
17231 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
17232 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
17233 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
17234 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
17235 ; GFX10-WGP-NEXT: s_endpgm
17237 ; GFX10-CU-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
17238 ; GFX10-CU: ; %bb.0: ; %entry
17239 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
17240 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
17241 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
17242 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
17243 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
17244 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
17245 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
17246 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
17247 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
17248 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
17249 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
17250 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
17251 ; GFX10-CU-NEXT: s_endpgm
17253 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
17254 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
17255 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
17256 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
17257 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
17258 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
17259 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
17260 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
17261 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
17262 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
17263 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
17264 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
17265 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
17266 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
17267 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
17268 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
17269 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
17270 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
17271 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
17272 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
17273 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
17274 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
17275 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
17276 ; SKIP-CACHE-INV-NEXT: s_endpgm
17278 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
17279 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
17280 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
17281 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
17282 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
17283 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
17284 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
17285 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
17286 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
17287 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17288 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
17289 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
17290 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
17291 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
17292 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
17294 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
17295 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
17296 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
17297 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
17298 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
17299 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
17300 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
17301 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
17302 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
17303 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17304 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
17305 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
17306 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
17307 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
17308 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
17309 ; GFX90A-TGSPLIT-NEXT: s_endpgm
17311 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
17312 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
17313 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
17314 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
17315 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
17316 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
17317 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
17318 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
17319 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
17320 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17321 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
17322 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
17323 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
17324 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
17325 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
17327 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
17328 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
17329 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
17330 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
17331 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
17332 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
17333 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
17334 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
17335 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
17336 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17337 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
17338 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
17339 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
17340 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
17341 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
17342 ; GFX940-TGSPLIT-NEXT: s_endpgm
17344 ; GFX11-WGP-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
17345 ; GFX11-WGP: ; %bb.0: ; %entry
17346 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
17347 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17348 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
17349 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
17350 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
17351 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
17352 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
17353 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
17354 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
17355 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
17356 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
17357 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
17358 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
17359 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
17360 ; GFX11-WGP-NEXT: s_endpgm
17362 ; GFX11-CU-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
17363 ; GFX11-CU: ; %bb.0: ; %entry
17364 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
17365 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17366 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
17367 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
17368 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
17369 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
17370 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
17371 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
17372 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
17373 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
17374 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
17375 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
17376 ; GFX11-CU-NEXT: s_endpgm
17378 ; GFX12-WGP-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
17379 ; GFX12-WGP: ; %bb.0: ; %entry
17380 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
17381 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17382 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
17383 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
17384 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
17385 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
17386 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
17387 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
17388 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
17389 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
17390 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
17391 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
17392 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
17393 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
17394 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
17395 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
17396 ; GFX12-WGP-NEXT: s_endpgm
17398 ; GFX12-CU-LABEL: global_workgroup_one_as_release_monotonic_ret_cmpxchg:
17399 ; GFX12-CU: ; %bb.0: ; %entry
17400 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
17401 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17402 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
17403 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
17404 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
17405 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
17406 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
17407 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
17408 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
17409 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
17410 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
17411 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
17412 ; GFX12-CU-NEXT: s_endpgm
17413 ptr addrspace(1) %out, i32 %in, i32 %old) {
17415 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
17416 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") release monotonic
17417 %val0 = extractvalue { i32, i1 } %val, 0
17418 store i32 %val0, ptr addrspace(1) %out, align 4
17422 define amdgpu_kernel void @global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg(
17423 ; GFX6-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
17424 ; GFX6: ; %bb.0: ; %entry
17425 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
17426 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
17427 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
17428 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
17429 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
17430 ; GFX6-NEXT: s_mov_b32 s12, s5
17431 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
17432 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
17433 ; GFX6-NEXT: s_mov_b32 s11, -1
17434 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
17435 ; GFX6-NEXT: s_mov_b32 s5, s12
17436 ; GFX6-NEXT: s_mov_b32 s6, s11
17437 ; GFX6-NEXT: s_mov_b32 s7, s10
17438 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
17439 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
17440 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
17441 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
17442 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
17443 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
17444 ; GFX6-NEXT: s_waitcnt vmcnt(0)
17445 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
17446 ; GFX6-NEXT: s_endpgm
17448 ; GFX7-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
17449 ; GFX7: ; %bb.0: ; %entry
17450 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
17451 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
17452 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
17453 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
17454 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
17455 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
17456 ; GFX7-NEXT: s_mov_b32 s6, s4
17457 ; GFX7-NEXT: s_mov_b32 s7, s5
17458 ; GFX7-NEXT: s_mov_b32 s11, s12
17459 ; GFX7-NEXT: s_mov_b32 s10, s13
17460 ; GFX7-NEXT: s_add_u32 s6, s6, s11
17461 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
17462 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
17463 ; GFX7-NEXT: s_mov_b32 s7, s10
17464 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
17465 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
17466 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17467 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
17468 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
17469 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
17470 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
17471 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
17472 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
17473 ; GFX7-NEXT: s_waitcnt vmcnt(0)
17474 ; GFX7-NEXT: flat_store_dword v[0:1], v2
17475 ; GFX7-NEXT: s_endpgm
17477 ; GFX10-WGP-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
17478 ; GFX10-WGP: ; %bb.0: ; %entry
17479 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
17480 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
17481 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
17482 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
17483 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
17484 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
17485 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
17486 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
17487 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
17488 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
17489 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
17490 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
17491 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
17492 ; GFX10-WGP-NEXT: buffer_gl0_inv
17493 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
17494 ; GFX10-WGP-NEXT: s_endpgm
17496 ; GFX10-CU-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
17497 ; GFX10-CU: ; %bb.0: ; %entry
17498 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
17499 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
17500 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
17501 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
17502 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
17503 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
17504 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
17505 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
17506 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
17507 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
17508 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
17509 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
17510 ; GFX10-CU-NEXT: s_endpgm
17512 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
17513 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
17514 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
17515 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
17516 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
17517 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
17518 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
17519 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
17520 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
17521 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
17522 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
17523 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
17524 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
17525 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
17526 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
17527 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
17528 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
17529 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
17530 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
17531 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
17532 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
17533 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
17534 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
17535 ; SKIP-CACHE-INV-NEXT: s_endpgm
17537 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
17538 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
17539 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
17540 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
17541 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
17542 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
17543 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
17544 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
17545 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
17546 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17547 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
17548 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
17549 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
17550 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
17551 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
17553 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
17554 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
17555 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
17556 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
17557 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
17558 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
17559 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
17560 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
17561 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
17562 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17563 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
17564 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
17565 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
17566 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
17567 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
17568 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
17569 ; GFX90A-TGSPLIT-NEXT: s_endpgm
17571 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
17572 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
17573 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
17574 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
17575 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
17576 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
17577 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
17578 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
17579 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
17580 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17581 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
17582 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
17583 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
17584 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
17585 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
17587 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
17588 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
17589 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
17590 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
17591 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
17592 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
17593 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
17594 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
17595 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
17596 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17597 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
17598 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
17599 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
17600 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
17601 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
17602 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
17603 ; GFX940-TGSPLIT-NEXT: s_endpgm
17605 ; GFX11-WGP-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
17606 ; GFX11-WGP: ; %bb.0: ; %entry
17607 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
17608 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17609 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
17610 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
17611 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
17612 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
17613 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
17614 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
17615 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
17616 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
17617 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
17618 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
17619 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
17620 ; GFX11-WGP-NEXT: buffer_gl0_inv
17621 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
17622 ; GFX11-WGP-NEXT: s_endpgm
17624 ; GFX11-CU-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
17625 ; GFX11-CU: ; %bb.0: ; %entry
17626 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
17627 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17628 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
17629 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
17630 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
17631 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
17632 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
17633 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
17634 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
17635 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
17636 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
17637 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
17638 ; GFX11-CU-NEXT: s_endpgm
17640 ; GFX12-WGP-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
17641 ; GFX12-WGP: ; %bb.0: ; %entry
17642 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
17643 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17644 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
17645 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
17646 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
17647 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
17648 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
17649 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
17650 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
17651 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
17652 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
17653 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
17654 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
17655 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
17656 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
17657 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
17658 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
17659 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
17660 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
17661 ; GFX12-WGP-NEXT: s_endpgm
17663 ; GFX12-CU-LABEL: global_workgroup_one_as_acq_rel_monotonic_ret_cmpxchg:
17664 ; GFX12-CU: ; %bb.0: ; %entry
17665 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
17666 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17667 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
17668 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
17669 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
17670 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
17671 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
17672 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
17673 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
17674 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
17675 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
17676 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
17677 ; GFX12-CU-NEXT: s_endpgm
17678 ptr addrspace(1) %out, i32 %in, i32 %old) {
17680 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
17681 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acq_rel monotonic
17682 %val0 = extractvalue { i32, i1 } %val, 0
17683 store i32 %val0, ptr addrspace(1) %out, align 4
17687 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg(
17688 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
17689 ; GFX6: ; %bb.0: ; %entry
17690 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
17691 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
17692 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
17693 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
17694 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
17695 ; GFX6-NEXT: s_mov_b32 s12, s5
17696 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
17697 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
17698 ; GFX6-NEXT: s_mov_b32 s11, -1
17699 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
17700 ; GFX6-NEXT: s_mov_b32 s5, s12
17701 ; GFX6-NEXT: s_mov_b32 s6, s11
17702 ; GFX6-NEXT: s_mov_b32 s7, s10
17703 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
17704 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
17705 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
17706 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
17707 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
17708 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
17709 ; GFX6-NEXT: s_waitcnt vmcnt(0)
17710 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
17711 ; GFX6-NEXT: s_endpgm
17713 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
17714 ; GFX7: ; %bb.0: ; %entry
17715 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
17716 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
17717 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
17718 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
17719 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
17720 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
17721 ; GFX7-NEXT: s_mov_b32 s6, s4
17722 ; GFX7-NEXT: s_mov_b32 s7, s5
17723 ; GFX7-NEXT: s_mov_b32 s11, s12
17724 ; GFX7-NEXT: s_mov_b32 s10, s13
17725 ; GFX7-NEXT: s_add_u32 s6, s6, s11
17726 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
17727 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
17728 ; GFX7-NEXT: s_mov_b32 s7, s10
17729 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
17730 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
17731 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17732 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
17733 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
17734 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
17735 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
17736 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
17737 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
17738 ; GFX7-NEXT: s_waitcnt vmcnt(0)
17739 ; GFX7-NEXT: flat_store_dword v[0:1], v2
17740 ; GFX7-NEXT: s_endpgm
17742 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
17743 ; GFX10-WGP: ; %bb.0: ; %entry
17744 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
17745 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
17746 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
17747 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
17748 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
17749 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
17750 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
17751 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
17752 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
17753 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
17754 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
17755 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
17756 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
17757 ; GFX10-WGP-NEXT: buffer_gl0_inv
17758 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
17759 ; GFX10-WGP-NEXT: s_endpgm
17761 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
17762 ; GFX10-CU: ; %bb.0: ; %entry
17763 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
17764 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
17765 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
17766 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
17767 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
17768 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
17769 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
17770 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
17771 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
17772 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
17773 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
17774 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
17775 ; GFX10-CU-NEXT: s_endpgm
17777 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
17778 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
17779 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
17780 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
17781 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
17782 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
17783 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
17784 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
17785 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
17786 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
17787 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
17788 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
17789 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
17790 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
17791 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
17792 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
17793 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
17794 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
17795 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
17796 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
17797 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
17798 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
17799 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
17800 ; SKIP-CACHE-INV-NEXT: s_endpgm
17802 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
17803 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
17804 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
17805 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
17806 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
17807 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
17808 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
17809 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
17810 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
17811 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17812 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
17813 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
17814 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
17815 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
17816 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
17818 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
17819 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
17820 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
17821 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
17822 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
17823 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
17824 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
17825 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
17826 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
17827 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17828 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
17829 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
17830 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
17831 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
17832 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
17833 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
17834 ; GFX90A-TGSPLIT-NEXT: s_endpgm
17836 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
17837 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
17838 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
17839 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
17840 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
17841 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
17842 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
17843 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
17844 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
17845 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17846 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
17847 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
17848 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
17849 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
17850 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
17852 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
17853 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
17854 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
17855 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
17856 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
17857 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
17858 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
17859 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
17860 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
17861 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17862 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
17863 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
17864 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
17865 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
17866 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
17867 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
17868 ; GFX940-TGSPLIT-NEXT: s_endpgm
17870 ; GFX11-WGP-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
17871 ; GFX11-WGP: ; %bb.0: ; %entry
17872 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
17873 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17874 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
17875 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
17876 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
17877 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
17878 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
17879 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
17880 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
17881 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
17882 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
17883 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
17884 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
17885 ; GFX11-WGP-NEXT: buffer_gl0_inv
17886 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
17887 ; GFX11-WGP-NEXT: s_endpgm
17889 ; GFX11-CU-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
17890 ; GFX11-CU: ; %bb.0: ; %entry
17891 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
17892 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17893 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
17894 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
17895 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
17896 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
17897 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
17898 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
17899 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
17900 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
17901 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
17902 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
17903 ; GFX11-CU-NEXT: s_endpgm
17905 ; GFX12-WGP-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
17906 ; GFX12-WGP: ; %bb.0: ; %entry
17907 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
17908 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17909 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
17910 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
17911 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
17912 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
17913 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
17914 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
17915 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
17916 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
17917 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
17918 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
17919 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
17920 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
17921 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
17922 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
17923 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
17924 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
17925 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
17926 ; GFX12-WGP-NEXT: s_endpgm
17928 ; GFX12-CU-LABEL: global_workgroup_one_as_seq_cst_monotonic_ret_cmpxchg:
17929 ; GFX12-CU: ; %bb.0: ; %entry
17930 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
17931 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
17932 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
17933 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
17934 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
17935 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
17936 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
17937 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
17938 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
17939 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
17940 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
17941 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
17942 ; GFX12-CU-NEXT: s_endpgm
17943 ptr addrspace(1) %out, i32 %in, i32 %old) {
17945 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
17946 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") seq_cst monotonic
17947 %val0 = extractvalue { i32, i1 } %val, 0
17948 store i32 %val0, ptr addrspace(1) %out, align 4
17952 define amdgpu_kernel void @global_workgroup_one_as_monotonic_acquire_ret_cmpxchg(
17953 ; GFX6-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
17954 ; GFX6: ; %bb.0: ; %entry
17955 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
17956 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
17957 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
17958 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
17959 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
17960 ; GFX6-NEXT: s_mov_b32 s12, s5
17961 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
17962 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
17963 ; GFX6-NEXT: s_mov_b32 s11, -1
17964 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
17965 ; GFX6-NEXT: s_mov_b32 s5, s12
17966 ; GFX6-NEXT: s_mov_b32 s6, s11
17967 ; GFX6-NEXT: s_mov_b32 s7, s10
17968 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
17969 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
17970 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
17971 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
17972 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
17973 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
17974 ; GFX6-NEXT: s_waitcnt vmcnt(0)
17975 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
17976 ; GFX6-NEXT: s_endpgm
17978 ; GFX7-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
17979 ; GFX7: ; %bb.0: ; %entry
17980 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
17981 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
17982 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
17983 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
17984 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
17985 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
17986 ; GFX7-NEXT: s_mov_b32 s6, s4
17987 ; GFX7-NEXT: s_mov_b32 s7, s5
17988 ; GFX7-NEXT: s_mov_b32 s11, s12
17989 ; GFX7-NEXT: s_mov_b32 s10, s13
17990 ; GFX7-NEXT: s_add_u32 s6, s6, s11
17991 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
17992 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
17993 ; GFX7-NEXT: s_mov_b32 s7, s10
17994 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
17995 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
17996 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
17997 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
17998 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
17999 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
18000 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
18001 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
18002 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
18003 ; GFX7-NEXT: s_waitcnt vmcnt(0)
18004 ; GFX7-NEXT: flat_store_dword v[0:1], v2
18005 ; GFX7-NEXT: s_endpgm
18007 ; GFX10-WGP-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
18008 ; GFX10-WGP: ; %bb.0: ; %entry
18009 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
18010 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
18011 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
18012 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
18013 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
18014 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
18015 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
18016 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
18017 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
18018 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
18019 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
18020 ; GFX10-WGP-NEXT: buffer_gl0_inv
18021 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
18022 ; GFX10-WGP-NEXT: s_endpgm
18024 ; GFX10-CU-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
18025 ; GFX10-CU: ; %bb.0: ; %entry
18026 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
18027 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
18028 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
18029 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
18030 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
18031 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
18032 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
18033 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
18034 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
18035 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
18036 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
18037 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
18038 ; GFX10-CU-NEXT: s_endpgm
18040 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
18041 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
18042 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
18043 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
18044 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
18045 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
18046 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
18047 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
18048 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
18049 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
18050 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
18051 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
18052 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
18053 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
18054 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
18055 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
18056 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
18057 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
18058 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
18059 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
18060 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
18061 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
18062 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
18063 ; SKIP-CACHE-INV-NEXT: s_endpgm
18065 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
18066 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
18067 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
18068 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
18069 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
18070 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
18071 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18072 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
18073 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
18074 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18075 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
18076 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
18077 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
18078 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
18079 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
18081 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
18082 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
18083 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
18084 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
18085 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
18086 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
18087 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18088 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
18089 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
18090 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18091 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
18092 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
18093 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
18094 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
18095 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
18096 ; GFX90A-TGSPLIT-NEXT: s_endpgm
18098 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
18099 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
18100 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
18101 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
18102 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
18103 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
18104 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18105 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
18106 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
18107 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18108 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
18109 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
18110 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
18111 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
18112 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
18114 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
18115 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
18116 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
18117 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
18118 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
18119 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
18120 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18121 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
18122 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
18123 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18124 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
18125 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
18126 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
18127 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
18128 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
18129 ; GFX940-TGSPLIT-NEXT: s_endpgm
18131 ; GFX11-WGP-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
18132 ; GFX11-WGP: ; %bb.0: ; %entry
18133 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
18134 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18135 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
18136 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
18137 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
18138 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
18139 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
18140 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
18141 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
18142 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
18143 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
18144 ; GFX11-WGP-NEXT: buffer_gl0_inv
18145 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
18146 ; GFX11-WGP-NEXT: s_endpgm
18148 ; GFX11-CU-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
18149 ; GFX11-CU: ; %bb.0: ; %entry
18150 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
18151 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18152 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
18153 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
18154 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
18155 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
18156 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
18157 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
18158 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
18159 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
18160 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
18161 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
18162 ; GFX11-CU-NEXT: s_endpgm
18164 ; GFX12-WGP-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
18165 ; GFX12-WGP: ; %bb.0: ; %entry
18166 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
18167 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18168 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
18169 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
18170 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
18171 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
18172 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
18173 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
18174 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
18175 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
18176 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
18177 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
18178 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
18179 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
18180 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
18181 ; GFX12-WGP-NEXT: s_endpgm
18183 ; GFX12-CU-LABEL: global_workgroup_one_as_monotonic_acquire_ret_cmpxchg:
18184 ; GFX12-CU: ; %bb.0: ; %entry
18185 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
18186 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18187 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
18188 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
18189 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
18190 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
18191 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
18192 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
18193 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
18194 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
18195 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
18196 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
18197 ; GFX12-CU-NEXT: s_endpgm
18198 ptr addrspace(1) %out, i32 %in, i32 %old) {
18200 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
18201 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") monotonic acquire
18202 %val0 = extractvalue { i32, i1 } %val, 0
18203 store i32 %val0, ptr addrspace(1) %out, align 4
18207 define amdgpu_kernel void @global_workgroup_one_as_acquire_acquire_ret_cmpxchg(
18208 ; GFX6-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
18209 ; GFX6: ; %bb.0: ; %entry
18210 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
18211 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
18212 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
18213 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
18214 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
18215 ; GFX6-NEXT: s_mov_b32 s12, s5
18216 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
18217 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
18218 ; GFX6-NEXT: s_mov_b32 s11, -1
18219 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
18220 ; GFX6-NEXT: s_mov_b32 s5, s12
18221 ; GFX6-NEXT: s_mov_b32 s6, s11
18222 ; GFX6-NEXT: s_mov_b32 s7, s10
18223 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
18224 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
18225 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
18226 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
18227 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
18228 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
18229 ; GFX6-NEXT: s_waitcnt vmcnt(0)
18230 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
18231 ; GFX6-NEXT: s_endpgm
18233 ; GFX7-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
18234 ; GFX7: ; %bb.0: ; %entry
18235 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
18236 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
18237 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
18238 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
18239 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
18240 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
18241 ; GFX7-NEXT: s_mov_b32 s6, s4
18242 ; GFX7-NEXT: s_mov_b32 s7, s5
18243 ; GFX7-NEXT: s_mov_b32 s11, s12
18244 ; GFX7-NEXT: s_mov_b32 s10, s13
18245 ; GFX7-NEXT: s_add_u32 s6, s6, s11
18246 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
18247 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
18248 ; GFX7-NEXT: s_mov_b32 s7, s10
18249 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
18250 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
18251 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18252 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
18253 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
18254 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
18255 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
18256 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
18257 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
18258 ; GFX7-NEXT: s_waitcnt vmcnt(0)
18259 ; GFX7-NEXT: flat_store_dword v[0:1], v2
18260 ; GFX7-NEXT: s_endpgm
18262 ; GFX10-WGP-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
18263 ; GFX10-WGP: ; %bb.0: ; %entry
18264 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
18265 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
18266 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
18267 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
18268 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
18269 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
18270 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
18271 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
18272 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
18273 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
18274 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
18275 ; GFX10-WGP-NEXT: buffer_gl0_inv
18276 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
18277 ; GFX10-WGP-NEXT: s_endpgm
18279 ; GFX10-CU-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
18280 ; GFX10-CU: ; %bb.0: ; %entry
18281 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
18282 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
18283 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
18284 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
18285 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
18286 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
18287 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
18288 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
18289 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
18290 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
18291 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
18292 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
18293 ; GFX10-CU-NEXT: s_endpgm
18295 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
18296 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
18297 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
18298 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
18299 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
18300 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
18301 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
18302 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
18303 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
18304 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
18305 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
18306 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
18307 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
18308 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
18309 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
18310 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
18311 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
18312 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
18313 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
18314 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
18315 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
18316 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
18317 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
18318 ; SKIP-CACHE-INV-NEXT: s_endpgm
18320 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
18321 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
18322 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
18323 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
18324 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
18325 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
18326 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18327 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
18328 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
18329 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18330 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
18331 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
18332 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
18333 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
18334 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
18336 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
18337 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
18338 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
18339 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
18340 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
18341 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
18342 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18343 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
18344 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
18345 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18346 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
18347 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
18348 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
18349 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
18350 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
18351 ; GFX90A-TGSPLIT-NEXT: s_endpgm
18353 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
18354 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
18355 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
18356 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
18357 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
18358 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
18359 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18360 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
18361 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
18362 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18363 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
18364 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
18365 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
18366 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
18367 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
18369 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
18370 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
18371 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
18372 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
18373 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
18374 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
18375 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18376 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
18377 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
18378 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18379 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
18380 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
18381 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
18382 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
18383 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
18384 ; GFX940-TGSPLIT-NEXT: s_endpgm
18386 ; GFX11-WGP-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
18387 ; GFX11-WGP: ; %bb.0: ; %entry
18388 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
18389 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18390 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
18391 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
18392 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
18393 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
18394 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
18395 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
18396 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
18397 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
18398 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
18399 ; GFX11-WGP-NEXT: buffer_gl0_inv
18400 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
18401 ; GFX11-WGP-NEXT: s_endpgm
18403 ; GFX11-CU-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
18404 ; GFX11-CU: ; %bb.0: ; %entry
18405 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
18406 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18407 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
18408 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
18409 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
18410 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
18411 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
18412 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
18413 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
18414 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
18415 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
18416 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
18417 ; GFX11-CU-NEXT: s_endpgm
18419 ; GFX12-WGP-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
18420 ; GFX12-WGP: ; %bb.0: ; %entry
18421 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
18422 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18423 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
18424 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
18425 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
18426 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
18427 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
18428 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
18429 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
18430 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
18431 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
18432 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
18433 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
18434 ; GFX12-WGP-NEXT: s_endpgm
18436 ; GFX12-CU-LABEL: global_workgroup_one_as_acquire_acquire_ret_cmpxchg:
18437 ; GFX12-CU: ; %bb.0: ; %entry
18438 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
18439 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18440 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
18441 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
18442 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
18443 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
18444 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
18445 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
18446 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
18447 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
18448 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
18449 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
18450 ; GFX12-CU-NEXT: s_endpgm
18451 ptr addrspace(1) %out, i32 %in, i32 %old) {
18453 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
18454 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acquire acquire
18455 %val0 = extractvalue { i32, i1 } %val, 0
18456 store i32 %val0, ptr addrspace(1) %out, align 4
18460 define amdgpu_kernel void @global_workgroup_one_as_release_acquire_ret_cmpxchg(
18461 ; GFX6-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
18462 ; GFX6: ; %bb.0: ; %entry
18463 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
18464 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
18465 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
18466 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
18467 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
18468 ; GFX6-NEXT: s_mov_b32 s12, s5
18469 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
18470 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
18471 ; GFX6-NEXT: s_mov_b32 s11, -1
18472 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
18473 ; GFX6-NEXT: s_mov_b32 s5, s12
18474 ; GFX6-NEXT: s_mov_b32 s6, s11
18475 ; GFX6-NEXT: s_mov_b32 s7, s10
18476 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
18477 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
18478 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
18479 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
18480 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
18481 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
18482 ; GFX6-NEXT: s_waitcnt vmcnt(0)
18483 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
18484 ; GFX6-NEXT: s_endpgm
18486 ; GFX7-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
18487 ; GFX7: ; %bb.0: ; %entry
18488 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
18489 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
18490 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
18491 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
18492 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
18493 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
18494 ; GFX7-NEXT: s_mov_b32 s6, s4
18495 ; GFX7-NEXT: s_mov_b32 s7, s5
18496 ; GFX7-NEXT: s_mov_b32 s11, s12
18497 ; GFX7-NEXT: s_mov_b32 s10, s13
18498 ; GFX7-NEXT: s_add_u32 s6, s6, s11
18499 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
18500 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
18501 ; GFX7-NEXT: s_mov_b32 s7, s10
18502 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
18503 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
18504 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18505 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
18506 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
18507 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
18508 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
18509 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
18510 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
18511 ; GFX7-NEXT: s_waitcnt vmcnt(0)
18512 ; GFX7-NEXT: flat_store_dword v[0:1], v2
18513 ; GFX7-NEXT: s_endpgm
18515 ; GFX10-WGP-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
18516 ; GFX10-WGP: ; %bb.0: ; %entry
18517 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
18518 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
18519 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
18520 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
18521 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
18522 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
18523 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
18524 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
18525 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
18526 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
18527 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
18528 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
18529 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
18530 ; GFX10-WGP-NEXT: buffer_gl0_inv
18531 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
18532 ; GFX10-WGP-NEXT: s_endpgm
18534 ; GFX10-CU-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
18535 ; GFX10-CU: ; %bb.0: ; %entry
18536 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
18537 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
18538 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
18539 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
18540 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
18541 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
18542 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
18543 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
18544 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
18545 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
18546 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
18547 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
18548 ; GFX10-CU-NEXT: s_endpgm
18550 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
18551 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
18552 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
18553 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
18554 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
18555 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
18556 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
18557 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
18558 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
18559 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
18560 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
18561 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
18562 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
18563 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
18564 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
18565 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
18566 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
18567 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
18568 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
18569 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
18570 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
18571 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
18572 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
18573 ; SKIP-CACHE-INV-NEXT: s_endpgm
18575 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
18576 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
18577 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
18578 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
18579 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
18580 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
18581 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18582 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
18583 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
18584 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18585 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
18586 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
18587 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
18588 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
18589 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
18591 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
18592 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
18593 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
18594 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
18595 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
18596 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
18597 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18598 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
18599 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
18600 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18601 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
18602 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
18603 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
18604 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
18605 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
18606 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
18607 ; GFX90A-TGSPLIT-NEXT: s_endpgm
18609 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
18610 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
18611 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
18612 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
18613 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
18614 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
18615 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18616 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
18617 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
18618 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18619 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
18620 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
18621 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
18622 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
18623 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
18625 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
18626 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
18627 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
18628 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
18629 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
18630 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
18631 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18632 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
18633 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
18634 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18635 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
18636 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
18637 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
18638 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
18639 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
18640 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
18641 ; GFX940-TGSPLIT-NEXT: s_endpgm
18643 ; GFX11-WGP-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
18644 ; GFX11-WGP: ; %bb.0: ; %entry
18645 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
18646 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18647 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
18648 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
18649 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
18650 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
18651 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
18652 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
18653 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
18654 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
18655 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
18656 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
18657 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
18658 ; GFX11-WGP-NEXT: buffer_gl0_inv
18659 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
18660 ; GFX11-WGP-NEXT: s_endpgm
18662 ; GFX11-CU-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
18663 ; GFX11-CU: ; %bb.0: ; %entry
18664 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
18665 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18666 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
18667 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
18668 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
18669 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
18670 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
18671 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
18672 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
18673 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
18674 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
18675 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
18676 ; GFX11-CU-NEXT: s_endpgm
18678 ; GFX12-WGP-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
18679 ; GFX12-WGP: ; %bb.0: ; %entry
18680 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
18681 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18682 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
18683 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
18684 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
18685 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
18686 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
18687 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
18688 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
18689 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
18690 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
18691 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
18692 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
18693 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
18694 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
18695 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
18696 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
18697 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
18698 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
18699 ; GFX12-WGP-NEXT: s_endpgm
18701 ; GFX12-CU-LABEL: global_workgroup_one_as_release_acquire_ret_cmpxchg:
18702 ; GFX12-CU: ; %bb.0: ; %entry
18703 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
18704 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18705 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
18706 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
18707 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
18708 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
18709 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
18710 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
18711 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
18712 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
18713 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
18714 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
18715 ; GFX12-CU-NEXT: s_endpgm
18716 ptr addrspace(1) %out, i32 %in, i32 %old) {
18718 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
18719 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") release acquire
18720 %val0 = extractvalue { i32, i1 } %val, 0
18721 store i32 %val0, ptr addrspace(1) %out, align 4
18725 define amdgpu_kernel void @global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg(
18726 ; GFX6-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
18727 ; GFX6: ; %bb.0: ; %entry
18728 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
18729 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
18730 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
18731 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
18732 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
18733 ; GFX6-NEXT: s_mov_b32 s12, s5
18734 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
18735 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
18736 ; GFX6-NEXT: s_mov_b32 s11, -1
18737 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
18738 ; GFX6-NEXT: s_mov_b32 s5, s12
18739 ; GFX6-NEXT: s_mov_b32 s6, s11
18740 ; GFX6-NEXT: s_mov_b32 s7, s10
18741 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
18742 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
18743 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
18744 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
18745 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
18746 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
18747 ; GFX6-NEXT: s_waitcnt vmcnt(0)
18748 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
18749 ; GFX6-NEXT: s_endpgm
18751 ; GFX7-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
18752 ; GFX7: ; %bb.0: ; %entry
18753 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
18754 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
18755 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
18756 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
18757 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
18758 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
18759 ; GFX7-NEXT: s_mov_b32 s6, s4
18760 ; GFX7-NEXT: s_mov_b32 s7, s5
18761 ; GFX7-NEXT: s_mov_b32 s11, s12
18762 ; GFX7-NEXT: s_mov_b32 s10, s13
18763 ; GFX7-NEXT: s_add_u32 s6, s6, s11
18764 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
18765 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
18766 ; GFX7-NEXT: s_mov_b32 s7, s10
18767 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
18768 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
18769 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18770 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
18771 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
18772 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
18773 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
18774 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
18775 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
18776 ; GFX7-NEXT: s_waitcnt vmcnt(0)
18777 ; GFX7-NEXT: flat_store_dword v[0:1], v2
18778 ; GFX7-NEXT: s_endpgm
18780 ; GFX10-WGP-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
18781 ; GFX10-WGP: ; %bb.0: ; %entry
18782 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
18783 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
18784 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
18785 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
18786 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
18787 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
18788 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
18789 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
18790 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
18791 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
18792 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
18793 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
18794 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
18795 ; GFX10-WGP-NEXT: buffer_gl0_inv
18796 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
18797 ; GFX10-WGP-NEXT: s_endpgm
18799 ; GFX10-CU-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
18800 ; GFX10-CU: ; %bb.0: ; %entry
18801 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
18802 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
18803 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
18804 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
18805 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
18806 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
18807 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
18808 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
18809 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
18810 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
18811 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
18812 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
18813 ; GFX10-CU-NEXT: s_endpgm
18815 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
18816 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
18817 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
18818 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
18819 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
18820 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
18821 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
18822 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
18823 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
18824 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
18825 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
18826 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
18827 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
18828 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
18829 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
18830 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
18831 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
18832 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
18833 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
18834 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
18835 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
18836 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
18837 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
18838 ; SKIP-CACHE-INV-NEXT: s_endpgm
18840 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
18841 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
18842 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
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 v1, s6
18849 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18850 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
18851 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
18852 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
18853 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
18854 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
18856 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
18857 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
18858 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
18859 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
18860 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
18861 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
18862 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18863 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
18864 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
18865 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18866 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
18867 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
18868 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
18869 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
18870 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
18871 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
18872 ; GFX90A-TGSPLIT-NEXT: s_endpgm
18874 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
18875 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
18876 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
18877 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
18878 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
18879 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
18880 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18881 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
18882 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
18883 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18884 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
18885 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
18886 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
18887 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
18888 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
18890 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
18891 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
18892 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
18893 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
18894 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
18895 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
18896 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
18897 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
18898 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
18899 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
18900 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
18901 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
18902 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
18903 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
18904 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
18905 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
18906 ; GFX940-TGSPLIT-NEXT: s_endpgm
18908 ; GFX11-WGP-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
18909 ; GFX11-WGP: ; %bb.0: ; %entry
18910 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
18911 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18912 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
18913 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
18914 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
18915 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
18916 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
18917 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
18918 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
18919 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
18920 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
18921 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
18922 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
18923 ; GFX11-WGP-NEXT: buffer_gl0_inv
18924 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
18925 ; GFX11-WGP-NEXT: s_endpgm
18927 ; GFX11-CU-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
18928 ; GFX11-CU: ; %bb.0: ; %entry
18929 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
18930 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18931 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
18932 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
18933 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
18934 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
18935 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
18936 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
18937 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
18938 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
18939 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
18940 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
18941 ; GFX11-CU-NEXT: s_endpgm
18943 ; GFX12-WGP-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
18944 ; GFX12-WGP: ; %bb.0: ; %entry
18945 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
18946 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18947 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
18948 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
18949 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
18950 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
18951 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
18952 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
18953 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
18954 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
18955 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
18956 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
18957 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
18958 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
18959 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
18960 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
18961 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
18962 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
18963 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
18964 ; GFX12-WGP-NEXT: s_endpgm
18966 ; GFX12-CU-LABEL: global_workgroup_one_as_acq_rel_acquire_ret_cmpxchg:
18967 ; GFX12-CU: ; %bb.0: ; %entry
18968 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
18969 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
18970 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
18971 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
18972 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
18973 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
18974 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
18975 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
18976 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
18977 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
18978 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
18979 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
18980 ; GFX12-CU-NEXT: s_endpgm
18981 ptr addrspace(1) %out, i32 %in, i32 %old) {
18983 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
18984 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acq_rel acquire
18985 %val0 = extractvalue { i32, i1 } %val, 0
18986 store i32 %val0, ptr addrspace(1) %out, align 4
18990 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg(
18991 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
18992 ; GFX6: ; %bb.0: ; %entry
18993 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
18994 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
18995 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
18996 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
18997 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
18998 ; GFX6-NEXT: s_mov_b32 s12, s5
18999 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
19000 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
19001 ; GFX6-NEXT: s_mov_b32 s11, -1
19002 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
19003 ; GFX6-NEXT: s_mov_b32 s5, s12
19004 ; GFX6-NEXT: s_mov_b32 s6, s11
19005 ; GFX6-NEXT: s_mov_b32 s7, s10
19006 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
19007 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
19008 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
19009 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
19010 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
19011 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
19012 ; GFX6-NEXT: s_waitcnt vmcnt(0)
19013 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
19014 ; GFX6-NEXT: s_endpgm
19016 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
19017 ; GFX7: ; %bb.0: ; %entry
19018 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
19019 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
19020 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
19021 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
19022 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
19023 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
19024 ; GFX7-NEXT: s_mov_b32 s6, s4
19025 ; GFX7-NEXT: s_mov_b32 s7, s5
19026 ; GFX7-NEXT: s_mov_b32 s11, s12
19027 ; GFX7-NEXT: s_mov_b32 s10, s13
19028 ; GFX7-NEXT: s_add_u32 s6, s6, s11
19029 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
19030 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
19031 ; GFX7-NEXT: s_mov_b32 s7, s10
19032 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
19033 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
19034 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19035 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
19036 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
19037 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
19038 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
19039 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
19040 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
19041 ; GFX7-NEXT: s_waitcnt vmcnt(0)
19042 ; GFX7-NEXT: flat_store_dword v[0:1], v2
19043 ; GFX7-NEXT: s_endpgm
19045 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
19046 ; GFX10-WGP: ; %bb.0: ; %entry
19047 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
19048 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
19049 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
19050 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
19051 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
19052 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
19053 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
19054 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
19055 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
19056 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
19057 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
19058 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
19059 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
19060 ; GFX10-WGP-NEXT: buffer_gl0_inv
19061 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
19062 ; GFX10-WGP-NEXT: s_endpgm
19064 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
19065 ; GFX10-CU: ; %bb.0: ; %entry
19066 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
19067 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
19068 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
19069 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
19070 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
19071 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
19072 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
19073 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
19074 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
19075 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
19076 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
19077 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
19078 ; GFX10-CU-NEXT: s_endpgm
19080 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
19081 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
19082 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
19083 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
19084 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
19085 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
19086 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
19087 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
19088 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
19089 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
19090 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
19091 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
19092 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
19093 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
19094 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
19095 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
19096 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
19097 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
19098 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
19099 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
19100 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
19101 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
19102 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
19103 ; SKIP-CACHE-INV-NEXT: s_endpgm
19105 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
19106 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
19107 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
19108 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
19109 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
19110 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
19111 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19112 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
19113 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
19114 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19115 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
19116 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
19117 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
19118 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
19119 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
19121 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
19122 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
19123 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
19124 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
19125 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
19126 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
19127 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19128 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
19129 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
19130 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19131 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
19132 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
19133 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
19134 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
19135 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
19136 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
19137 ; GFX90A-TGSPLIT-NEXT: s_endpgm
19139 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
19140 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
19141 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
19142 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
19143 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
19144 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
19145 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19146 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
19147 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
19148 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19149 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
19150 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
19151 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
19152 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
19153 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
19155 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
19156 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
19157 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
19158 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
19159 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
19160 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
19161 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19162 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
19163 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
19164 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19165 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
19166 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
19167 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
19168 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
19169 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
19170 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
19171 ; GFX940-TGSPLIT-NEXT: s_endpgm
19173 ; GFX11-WGP-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
19174 ; GFX11-WGP: ; %bb.0: ; %entry
19175 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
19176 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
19177 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
19178 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
19179 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
19180 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
19181 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
19182 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
19183 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
19184 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
19185 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
19186 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
19187 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
19188 ; GFX11-WGP-NEXT: buffer_gl0_inv
19189 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
19190 ; GFX11-WGP-NEXT: s_endpgm
19192 ; GFX11-CU-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
19193 ; GFX11-CU: ; %bb.0: ; %entry
19194 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
19195 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
19196 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
19197 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
19198 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
19199 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
19200 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
19201 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
19202 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
19203 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
19204 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
19205 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
19206 ; GFX11-CU-NEXT: s_endpgm
19208 ; GFX12-WGP-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
19209 ; GFX12-WGP: ; %bb.0: ; %entry
19210 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
19211 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
19212 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
19213 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
19214 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
19215 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
19216 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
19217 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
19218 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
19219 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
19220 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
19221 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
19222 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
19223 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
19224 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
19225 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
19226 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
19227 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
19228 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
19229 ; GFX12-WGP-NEXT: s_endpgm
19231 ; GFX12-CU-LABEL: global_workgroup_one_as_seq_cst_acquire_ret_cmpxchg:
19232 ; GFX12-CU: ; %bb.0: ; %entry
19233 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
19234 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
19235 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
19236 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
19237 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
19238 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
19239 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
19240 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
19241 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
19242 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
19243 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
19244 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
19245 ; GFX12-CU-NEXT: s_endpgm
19246 ptr addrspace(1) %out, i32 %in, i32 %old) {
19248 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
19249 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") seq_cst acquire
19250 %val0 = extractvalue { i32, i1 } %val, 0
19251 store i32 %val0, ptr addrspace(1) %out, align 4
19255 define amdgpu_kernel void @global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg(
19256 ; GFX6-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
19257 ; GFX6: ; %bb.0: ; %entry
19258 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
19259 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
19260 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
19261 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
19262 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
19263 ; GFX6-NEXT: s_mov_b32 s12, s5
19264 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
19265 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
19266 ; GFX6-NEXT: s_mov_b32 s11, -1
19267 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
19268 ; GFX6-NEXT: s_mov_b32 s5, s12
19269 ; GFX6-NEXT: s_mov_b32 s6, s11
19270 ; GFX6-NEXT: s_mov_b32 s7, s10
19271 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
19272 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
19273 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
19274 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
19275 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
19276 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
19277 ; GFX6-NEXT: s_waitcnt vmcnt(0)
19278 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
19279 ; GFX6-NEXT: s_endpgm
19281 ; GFX7-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
19282 ; GFX7: ; %bb.0: ; %entry
19283 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
19284 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
19285 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
19286 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
19287 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
19288 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
19289 ; GFX7-NEXT: s_mov_b32 s6, s4
19290 ; GFX7-NEXT: s_mov_b32 s7, s5
19291 ; GFX7-NEXT: s_mov_b32 s11, s12
19292 ; GFX7-NEXT: s_mov_b32 s10, s13
19293 ; GFX7-NEXT: s_add_u32 s6, s6, s11
19294 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
19295 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
19296 ; GFX7-NEXT: s_mov_b32 s7, s10
19297 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
19298 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
19299 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19300 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
19301 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
19302 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
19303 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
19304 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
19305 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
19306 ; GFX7-NEXT: s_waitcnt vmcnt(0)
19307 ; GFX7-NEXT: flat_store_dword v[0:1], v2
19308 ; GFX7-NEXT: s_endpgm
19310 ; GFX10-WGP-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
19311 ; GFX10-WGP: ; %bb.0: ; %entry
19312 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
19313 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
19314 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
19315 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
19316 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
19317 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
19318 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
19319 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
19320 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
19321 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
19322 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
19323 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
19324 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
19325 ; GFX10-WGP-NEXT: buffer_gl0_inv
19326 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
19327 ; GFX10-WGP-NEXT: s_endpgm
19329 ; GFX10-CU-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
19330 ; GFX10-CU: ; %bb.0: ; %entry
19331 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
19332 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
19333 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
19334 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
19335 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
19336 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
19337 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
19338 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
19339 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
19340 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
19341 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
19342 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
19343 ; GFX10-CU-NEXT: s_endpgm
19345 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
19346 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
19347 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
19348 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
19349 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
19350 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
19351 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
19352 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
19353 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
19354 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
19355 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
19356 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
19357 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
19358 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
19359 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
19360 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
19361 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
19362 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
19363 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
19364 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
19365 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
19366 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
19367 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
19368 ; SKIP-CACHE-INV-NEXT: s_endpgm
19370 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
19371 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
19372 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
19373 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
19374 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
19375 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
19376 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19377 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
19378 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
19379 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19380 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
19381 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
19382 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
19383 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
19384 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
19386 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
19387 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
19388 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
19389 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
19390 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
19391 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
19392 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19393 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
19394 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
19395 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19396 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
19397 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
19398 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
19399 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
19400 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
19401 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
19402 ; GFX90A-TGSPLIT-NEXT: s_endpgm
19404 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
19405 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
19406 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
19407 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
19408 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
19409 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
19410 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19411 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
19412 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
19413 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19414 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
19415 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
19416 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
19417 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
19418 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
19420 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
19421 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
19422 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
19423 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
19424 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
19425 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
19426 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19427 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
19428 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
19429 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19430 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
19431 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
19432 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
19433 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
19434 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
19435 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
19436 ; GFX940-TGSPLIT-NEXT: s_endpgm
19438 ; GFX11-WGP-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
19439 ; GFX11-WGP: ; %bb.0: ; %entry
19440 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
19441 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
19442 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
19443 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
19444 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
19445 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
19446 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
19447 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
19448 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
19449 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
19450 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
19451 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
19452 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
19453 ; GFX11-WGP-NEXT: buffer_gl0_inv
19454 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
19455 ; GFX11-WGP-NEXT: s_endpgm
19457 ; GFX11-CU-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
19458 ; GFX11-CU: ; %bb.0: ; %entry
19459 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
19460 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
19461 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
19462 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
19463 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
19464 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
19465 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
19466 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
19467 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
19468 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
19469 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
19470 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
19471 ; GFX11-CU-NEXT: s_endpgm
19473 ; GFX12-WGP-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
19474 ; GFX12-WGP: ; %bb.0: ; %entry
19475 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
19476 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
19477 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
19478 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
19479 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
19480 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
19481 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
19482 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
19483 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
19484 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
19485 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
19486 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
19487 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
19488 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
19489 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
19490 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
19491 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
19492 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
19493 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
19494 ; GFX12-WGP-NEXT: s_endpgm
19496 ; GFX12-CU-LABEL: global_workgroup_one_as_monotonic_seq_cst_ret_cmpxchg:
19497 ; GFX12-CU: ; %bb.0: ; %entry
19498 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
19499 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
19500 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
19501 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
19502 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
19503 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
19504 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
19505 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
19506 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
19507 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
19508 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
19509 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
19510 ; GFX12-CU-NEXT: s_endpgm
19511 ptr addrspace(1) %out, i32 %in, i32 %old) {
19513 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
19514 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") monotonic seq_cst
19515 %val0 = extractvalue { i32, i1 } %val, 0
19516 store i32 %val0, ptr addrspace(1) %out, align 4
19520 define amdgpu_kernel void @global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg(
19521 ; GFX6-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
19522 ; GFX6: ; %bb.0: ; %entry
19523 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
19524 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
19525 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
19526 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
19527 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
19528 ; GFX6-NEXT: s_mov_b32 s12, s5
19529 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
19530 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
19531 ; GFX6-NEXT: s_mov_b32 s11, -1
19532 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
19533 ; GFX6-NEXT: s_mov_b32 s5, s12
19534 ; GFX6-NEXT: s_mov_b32 s6, s11
19535 ; GFX6-NEXT: s_mov_b32 s7, s10
19536 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
19537 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
19538 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
19539 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
19540 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
19541 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
19542 ; GFX6-NEXT: s_waitcnt vmcnt(0)
19543 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
19544 ; GFX6-NEXT: s_endpgm
19546 ; GFX7-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
19547 ; GFX7: ; %bb.0: ; %entry
19548 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
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)
19572 ; GFX7-NEXT: flat_store_dword v[0:1], v2
19573 ; GFX7-NEXT: s_endpgm
19575 ; GFX10-WGP-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
19576 ; GFX10-WGP: ; %bb.0: ; %entry
19577 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
19578 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
19579 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
19580 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
19581 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
19582 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
19583 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
19584 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
19585 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
19586 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
19587 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
19588 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
19589 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
19590 ; GFX10-WGP-NEXT: buffer_gl0_inv
19591 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
19592 ; GFX10-WGP-NEXT: s_endpgm
19594 ; GFX10-CU-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
19595 ; GFX10-CU: ; %bb.0: ; %entry
19596 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
19597 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
19598 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
19599 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
19600 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
19601 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
19602 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
19603 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
19604 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
19605 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
19606 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
19607 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
19608 ; GFX10-CU-NEXT: s_endpgm
19610 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
19611 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
19612 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
19613 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
19614 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
19615 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
19616 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
19617 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
19618 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
19619 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
19620 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
19621 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
19622 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
19623 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
19624 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
19625 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
19626 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
19627 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
19628 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
19629 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
19630 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
19631 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
19632 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
19633 ; SKIP-CACHE-INV-NEXT: s_endpgm
19635 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
19636 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
19637 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
19638 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
19639 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
19640 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
19641 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19642 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
19643 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
19644 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19645 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
19646 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
19647 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
19648 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
19649 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
19651 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
19652 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
19653 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
19654 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
19655 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
19656 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
19657 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19658 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
19659 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
19660 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19661 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
19662 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
19663 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
19664 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
19665 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
19666 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
19667 ; GFX90A-TGSPLIT-NEXT: s_endpgm
19669 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
19670 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
19671 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
19672 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
19673 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
19674 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
19675 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19676 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
19677 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
19678 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19679 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
19680 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
19681 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
19682 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
19683 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
19685 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
19686 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
19687 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
19688 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
19689 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
19690 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
19691 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19692 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
19693 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
19694 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19695 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
19696 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
19697 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
19698 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
19699 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
19700 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
19701 ; GFX940-TGSPLIT-NEXT: s_endpgm
19703 ; GFX11-WGP-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
19704 ; GFX11-WGP: ; %bb.0: ; %entry
19705 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
19706 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
19707 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
19708 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
19709 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
19710 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
19711 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
19712 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
19713 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
19714 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
19715 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
19716 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
19717 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
19718 ; GFX11-WGP-NEXT: buffer_gl0_inv
19719 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
19720 ; GFX11-WGP-NEXT: s_endpgm
19722 ; GFX11-CU-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
19723 ; GFX11-CU: ; %bb.0: ; %entry
19724 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
19725 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
19726 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
19727 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
19728 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
19729 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
19730 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
19731 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
19732 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
19733 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
19734 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
19735 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
19736 ; GFX11-CU-NEXT: s_endpgm
19738 ; GFX12-WGP-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
19739 ; GFX12-WGP: ; %bb.0: ; %entry
19740 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
19741 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
19742 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
19743 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
19744 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
19745 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
19746 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
19747 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
19748 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
19749 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
19750 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
19751 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
19752 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
19753 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
19754 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
19755 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
19756 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
19757 ; GFX12-WGP-NEXT: s_endpgm
19759 ; GFX12-CU-LABEL: global_workgroup_one_as_acquire_seq_cst_ret_cmpxchg:
19760 ; GFX12-CU: ; %bb.0: ; %entry
19761 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
19762 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
19763 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
19764 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
19765 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
19766 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
19767 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
19768 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
19769 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
19770 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
19771 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
19772 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
19773 ; GFX12-CU-NEXT: s_endpgm
19774 ptr addrspace(1) %out, i32 %in, i32 %old) {
19776 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
19777 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acquire seq_cst
19778 %val0 = extractvalue { i32, i1 } %val, 0
19779 store i32 %val0, ptr addrspace(1) %out, align 4
19783 define amdgpu_kernel void @global_workgroup_one_as_release_seq_cst_ret_cmpxchg(
19784 ; GFX6-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
19785 ; GFX6: ; %bb.0: ; %entry
19786 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
19787 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
19788 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
19789 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
19790 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
19791 ; GFX6-NEXT: s_mov_b32 s12, s5
19792 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
19793 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
19794 ; GFX6-NEXT: s_mov_b32 s11, -1
19795 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
19796 ; GFX6-NEXT: s_mov_b32 s5, s12
19797 ; GFX6-NEXT: s_mov_b32 s6, s11
19798 ; GFX6-NEXT: s_mov_b32 s7, s10
19799 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
19800 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
19801 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
19802 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
19803 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
19804 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
19805 ; GFX6-NEXT: s_waitcnt vmcnt(0)
19806 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
19807 ; GFX6-NEXT: s_endpgm
19809 ; GFX7-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
19810 ; GFX7: ; %bb.0: ; %entry
19811 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
19812 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
19813 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
19814 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
19815 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
19816 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
19817 ; GFX7-NEXT: s_mov_b32 s6, s4
19818 ; GFX7-NEXT: s_mov_b32 s7, s5
19819 ; GFX7-NEXT: s_mov_b32 s11, s12
19820 ; GFX7-NEXT: s_mov_b32 s10, s13
19821 ; GFX7-NEXT: s_add_u32 s6, s6, s11
19822 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
19823 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
19824 ; GFX7-NEXT: s_mov_b32 s7, s10
19825 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
19826 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
19827 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19828 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
19829 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
19830 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
19831 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
19832 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
19833 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
19834 ; GFX7-NEXT: s_waitcnt vmcnt(0)
19835 ; GFX7-NEXT: flat_store_dword v[0:1], v2
19836 ; GFX7-NEXT: s_endpgm
19838 ; GFX10-WGP-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
19839 ; GFX10-WGP: ; %bb.0: ; %entry
19840 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
19841 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
19842 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
19843 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
19844 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
19845 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
19846 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
19847 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
19848 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
19849 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
19850 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
19851 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
19852 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
19853 ; GFX10-WGP-NEXT: buffer_gl0_inv
19854 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
19855 ; GFX10-WGP-NEXT: s_endpgm
19857 ; GFX10-CU-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
19858 ; GFX10-CU: ; %bb.0: ; %entry
19859 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
19860 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
19861 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
19862 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
19863 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
19864 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
19865 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
19866 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
19867 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
19868 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
19869 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
19870 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
19871 ; GFX10-CU-NEXT: s_endpgm
19873 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
19874 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
19875 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
19876 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
19877 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
19878 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
19879 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
19880 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
19881 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
19882 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
19883 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
19884 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
19885 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
19886 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
19887 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
19888 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
19889 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
19890 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
19891 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
19892 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
19893 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
19894 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
19895 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
19896 ; SKIP-CACHE-INV-NEXT: s_endpgm
19898 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
19899 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
19900 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
19901 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
19902 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
19903 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
19904 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19905 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
19906 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
19907 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19908 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
19909 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
19910 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
19911 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
19912 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
19914 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
19915 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
19916 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
19917 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
19918 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
19919 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
19920 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19921 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
19922 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
19923 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19924 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
19925 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
19926 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
19927 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
19928 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
19929 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
19930 ; GFX90A-TGSPLIT-NEXT: s_endpgm
19932 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
19933 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
19934 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
19935 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
19936 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
19937 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
19938 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19939 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
19940 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
19941 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19942 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
19943 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
19944 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
19945 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
19946 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
19948 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
19949 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
19950 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
19951 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
19952 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
19953 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
19954 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
19955 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
19956 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
19957 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
19958 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
19959 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
19960 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
19961 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
19962 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
19963 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
19964 ; GFX940-TGSPLIT-NEXT: s_endpgm
19966 ; GFX11-WGP-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
19967 ; GFX11-WGP: ; %bb.0: ; %entry
19968 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
19969 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
19970 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
19971 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
19972 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
19973 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
19974 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
19975 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
19976 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
19977 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
19978 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
19979 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
19980 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
19981 ; GFX11-WGP-NEXT: buffer_gl0_inv
19982 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
19983 ; GFX11-WGP-NEXT: s_endpgm
19985 ; GFX11-CU-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
19986 ; GFX11-CU: ; %bb.0: ; %entry
19987 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
19988 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
19989 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
19990 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
19991 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
19992 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
19993 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
19994 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
19995 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
19996 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
19997 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
19998 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
19999 ; GFX11-CU-NEXT: s_endpgm
20001 ; GFX12-WGP-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
20002 ; GFX12-WGP: ; %bb.0: ; %entry
20003 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
20004 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
20005 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
20006 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
20007 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
20008 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
20009 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
20010 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
20011 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
20012 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
20013 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
20014 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
20015 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
20016 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
20017 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
20018 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
20019 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
20020 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
20021 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
20022 ; GFX12-WGP-NEXT: s_endpgm
20024 ; GFX12-CU-LABEL: global_workgroup_one_as_release_seq_cst_ret_cmpxchg:
20025 ; GFX12-CU: ; %bb.0: ; %entry
20026 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
20027 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
20028 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
20029 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
20030 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
20031 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
20032 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
20033 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
20034 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
20035 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
20036 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
20037 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
20038 ; GFX12-CU-NEXT: s_endpgm
20039 ptr addrspace(1) %out, i32 %in, i32 %old) {
20041 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
20042 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") release seq_cst
20043 %val0 = extractvalue { i32, i1 } %val, 0
20044 store i32 %val0, ptr addrspace(1) %out, align 4
20048 define amdgpu_kernel void @global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg(
20049 ; GFX6-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
20050 ; GFX6: ; %bb.0: ; %entry
20051 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
20052 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
20053 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
20054 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
20055 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
20056 ; GFX6-NEXT: s_mov_b32 s12, s5
20057 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
20058 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
20059 ; GFX6-NEXT: s_mov_b32 s11, -1
20060 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
20061 ; GFX6-NEXT: s_mov_b32 s5, s12
20062 ; GFX6-NEXT: s_mov_b32 s6, s11
20063 ; GFX6-NEXT: s_mov_b32 s7, s10
20064 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
20065 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
20066 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
20067 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
20068 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
20069 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
20070 ; GFX6-NEXT: s_waitcnt vmcnt(0)
20071 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
20072 ; GFX6-NEXT: s_endpgm
20074 ; GFX7-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
20075 ; GFX7: ; %bb.0: ; %entry
20076 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
20077 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
20078 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
20079 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
20080 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
20081 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
20082 ; GFX7-NEXT: s_mov_b32 s6, s4
20083 ; GFX7-NEXT: s_mov_b32 s7, s5
20084 ; GFX7-NEXT: s_mov_b32 s11, s12
20085 ; GFX7-NEXT: s_mov_b32 s10, s13
20086 ; GFX7-NEXT: s_add_u32 s6, s6, s11
20087 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
20088 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
20089 ; GFX7-NEXT: s_mov_b32 s7, s10
20090 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
20091 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
20092 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
20093 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
20094 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
20095 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
20096 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
20097 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
20098 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
20099 ; GFX7-NEXT: s_waitcnt vmcnt(0)
20100 ; GFX7-NEXT: flat_store_dword v[0:1], v2
20101 ; GFX7-NEXT: s_endpgm
20103 ; GFX10-WGP-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
20104 ; GFX10-WGP: ; %bb.0: ; %entry
20105 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
20106 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
20107 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
20108 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
20109 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
20110 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
20111 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
20112 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
20113 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
20114 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
20115 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
20116 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
20117 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
20118 ; GFX10-WGP-NEXT: buffer_gl0_inv
20119 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
20120 ; GFX10-WGP-NEXT: s_endpgm
20122 ; GFX10-CU-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
20123 ; GFX10-CU: ; %bb.0: ; %entry
20124 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
20125 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
20126 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
20127 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
20128 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
20129 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
20130 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
20131 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
20132 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
20133 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
20134 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
20135 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
20136 ; GFX10-CU-NEXT: s_endpgm
20138 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
20139 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
20140 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
20141 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
20142 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
20143 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
20144 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
20145 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
20146 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
20147 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
20148 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
20149 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
20150 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
20151 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
20152 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
20153 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
20154 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
20155 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
20156 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
20157 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
20158 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
20159 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
20160 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
20161 ; SKIP-CACHE-INV-NEXT: s_endpgm
20163 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
20164 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
20165 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
20166 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
20167 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
20168 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
20169 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
20170 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
20171 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
20172 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
20173 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
20174 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
20175 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
20176 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
20177 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
20179 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
20180 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
20181 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
20182 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
20183 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
20184 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
20185 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
20186 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
20187 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
20188 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
20189 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
20190 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
20191 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
20192 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
20193 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
20194 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
20195 ; GFX90A-TGSPLIT-NEXT: s_endpgm
20197 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
20198 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
20199 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
20200 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
20201 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
20202 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
20203 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
20204 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
20205 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
20206 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
20207 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
20208 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
20209 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
20210 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
20211 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
20213 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
20214 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
20215 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
20216 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
20217 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
20218 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
20219 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
20220 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
20221 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
20222 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
20223 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
20224 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
20225 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
20226 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
20227 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
20228 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
20229 ; GFX940-TGSPLIT-NEXT: s_endpgm
20231 ; GFX11-WGP-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
20232 ; GFX11-WGP: ; %bb.0: ; %entry
20233 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
20234 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
20235 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
20236 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
20237 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
20238 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
20239 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
20240 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
20241 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
20242 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
20243 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
20244 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
20245 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
20246 ; GFX11-WGP-NEXT: buffer_gl0_inv
20247 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
20248 ; GFX11-WGP-NEXT: s_endpgm
20250 ; GFX11-CU-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
20251 ; GFX11-CU: ; %bb.0: ; %entry
20252 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
20253 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
20254 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
20255 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
20256 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
20257 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
20258 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
20259 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
20260 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
20261 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
20262 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
20263 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
20264 ; GFX11-CU-NEXT: s_endpgm
20266 ; GFX12-WGP-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
20267 ; GFX12-WGP: ; %bb.0: ; %entry
20268 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
20269 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
20270 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
20271 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
20272 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
20273 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
20274 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
20275 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
20276 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
20277 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
20278 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
20279 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
20280 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
20281 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
20282 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
20283 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
20284 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
20285 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
20286 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
20287 ; GFX12-WGP-NEXT: s_endpgm
20289 ; GFX12-CU-LABEL: global_workgroup_one_as_acq_rel_seq_cst_ret_cmpxchg:
20290 ; GFX12-CU: ; %bb.0: ; %entry
20291 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
20292 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
20293 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
20294 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
20295 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
20296 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
20297 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
20298 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
20299 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
20300 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
20301 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
20302 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
20303 ; GFX12-CU-NEXT: s_endpgm
20304 ptr addrspace(1) %out, i32 %in, i32 %old) {
20306 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
20307 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") acq_rel seq_cst
20308 %val0 = extractvalue { i32, i1 } %val, 0
20309 store i32 %val0, ptr addrspace(1) %out, align 4
20313 define amdgpu_kernel void @global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg(
20314 ; GFX6-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
20315 ; GFX6: ; %bb.0: ; %entry
20316 ; GFX6-NEXT: s_mov_b64 s[6:7], s[8:9]
20317 ; GFX6-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
20318 ; GFX6-NEXT: s_load_dword s9, s[6:7], 0x2
20319 ; GFX6-NEXT: s_load_dword s8, s[6:7], 0x3
20320 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
20321 ; GFX6-NEXT: s_mov_b32 s12, s5
20322 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 killed $sgpr4_sgpr5
20323 ; GFX6-NEXT: s_mov_b32 s10, 0x100f000
20324 ; GFX6-NEXT: s_mov_b32 s11, -1
20325 ; GFX6-NEXT: ; kill: def $sgpr4 killed $sgpr4 def $sgpr4_sgpr5_sgpr6_sgpr7
20326 ; GFX6-NEXT: s_mov_b32 s5, s12
20327 ; GFX6-NEXT: s_mov_b32 s6, s11
20328 ; GFX6-NEXT: s_mov_b32 s7, s10
20329 ; GFX6-NEXT: v_mov_b32_e32 v0, s9
20330 ; GFX6-NEXT: v_mov_b32_e32 v2, s8
20331 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
20332 ; GFX6-NEXT: v_mov_b32_e32 v1, v2
20333 ; GFX6-NEXT: buffer_atomic_cmpswap v[0:1], off, s[4:7], 0 offset:16 glc
20334 ; GFX6-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
20335 ; GFX6-NEXT: s_waitcnt vmcnt(0)
20336 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
20337 ; GFX6-NEXT: s_endpgm
20339 ; GFX7-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
20340 ; GFX7: ; %bb.0: ; %entry
20341 ; GFX7-NEXT: s_mov_b64 s[6:7], s[8:9]
20342 ; GFX7-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0
20343 ; GFX7-NEXT: s_load_dword s9, s[6:7], 0x2
20344 ; GFX7-NEXT: s_load_dword s8, s[6:7], 0x3
20345 ; GFX7-NEXT: s_mov_b64 s[12:13], 16
20346 ; GFX7-NEXT: s_waitcnt lgkmcnt(0)
20347 ; GFX7-NEXT: s_mov_b32 s6, s4
20348 ; GFX7-NEXT: s_mov_b32 s7, s5
20349 ; GFX7-NEXT: s_mov_b32 s11, s12
20350 ; GFX7-NEXT: s_mov_b32 s10, s13
20351 ; GFX7-NEXT: s_add_u32 s6, s6, s11
20352 ; GFX7-NEXT: s_addc_u32 s10, s7, s10
20353 ; GFX7-NEXT: ; kill: def $sgpr6 killed $sgpr6 def $sgpr6_sgpr7
20354 ; GFX7-NEXT: s_mov_b32 s7, s10
20355 ; GFX7-NEXT: v_mov_b32_e32 v2, s9
20356 ; GFX7-NEXT: v_mov_b32_e32 v0, s8
20357 ; GFX7-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
20358 ; GFX7-NEXT: v_mov_b32_e32 v3, v0
20359 ; GFX7-NEXT: v_mov_b32_e32 v0, s6
20360 ; GFX7-NEXT: v_mov_b32_e32 v1, s7
20361 ; GFX7-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
20362 ; GFX7-NEXT: v_mov_b32_e32 v0, s4
20363 ; GFX7-NEXT: v_mov_b32_e32 v1, s5
20364 ; GFX7-NEXT: s_waitcnt vmcnt(0)
20365 ; GFX7-NEXT: flat_store_dword v[0:1], v2
20366 ; GFX7-NEXT: s_endpgm
20368 ; GFX10-WGP-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
20369 ; GFX10-WGP: ; %bb.0: ; %entry
20370 ; GFX10-WGP-NEXT: v_mov_b32_e32 v0, 0
20371 ; GFX10-WGP-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
20372 ; GFX10-WGP-NEXT: s_load_dword s7, s[8:9], 0x8
20373 ; GFX10-WGP-NEXT: s_load_dword s6, s[8:9], 0xc
20374 ; GFX10-WGP-NEXT: s_waitcnt lgkmcnt(0)
20375 ; GFX10-WGP-NEXT: v_mov_b32_e32 v1, s7
20376 ; GFX10-WGP-NEXT: v_mov_b32_e32 v3, s6
20377 ; GFX10-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
20378 ; GFX10-WGP-NEXT: v_mov_b32_e32 v2, v3
20379 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
20380 ; GFX10-WGP-NEXT: s_waitcnt_vscnt null, 0x0
20381 ; GFX10-WGP-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
20382 ; GFX10-WGP-NEXT: s_waitcnt vmcnt(0)
20383 ; GFX10-WGP-NEXT: buffer_gl0_inv
20384 ; GFX10-WGP-NEXT: global_store_dword v0, v1, s[4:5]
20385 ; GFX10-WGP-NEXT: s_endpgm
20387 ; GFX10-CU-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
20388 ; GFX10-CU: ; %bb.0: ; %entry
20389 ; GFX10-CU-NEXT: v_mov_b32_e32 v0, 0
20390 ; GFX10-CU-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
20391 ; GFX10-CU-NEXT: s_load_dword s7, s[8:9], 0x8
20392 ; GFX10-CU-NEXT: s_load_dword s6, s[8:9], 0xc
20393 ; GFX10-CU-NEXT: s_waitcnt lgkmcnt(0)
20394 ; GFX10-CU-NEXT: v_mov_b32_e32 v1, s7
20395 ; GFX10-CU-NEXT: v_mov_b32_e32 v3, s6
20396 ; GFX10-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
20397 ; GFX10-CU-NEXT: v_mov_b32_e32 v2, v3
20398 ; GFX10-CU-NEXT: global_atomic_cmpswap v1, v0, v[1:2], s[4:5] offset:16 glc
20399 ; GFX10-CU-NEXT: s_waitcnt vmcnt(0)
20400 ; GFX10-CU-NEXT: global_store_dword v0, v1, s[4:5]
20401 ; GFX10-CU-NEXT: s_endpgm
20403 ; SKIP-CACHE-INV-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
20404 ; SKIP-CACHE-INV: ; %bb.0: ; %entry
20405 ; SKIP-CACHE-INV-NEXT: s_mov_b64 s[2:3], s[4:5]
20406 ; SKIP-CACHE-INV-NEXT: s_load_dwordx2 s[0:1], s[2:3], 0x0
20407 ; SKIP-CACHE-INV-NEXT: s_load_dword s5, s[2:3], 0x2
20408 ; SKIP-CACHE-INV-NEXT: s_load_dword s4, s[2:3], 0x3
20409 ; SKIP-CACHE-INV-NEXT: s_waitcnt lgkmcnt(0)
20410 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s8, s1
20411 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 killed $sgpr0_sgpr1
20412 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s6, 0xf000
20413 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s7, -1
20414 ; SKIP-CACHE-INV-NEXT: ; kill: def $sgpr0 killed $sgpr0 def $sgpr0_sgpr1_sgpr2_sgpr3
20415 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s1, s8
20416 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s2, s7
20417 ; SKIP-CACHE-INV-NEXT: s_mov_b32 s3, s6
20418 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v0, s5
20419 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v2, s4
20420 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
20421 ; SKIP-CACHE-INV-NEXT: v_mov_b32_e32 v1, v2
20422 ; SKIP-CACHE-INV-NEXT: buffer_atomic_cmpswap v[0:1], off, s[0:3], 0 offset:16 glc
20423 ; SKIP-CACHE-INV-NEXT: ; kill: def $vgpr0 killed $vgpr0 killed $vgpr0_vgpr1 killed $exec
20424 ; SKIP-CACHE-INV-NEXT: s_waitcnt vmcnt(0)
20425 ; SKIP-CACHE-INV-NEXT: buffer_store_dword v0, off, s[0:3], 0
20426 ; SKIP-CACHE-INV-NEXT: s_endpgm
20428 ; GFX90A-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
20429 ; GFX90A-NOTTGSPLIT: ; %bb.0: ; %entry
20430 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
20431 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
20432 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
20433 ; GFX90A-NOTTGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
20434 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
20435 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s7
20436 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s6
20437 ; GFX90A-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
20438 ; GFX90A-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
20439 ; GFX90A-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
20440 ; GFX90A-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
20441 ; GFX90A-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
20442 ; GFX90A-NOTTGSPLIT-NEXT: s_endpgm
20444 ; GFX90A-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
20445 ; GFX90A-TGSPLIT: ; %bb.0: ; %entry
20446 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
20447 ; GFX90A-TGSPLIT-NEXT: s_load_dwordx2 s[4:5], s[8:9], 0x0
20448 ; GFX90A-TGSPLIT-NEXT: s_load_dword s7, s[8:9], 0x8
20449 ; GFX90A-TGSPLIT-NEXT: s_load_dword s6, s[8:9], 0xc
20450 ; GFX90A-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
20451 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v2, s7
20452 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v1, s6
20453 ; GFX90A-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
20454 ; GFX90A-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
20455 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
20456 ; GFX90A-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[4:5] offset:16 glc
20457 ; GFX90A-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
20458 ; GFX90A-TGSPLIT-NEXT: buffer_wbinvl1_vol
20459 ; GFX90A-TGSPLIT-NEXT: global_store_dword v0, v1, s[4:5]
20460 ; GFX90A-TGSPLIT-NEXT: s_endpgm
20462 ; GFX940-NOTTGSPLIT-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
20463 ; GFX940-NOTTGSPLIT: ; %bb.0: ; %entry
20464 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v0, 0
20465 ; GFX940-NOTTGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
20466 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
20467 ; GFX940-NOTTGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
20468 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
20469 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v2, s3
20470 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v1, s2
20471 ; GFX940-NOTTGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
20472 ; GFX940-NOTTGSPLIT-NEXT: v_mov_b32_e32 v3, v1
20473 ; GFX940-NOTTGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
20474 ; GFX940-NOTTGSPLIT-NEXT: s_waitcnt vmcnt(0)
20475 ; GFX940-NOTTGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
20476 ; GFX940-NOTTGSPLIT-NEXT: s_endpgm
20478 ; GFX940-TGSPLIT-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
20479 ; GFX940-TGSPLIT: ; %bb.0: ; %entry
20480 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v0, 0
20481 ; GFX940-TGSPLIT-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
20482 ; GFX940-TGSPLIT-NEXT: s_load_dword s3, s[4:5], 0x8
20483 ; GFX940-TGSPLIT-NEXT: s_load_dword s2, s[4:5], 0xc
20484 ; GFX940-TGSPLIT-NEXT: s_waitcnt lgkmcnt(0)
20485 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v2, s3
20486 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v1, s2
20487 ; GFX940-TGSPLIT-NEXT: ; kill: def $vgpr2 killed $vgpr2 def $vgpr2_vgpr3 killed $exec
20488 ; GFX940-TGSPLIT-NEXT: v_mov_b32_e32 v3, v1
20489 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
20490 ; GFX940-TGSPLIT-NEXT: global_atomic_cmpswap v1, v0, v[2:3], s[0:1] offset:16 sc0
20491 ; GFX940-TGSPLIT-NEXT: s_waitcnt vmcnt(0)
20492 ; GFX940-TGSPLIT-NEXT: buffer_inv sc0
20493 ; GFX940-TGSPLIT-NEXT: global_store_dword v0, v1, s[0:1] sc0 sc1
20494 ; GFX940-TGSPLIT-NEXT: s_endpgm
20496 ; GFX11-WGP-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
20497 ; GFX11-WGP: ; %bb.0: ; %entry
20498 ; GFX11-WGP-NEXT: v_mov_b32_e32 v0, 0
20499 ; GFX11-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
20500 ; GFX11-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
20501 ; GFX11-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
20502 ; GFX11-WGP-NEXT: s_waitcnt lgkmcnt(0)
20503 ; GFX11-WGP-NEXT: v_mov_b32_e32 v1, s3
20504 ; GFX11-WGP-NEXT: v_mov_b32_e32 v3, s2
20505 ; GFX11-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
20506 ; GFX11-WGP-NEXT: v_mov_b32_e32 v2, v3
20507 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
20508 ; GFX11-WGP-NEXT: s_waitcnt_vscnt null, 0x0
20509 ; GFX11-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
20510 ; GFX11-WGP-NEXT: s_waitcnt vmcnt(0)
20511 ; GFX11-WGP-NEXT: buffer_gl0_inv
20512 ; GFX11-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
20513 ; GFX11-WGP-NEXT: s_endpgm
20515 ; GFX11-CU-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
20516 ; GFX11-CU: ; %bb.0: ; %entry
20517 ; GFX11-CU-NEXT: v_mov_b32_e32 v0, 0
20518 ; GFX11-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
20519 ; GFX11-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
20520 ; GFX11-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
20521 ; GFX11-CU-NEXT: s_waitcnt lgkmcnt(0)
20522 ; GFX11-CU-NEXT: v_mov_b32_e32 v1, s3
20523 ; GFX11-CU-NEXT: v_mov_b32_e32 v3, s2
20524 ; GFX11-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
20525 ; GFX11-CU-NEXT: v_mov_b32_e32 v2, v3
20526 ; GFX11-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 glc
20527 ; GFX11-CU-NEXT: s_waitcnt vmcnt(0)
20528 ; GFX11-CU-NEXT: global_store_b32 v0, v1, s[0:1]
20529 ; GFX11-CU-NEXT: s_endpgm
20531 ; GFX12-WGP-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
20532 ; GFX12-WGP: ; %bb.0: ; %entry
20533 ; GFX12-WGP-NEXT: v_mov_b32_e32 v0, 0
20534 ; GFX12-WGP-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
20535 ; GFX12-WGP-NEXT: s_load_b32 s3, s[4:5], 0x8
20536 ; GFX12-WGP-NEXT: s_load_b32 s2, s[4:5], 0xc
20537 ; GFX12-WGP-NEXT: s_wait_kmcnt 0x0
20538 ; GFX12-WGP-NEXT: v_mov_b32_e32 v1, s3
20539 ; GFX12-WGP-NEXT: v_mov_b32_e32 v3, s2
20540 ; GFX12-WGP-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
20541 ; GFX12-WGP-NEXT: v_mov_b32_e32 v2, v3
20542 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
20543 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
20544 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
20545 ; GFX12-WGP-NEXT: s_wait_storecnt 0x0
20546 ; GFX12-WGP-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN scope:SCOPE_SE
20547 ; GFX12-WGP-NEXT: s_wait_bvhcnt 0x0
20548 ; GFX12-WGP-NEXT: s_wait_samplecnt 0x0
20549 ; GFX12-WGP-NEXT: s_wait_loadcnt 0x0
20550 ; GFX12-WGP-NEXT: global_inv scope:SCOPE_SE
20551 ; GFX12-WGP-NEXT: global_store_b32 v0, v1, s[0:1]
20552 ; GFX12-WGP-NEXT: s_endpgm
20554 ; GFX12-CU-LABEL: global_workgroup_one_as_seq_cst_seq_cst_ret_cmpxchg:
20555 ; GFX12-CU: ; %bb.0: ; %entry
20556 ; GFX12-CU-NEXT: v_mov_b32_e32 v0, 0
20557 ; GFX12-CU-NEXT: s_load_b64 s[0:1], s[4:5], 0x0
20558 ; GFX12-CU-NEXT: s_load_b32 s3, s[4:5], 0x8
20559 ; GFX12-CU-NEXT: s_load_b32 s2, s[4:5], 0xc
20560 ; GFX12-CU-NEXT: s_wait_kmcnt 0x0
20561 ; GFX12-CU-NEXT: v_mov_b32_e32 v1, s3
20562 ; GFX12-CU-NEXT: v_mov_b32_e32 v3, s2
20563 ; GFX12-CU-NEXT: ; kill: def $vgpr1 killed $vgpr1 def $vgpr1_vgpr2 killed $exec
20564 ; GFX12-CU-NEXT: v_mov_b32_e32 v2, v3
20565 ; GFX12-CU-NEXT: global_atomic_cmpswap_b32 v1, v0, v[1:2], s[0:1] offset:16 th:TH_ATOMIC_RETURN
20566 ; GFX12-CU-NEXT: s_wait_loadcnt 0x0
20567 ; GFX12-CU-NEXT: global_store_b32 v0, v1, s[0:1]
20568 ; GFX12-CU-NEXT: s_endpgm
20569 ptr addrspace(1) %out, i32 %in, i32 %old) {
20571 %gep = getelementptr i32, ptr addrspace(1) %out, i32 4
20572 %val = cmpxchg volatile ptr addrspace(1) %gep, i32 %old, i32 %in syncscope("workgroup-one-as") seq_cst seq_cst
20573 %val0 = extractvalue { i32, i1 } %val, 0
20574 store i32 %val0, ptr addrspace(1) %out, align 4