1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -march=amdgcn -mcpu=bonaire -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN1 %s
3 ; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN2 %s
4 ; RUN: llc -march=amdgcn -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN3 %s
6 define amdgpu_kernel void @atomic_add_i32_offset(ptr %out, i32 %in) {
7 ; GCN1-LABEL: atomic_add_i32_offset:
8 ; GCN1: ; %bb.0: ; %entry
9 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
10 ; GCN1-NEXT: s_load_dword s4, s[0:1], 0xb
11 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
12 ; GCN1-NEXT: s_add_u32 s0, s2, 16
13 ; GCN1-NEXT: s_addc_u32 s1, s3, 0
14 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
15 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
16 ; GCN1-NEXT: v_mov_b32_e32 v2, s4
17 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18 ; GCN1-NEXT: flat_atomic_add v[0:1], v2
19 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
20 ; GCN1-NEXT: buffer_wbinvl1_vol
23 ; GCN2-LABEL: atomic_add_i32_offset:
24 ; GCN2: ; %bb.0: ; %entry
25 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
26 ; GCN2-NEXT: s_load_dword s4, s[0:1], 0x2c
27 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
28 ; GCN2-NEXT: s_add_u32 s0, s2, 16
29 ; GCN2-NEXT: s_addc_u32 s1, s3, 0
30 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
31 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
32 ; GCN2-NEXT: v_mov_b32_e32 v2, s4
33 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
34 ; GCN2-NEXT: flat_atomic_add v[0:1], v2
35 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
36 ; GCN2-NEXT: buffer_wbinvl1_vol
39 ; GCN3-LABEL: atomic_add_i32_offset:
40 ; GCN3: ; %bb.0: ; %entry
41 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
42 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
43 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
44 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
45 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
46 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
47 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
48 ; GCN3-NEXT: flat_atomic_add v[0:1], v2 offset:16
49 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
50 ; GCN3-NEXT: buffer_wbinvl1_vol
53 %gep = getelementptr i32, ptr %out, i32 4
54 %val = atomicrmw add ptr %gep, i32 %in syncscope("agent") seq_cst
58 define amdgpu_kernel void @atomic_add_i32_max_offset(ptr %out, i32 %in) {
59 ; GCN1-LABEL: atomic_add_i32_max_offset:
60 ; GCN1: ; %bb.0: ; %entry
61 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
62 ; GCN1-NEXT: s_load_dword s4, s[0:1], 0xb
63 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
64 ; GCN1-NEXT: s_add_u32 s0, s2, 0xffc
65 ; GCN1-NEXT: s_addc_u32 s1, s3, 0
66 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
67 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
68 ; GCN1-NEXT: v_mov_b32_e32 v2, s4
69 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
70 ; GCN1-NEXT: flat_atomic_add v[0:1], v2
71 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
72 ; GCN1-NEXT: buffer_wbinvl1_vol
75 ; GCN2-LABEL: atomic_add_i32_max_offset:
76 ; GCN2: ; %bb.0: ; %entry
77 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
78 ; GCN2-NEXT: s_load_dword s4, s[0:1], 0x2c
79 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
80 ; GCN2-NEXT: s_add_u32 s0, s2, 0xffc
81 ; GCN2-NEXT: s_addc_u32 s1, s3, 0
82 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
83 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
84 ; GCN2-NEXT: v_mov_b32_e32 v2, s4
85 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
86 ; GCN2-NEXT: flat_atomic_add v[0:1], v2
87 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
88 ; GCN2-NEXT: buffer_wbinvl1_vol
91 ; GCN3-LABEL: atomic_add_i32_max_offset:
92 ; GCN3: ; %bb.0: ; %entry
93 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
94 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
95 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
96 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
97 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
98 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
99 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
100 ; GCN3-NEXT: flat_atomic_add v[0:1], v2 offset:4092
101 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
102 ; GCN3-NEXT: buffer_wbinvl1_vol
103 ; GCN3-NEXT: s_endpgm
105 %gep = getelementptr i32, ptr %out, i32 1023
106 %val = atomicrmw volatile add ptr %gep, i32 %in syncscope("agent") seq_cst
110 define amdgpu_kernel void @atomic_add_i32_max_offset_p1(ptr %out, i32 %in) {
111 ; GCN1-LABEL: atomic_add_i32_max_offset_p1:
112 ; GCN1: ; %bb.0: ; %entry
113 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
114 ; GCN1-NEXT: s_load_dword s4, s[0:1], 0xb
115 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
116 ; GCN1-NEXT: s_add_u32 s0, s2, 0x1000
117 ; GCN1-NEXT: s_addc_u32 s1, s3, 0
118 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
119 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
120 ; GCN1-NEXT: v_mov_b32_e32 v2, s4
121 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
122 ; GCN1-NEXT: flat_atomic_add v[0:1], v2
123 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
124 ; GCN1-NEXT: buffer_wbinvl1_vol
125 ; GCN1-NEXT: s_endpgm
127 ; GCN2-LABEL: atomic_add_i32_max_offset_p1:
128 ; GCN2: ; %bb.0: ; %entry
129 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
130 ; GCN2-NEXT: s_load_dword s4, s[0:1], 0x2c
131 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
132 ; GCN2-NEXT: s_add_u32 s0, s2, 0x1000
133 ; GCN2-NEXT: s_addc_u32 s1, s3, 0
134 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
135 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
136 ; GCN2-NEXT: v_mov_b32_e32 v2, s4
137 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
138 ; GCN2-NEXT: flat_atomic_add v[0:1], v2
139 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
140 ; GCN2-NEXT: buffer_wbinvl1_vol
141 ; GCN2-NEXT: s_endpgm
143 ; GCN3-LABEL: atomic_add_i32_max_offset_p1:
144 ; GCN3: ; %bb.0: ; %entry
145 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
146 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
147 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
148 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
149 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
150 ; GCN3-NEXT: v_add_co_u32_e32 v0, vcc, 0x1000, v0
151 ; GCN3-NEXT: v_addc_co_u32_e32 v1, vcc, 0, v1, vcc
152 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
153 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
154 ; GCN3-NEXT: flat_atomic_add v[0:1], v2
155 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
156 ; GCN3-NEXT: buffer_wbinvl1_vol
157 ; GCN3-NEXT: s_endpgm
159 %gep = getelementptr i32, ptr %out, i32 1024
160 %val = atomicrmw volatile add ptr %gep, i32 %in syncscope("agent") seq_cst
164 define amdgpu_kernel void @atomic_add_i32_ret_offset(ptr %out, ptr %out2, i32 %in) {
165 ; GCN1-LABEL: atomic_add_i32_ret_offset:
166 ; GCN1: ; %bb.0: ; %entry
167 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
168 ; GCN1-NEXT: s_load_dword s2, s[0:1], 0xd
169 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
170 ; GCN1-NEXT: s_add_u32 s0, s4, 16
171 ; GCN1-NEXT: s_addc_u32 s1, s5, 0
172 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
173 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
174 ; GCN1-NEXT: v_mov_b32_e32 v2, s2
175 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
176 ; GCN1-NEXT: flat_atomic_add v2, v[0:1], v2 glc
177 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
178 ; GCN1-NEXT: buffer_wbinvl1_vol
179 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
180 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
181 ; GCN1-NEXT: flat_store_dword v[0:1], v2
182 ; GCN1-NEXT: s_endpgm
184 ; GCN2-LABEL: atomic_add_i32_ret_offset:
185 ; GCN2: ; %bb.0: ; %entry
186 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
187 ; GCN2-NEXT: s_load_dword s2, s[0:1], 0x34
188 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
189 ; GCN2-NEXT: s_add_u32 s0, s4, 16
190 ; GCN2-NEXT: s_addc_u32 s1, s5, 0
191 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
192 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
193 ; GCN2-NEXT: v_mov_b32_e32 v2, s2
194 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
195 ; GCN2-NEXT: flat_atomic_add v2, v[0:1], v2 glc
196 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
197 ; GCN2-NEXT: buffer_wbinvl1_vol
198 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
199 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
200 ; GCN2-NEXT: flat_store_dword v[0:1], v2
201 ; GCN2-NEXT: s_endpgm
203 ; GCN3-LABEL: atomic_add_i32_ret_offset:
204 ; GCN3: ; %bb.0: ; %entry
205 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
206 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x34
207 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
208 ; GCN3-NEXT: v_mov_b32_e32 v0, s4
209 ; GCN3-NEXT: v_mov_b32_e32 v1, s5
210 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
211 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
212 ; GCN3-NEXT: flat_atomic_add v2, v[0:1], v2 offset:16 glc
213 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
214 ; GCN3-NEXT: buffer_wbinvl1_vol
215 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
216 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
217 ; GCN3-NEXT: flat_store_dword v[0:1], v2
218 ; GCN3-NEXT: s_endpgm
220 %gep = getelementptr i32, ptr %out, i32 4
221 %val = atomicrmw volatile add ptr %gep, i32 %in syncscope("agent") seq_cst
222 store i32 %val, ptr %out2
226 define amdgpu_kernel void @atomic_add_i32_addr64_offset(ptr %out, i32 %in, i64 %index) {
227 ; GCN1-LABEL: atomic_add_i32_addr64_offset:
228 ; GCN1: ; %bb.0: ; %entry
229 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xd
230 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
231 ; GCN1-NEXT: s_load_dword s6, s[0:1], 0xb
232 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
233 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
234 ; GCN1-NEXT: s_add_u32 s0, s4, s0
235 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
236 ; GCN1-NEXT: s_add_u32 s0, s0, 16
237 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
238 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
239 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
240 ; GCN1-NEXT: v_mov_b32_e32 v2, s6
241 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
242 ; GCN1-NEXT: flat_atomic_add v[0:1], v2
243 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
244 ; GCN1-NEXT: buffer_wbinvl1_vol
245 ; GCN1-NEXT: s_endpgm
247 ; GCN2-LABEL: atomic_add_i32_addr64_offset:
248 ; GCN2: ; %bb.0: ; %entry
249 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
250 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
251 ; GCN2-NEXT: s_load_dword s6, s[0:1], 0x2c
252 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
253 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
254 ; GCN2-NEXT: s_add_u32 s0, s4, s0
255 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
256 ; GCN2-NEXT: s_add_u32 s0, s0, 16
257 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
258 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
259 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
260 ; GCN2-NEXT: v_mov_b32_e32 v2, s6
261 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
262 ; GCN2-NEXT: flat_atomic_add v[0:1], v2
263 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
264 ; GCN2-NEXT: buffer_wbinvl1_vol
265 ; GCN2-NEXT: s_endpgm
267 ; GCN3-LABEL: atomic_add_i32_addr64_offset:
268 ; GCN3: ; %bb.0: ; %entry
269 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
270 ; GCN3-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
271 ; GCN3-NEXT: s_load_dword s6, s[0:1], 0x2c
272 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
273 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
274 ; GCN3-NEXT: s_add_u32 s0, s4, s0
275 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
276 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
277 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
278 ; GCN3-NEXT: v_mov_b32_e32 v2, s6
279 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
280 ; GCN3-NEXT: flat_atomic_add v[0:1], v2 offset:16
281 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
282 ; GCN3-NEXT: buffer_wbinvl1_vol
283 ; GCN3-NEXT: s_endpgm
285 %ptr = getelementptr i32, ptr %out, i64 %index
286 %gep = getelementptr i32, ptr %ptr, i32 4
287 %val = atomicrmw volatile add ptr %gep, i32 %in syncscope("agent") seq_cst
291 define amdgpu_kernel void @atomic_add_i32_ret_addr64_offset(ptr %out, ptr %out2, i32 %in, i64 %index) {
292 ; GCN1-LABEL: atomic_add_i32_ret_addr64_offset:
293 ; GCN1: ; %bb.0: ; %entry
294 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xf
295 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
296 ; GCN1-NEXT: s_load_dword s8, s[0:1], 0xd
297 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
298 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
299 ; GCN1-NEXT: s_add_u32 s0, s4, s0
300 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
301 ; GCN1-NEXT: s_add_u32 s0, s0, 16
302 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
303 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
304 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
305 ; GCN1-NEXT: v_mov_b32_e32 v2, s8
306 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
307 ; GCN1-NEXT: flat_atomic_add v2, v[0:1], v2 glc
308 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
309 ; GCN1-NEXT: buffer_wbinvl1_vol
310 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
311 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
312 ; GCN1-NEXT: flat_store_dword v[0:1], v2
313 ; GCN1-NEXT: s_endpgm
315 ; GCN2-LABEL: atomic_add_i32_ret_addr64_offset:
316 ; GCN2: ; %bb.0: ; %entry
317 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
318 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
319 ; GCN2-NEXT: s_load_dword s8, s[0:1], 0x34
320 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
321 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
322 ; GCN2-NEXT: s_add_u32 s0, s4, s0
323 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
324 ; GCN2-NEXT: s_add_u32 s0, s0, 16
325 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
326 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
327 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
328 ; GCN2-NEXT: v_mov_b32_e32 v2, s8
329 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
330 ; GCN2-NEXT: flat_atomic_add v2, v[0:1], v2 glc
331 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
332 ; GCN2-NEXT: buffer_wbinvl1_vol
333 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
334 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
335 ; GCN2-NEXT: flat_store_dword v[0:1], v2
336 ; GCN2-NEXT: s_endpgm
338 ; GCN3-LABEL: atomic_add_i32_ret_addr64_offset:
339 ; GCN3: ; %bb.0: ; %entry
340 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
341 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
342 ; GCN3-NEXT: s_load_dword s8, s[0:1], 0x34
343 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
344 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
345 ; GCN3-NEXT: s_add_u32 s0, s4, s0
346 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
347 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
348 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
349 ; GCN3-NEXT: v_mov_b32_e32 v2, s8
350 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
351 ; GCN3-NEXT: flat_atomic_add v2, v[0:1], v2 offset:16 glc
352 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
353 ; GCN3-NEXT: buffer_wbinvl1_vol
354 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
355 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
356 ; GCN3-NEXT: flat_store_dword v[0:1], v2
357 ; GCN3-NEXT: s_endpgm
359 %ptr = getelementptr i32, ptr %out, i64 %index
360 %gep = getelementptr i32, ptr %ptr, i32 4
361 %val = atomicrmw volatile add ptr %gep, i32 %in syncscope("agent") seq_cst
362 store i32 %val, ptr %out2
366 define amdgpu_kernel void @atomic_add_i32(ptr %out, i32 %in) {
367 ; GCN1-LABEL: atomic_add_i32:
368 ; GCN1: ; %bb.0: ; %entry
369 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
370 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0xb
371 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
372 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
373 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
374 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
375 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
376 ; GCN1-NEXT: flat_atomic_add v[0:1], v2
377 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
378 ; GCN1-NEXT: buffer_wbinvl1_vol
379 ; GCN1-NEXT: s_endpgm
381 ; GCN2-LABEL: atomic_add_i32:
382 ; GCN2: ; %bb.0: ; %entry
383 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
384 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x2c
385 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
386 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
387 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
388 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
389 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
390 ; GCN2-NEXT: flat_atomic_add v[0:1], v2
391 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
392 ; GCN2-NEXT: buffer_wbinvl1_vol
393 ; GCN2-NEXT: s_endpgm
395 ; GCN3-LABEL: atomic_add_i32:
396 ; GCN3: ; %bb.0: ; %entry
397 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
398 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
399 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
400 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
401 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
402 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
403 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
404 ; GCN3-NEXT: flat_atomic_add v[0:1], v2
405 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
406 ; GCN3-NEXT: buffer_wbinvl1_vol
407 ; GCN3-NEXT: s_endpgm
409 %val = atomicrmw volatile add ptr %out, i32 %in syncscope("agent") seq_cst
413 define amdgpu_kernel void @atomic_add_i32_ret(ptr %out, ptr %out2, i32 %in) {
414 ; GCN1-LABEL: atomic_add_i32_ret:
415 ; GCN1: ; %bb.0: ; %entry
416 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
417 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0xd
418 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
419 ; GCN1-NEXT: v_mov_b32_e32 v0, s4
420 ; GCN1-NEXT: v_mov_b32_e32 v1, s5
421 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
422 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
423 ; GCN1-NEXT: flat_atomic_add v2, v[0:1], v2 glc
424 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
425 ; GCN1-NEXT: buffer_wbinvl1_vol
426 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
427 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
428 ; GCN1-NEXT: flat_store_dword v[0:1], v2
429 ; GCN1-NEXT: s_endpgm
431 ; GCN2-LABEL: atomic_add_i32_ret:
432 ; GCN2: ; %bb.0: ; %entry
433 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
434 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x34
435 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
436 ; GCN2-NEXT: v_mov_b32_e32 v0, s4
437 ; GCN2-NEXT: v_mov_b32_e32 v1, s5
438 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
439 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
440 ; GCN2-NEXT: flat_atomic_add v2, v[0:1], v2 glc
441 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
442 ; GCN2-NEXT: buffer_wbinvl1_vol
443 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
444 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
445 ; GCN2-NEXT: flat_store_dword v[0:1], v2
446 ; GCN2-NEXT: s_endpgm
448 ; GCN3-LABEL: atomic_add_i32_ret:
449 ; GCN3: ; %bb.0: ; %entry
450 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
451 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x34
452 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
453 ; GCN3-NEXT: v_mov_b32_e32 v0, s4
454 ; GCN3-NEXT: v_mov_b32_e32 v1, s5
455 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
456 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
457 ; GCN3-NEXT: flat_atomic_add v2, v[0:1], v2 glc
458 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
459 ; GCN3-NEXT: buffer_wbinvl1_vol
460 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
461 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
462 ; GCN3-NEXT: flat_store_dword v[0:1], v2
463 ; GCN3-NEXT: s_endpgm
465 %val = atomicrmw volatile add ptr %out, i32 %in syncscope("agent") seq_cst
466 store i32 %val, ptr %out2
470 define amdgpu_kernel void @atomic_add_i32_addr64(ptr %out, i32 %in, i64 %index) {
471 ; GCN1-LABEL: atomic_add_i32_addr64:
472 ; GCN1: ; %bb.0: ; %entry
473 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xd
474 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
475 ; GCN1-NEXT: s_load_dword s6, s[0:1], 0xb
476 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
477 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
478 ; GCN1-NEXT: s_add_u32 s0, s4, s0
479 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
480 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
481 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
482 ; GCN1-NEXT: v_mov_b32_e32 v2, s6
483 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
484 ; GCN1-NEXT: flat_atomic_add v[0:1], v2
485 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
486 ; GCN1-NEXT: buffer_wbinvl1_vol
487 ; GCN1-NEXT: s_endpgm
489 ; GCN2-LABEL: atomic_add_i32_addr64:
490 ; GCN2: ; %bb.0: ; %entry
491 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
492 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
493 ; GCN2-NEXT: s_load_dword s6, s[0:1], 0x2c
494 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
495 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
496 ; GCN2-NEXT: s_add_u32 s0, s4, s0
497 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
498 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
499 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
500 ; GCN2-NEXT: v_mov_b32_e32 v2, s6
501 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
502 ; GCN2-NEXT: flat_atomic_add v[0:1], v2
503 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
504 ; GCN2-NEXT: buffer_wbinvl1_vol
505 ; GCN2-NEXT: s_endpgm
507 ; GCN3-LABEL: atomic_add_i32_addr64:
508 ; GCN3: ; %bb.0: ; %entry
509 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
510 ; GCN3-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
511 ; GCN3-NEXT: s_load_dword s6, s[0:1], 0x2c
512 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
513 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
514 ; GCN3-NEXT: s_add_u32 s0, s4, s0
515 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
516 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
517 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
518 ; GCN3-NEXT: v_mov_b32_e32 v2, s6
519 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
520 ; GCN3-NEXT: flat_atomic_add v[0:1], v2
521 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
522 ; GCN3-NEXT: buffer_wbinvl1_vol
523 ; GCN3-NEXT: s_endpgm
525 %ptr = getelementptr i32, ptr %out, i64 %index
526 %val = atomicrmw volatile add ptr %ptr, i32 %in syncscope("agent") seq_cst
530 define amdgpu_kernel void @atomic_add_i32_ret_addr64(ptr %out, ptr %out2, i32 %in, i64 %index) {
531 ; GCN1-LABEL: atomic_add_i32_ret_addr64:
532 ; GCN1: ; %bb.0: ; %entry
533 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xf
534 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
535 ; GCN1-NEXT: s_load_dword s8, s[0:1], 0xd
536 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
537 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
538 ; GCN1-NEXT: s_add_u32 s0, s4, s0
539 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
540 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
541 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
542 ; GCN1-NEXT: v_mov_b32_e32 v2, s8
543 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
544 ; GCN1-NEXT: flat_atomic_add v2, v[0:1], v2 glc
545 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
546 ; GCN1-NEXT: buffer_wbinvl1_vol
547 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
548 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
549 ; GCN1-NEXT: flat_store_dword v[0:1], v2
550 ; GCN1-NEXT: s_endpgm
552 ; GCN2-LABEL: atomic_add_i32_ret_addr64:
553 ; GCN2: ; %bb.0: ; %entry
554 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
555 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
556 ; GCN2-NEXT: s_load_dword s8, s[0:1], 0x34
557 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
558 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
559 ; GCN2-NEXT: s_add_u32 s0, s4, s0
560 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
561 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
562 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
563 ; GCN2-NEXT: v_mov_b32_e32 v2, s8
564 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
565 ; GCN2-NEXT: flat_atomic_add v2, v[0:1], v2 glc
566 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
567 ; GCN2-NEXT: buffer_wbinvl1_vol
568 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
569 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
570 ; GCN2-NEXT: flat_store_dword v[0:1], v2
571 ; GCN2-NEXT: s_endpgm
573 ; GCN3-LABEL: atomic_add_i32_ret_addr64:
574 ; GCN3: ; %bb.0: ; %entry
575 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
576 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
577 ; GCN3-NEXT: s_load_dword s8, s[0:1], 0x34
578 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
579 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
580 ; GCN3-NEXT: s_add_u32 s0, s4, s0
581 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
582 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
583 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
584 ; GCN3-NEXT: v_mov_b32_e32 v2, s8
585 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
586 ; GCN3-NEXT: flat_atomic_add v2, v[0:1], v2 glc
587 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
588 ; GCN3-NEXT: buffer_wbinvl1_vol
589 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
590 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
591 ; GCN3-NEXT: flat_store_dword v[0:1], v2
592 ; GCN3-NEXT: s_endpgm
594 %ptr = getelementptr i32, ptr %out, i64 %index
595 %val = atomicrmw volatile add ptr %ptr, i32 %in syncscope("agent") seq_cst
596 store i32 %val, ptr %out2
600 define amdgpu_kernel void @atomic_and_i32_offset(ptr %out, i32 %in) {
601 ; GCN1-LABEL: atomic_and_i32_offset:
602 ; GCN1: ; %bb.0: ; %entry
603 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
604 ; GCN1-NEXT: s_load_dword s4, s[0:1], 0xb
605 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
606 ; GCN1-NEXT: s_add_u32 s0, s2, 16
607 ; GCN1-NEXT: s_addc_u32 s1, s3, 0
608 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
609 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
610 ; GCN1-NEXT: v_mov_b32_e32 v2, s4
611 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
612 ; GCN1-NEXT: flat_atomic_and v[0:1], v2
613 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
614 ; GCN1-NEXT: buffer_wbinvl1_vol
615 ; GCN1-NEXT: s_endpgm
617 ; GCN2-LABEL: atomic_and_i32_offset:
618 ; GCN2: ; %bb.0: ; %entry
619 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
620 ; GCN2-NEXT: s_load_dword s4, s[0:1], 0x2c
621 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
622 ; GCN2-NEXT: s_add_u32 s0, s2, 16
623 ; GCN2-NEXT: s_addc_u32 s1, s3, 0
624 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
625 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
626 ; GCN2-NEXT: v_mov_b32_e32 v2, s4
627 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
628 ; GCN2-NEXT: flat_atomic_and v[0:1], v2
629 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
630 ; GCN2-NEXT: buffer_wbinvl1_vol
631 ; GCN2-NEXT: s_endpgm
633 ; GCN3-LABEL: atomic_and_i32_offset:
634 ; GCN3: ; %bb.0: ; %entry
635 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
636 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
637 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
638 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
639 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
640 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
641 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
642 ; GCN3-NEXT: flat_atomic_and v[0:1], v2 offset:16
643 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
644 ; GCN3-NEXT: buffer_wbinvl1_vol
645 ; GCN3-NEXT: s_endpgm
647 %gep = getelementptr i32, ptr %out, i32 4
648 %val = atomicrmw volatile and ptr %gep, i32 %in syncscope("agent") seq_cst
652 define amdgpu_kernel void @atomic_and_i32_ret_offset(ptr %out, ptr %out2, i32 %in) {
653 ; GCN1-LABEL: atomic_and_i32_ret_offset:
654 ; GCN1: ; %bb.0: ; %entry
655 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
656 ; GCN1-NEXT: s_load_dword s2, s[0:1], 0xd
657 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
658 ; GCN1-NEXT: s_add_u32 s0, s4, 16
659 ; GCN1-NEXT: s_addc_u32 s1, s5, 0
660 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
661 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
662 ; GCN1-NEXT: v_mov_b32_e32 v2, s2
663 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
664 ; GCN1-NEXT: flat_atomic_and v2, v[0:1], v2 glc
665 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
666 ; GCN1-NEXT: buffer_wbinvl1_vol
667 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
668 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
669 ; GCN1-NEXT: flat_store_dword v[0:1], v2
670 ; GCN1-NEXT: s_endpgm
672 ; GCN2-LABEL: atomic_and_i32_ret_offset:
673 ; GCN2: ; %bb.0: ; %entry
674 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
675 ; GCN2-NEXT: s_load_dword s2, s[0:1], 0x34
676 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
677 ; GCN2-NEXT: s_add_u32 s0, s4, 16
678 ; GCN2-NEXT: s_addc_u32 s1, s5, 0
679 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
680 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
681 ; GCN2-NEXT: v_mov_b32_e32 v2, s2
682 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
683 ; GCN2-NEXT: flat_atomic_and v2, v[0:1], v2 glc
684 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
685 ; GCN2-NEXT: buffer_wbinvl1_vol
686 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
687 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
688 ; GCN2-NEXT: flat_store_dword v[0:1], v2
689 ; GCN2-NEXT: s_endpgm
691 ; GCN3-LABEL: atomic_and_i32_ret_offset:
692 ; GCN3: ; %bb.0: ; %entry
693 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
694 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x34
695 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
696 ; GCN3-NEXT: v_mov_b32_e32 v0, s4
697 ; GCN3-NEXT: v_mov_b32_e32 v1, s5
698 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
699 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
700 ; GCN3-NEXT: flat_atomic_and v2, v[0:1], v2 offset:16 glc
701 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
702 ; GCN3-NEXT: buffer_wbinvl1_vol
703 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
704 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
705 ; GCN3-NEXT: flat_store_dword v[0:1], v2
706 ; GCN3-NEXT: s_endpgm
708 %gep = getelementptr i32, ptr %out, i32 4
709 %val = atomicrmw volatile and ptr %gep, i32 %in syncscope("agent") seq_cst
710 store i32 %val, ptr %out2
714 define amdgpu_kernel void @atomic_and_i32_addr64_offset(ptr %out, i32 %in, i64 %index) {
715 ; GCN1-LABEL: atomic_and_i32_addr64_offset:
716 ; GCN1: ; %bb.0: ; %entry
717 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xd
718 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
719 ; GCN1-NEXT: s_load_dword s6, s[0:1], 0xb
720 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
721 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
722 ; GCN1-NEXT: s_add_u32 s0, s4, s0
723 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
724 ; GCN1-NEXT: s_add_u32 s0, s0, 16
725 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
726 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
727 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
728 ; GCN1-NEXT: v_mov_b32_e32 v2, s6
729 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
730 ; GCN1-NEXT: flat_atomic_and v[0:1], v2
731 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
732 ; GCN1-NEXT: buffer_wbinvl1_vol
733 ; GCN1-NEXT: s_endpgm
735 ; GCN2-LABEL: atomic_and_i32_addr64_offset:
736 ; GCN2: ; %bb.0: ; %entry
737 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
738 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
739 ; GCN2-NEXT: s_load_dword s6, s[0:1], 0x2c
740 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
741 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
742 ; GCN2-NEXT: s_add_u32 s0, s4, s0
743 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
744 ; GCN2-NEXT: s_add_u32 s0, s0, 16
745 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
746 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
747 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
748 ; GCN2-NEXT: v_mov_b32_e32 v2, s6
749 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
750 ; GCN2-NEXT: flat_atomic_and v[0:1], v2
751 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
752 ; GCN2-NEXT: buffer_wbinvl1_vol
753 ; GCN2-NEXT: s_endpgm
755 ; GCN3-LABEL: atomic_and_i32_addr64_offset:
756 ; GCN3: ; %bb.0: ; %entry
757 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
758 ; GCN3-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
759 ; GCN3-NEXT: s_load_dword s6, s[0:1], 0x2c
760 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
761 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
762 ; GCN3-NEXT: s_add_u32 s0, s4, s0
763 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
764 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
765 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
766 ; GCN3-NEXT: v_mov_b32_e32 v2, s6
767 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
768 ; GCN3-NEXT: flat_atomic_and v[0:1], v2 offset:16
769 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
770 ; GCN3-NEXT: buffer_wbinvl1_vol
771 ; GCN3-NEXT: s_endpgm
773 %ptr = getelementptr i32, ptr %out, i64 %index
774 %gep = getelementptr i32, ptr %ptr, i32 4
775 %val = atomicrmw volatile and ptr %gep, i32 %in syncscope("agent") seq_cst
779 define amdgpu_kernel void @atomic_and_i32_ret_addr64_offset(ptr %out, ptr %out2, i32 %in, i64 %index) {
780 ; GCN1-LABEL: atomic_and_i32_ret_addr64_offset:
781 ; GCN1: ; %bb.0: ; %entry
782 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xf
783 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
784 ; GCN1-NEXT: s_load_dword s8, s[0:1], 0xd
785 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
786 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
787 ; GCN1-NEXT: s_add_u32 s0, s4, s0
788 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
789 ; GCN1-NEXT: s_add_u32 s0, s0, 16
790 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
791 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
792 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
793 ; GCN1-NEXT: v_mov_b32_e32 v2, s8
794 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
795 ; GCN1-NEXT: flat_atomic_and v2, v[0:1], v2 glc
796 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
797 ; GCN1-NEXT: buffer_wbinvl1_vol
798 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
799 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
800 ; GCN1-NEXT: flat_store_dword v[0:1], v2
801 ; GCN1-NEXT: s_endpgm
803 ; GCN2-LABEL: atomic_and_i32_ret_addr64_offset:
804 ; GCN2: ; %bb.0: ; %entry
805 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
806 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
807 ; GCN2-NEXT: s_load_dword s8, s[0:1], 0x34
808 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
809 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
810 ; GCN2-NEXT: s_add_u32 s0, s4, s0
811 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
812 ; GCN2-NEXT: s_add_u32 s0, s0, 16
813 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
814 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
815 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
816 ; GCN2-NEXT: v_mov_b32_e32 v2, s8
817 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
818 ; GCN2-NEXT: flat_atomic_and v2, v[0:1], v2 glc
819 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
820 ; GCN2-NEXT: buffer_wbinvl1_vol
821 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
822 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
823 ; GCN2-NEXT: flat_store_dword v[0:1], v2
824 ; GCN2-NEXT: s_endpgm
826 ; GCN3-LABEL: atomic_and_i32_ret_addr64_offset:
827 ; GCN3: ; %bb.0: ; %entry
828 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
829 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
830 ; GCN3-NEXT: s_load_dword s8, s[0:1], 0x34
831 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
832 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
833 ; GCN3-NEXT: s_add_u32 s0, s4, s0
834 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
835 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
836 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
837 ; GCN3-NEXT: v_mov_b32_e32 v2, s8
838 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
839 ; GCN3-NEXT: flat_atomic_and v2, v[0:1], v2 offset:16 glc
840 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
841 ; GCN3-NEXT: buffer_wbinvl1_vol
842 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
843 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
844 ; GCN3-NEXT: flat_store_dword v[0:1], v2
845 ; GCN3-NEXT: s_endpgm
847 %ptr = getelementptr i32, ptr %out, i64 %index
848 %gep = getelementptr i32, ptr %ptr, i32 4
849 %val = atomicrmw volatile and ptr %gep, i32 %in syncscope("agent") seq_cst
850 store i32 %val, ptr %out2
854 define amdgpu_kernel void @atomic_and_i32(ptr %out, i32 %in) {
855 ; GCN1-LABEL: atomic_and_i32:
856 ; GCN1: ; %bb.0: ; %entry
857 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
858 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0xb
859 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
860 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
861 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
862 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
863 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
864 ; GCN1-NEXT: flat_atomic_and v[0:1], v2
865 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
866 ; GCN1-NEXT: buffer_wbinvl1_vol
867 ; GCN1-NEXT: s_endpgm
869 ; GCN2-LABEL: atomic_and_i32:
870 ; GCN2: ; %bb.0: ; %entry
871 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
872 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x2c
873 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
874 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
875 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
876 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
877 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
878 ; GCN2-NEXT: flat_atomic_and v[0:1], v2
879 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
880 ; GCN2-NEXT: buffer_wbinvl1_vol
881 ; GCN2-NEXT: s_endpgm
883 ; GCN3-LABEL: atomic_and_i32:
884 ; GCN3: ; %bb.0: ; %entry
885 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
886 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
887 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
888 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
889 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
890 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
891 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
892 ; GCN3-NEXT: flat_atomic_and v[0:1], v2
893 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
894 ; GCN3-NEXT: buffer_wbinvl1_vol
895 ; GCN3-NEXT: s_endpgm
897 %val = atomicrmw volatile and ptr %out, i32 %in syncscope("agent") seq_cst
901 define amdgpu_kernel void @atomic_and_i32_ret(ptr %out, ptr %out2, i32 %in) {
902 ; GCN1-LABEL: atomic_and_i32_ret:
903 ; GCN1: ; %bb.0: ; %entry
904 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
905 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0xd
906 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
907 ; GCN1-NEXT: v_mov_b32_e32 v0, s4
908 ; GCN1-NEXT: v_mov_b32_e32 v1, s5
909 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
910 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
911 ; GCN1-NEXT: flat_atomic_and v2, v[0:1], v2 glc
912 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
913 ; GCN1-NEXT: buffer_wbinvl1_vol
914 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
915 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
916 ; GCN1-NEXT: flat_store_dword v[0:1], v2
917 ; GCN1-NEXT: s_endpgm
919 ; GCN2-LABEL: atomic_and_i32_ret:
920 ; GCN2: ; %bb.0: ; %entry
921 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
922 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x34
923 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
924 ; GCN2-NEXT: v_mov_b32_e32 v0, s4
925 ; GCN2-NEXT: v_mov_b32_e32 v1, s5
926 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
927 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
928 ; GCN2-NEXT: flat_atomic_and v2, v[0:1], v2 glc
929 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
930 ; GCN2-NEXT: buffer_wbinvl1_vol
931 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
932 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
933 ; GCN2-NEXT: flat_store_dword v[0:1], v2
934 ; GCN2-NEXT: s_endpgm
936 ; GCN3-LABEL: atomic_and_i32_ret:
937 ; GCN3: ; %bb.0: ; %entry
938 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
939 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x34
940 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
941 ; GCN3-NEXT: v_mov_b32_e32 v0, s4
942 ; GCN3-NEXT: v_mov_b32_e32 v1, s5
943 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
944 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
945 ; GCN3-NEXT: flat_atomic_and v2, v[0:1], v2 glc
946 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
947 ; GCN3-NEXT: buffer_wbinvl1_vol
948 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
949 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
950 ; GCN3-NEXT: flat_store_dword v[0:1], v2
951 ; GCN3-NEXT: s_endpgm
953 %val = atomicrmw volatile and ptr %out, i32 %in syncscope("agent") seq_cst
954 store i32 %val, ptr %out2
958 define amdgpu_kernel void @atomic_and_i32_addr64(ptr %out, i32 %in, i64 %index) {
959 ; GCN1-LABEL: atomic_and_i32_addr64:
960 ; GCN1: ; %bb.0: ; %entry
961 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xd
962 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
963 ; GCN1-NEXT: s_load_dword s6, s[0:1], 0xb
964 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
965 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
966 ; GCN1-NEXT: s_add_u32 s0, s4, s0
967 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
968 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
969 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
970 ; GCN1-NEXT: v_mov_b32_e32 v2, s6
971 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
972 ; GCN1-NEXT: flat_atomic_and v[0:1], v2
973 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
974 ; GCN1-NEXT: buffer_wbinvl1_vol
975 ; GCN1-NEXT: s_endpgm
977 ; GCN2-LABEL: atomic_and_i32_addr64:
978 ; GCN2: ; %bb.0: ; %entry
979 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
980 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
981 ; GCN2-NEXT: s_load_dword s6, s[0:1], 0x2c
982 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
983 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
984 ; GCN2-NEXT: s_add_u32 s0, s4, s0
985 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
986 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
987 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
988 ; GCN2-NEXT: v_mov_b32_e32 v2, s6
989 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
990 ; GCN2-NEXT: flat_atomic_and v[0:1], v2
991 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
992 ; GCN2-NEXT: buffer_wbinvl1_vol
993 ; GCN2-NEXT: s_endpgm
995 ; GCN3-LABEL: atomic_and_i32_addr64:
996 ; GCN3: ; %bb.0: ; %entry
997 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
998 ; GCN3-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
999 ; GCN3-NEXT: s_load_dword s6, s[0:1], 0x2c
1000 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1001 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
1002 ; GCN3-NEXT: s_add_u32 s0, s4, s0
1003 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
1004 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
1005 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
1006 ; GCN3-NEXT: v_mov_b32_e32 v2, s6
1007 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1008 ; GCN3-NEXT: flat_atomic_and v[0:1], v2
1009 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1010 ; GCN3-NEXT: buffer_wbinvl1_vol
1011 ; GCN3-NEXT: s_endpgm
1013 %ptr = getelementptr i32, ptr %out, i64 %index
1014 %val = atomicrmw volatile and ptr %ptr, i32 %in syncscope("agent") seq_cst
1018 define amdgpu_kernel void @atomic_and_i32_ret_addr64(ptr %out, ptr %out2, i32 %in, i64 %index) {
1019 ; GCN1-LABEL: atomic_and_i32_ret_addr64:
1020 ; GCN1: ; %bb.0: ; %entry
1021 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xf
1022 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
1023 ; GCN1-NEXT: s_load_dword s8, s[0:1], 0xd
1024 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1025 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
1026 ; GCN1-NEXT: s_add_u32 s0, s4, s0
1027 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
1028 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
1029 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
1030 ; GCN1-NEXT: v_mov_b32_e32 v2, s8
1031 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1032 ; GCN1-NEXT: flat_atomic_and v2, v[0:1], v2 glc
1033 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1034 ; GCN1-NEXT: buffer_wbinvl1_vol
1035 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
1036 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
1037 ; GCN1-NEXT: flat_store_dword v[0:1], v2
1038 ; GCN1-NEXT: s_endpgm
1040 ; GCN2-LABEL: atomic_and_i32_ret_addr64:
1041 ; GCN2: ; %bb.0: ; %entry
1042 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
1043 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
1044 ; GCN2-NEXT: s_load_dword s8, s[0:1], 0x34
1045 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1046 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
1047 ; GCN2-NEXT: s_add_u32 s0, s4, s0
1048 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
1049 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
1050 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
1051 ; GCN2-NEXT: v_mov_b32_e32 v2, s8
1052 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1053 ; GCN2-NEXT: flat_atomic_and v2, v[0:1], v2 glc
1054 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1055 ; GCN2-NEXT: buffer_wbinvl1_vol
1056 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
1057 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
1058 ; GCN2-NEXT: flat_store_dword v[0:1], v2
1059 ; GCN2-NEXT: s_endpgm
1061 ; GCN3-LABEL: atomic_and_i32_ret_addr64:
1062 ; GCN3: ; %bb.0: ; %entry
1063 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
1064 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
1065 ; GCN3-NEXT: s_load_dword s8, s[0:1], 0x34
1066 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1067 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
1068 ; GCN3-NEXT: s_add_u32 s0, s4, s0
1069 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
1070 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
1071 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
1072 ; GCN3-NEXT: v_mov_b32_e32 v2, s8
1073 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1074 ; GCN3-NEXT: flat_atomic_and v2, v[0:1], v2 glc
1075 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1076 ; GCN3-NEXT: buffer_wbinvl1_vol
1077 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
1078 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
1079 ; GCN3-NEXT: flat_store_dword v[0:1], v2
1080 ; GCN3-NEXT: s_endpgm
1082 %ptr = getelementptr i32, ptr %out, i64 %index
1083 %val = atomicrmw volatile and ptr %ptr, i32 %in syncscope("agent") seq_cst
1084 store i32 %val, ptr %out2
1088 define amdgpu_kernel void @atomic_sub_i32_offset(ptr %out, i32 %in) {
1089 ; GCN1-LABEL: atomic_sub_i32_offset:
1090 ; GCN1: ; %bb.0: ; %entry
1091 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
1092 ; GCN1-NEXT: s_load_dword s4, s[0:1], 0xb
1093 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1094 ; GCN1-NEXT: s_add_u32 s0, s2, 16
1095 ; GCN1-NEXT: s_addc_u32 s1, s3, 0
1096 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
1097 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
1098 ; GCN1-NEXT: v_mov_b32_e32 v2, s4
1099 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1100 ; GCN1-NEXT: flat_atomic_sub v[0:1], v2
1101 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1102 ; GCN1-NEXT: buffer_wbinvl1_vol
1103 ; GCN1-NEXT: s_endpgm
1105 ; GCN2-LABEL: atomic_sub_i32_offset:
1106 ; GCN2: ; %bb.0: ; %entry
1107 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
1108 ; GCN2-NEXT: s_load_dword s4, s[0:1], 0x2c
1109 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1110 ; GCN2-NEXT: s_add_u32 s0, s2, 16
1111 ; GCN2-NEXT: s_addc_u32 s1, s3, 0
1112 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
1113 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
1114 ; GCN2-NEXT: v_mov_b32_e32 v2, s4
1115 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1116 ; GCN2-NEXT: flat_atomic_sub v[0:1], v2
1117 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1118 ; GCN2-NEXT: buffer_wbinvl1_vol
1119 ; GCN2-NEXT: s_endpgm
1121 ; GCN3-LABEL: atomic_sub_i32_offset:
1122 ; GCN3: ; %bb.0: ; %entry
1123 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
1124 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
1125 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1126 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
1127 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
1128 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
1129 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1130 ; GCN3-NEXT: flat_atomic_sub v[0:1], v2 offset:16
1131 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1132 ; GCN3-NEXT: buffer_wbinvl1_vol
1133 ; GCN3-NEXT: s_endpgm
1135 %gep = getelementptr i32, ptr %out, i32 4
1136 %val = atomicrmw volatile sub ptr %gep, i32 %in syncscope("agent") seq_cst
1140 define amdgpu_kernel void @atomic_sub_i32_ret_offset(ptr %out, ptr %out2, i32 %in) {
1141 ; GCN1-LABEL: atomic_sub_i32_ret_offset:
1142 ; GCN1: ; %bb.0: ; %entry
1143 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
1144 ; GCN1-NEXT: s_load_dword s2, s[0:1], 0xd
1145 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1146 ; GCN1-NEXT: s_add_u32 s0, s4, 16
1147 ; GCN1-NEXT: s_addc_u32 s1, s5, 0
1148 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
1149 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
1150 ; GCN1-NEXT: v_mov_b32_e32 v2, s2
1151 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1152 ; GCN1-NEXT: flat_atomic_sub v2, v[0:1], v2 glc
1153 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1154 ; GCN1-NEXT: buffer_wbinvl1_vol
1155 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
1156 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
1157 ; GCN1-NEXT: flat_store_dword v[0:1], v2
1158 ; GCN1-NEXT: s_endpgm
1160 ; GCN2-LABEL: atomic_sub_i32_ret_offset:
1161 ; GCN2: ; %bb.0: ; %entry
1162 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
1163 ; GCN2-NEXT: s_load_dword s2, s[0:1], 0x34
1164 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1165 ; GCN2-NEXT: s_add_u32 s0, s4, 16
1166 ; GCN2-NEXT: s_addc_u32 s1, s5, 0
1167 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
1168 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
1169 ; GCN2-NEXT: v_mov_b32_e32 v2, s2
1170 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1171 ; GCN2-NEXT: flat_atomic_sub v2, v[0:1], v2 glc
1172 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1173 ; GCN2-NEXT: buffer_wbinvl1_vol
1174 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
1175 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
1176 ; GCN2-NEXT: flat_store_dword v[0:1], v2
1177 ; GCN2-NEXT: s_endpgm
1179 ; GCN3-LABEL: atomic_sub_i32_ret_offset:
1180 ; GCN3: ; %bb.0: ; %entry
1181 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
1182 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x34
1183 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1184 ; GCN3-NEXT: v_mov_b32_e32 v0, s4
1185 ; GCN3-NEXT: v_mov_b32_e32 v1, s5
1186 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
1187 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1188 ; GCN3-NEXT: flat_atomic_sub v2, v[0:1], v2 offset:16 glc
1189 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1190 ; GCN3-NEXT: buffer_wbinvl1_vol
1191 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
1192 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
1193 ; GCN3-NEXT: flat_store_dword v[0:1], v2
1194 ; GCN3-NEXT: s_endpgm
1196 %gep = getelementptr i32, ptr %out, i32 4
1197 %val = atomicrmw volatile sub ptr %gep, i32 %in syncscope("agent") seq_cst
1198 store i32 %val, ptr %out2
1202 define amdgpu_kernel void @atomic_sub_i32_addr64_offset(ptr %out, i32 %in, i64 %index) {
1203 ; GCN1-LABEL: atomic_sub_i32_addr64_offset:
1204 ; GCN1: ; %bb.0: ; %entry
1205 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xd
1206 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
1207 ; GCN1-NEXT: s_load_dword s6, s[0:1], 0xb
1208 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1209 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
1210 ; GCN1-NEXT: s_add_u32 s0, s4, s0
1211 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
1212 ; GCN1-NEXT: s_add_u32 s0, s0, 16
1213 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
1214 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
1215 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
1216 ; GCN1-NEXT: v_mov_b32_e32 v2, s6
1217 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1218 ; GCN1-NEXT: flat_atomic_sub v[0:1], v2
1219 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1220 ; GCN1-NEXT: buffer_wbinvl1_vol
1221 ; GCN1-NEXT: s_endpgm
1223 ; GCN2-LABEL: atomic_sub_i32_addr64_offset:
1224 ; GCN2: ; %bb.0: ; %entry
1225 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
1226 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
1227 ; GCN2-NEXT: s_load_dword s6, s[0:1], 0x2c
1228 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1229 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
1230 ; GCN2-NEXT: s_add_u32 s0, s4, s0
1231 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
1232 ; GCN2-NEXT: s_add_u32 s0, s0, 16
1233 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
1234 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
1235 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
1236 ; GCN2-NEXT: v_mov_b32_e32 v2, s6
1237 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1238 ; GCN2-NEXT: flat_atomic_sub v[0:1], v2
1239 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1240 ; GCN2-NEXT: buffer_wbinvl1_vol
1241 ; GCN2-NEXT: s_endpgm
1243 ; GCN3-LABEL: atomic_sub_i32_addr64_offset:
1244 ; GCN3: ; %bb.0: ; %entry
1245 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
1246 ; GCN3-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
1247 ; GCN3-NEXT: s_load_dword s6, s[0:1], 0x2c
1248 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1249 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
1250 ; GCN3-NEXT: s_add_u32 s0, s4, s0
1251 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
1252 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
1253 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
1254 ; GCN3-NEXT: v_mov_b32_e32 v2, s6
1255 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1256 ; GCN3-NEXT: flat_atomic_sub v[0:1], v2 offset:16
1257 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1258 ; GCN3-NEXT: buffer_wbinvl1_vol
1259 ; GCN3-NEXT: s_endpgm
1261 %ptr = getelementptr i32, ptr %out, i64 %index
1262 %gep = getelementptr i32, ptr %ptr, i32 4
1263 %val = atomicrmw volatile sub ptr %gep, i32 %in syncscope("agent") seq_cst
1267 define amdgpu_kernel void @atomic_sub_i32_ret_addr64_offset(ptr %out, ptr %out2, i32 %in, i64 %index) {
1268 ; GCN1-LABEL: atomic_sub_i32_ret_addr64_offset:
1269 ; GCN1: ; %bb.0: ; %entry
1270 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xf
1271 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
1272 ; GCN1-NEXT: s_load_dword s8, s[0:1], 0xd
1273 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1274 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
1275 ; GCN1-NEXT: s_add_u32 s0, s4, s0
1276 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
1277 ; GCN1-NEXT: s_add_u32 s0, s0, 16
1278 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
1279 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
1280 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
1281 ; GCN1-NEXT: v_mov_b32_e32 v2, s8
1282 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1283 ; GCN1-NEXT: flat_atomic_sub v2, v[0:1], v2 glc
1284 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1285 ; GCN1-NEXT: buffer_wbinvl1_vol
1286 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
1287 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
1288 ; GCN1-NEXT: flat_store_dword v[0:1], v2
1289 ; GCN1-NEXT: s_endpgm
1291 ; GCN2-LABEL: atomic_sub_i32_ret_addr64_offset:
1292 ; GCN2: ; %bb.0: ; %entry
1293 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
1294 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
1295 ; GCN2-NEXT: s_load_dword s8, s[0:1], 0x34
1296 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1297 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
1298 ; GCN2-NEXT: s_add_u32 s0, s4, s0
1299 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
1300 ; GCN2-NEXT: s_add_u32 s0, s0, 16
1301 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
1302 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
1303 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
1304 ; GCN2-NEXT: v_mov_b32_e32 v2, s8
1305 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1306 ; GCN2-NEXT: flat_atomic_sub v2, v[0:1], v2 glc
1307 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1308 ; GCN2-NEXT: buffer_wbinvl1_vol
1309 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
1310 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
1311 ; GCN2-NEXT: flat_store_dword v[0:1], v2
1312 ; GCN2-NEXT: s_endpgm
1314 ; GCN3-LABEL: atomic_sub_i32_ret_addr64_offset:
1315 ; GCN3: ; %bb.0: ; %entry
1316 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
1317 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
1318 ; GCN3-NEXT: s_load_dword s8, s[0:1], 0x34
1319 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1320 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
1321 ; GCN3-NEXT: s_add_u32 s0, s4, s0
1322 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
1323 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
1324 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
1325 ; GCN3-NEXT: v_mov_b32_e32 v2, s8
1326 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1327 ; GCN3-NEXT: flat_atomic_sub v2, v[0:1], v2 offset:16 glc
1328 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1329 ; GCN3-NEXT: buffer_wbinvl1_vol
1330 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
1331 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
1332 ; GCN3-NEXT: flat_store_dword v[0:1], v2
1333 ; GCN3-NEXT: s_endpgm
1335 %ptr = getelementptr i32, ptr %out, i64 %index
1336 %gep = getelementptr i32, ptr %ptr, i32 4
1337 %val = atomicrmw volatile sub ptr %gep, i32 %in syncscope("agent") seq_cst
1338 store i32 %val, ptr %out2
1342 define amdgpu_kernel void @atomic_sub_i32(ptr %out, i32 %in) {
1343 ; GCN1-LABEL: atomic_sub_i32:
1344 ; GCN1: ; %bb.0: ; %entry
1345 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
1346 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0xb
1347 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1348 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
1349 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
1350 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
1351 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1352 ; GCN1-NEXT: flat_atomic_sub v[0:1], v2
1353 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1354 ; GCN1-NEXT: buffer_wbinvl1_vol
1355 ; GCN1-NEXT: s_endpgm
1357 ; GCN2-LABEL: atomic_sub_i32:
1358 ; GCN2: ; %bb.0: ; %entry
1359 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
1360 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x2c
1361 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1362 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
1363 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
1364 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
1365 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1366 ; GCN2-NEXT: flat_atomic_sub v[0:1], v2
1367 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1368 ; GCN2-NEXT: buffer_wbinvl1_vol
1369 ; GCN2-NEXT: s_endpgm
1371 ; GCN3-LABEL: atomic_sub_i32:
1372 ; GCN3: ; %bb.0: ; %entry
1373 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
1374 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
1375 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1376 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
1377 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
1378 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
1379 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1380 ; GCN3-NEXT: flat_atomic_sub v[0:1], v2
1381 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1382 ; GCN3-NEXT: buffer_wbinvl1_vol
1383 ; GCN3-NEXT: s_endpgm
1385 %val = atomicrmw volatile sub ptr %out, i32 %in syncscope("agent") seq_cst
1389 define amdgpu_kernel void @atomic_sub_i32_ret(ptr %out, ptr %out2, i32 %in) {
1390 ; GCN1-LABEL: atomic_sub_i32_ret:
1391 ; GCN1: ; %bb.0: ; %entry
1392 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
1393 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0xd
1394 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1395 ; GCN1-NEXT: v_mov_b32_e32 v0, s4
1396 ; GCN1-NEXT: v_mov_b32_e32 v1, s5
1397 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
1398 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1399 ; GCN1-NEXT: flat_atomic_sub v2, v[0:1], v2 glc
1400 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1401 ; GCN1-NEXT: buffer_wbinvl1_vol
1402 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
1403 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
1404 ; GCN1-NEXT: flat_store_dword v[0:1], v2
1405 ; GCN1-NEXT: s_endpgm
1407 ; GCN2-LABEL: atomic_sub_i32_ret:
1408 ; GCN2: ; %bb.0: ; %entry
1409 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
1410 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x34
1411 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1412 ; GCN2-NEXT: v_mov_b32_e32 v0, s4
1413 ; GCN2-NEXT: v_mov_b32_e32 v1, s5
1414 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
1415 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1416 ; GCN2-NEXT: flat_atomic_sub v2, v[0:1], v2 glc
1417 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1418 ; GCN2-NEXT: buffer_wbinvl1_vol
1419 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
1420 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
1421 ; GCN2-NEXT: flat_store_dword v[0:1], v2
1422 ; GCN2-NEXT: s_endpgm
1424 ; GCN3-LABEL: atomic_sub_i32_ret:
1425 ; GCN3: ; %bb.0: ; %entry
1426 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
1427 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x34
1428 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1429 ; GCN3-NEXT: v_mov_b32_e32 v0, s4
1430 ; GCN3-NEXT: v_mov_b32_e32 v1, s5
1431 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
1432 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1433 ; GCN3-NEXT: flat_atomic_sub v2, v[0:1], v2 glc
1434 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1435 ; GCN3-NEXT: buffer_wbinvl1_vol
1436 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
1437 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
1438 ; GCN3-NEXT: flat_store_dword v[0:1], v2
1439 ; GCN3-NEXT: s_endpgm
1441 %val = atomicrmw volatile sub ptr %out, i32 %in syncscope("agent") seq_cst
1442 store i32 %val, ptr %out2
1446 define amdgpu_kernel void @atomic_sub_i32_addr64(ptr %out, i32 %in, i64 %index) {
1447 ; GCN1-LABEL: atomic_sub_i32_addr64:
1448 ; GCN1: ; %bb.0: ; %entry
1449 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xd
1450 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
1451 ; GCN1-NEXT: s_load_dword s6, s[0:1], 0xb
1452 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1453 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
1454 ; GCN1-NEXT: s_add_u32 s0, s4, s0
1455 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
1456 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
1457 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
1458 ; GCN1-NEXT: v_mov_b32_e32 v2, s6
1459 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1460 ; GCN1-NEXT: flat_atomic_sub v[0:1], v2
1461 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1462 ; GCN1-NEXT: buffer_wbinvl1_vol
1463 ; GCN1-NEXT: s_endpgm
1465 ; GCN2-LABEL: atomic_sub_i32_addr64:
1466 ; GCN2: ; %bb.0: ; %entry
1467 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
1468 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
1469 ; GCN2-NEXT: s_load_dword s6, s[0:1], 0x2c
1470 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1471 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
1472 ; GCN2-NEXT: s_add_u32 s0, s4, s0
1473 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
1474 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
1475 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
1476 ; GCN2-NEXT: v_mov_b32_e32 v2, s6
1477 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1478 ; GCN2-NEXT: flat_atomic_sub v[0:1], v2
1479 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1480 ; GCN2-NEXT: buffer_wbinvl1_vol
1481 ; GCN2-NEXT: s_endpgm
1483 ; GCN3-LABEL: atomic_sub_i32_addr64:
1484 ; GCN3: ; %bb.0: ; %entry
1485 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
1486 ; GCN3-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
1487 ; GCN3-NEXT: s_load_dword s6, s[0:1], 0x2c
1488 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1489 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
1490 ; GCN3-NEXT: s_add_u32 s0, s4, s0
1491 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
1492 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
1493 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
1494 ; GCN3-NEXT: v_mov_b32_e32 v2, s6
1495 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1496 ; GCN3-NEXT: flat_atomic_sub v[0:1], v2
1497 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1498 ; GCN3-NEXT: buffer_wbinvl1_vol
1499 ; GCN3-NEXT: s_endpgm
1501 %ptr = getelementptr i32, ptr %out, i64 %index
1502 %val = atomicrmw volatile sub ptr %ptr, i32 %in syncscope("agent") seq_cst
1506 define amdgpu_kernel void @atomic_sub_i32_ret_addr64(ptr %out, ptr %out2, i32 %in, i64 %index) {
1507 ; GCN1-LABEL: atomic_sub_i32_ret_addr64:
1508 ; GCN1: ; %bb.0: ; %entry
1509 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xf
1510 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
1511 ; GCN1-NEXT: s_load_dword s8, s[0:1], 0xd
1512 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1513 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
1514 ; GCN1-NEXT: s_add_u32 s0, s4, s0
1515 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
1516 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
1517 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
1518 ; GCN1-NEXT: v_mov_b32_e32 v2, s8
1519 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1520 ; GCN1-NEXT: flat_atomic_sub v2, v[0:1], v2 glc
1521 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1522 ; GCN1-NEXT: buffer_wbinvl1_vol
1523 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
1524 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
1525 ; GCN1-NEXT: flat_store_dword v[0:1], v2
1526 ; GCN1-NEXT: s_endpgm
1528 ; GCN2-LABEL: atomic_sub_i32_ret_addr64:
1529 ; GCN2: ; %bb.0: ; %entry
1530 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
1531 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
1532 ; GCN2-NEXT: s_load_dword s8, s[0:1], 0x34
1533 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1534 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
1535 ; GCN2-NEXT: s_add_u32 s0, s4, s0
1536 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
1537 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
1538 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
1539 ; GCN2-NEXT: v_mov_b32_e32 v2, s8
1540 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1541 ; GCN2-NEXT: flat_atomic_sub v2, v[0:1], v2 glc
1542 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1543 ; GCN2-NEXT: buffer_wbinvl1_vol
1544 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
1545 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
1546 ; GCN2-NEXT: flat_store_dword v[0:1], v2
1547 ; GCN2-NEXT: s_endpgm
1549 ; GCN3-LABEL: atomic_sub_i32_ret_addr64:
1550 ; GCN3: ; %bb.0: ; %entry
1551 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
1552 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
1553 ; GCN3-NEXT: s_load_dword s8, s[0:1], 0x34
1554 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1555 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
1556 ; GCN3-NEXT: s_add_u32 s0, s4, s0
1557 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
1558 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
1559 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
1560 ; GCN3-NEXT: v_mov_b32_e32 v2, s8
1561 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1562 ; GCN3-NEXT: flat_atomic_sub v2, v[0:1], v2 glc
1563 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
1564 ; GCN3-NEXT: buffer_wbinvl1_vol
1565 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
1566 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
1567 ; GCN3-NEXT: flat_store_dword v[0:1], v2
1568 ; GCN3-NEXT: s_endpgm
1570 %ptr = getelementptr i32, ptr %out, i64 %index
1571 %val = atomicrmw volatile sub ptr %ptr, i32 %in syncscope("agent") seq_cst
1572 store i32 %val, ptr %out2
1576 define amdgpu_kernel void @atomic_max_i32_offset(ptr %out, i32 %in) {
1577 ; GCN1-LABEL: atomic_max_i32_offset:
1578 ; GCN1: ; %bb.0: ; %entry
1579 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
1580 ; GCN1-NEXT: s_load_dword s4, s[0:1], 0xb
1581 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1582 ; GCN1-NEXT: s_add_u32 s0, s2, 16
1583 ; GCN1-NEXT: s_addc_u32 s1, s3, 0
1584 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
1585 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
1586 ; GCN1-NEXT: v_mov_b32_e32 v2, s4
1587 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1588 ; GCN1-NEXT: flat_atomic_smax v[0:1], v2
1589 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1590 ; GCN1-NEXT: s_endpgm
1592 ; GCN2-LABEL: atomic_max_i32_offset:
1593 ; GCN2: ; %bb.0: ; %entry
1594 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
1595 ; GCN2-NEXT: s_load_dword s4, s[0:1], 0x2c
1596 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1597 ; GCN2-NEXT: s_add_u32 s0, s2, 16
1598 ; GCN2-NEXT: s_addc_u32 s1, s3, 0
1599 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
1600 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
1601 ; GCN2-NEXT: v_mov_b32_e32 v2, s4
1602 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1603 ; GCN2-NEXT: flat_atomic_smax v[0:1], v2
1604 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1605 ; GCN2-NEXT: s_endpgm
1607 ; GCN3-LABEL: atomic_max_i32_offset:
1608 ; GCN3: ; %bb.0: ; %entry
1609 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
1610 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
1611 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1612 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
1613 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
1614 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
1615 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1616 ; GCN3-NEXT: flat_atomic_smax v[0:1], v2 offset:16
1617 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1618 ; GCN3-NEXT: s_endpgm
1620 %gep = getelementptr i32, ptr %out, i32 4
1621 %val = atomicrmw volatile max ptr %gep, i32 %in syncscope("workgroup") seq_cst
1625 define amdgpu_kernel void @atomic_max_i32_ret_offset(ptr %out, ptr %out2, i32 %in) {
1626 ; GCN1-LABEL: atomic_max_i32_ret_offset:
1627 ; GCN1: ; %bb.0: ; %entry
1628 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
1629 ; GCN1-NEXT: s_load_dword s2, s[0:1], 0xd
1630 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1631 ; GCN1-NEXT: s_add_u32 s0, s4, 16
1632 ; GCN1-NEXT: s_addc_u32 s1, s5, 0
1633 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
1634 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
1635 ; GCN1-NEXT: v_mov_b32_e32 v2, s2
1636 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1637 ; GCN1-NEXT: flat_atomic_smax v2, v[0:1], v2 glc
1638 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1639 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
1640 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
1641 ; GCN1-NEXT: s_waitcnt vmcnt(0)
1642 ; GCN1-NEXT: flat_store_dword v[0:1], v2
1643 ; GCN1-NEXT: s_endpgm
1645 ; GCN2-LABEL: atomic_max_i32_ret_offset:
1646 ; GCN2: ; %bb.0: ; %entry
1647 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
1648 ; GCN2-NEXT: s_load_dword s2, s[0:1], 0x34
1649 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1650 ; GCN2-NEXT: s_add_u32 s0, s4, 16
1651 ; GCN2-NEXT: s_addc_u32 s1, s5, 0
1652 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
1653 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
1654 ; GCN2-NEXT: v_mov_b32_e32 v2, s2
1655 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1656 ; GCN2-NEXT: flat_atomic_smax v2, v[0:1], v2 glc
1657 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1658 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
1659 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
1660 ; GCN2-NEXT: s_waitcnt vmcnt(0)
1661 ; GCN2-NEXT: flat_store_dword v[0:1], v2
1662 ; GCN2-NEXT: s_endpgm
1664 ; GCN3-LABEL: atomic_max_i32_ret_offset:
1665 ; GCN3: ; %bb.0: ; %entry
1666 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
1667 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x34
1668 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1669 ; GCN3-NEXT: v_mov_b32_e32 v0, s4
1670 ; GCN3-NEXT: v_mov_b32_e32 v1, s5
1671 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
1672 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1673 ; GCN3-NEXT: flat_atomic_smax v2, v[0:1], v2 offset:16 glc
1674 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1675 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
1676 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
1677 ; GCN3-NEXT: s_waitcnt vmcnt(0)
1678 ; GCN3-NEXT: flat_store_dword v[0:1], v2
1679 ; GCN3-NEXT: s_endpgm
1681 %gep = getelementptr i32, ptr %out, i32 4
1682 %val = atomicrmw volatile max ptr %gep, i32 %in syncscope("workgroup") seq_cst
1683 store i32 %val, ptr %out2
1687 define amdgpu_kernel void @atomic_max_i32_addr64_offset(ptr %out, i32 %in, i64 %index) {
1688 ; GCN1-LABEL: atomic_max_i32_addr64_offset:
1689 ; GCN1: ; %bb.0: ; %entry
1690 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xd
1691 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
1692 ; GCN1-NEXT: s_load_dword s6, s[0:1], 0xb
1693 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1694 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
1695 ; GCN1-NEXT: s_add_u32 s0, s4, s0
1696 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
1697 ; GCN1-NEXT: s_add_u32 s0, s0, 16
1698 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
1699 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
1700 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
1701 ; GCN1-NEXT: v_mov_b32_e32 v2, s6
1702 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1703 ; GCN1-NEXT: flat_atomic_smax v[0:1], v2
1704 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1705 ; GCN1-NEXT: s_endpgm
1707 ; GCN2-LABEL: atomic_max_i32_addr64_offset:
1708 ; GCN2: ; %bb.0: ; %entry
1709 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
1710 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
1711 ; GCN2-NEXT: s_load_dword s6, s[0:1], 0x2c
1712 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1713 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
1714 ; GCN2-NEXT: s_add_u32 s0, s4, s0
1715 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
1716 ; GCN2-NEXT: s_add_u32 s0, s0, 16
1717 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
1718 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
1719 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
1720 ; GCN2-NEXT: v_mov_b32_e32 v2, s6
1721 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1722 ; GCN2-NEXT: flat_atomic_smax v[0:1], v2
1723 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1724 ; GCN2-NEXT: s_endpgm
1726 ; GCN3-LABEL: atomic_max_i32_addr64_offset:
1727 ; GCN3: ; %bb.0: ; %entry
1728 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
1729 ; GCN3-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
1730 ; GCN3-NEXT: s_load_dword s6, s[0:1], 0x2c
1731 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1732 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
1733 ; GCN3-NEXT: s_add_u32 s0, s4, s0
1734 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
1735 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
1736 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
1737 ; GCN3-NEXT: v_mov_b32_e32 v2, s6
1738 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1739 ; GCN3-NEXT: flat_atomic_smax v[0:1], v2 offset:16
1740 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1741 ; GCN3-NEXT: s_endpgm
1743 %ptr = getelementptr i32, ptr %out, i64 %index
1744 %gep = getelementptr i32, ptr %ptr, i32 4
1745 %val = atomicrmw volatile max ptr %gep, i32 %in syncscope("workgroup") seq_cst
1749 define amdgpu_kernel void @atomic_max_i32_ret_addr64_offset(ptr %out, ptr %out2, i32 %in, i64 %index) {
1750 ; GCN1-LABEL: atomic_max_i32_ret_addr64_offset:
1751 ; GCN1: ; %bb.0: ; %entry
1752 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xf
1753 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
1754 ; GCN1-NEXT: s_load_dword s8, s[0:1], 0xd
1755 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1756 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
1757 ; GCN1-NEXT: s_add_u32 s0, s4, s0
1758 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
1759 ; GCN1-NEXT: s_add_u32 s0, s0, 16
1760 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
1761 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
1762 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
1763 ; GCN1-NEXT: v_mov_b32_e32 v2, s8
1764 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1765 ; GCN1-NEXT: flat_atomic_smax v2, v[0:1], v2 glc
1766 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1767 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
1768 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
1769 ; GCN1-NEXT: s_waitcnt vmcnt(0)
1770 ; GCN1-NEXT: flat_store_dword v[0:1], v2
1771 ; GCN1-NEXT: s_endpgm
1773 ; GCN2-LABEL: atomic_max_i32_ret_addr64_offset:
1774 ; GCN2: ; %bb.0: ; %entry
1775 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
1776 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
1777 ; GCN2-NEXT: s_load_dword s8, s[0:1], 0x34
1778 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1779 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
1780 ; GCN2-NEXT: s_add_u32 s0, s4, s0
1781 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
1782 ; GCN2-NEXT: s_add_u32 s0, s0, 16
1783 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
1784 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
1785 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
1786 ; GCN2-NEXT: v_mov_b32_e32 v2, s8
1787 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1788 ; GCN2-NEXT: flat_atomic_smax v2, v[0:1], v2 glc
1789 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1790 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
1791 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
1792 ; GCN2-NEXT: s_waitcnt vmcnt(0)
1793 ; GCN2-NEXT: flat_store_dword v[0:1], v2
1794 ; GCN2-NEXT: s_endpgm
1796 ; GCN3-LABEL: atomic_max_i32_ret_addr64_offset:
1797 ; GCN3: ; %bb.0: ; %entry
1798 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
1799 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
1800 ; GCN3-NEXT: s_load_dword s8, s[0:1], 0x34
1801 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1802 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
1803 ; GCN3-NEXT: s_add_u32 s0, s4, s0
1804 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
1805 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
1806 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
1807 ; GCN3-NEXT: v_mov_b32_e32 v2, s8
1808 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1809 ; GCN3-NEXT: flat_atomic_smax v2, v[0:1], v2 offset:16 glc
1810 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1811 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
1812 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
1813 ; GCN3-NEXT: s_waitcnt vmcnt(0)
1814 ; GCN3-NEXT: flat_store_dword v[0:1], v2
1815 ; GCN3-NEXT: s_endpgm
1817 %ptr = getelementptr i32, ptr %out, i64 %index
1818 %gep = getelementptr i32, ptr %ptr, i32 4
1819 %val = atomicrmw volatile max ptr %gep, i32 %in syncscope("workgroup") seq_cst
1820 store i32 %val, ptr %out2
1824 define amdgpu_kernel void @atomic_max_i32(ptr %out, i32 %in) {
1825 ; GCN1-LABEL: atomic_max_i32:
1826 ; GCN1: ; %bb.0: ; %entry
1827 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
1828 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0xb
1829 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1830 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
1831 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
1832 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
1833 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1834 ; GCN1-NEXT: flat_atomic_smax v[0:1], v2
1835 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1836 ; GCN1-NEXT: s_endpgm
1838 ; GCN2-LABEL: atomic_max_i32:
1839 ; GCN2: ; %bb.0: ; %entry
1840 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
1841 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x2c
1842 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1843 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
1844 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
1845 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
1846 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1847 ; GCN2-NEXT: flat_atomic_smax v[0:1], v2
1848 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1849 ; GCN2-NEXT: s_endpgm
1851 ; GCN3-LABEL: atomic_max_i32:
1852 ; GCN3: ; %bb.0: ; %entry
1853 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
1854 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
1855 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1856 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
1857 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
1858 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
1859 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1860 ; GCN3-NEXT: flat_atomic_smax v[0:1], v2
1861 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1862 ; GCN3-NEXT: s_endpgm
1864 %val = atomicrmw volatile max ptr %out, i32 %in syncscope("workgroup") seq_cst
1868 define amdgpu_kernel void @atomic_max_i32_ret(ptr %out, ptr %out2, i32 %in) {
1869 ; GCN1-LABEL: atomic_max_i32_ret:
1870 ; GCN1: ; %bb.0: ; %entry
1871 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
1872 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0xd
1873 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1874 ; GCN1-NEXT: v_mov_b32_e32 v0, s4
1875 ; GCN1-NEXT: v_mov_b32_e32 v1, s5
1876 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
1877 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1878 ; GCN1-NEXT: flat_atomic_smax v2, v[0:1], v2 glc
1879 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1880 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
1881 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
1882 ; GCN1-NEXT: s_waitcnt vmcnt(0)
1883 ; GCN1-NEXT: flat_store_dword v[0:1], v2
1884 ; GCN1-NEXT: s_endpgm
1886 ; GCN2-LABEL: atomic_max_i32_ret:
1887 ; GCN2: ; %bb.0: ; %entry
1888 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
1889 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x34
1890 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1891 ; GCN2-NEXT: v_mov_b32_e32 v0, s4
1892 ; GCN2-NEXT: v_mov_b32_e32 v1, s5
1893 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
1894 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1895 ; GCN2-NEXT: flat_atomic_smax v2, v[0:1], v2 glc
1896 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1897 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
1898 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
1899 ; GCN2-NEXT: s_waitcnt vmcnt(0)
1900 ; GCN2-NEXT: flat_store_dword v[0:1], v2
1901 ; GCN2-NEXT: s_endpgm
1903 ; GCN3-LABEL: atomic_max_i32_ret:
1904 ; GCN3: ; %bb.0: ; %entry
1905 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
1906 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x34
1907 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1908 ; GCN3-NEXT: v_mov_b32_e32 v0, s4
1909 ; GCN3-NEXT: v_mov_b32_e32 v1, s5
1910 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
1911 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1912 ; GCN3-NEXT: flat_atomic_smax v2, v[0:1], v2 glc
1913 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1914 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
1915 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
1916 ; GCN3-NEXT: s_waitcnt vmcnt(0)
1917 ; GCN3-NEXT: flat_store_dword v[0:1], v2
1918 ; GCN3-NEXT: s_endpgm
1920 %val = atomicrmw volatile max ptr %out, i32 %in syncscope("workgroup") seq_cst
1921 store i32 %val, ptr %out2
1925 define amdgpu_kernel void @atomic_max_i32_addr64(ptr %out, i32 %in, i64 %index) {
1926 ; GCN1-LABEL: atomic_max_i32_addr64:
1927 ; GCN1: ; %bb.0: ; %entry
1928 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xd
1929 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
1930 ; GCN1-NEXT: s_load_dword s6, s[0:1], 0xb
1931 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1932 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
1933 ; GCN1-NEXT: s_add_u32 s0, s4, s0
1934 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
1935 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
1936 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
1937 ; GCN1-NEXT: v_mov_b32_e32 v2, s6
1938 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1939 ; GCN1-NEXT: flat_atomic_smax v[0:1], v2
1940 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1941 ; GCN1-NEXT: s_endpgm
1943 ; GCN2-LABEL: atomic_max_i32_addr64:
1944 ; GCN2: ; %bb.0: ; %entry
1945 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
1946 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
1947 ; GCN2-NEXT: s_load_dword s6, s[0:1], 0x2c
1948 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1949 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
1950 ; GCN2-NEXT: s_add_u32 s0, s4, s0
1951 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
1952 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
1953 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
1954 ; GCN2-NEXT: v_mov_b32_e32 v2, s6
1955 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1956 ; GCN2-NEXT: flat_atomic_smax v[0:1], v2
1957 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
1958 ; GCN2-NEXT: s_endpgm
1960 ; GCN3-LABEL: atomic_max_i32_addr64:
1961 ; GCN3: ; %bb.0: ; %entry
1962 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
1963 ; GCN3-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
1964 ; GCN3-NEXT: s_load_dword s6, s[0:1], 0x2c
1965 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1966 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
1967 ; GCN3-NEXT: s_add_u32 s0, s4, s0
1968 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
1969 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
1970 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
1971 ; GCN3-NEXT: v_mov_b32_e32 v2, s6
1972 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1973 ; GCN3-NEXT: flat_atomic_smax v[0:1], v2
1974 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
1975 ; GCN3-NEXT: s_endpgm
1977 %ptr = getelementptr i32, ptr %out, i64 %index
1978 %val = atomicrmw volatile max ptr %ptr, i32 %in syncscope("workgroup") seq_cst
1982 define amdgpu_kernel void @atomic_max_i32_ret_addr64(ptr %out, ptr %out2, i32 %in, i64 %index) {
1983 ; GCN1-LABEL: atomic_max_i32_ret_addr64:
1984 ; GCN1: ; %bb.0: ; %entry
1985 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xf
1986 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
1987 ; GCN1-NEXT: s_load_dword s8, s[0:1], 0xd
1988 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1989 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
1990 ; GCN1-NEXT: s_add_u32 s0, s4, s0
1991 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
1992 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
1993 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
1994 ; GCN1-NEXT: v_mov_b32_e32 v2, s8
1995 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1996 ; GCN1-NEXT: flat_atomic_smax v2, v[0:1], v2 glc
1997 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
1998 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
1999 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
2000 ; GCN1-NEXT: s_waitcnt vmcnt(0)
2001 ; GCN1-NEXT: flat_store_dword v[0:1], v2
2002 ; GCN1-NEXT: s_endpgm
2004 ; GCN2-LABEL: atomic_max_i32_ret_addr64:
2005 ; GCN2: ; %bb.0: ; %entry
2006 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
2007 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
2008 ; GCN2-NEXT: s_load_dword s8, s[0:1], 0x34
2009 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2010 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
2011 ; GCN2-NEXT: s_add_u32 s0, s4, s0
2012 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
2013 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
2014 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
2015 ; GCN2-NEXT: v_mov_b32_e32 v2, s8
2016 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2017 ; GCN2-NEXT: flat_atomic_smax v2, v[0:1], v2 glc
2018 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2019 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
2020 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
2021 ; GCN2-NEXT: s_waitcnt vmcnt(0)
2022 ; GCN2-NEXT: flat_store_dword v[0:1], v2
2023 ; GCN2-NEXT: s_endpgm
2025 ; GCN3-LABEL: atomic_max_i32_ret_addr64:
2026 ; GCN3: ; %bb.0: ; %entry
2027 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
2028 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
2029 ; GCN3-NEXT: s_load_dword s8, s[0:1], 0x34
2030 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2031 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
2032 ; GCN3-NEXT: s_add_u32 s0, s4, s0
2033 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
2034 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
2035 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
2036 ; GCN3-NEXT: v_mov_b32_e32 v2, s8
2037 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2038 ; GCN3-NEXT: flat_atomic_smax v2, v[0:1], v2 glc
2039 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2040 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
2041 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
2042 ; GCN3-NEXT: s_waitcnt vmcnt(0)
2043 ; GCN3-NEXT: flat_store_dword v[0:1], v2
2044 ; GCN3-NEXT: s_endpgm
2046 %ptr = getelementptr i32, ptr %out, i64 %index
2047 %val = atomicrmw volatile max ptr %ptr, i32 %in syncscope("workgroup") seq_cst
2048 store i32 %val, ptr %out2
2052 define amdgpu_kernel void @atomic_umax_i32_offset(ptr %out, i32 %in) {
2053 ; GCN1-LABEL: atomic_umax_i32_offset:
2054 ; GCN1: ; %bb.0: ; %entry
2055 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
2056 ; GCN1-NEXT: s_load_dword s4, s[0:1], 0xb
2057 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2058 ; GCN1-NEXT: s_add_u32 s0, s2, 16
2059 ; GCN1-NEXT: s_addc_u32 s1, s3, 0
2060 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
2061 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
2062 ; GCN1-NEXT: v_mov_b32_e32 v2, s4
2063 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2064 ; GCN1-NEXT: flat_atomic_umax v[0:1], v2
2065 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2066 ; GCN1-NEXT: s_endpgm
2068 ; GCN2-LABEL: atomic_umax_i32_offset:
2069 ; GCN2: ; %bb.0: ; %entry
2070 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
2071 ; GCN2-NEXT: s_load_dword s4, s[0:1], 0x2c
2072 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2073 ; GCN2-NEXT: s_add_u32 s0, s2, 16
2074 ; GCN2-NEXT: s_addc_u32 s1, s3, 0
2075 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
2076 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
2077 ; GCN2-NEXT: v_mov_b32_e32 v2, s4
2078 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2079 ; GCN2-NEXT: flat_atomic_umax v[0:1], v2
2080 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2081 ; GCN2-NEXT: s_endpgm
2083 ; GCN3-LABEL: atomic_umax_i32_offset:
2084 ; GCN3: ; %bb.0: ; %entry
2085 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
2086 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
2087 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2088 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
2089 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
2090 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
2091 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2092 ; GCN3-NEXT: flat_atomic_umax v[0:1], v2 offset:16
2093 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2094 ; GCN3-NEXT: s_endpgm
2096 %gep = getelementptr i32, ptr %out, i32 4
2097 %val = atomicrmw volatile umax ptr %gep, i32 %in syncscope("workgroup") seq_cst
2101 define amdgpu_kernel void @atomic_umax_i32_ret_offset(ptr %out, ptr %out2, i32 %in) {
2102 ; GCN1-LABEL: atomic_umax_i32_ret_offset:
2103 ; GCN1: ; %bb.0: ; %entry
2104 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
2105 ; GCN1-NEXT: s_load_dword s2, s[0:1], 0xd
2106 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2107 ; GCN1-NEXT: s_add_u32 s0, s4, 16
2108 ; GCN1-NEXT: s_addc_u32 s1, s5, 0
2109 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
2110 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
2111 ; GCN1-NEXT: v_mov_b32_e32 v2, s2
2112 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2113 ; GCN1-NEXT: flat_atomic_umax v2, v[0:1], v2 glc
2114 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2115 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
2116 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
2117 ; GCN1-NEXT: s_waitcnt vmcnt(0)
2118 ; GCN1-NEXT: flat_store_dword v[0:1], v2
2119 ; GCN1-NEXT: s_endpgm
2121 ; GCN2-LABEL: atomic_umax_i32_ret_offset:
2122 ; GCN2: ; %bb.0: ; %entry
2123 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
2124 ; GCN2-NEXT: s_load_dword s2, s[0:1], 0x34
2125 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2126 ; GCN2-NEXT: s_add_u32 s0, s4, 16
2127 ; GCN2-NEXT: s_addc_u32 s1, s5, 0
2128 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
2129 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
2130 ; GCN2-NEXT: v_mov_b32_e32 v2, s2
2131 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2132 ; GCN2-NEXT: flat_atomic_umax v2, v[0:1], v2 glc
2133 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2134 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
2135 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
2136 ; GCN2-NEXT: s_waitcnt vmcnt(0)
2137 ; GCN2-NEXT: flat_store_dword v[0:1], v2
2138 ; GCN2-NEXT: s_endpgm
2140 ; GCN3-LABEL: atomic_umax_i32_ret_offset:
2141 ; GCN3: ; %bb.0: ; %entry
2142 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
2143 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x34
2144 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2145 ; GCN3-NEXT: v_mov_b32_e32 v0, s4
2146 ; GCN3-NEXT: v_mov_b32_e32 v1, s5
2147 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
2148 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2149 ; GCN3-NEXT: flat_atomic_umax v2, v[0:1], v2 offset:16 glc
2150 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2151 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
2152 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
2153 ; GCN3-NEXT: s_waitcnt vmcnt(0)
2154 ; GCN3-NEXT: flat_store_dword v[0:1], v2
2155 ; GCN3-NEXT: s_endpgm
2157 %gep = getelementptr i32, ptr %out, i32 4
2158 %val = atomicrmw volatile umax ptr %gep, i32 %in syncscope("workgroup") seq_cst
2159 store i32 %val, ptr %out2
2163 define amdgpu_kernel void @atomic_umax_i32_addr64_offset(ptr %out, i32 %in, i64 %index) {
2164 ; GCN1-LABEL: atomic_umax_i32_addr64_offset:
2165 ; GCN1: ; %bb.0: ; %entry
2166 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xd
2167 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
2168 ; GCN1-NEXT: s_load_dword s6, s[0:1], 0xb
2169 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2170 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
2171 ; GCN1-NEXT: s_add_u32 s0, s4, s0
2172 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
2173 ; GCN1-NEXT: s_add_u32 s0, s0, 16
2174 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
2175 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
2176 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
2177 ; GCN1-NEXT: v_mov_b32_e32 v2, s6
2178 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2179 ; GCN1-NEXT: flat_atomic_umax v[0:1], v2
2180 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2181 ; GCN1-NEXT: s_endpgm
2183 ; GCN2-LABEL: atomic_umax_i32_addr64_offset:
2184 ; GCN2: ; %bb.0: ; %entry
2185 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
2186 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
2187 ; GCN2-NEXT: s_load_dword s6, s[0:1], 0x2c
2188 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2189 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
2190 ; GCN2-NEXT: s_add_u32 s0, s4, s0
2191 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
2192 ; GCN2-NEXT: s_add_u32 s0, s0, 16
2193 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
2194 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
2195 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
2196 ; GCN2-NEXT: v_mov_b32_e32 v2, s6
2197 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2198 ; GCN2-NEXT: flat_atomic_umax v[0:1], v2
2199 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2200 ; GCN2-NEXT: s_endpgm
2202 ; GCN3-LABEL: atomic_umax_i32_addr64_offset:
2203 ; GCN3: ; %bb.0: ; %entry
2204 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
2205 ; GCN3-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
2206 ; GCN3-NEXT: s_load_dword s6, s[0:1], 0x2c
2207 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2208 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
2209 ; GCN3-NEXT: s_add_u32 s0, s4, s0
2210 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
2211 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
2212 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
2213 ; GCN3-NEXT: v_mov_b32_e32 v2, s6
2214 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2215 ; GCN3-NEXT: flat_atomic_umax v[0:1], v2 offset:16
2216 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2217 ; GCN3-NEXT: s_endpgm
2219 %ptr = getelementptr i32, ptr %out, i64 %index
2220 %gep = getelementptr i32, ptr %ptr, i32 4
2221 %val = atomicrmw volatile umax ptr %gep, i32 %in syncscope("workgroup") seq_cst
2225 define amdgpu_kernel void @atomic_umax_i32_ret_addr64_offset(ptr %out, ptr %out2, i32 %in, i64 %index) {
2226 ; GCN1-LABEL: atomic_umax_i32_ret_addr64_offset:
2227 ; GCN1: ; %bb.0: ; %entry
2228 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xf
2229 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
2230 ; GCN1-NEXT: s_load_dword s8, s[0:1], 0xd
2231 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2232 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
2233 ; GCN1-NEXT: s_add_u32 s0, s4, s0
2234 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
2235 ; GCN1-NEXT: s_add_u32 s0, s0, 16
2236 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
2237 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
2238 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
2239 ; GCN1-NEXT: v_mov_b32_e32 v2, s8
2240 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2241 ; GCN1-NEXT: flat_atomic_umax v2, v[0:1], v2 glc
2242 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2243 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
2244 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
2245 ; GCN1-NEXT: s_waitcnt vmcnt(0)
2246 ; GCN1-NEXT: flat_store_dword v[0:1], v2
2247 ; GCN1-NEXT: s_endpgm
2249 ; GCN2-LABEL: atomic_umax_i32_ret_addr64_offset:
2250 ; GCN2: ; %bb.0: ; %entry
2251 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
2252 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
2253 ; GCN2-NEXT: s_load_dword s8, s[0:1], 0x34
2254 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2255 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
2256 ; GCN2-NEXT: s_add_u32 s0, s4, s0
2257 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
2258 ; GCN2-NEXT: s_add_u32 s0, s0, 16
2259 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
2260 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
2261 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
2262 ; GCN2-NEXT: v_mov_b32_e32 v2, s8
2263 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2264 ; GCN2-NEXT: flat_atomic_umax v2, v[0:1], v2 glc
2265 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2266 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
2267 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
2268 ; GCN2-NEXT: s_waitcnt vmcnt(0)
2269 ; GCN2-NEXT: flat_store_dword v[0:1], v2
2270 ; GCN2-NEXT: s_endpgm
2272 ; GCN3-LABEL: atomic_umax_i32_ret_addr64_offset:
2273 ; GCN3: ; %bb.0: ; %entry
2274 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
2275 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
2276 ; GCN3-NEXT: s_load_dword s8, s[0:1], 0x34
2277 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2278 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
2279 ; GCN3-NEXT: s_add_u32 s0, s4, s0
2280 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
2281 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
2282 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
2283 ; GCN3-NEXT: v_mov_b32_e32 v2, s8
2284 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2285 ; GCN3-NEXT: flat_atomic_umax v2, v[0:1], v2 offset:16 glc
2286 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2287 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
2288 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
2289 ; GCN3-NEXT: s_waitcnt vmcnt(0)
2290 ; GCN3-NEXT: flat_store_dword v[0:1], v2
2291 ; GCN3-NEXT: s_endpgm
2293 %ptr = getelementptr i32, ptr %out, i64 %index
2294 %gep = getelementptr i32, ptr %ptr, i32 4
2295 %val = atomicrmw volatile umax ptr %gep, i32 %in syncscope("workgroup") seq_cst
2296 store i32 %val, ptr %out2
2300 define amdgpu_kernel void @atomic_umax_i32(ptr %out, i32 %in) {
2301 ; GCN1-LABEL: atomic_umax_i32:
2302 ; GCN1: ; %bb.0: ; %entry
2303 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
2304 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0xb
2305 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2306 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
2307 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
2308 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
2309 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2310 ; GCN1-NEXT: flat_atomic_umax v[0:1], v2
2311 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2312 ; GCN1-NEXT: s_endpgm
2314 ; GCN2-LABEL: atomic_umax_i32:
2315 ; GCN2: ; %bb.0: ; %entry
2316 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
2317 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x2c
2318 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2319 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
2320 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
2321 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
2322 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2323 ; GCN2-NEXT: flat_atomic_umax v[0:1], v2
2324 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2325 ; GCN2-NEXT: s_endpgm
2327 ; GCN3-LABEL: atomic_umax_i32:
2328 ; GCN3: ; %bb.0: ; %entry
2329 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
2330 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
2331 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2332 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
2333 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
2334 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
2335 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2336 ; GCN3-NEXT: flat_atomic_umax v[0:1], v2
2337 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2338 ; GCN3-NEXT: s_endpgm
2340 %val = atomicrmw volatile umax ptr %out, i32 %in syncscope("workgroup") seq_cst
2344 define amdgpu_kernel void @atomic_umax_i32_ret(ptr %out, ptr %out2, i32 %in) {
2345 ; GCN1-LABEL: atomic_umax_i32_ret:
2346 ; GCN1: ; %bb.0: ; %entry
2347 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
2348 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0xd
2349 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2350 ; GCN1-NEXT: v_mov_b32_e32 v0, s4
2351 ; GCN1-NEXT: v_mov_b32_e32 v1, s5
2352 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
2353 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2354 ; GCN1-NEXT: flat_atomic_umax v2, v[0:1], v2 glc
2355 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2356 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
2357 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
2358 ; GCN1-NEXT: s_waitcnt vmcnt(0)
2359 ; GCN1-NEXT: flat_store_dword v[0:1], v2
2360 ; GCN1-NEXT: s_endpgm
2362 ; GCN2-LABEL: atomic_umax_i32_ret:
2363 ; GCN2: ; %bb.0: ; %entry
2364 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
2365 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x34
2366 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2367 ; GCN2-NEXT: v_mov_b32_e32 v0, s4
2368 ; GCN2-NEXT: v_mov_b32_e32 v1, s5
2369 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
2370 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2371 ; GCN2-NEXT: flat_atomic_umax v2, v[0:1], v2 glc
2372 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2373 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
2374 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
2375 ; GCN2-NEXT: s_waitcnt vmcnt(0)
2376 ; GCN2-NEXT: flat_store_dword v[0:1], v2
2377 ; GCN2-NEXT: s_endpgm
2379 ; GCN3-LABEL: atomic_umax_i32_ret:
2380 ; GCN3: ; %bb.0: ; %entry
2381 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
2382 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x34
2383 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2384 ; GCN3-NEXT: v_mov_b32_e32 v0, s4
2385 ; GCN3-NEXT: v_mov_b32_e32 v1, s5
2386 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
2387 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2388 ; GCN3-NEXT: flat_atomic_umax v2, v[0:1], v2 glc
2389 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2390 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
2391 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
2392 ; GCN3-NEXT: s_waitcnt vmcnt(0)
2393 ; GCN3-NEXT: flat_store_dword v[0:1], v2
2394 ; GCN3-NEXT: s_endpgm
2396 %val = atomicrmw volatile umax ptr %out, i32 %in syncscope("workgroup") seq_cst
2397 store i32 %val, ptr %out2
2401 define amdgpu_kernel void @atomic_umax_i32_addr64(ptr %out, i32 %in, i64 %index) {
2402 ; GCN1-LABEL: atomic_umax_i32_addr64:
2403 ; GCN1: ; %bb.0: ; %entry
2404 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xd
2405 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
2406 ; GCN1-NEXT: s_load_dword s6, s[0:1], 0xb
2407 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2408 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
2409 ; GCN1-NEXT: s_add_u32 s0, s4, s0
2410 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
2411 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
2412 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
2413 ; GCN1-NEXT: v_mov_b32_e32 v2, s6
2414 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2415 ; GCN1-NEXT: flat_atomic_umax v[0:1], v2
2416 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2417 ; GCN1-NEXT: s_endpgm
2419 ; GCN2-LABEL: atomic_umax_i32_addr64:
2420 ; GCN2: ; %bb.0: ; %entry
2421 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
2422 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
2423 ; GCN2-NEXT: s_load_dword s6, s[0:1], 0x2c
2424 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2425 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
2426 ; GCN2-NEXT: s_add_u32 s0, s4, s0
2427 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
2428 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
2429 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
2430 ; GCN2-NEXT: v_mov_b32_e32 v2, s6
2431 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2432 ; GCN2-NEXT: flat_atomic_umax v[0:1], v2
2433 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2434 ; GCN2-NEXT: s_endpgm
2436 ; GCN3-LABEL: atomic_umax_i32_addr64:
2437 ; GCN3: ; %bb.0: ; %entry
2438 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
2439 ; GCN3-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
2440 ; GCN3-NEXT: s_load_dword s6, s[0:1], 0x2c
2441 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2442 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
2443 ; GCN3-NEXT: s_add_u32 s0, s4, s0
2444 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
2445 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
2446 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
2447 ; GCN3-NEXT: v_mov_b32_e32 v2, s6
2448 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2449 ; GCN3-NEXT: flat_atomic_umax v[0:1], v2
2450 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2451 ; GCN3-NEXT: s_endpgm
2453 %ptr = getelementptr i32, ptr %out, i64 %index
2454 %val = atomicrmw volatile umax ptr %ptr, i32 %in syncscope("workgroup") seq_cst
2458 define amdgpu_kernel void @atomic_umax_i32_ret_addr64(ptr %out, ptr %out2, i32 %in, i64 %index) {
2459 ; GCN1-LABEL: atomic_umax_i32_ret_addr64:
2460 ; GCN1: ; %bb.0: ; %entry
2461 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xf
2462 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
2463 ; GCN1-NEXT: s_load_dword s8, s[0:1], 0xd
2464 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2465 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
2466 ; GCN1-NEXT: s_add_u32 s0, s4, s0
2467 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
2468 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
2469 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
2470 ; GCN1-NEXT: v_mov_b32_e32 v2, s8
2471 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2472 ; GCN1-NEXT: flat_atomic_umax v2, v[0:1], v2 glc
2473 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2474 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
2475 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
2476 ; GCN1-NEXT: s_waitcnt vmcnt(0)
2477 ; GCN1-NEXT: flat_store_dword v[0:1], v2
2478 ; GCN1-NEXT: s_endpgm
2480 ; GCN2-LABEL: atomic_umax_i32_ret_addr64:
2481 ; GCN2: ; %bb.0: ; %entry
2482 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
2483 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
2484 ; GCN2-NEXT: s_load_dword s8, s[0:1], 0x34
2485 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2486 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
2487 ; GCN2-NEXT: s_add_u32 s0, s4, s0
2488 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
2489 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
2490 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
2491 ; GCN2-NEXT: v_mov_b32_e32 v2, s8
2492 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2493 ; GCN2-NEXT: flat_atomic_umax v2, v[0:1], v2 glc
2494 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2495 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
2496 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
2497 ; GCN2-NEXT: s_waitcnt vmcnt(0)
2498 ; GCN2-NEXT: flat_store_dword v[0:1], v2
2499 ; GCN2-NEXT: s_endpgm
2501 ; GCN3-LABEL: atomic_umax_i32_ret_addr64:
2502 ; GCN3: ; %bb.0: ; %entry
2503 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
2504 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
2505 ; GCN3-NEXT: s_load_dword s8, s[0:1], 0x34
2506 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2507 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
2508 ; GCN3-NEXT: s_add_u32 s0, s4, s0
2509 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
2510 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
2511 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
2512 ; GCN3-NEXT: v_mov_b32_e32 v2, s8
2513 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2514 ; GCN3-NEXT: flat_atomic_umax v2, v[0:1], v2 glc
2515 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2516 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
2517 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
2518 ; GCN3-NEXT: s_waitcnt vmcnt(0)
2519 ; GCN3-NEXT: flat_store_dword v[0:1], v2
2520 ; GCN3-NEXT: s_endpgm
2522 %ptr = getelementptr i32, ptr %out, i64 %index
2523 %val = atomicrmw volatile umax ptr %ptr, i32 %in syncscope("workgroup") seq_cst
2524 store i32 %val, ptr %out2
2528 define amdgpu_kernel void @atomic_min_i32_offset(ptr %out, i32 %in) {
2529 ; GCN1-LABEL: atomic_min_i32_offset:
2530 ; GCN1: ; %bb.0: ; %entry
2531 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
2532 ; GCN1-NEXT: s_load_dword s4, s[0:1], 0xb
2533 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2534 ; GCN1-NEXT: s_add_u32 s0, s2, 16
2535 ; GCN1-NEXT: s_addc_u32 s1, s3, 0
2536 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
2537 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
2538 ; GCN1-NEXT: v_mov_b32_e32 v2, s4
2539 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2540 ; GCN1-NEXT: flat_atomic_smin v[0:1], v2
2541 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2542 ; GCN1-NEXT: s_endpgm
2544 ; GCN2-LABEL: atomic_min_i32_offset:
2545 ; GCN2: ; %bb.0: ; %entry
2546 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
2547 ; GCN2-NEXT: s_load_dword s4, s[0:1], 0x2c
2548 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2549 ; GCN2-NEXT: s_add_u32 s0, s2, 16
2550 ; GCN2-NEXT: s_addc_u32 s1, s3, 0
2551 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
2552 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
2553 ; GCN2-NEXT: v_mov_b32_e32 v2, s4
2554 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2555 ; GCN2-NEXT: flat_atomic_smin v[0:1], v2
2556 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2557 ; GCN2-NEXT: s_endpgm
2559 ; GCN3-LABEL: atomic_min_i32_offset:
2560 ; GCN3: ; %bb.0: ; %entry
2561 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
2562 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
2563 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2564 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
2565 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
2566 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
2567 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2568 ; GCN3-NEXT: flat_atomic_smin v[0:1], v2 offset:16
2569 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2570 ; GCN3-NEXT: s_endpgm
2572 %gep = getelementptr i32, ptr %out, i32 4
2573 %val = atomicrmw volatile min ptr %gep, i32 %in syncscope("workgroup") seq_cst
2577 define amdgpu_kernel void @atomic_min_i32_ret_offset(ptr %out, ptr %out2, i32 %in) {
2578 ; GCN1-LABEL: atomic_min_i32_ret_offset:
2579 ; GCN1: ; %bb.0: ; %entry
2580 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
2581 ; GCN1-NEXT: s_load_dword s2, s[0:1], 0xd
2582 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2583 ; GCN1-NEXT: s_add_u32 s0, s4, 16
2584 ; GCN1-NEXT: s_addc_u32 s1, s5, 0
2585 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
2586 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
2587 ; GCN1-NEXT: v_mov_b32_e32 v2, s2
2588 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2589 ; GCN1-NEXT: flat_atomic_smin v2, v[0:1], v2 glc
2590 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2591 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
2592 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
2593 ; GCN1-NEXT: s_waitcnt vmcnt(0)
2594 ; GCN1-NEXT: flat_store_dword v[0:1], v2
2595 ; GCN1-NEXT: s_endpgm
2597 ; GCN2-LABEL: atomic_min_i32_ret_offset:
2598 ; GCN2: ; %bb.0: ; %entry
2599 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
2600 ; GCN2-NEXT: s_load_dword s2, s[0:1], 0x34
2601 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2602 ; GCN2-NEXT: s_add_u32 s0, s4, 16
2603 ; GCN2-NEXT: s_addc_u32 s1, s5, 0
2604 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
2605 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
2606 ; GCN2-NEXT: v_mov_b32_e32 v2, s2
2607 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2608 ; GCN2-NEXT: flat_atomic_smin v2, v[0:1], v2 glc
2609 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2610 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
2611 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
2612 ; GCN2-NEXT: s_waitcnt vmcnt(0)
2613 ; GCN2-NEXT: flat_store_dword v[0:1], v2
2614 ; GCN2-NEXT: s_endpgm
2616 ; GCN3-LABEL: atomic_min_i32_ret_offset:
2617 ; GCN3: ; %bb.0: ; %entry
2618 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
2619 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x34
2620 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2621 ; GCN3-NEXT: v_mov_b32_e32 v0, s4
2622 ; GCN3-NEXT: v_mov_b32_e32 v1, s5
2623 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
2624 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2625 ; GCN3-NEXT: flat_atomic_smin v2, v[0:1], v2 offset:16 glc
2626 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2627 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
2628 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
2629 ; GCN3-NEXT: s_waitcnt vmcnt(0)
2630 ; GCN3-NEXT: flat_store_dword v[0:1], v2
2631 ; GCN3-NEXT: s_endpgm
2633 %gep = getelementptr i32, ptr %out, i32 4
2634 %val = atomicrmw volatile min ptr %gep, i32 %in syncscope("workgroup") seq_cst
2635 store i32 %val, ptr %out2
2639 define amdgpu_kernel void @atomic_min_i32_addr64_offset(ptr %out, i32 %in, i64 %index) {
2640 ; GCN1-LABEL: atomic_min_i32_addr64_offset:
2641 ; GCN1: ; %bb.0: ; %entry
2642 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xd
2643 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
2644 ; GCN1-NEXT: s_load_dword s6, s[0:1], 0xb
2645 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2646 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
2647 ; GCN1-NEXT: s_add_u32 s0, s4, s0
2648 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
2649 ; GCN1-NEXT: s_add_u32 s0, s0, 16
2650 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
2651 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
2652 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
2653 ; GCN1-NEXT: v_mov_b32_e32 v2, s6
2654 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2655 ; GCN1-NEXT: flat_atomic_smin v[0:1], v2
2656 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2657 ; GCN1-NEXT: s_endpgm
2659 ; GCN2-LABEL: atomic_min_i32_addr64_offset:
2660 ; GCN2: ; %bb.0: ; %entry
2661 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
2662 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
2663 ; GCN2-NEXT: s_load_dword s6, s[0:1], 0x2c
2664 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2665 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
2666 ; GCN2-NEXT: s_add_u32 s0, s4, s0
2667 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
2668 ; GCN2-NEXT: s_add_u32 s0, s0, 16
2669 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
2670 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
2671 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
2672 ; GCN2-NEXT: v_mov_b32_e32 v2, s6
2673 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2674 ; GCN2-NEXT: flat_atomic_smin v[0:1], v2
2675 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2676 ; GCN2-NEXT: s_endpgm
2678 ; GCN3-LABEL: atomic_min_i32_addr64_offset:
2679 ; GCN3: ; %bb.0: ; %entry
2680 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
2681 ; GCN3-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
2682 ; GCN3-NEXT: s_load_dword s6, s[0:1], 0x2c
2683 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2684 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
2685 ; GCN3-NEXT: s_add_u32 s0, s4, s0
2686 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
2687 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
2688 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
2689 ; GCN3-NEXT: v_mov_b32_e32 v2, s6
2690 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2691 ; GCN3-NEXT: flat_atomic_smin v[0:1], v2 offset:16
2692 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2693 ; GCN3-NEXT: s_endpgm
2695 %ptr = getelementptr i32, ptr %out, i64 %index
2696 %gep = getelementptr i32, ptr %ptr, i32 4
2697 %val = atomicrmw volatile min ptr %gep, i32 %in syncscope("workgroup") seq_cst
2701 define amdgpu_kernel void @atomic_min_i32_ret_addr64_offset(ptr %out, ptr %out2, i32 %in, i64 %index) {
2702 ; GCN1-LABEL: atomic_min_i32_ret_addr64_offset:
2703 ; GCN1: ; %bb.0: ; %entry
2704 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xf
2705 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
2706 ; GCN1-NEXT: s_load_dword s8, s[0:1], 0xd
2707 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2708 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
2709 ; GCN1-NEXT: s_add_u32 s0, s4, s0
2710 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
2711 ; GCN1-NEXT: s_add_u32 s0, s0, 16
2712 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
2713 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
2714 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
2715 ; GCN1-NEXT: v_mov_b32_e32 v2, s8
2716 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2717 ; GCN1-NEXT: flat_atomic_smin v2, v[0:1], v2 glc
2718 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2719 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
2720 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
2721 ; GCN1-NEXT: s_waitcnt vmcnt(0)
2722 ; GCN1-NEXT: flat_store_dword v[0:1], v2
2723 ; GCN1-NEXT: s_endpgm
2725 ; GCN2-LABEL: atomic_min_i32_ret_addr64_offset:
2726 ; GCN2: ; %bb.0: ; %entry
2727 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
2728 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
2729 ; GCN2-NEXT: s_load_dword s8, s[0:1], 0x34
2730 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2731 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
2732 ; GCN2-NEXT: s_add_u32 s0, s4, s0
2733 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
2734 ; GCN2-NEXT: s_add_u32 s0, s0, 16
2735 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
2736 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
2737 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
2738 ; GCN2-NEXT: v_mov_b32_e32 v2, s8
2739 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2740 ; GCN2-NEXT: flat_atomic_smin v2, v[0:1], v2 glc
2741 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2742 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
2743 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
2744 ; GCN2-NEXT: s_waitcnt vmcnt(0)
2745 ; GCN2-NEXT: flat_store_dword v[0:1], v2
2746 ; GCN2-NEXT: s_endpgm
2748 ; GCN3-LABEL: atomic_min_i32_ret_addr64_offset:
2749 ; GCN3: ; %bb.0: ; %entry
2750 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
2751 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
2752 ; GCN3-NEXT: s_load_dword s8, s[0:1], 0x34
2753 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2754 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
2755 ; GCN3-NEXT: s_add_u32 s0, s4, s0
2756 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
2757 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
2758 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
2759 ; GCN3-NEXT: v_mov_b32_e32 v2, s8
2760 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2761 ; GCN3-NEXT: flat_atomic_smin v2, v[0:1], v2 offset:16 glc
2762 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2763 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
2764 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
2765 ; GCN3-NEXT: s_waitcnt vmcnt(0)
2766 ; GCN3-NEXT: flat_store_dword v[0:1], v2
2767 ; GCN3-NEXT: s_endpgm
2769 %ptr = getelementptr i32, ptr %out, i64 %index
2770 %gep = getelementptr i32, ptr %ptr, i32 4
2771 %val = atomicrmw volatile min ptr %gep, i32 %in syncscope("workgroup") seq_cst
2772 store i32 %val, ptr %out2
2776 define amdgpu_kernel void @atomic_min_i32(ptr %out, i32 %in) {
2777 ; GCN1-LABEL: atomic_min_i32:
2778 ; GCN1: ; %bb.0: ; %entry
2779 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
2780 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0xb
2781 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2782 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
2783 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
2784 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
2785 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2786 ; GCN1-NEXT: flat_atomic_smin v[0:1], v2
2787 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2788 ; GCN1-NEXT: s_endpgm
2790 ; GCN2-LABEL: atomic_min_i32:
2791 ; GCN2: ; %bb.0: ; %entry
2792 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
2793 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x2c
2794 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2795 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
2796 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
2797 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
2798 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2799 ; GCN2-NEXT: flat_atomic_smin v[0:1], v2
2800 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2801 ; GCN2-NEXT: s_endpgm
2803 ; GCN3-LABEL: atomic_min_i32:
2804 ; GCN3: ; %bb.0: ; %entry
2805 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
2806 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
2807 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2808 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
2809 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
2810 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
2811 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2812 ; GCN3-NEXT: flat_atomic_smin v[0:1], v2
2813 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2814 ; GCN3-NEXT: s_endpgm
2816 %val = atomicrmw volatile min ptr %out, i32 %in syncscope("workgroup") seq_cst
2820 define amdgpu_kernel void @atomic_min_i32_ret(ptr %out, ptr %out2, i32 %in) {
2821 ; GCN1-LABEL: atomic_min_i32_ret:
2822 ; GCN1: ; %bb.0: ; %entry
2823 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
2824 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0xd
2825 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2826 ; GCN1-NEXT: v_mov_b32_e32 v0, s4
2827 ; GCN1-NEXT: v_mov_b32_e32 v1, s5
2828 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
2829 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2830 ; GCN1-NEXT: flat_atomic_smin v2, v[0:1], v2 glc
2831 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2832 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
2833 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
2834 ; GCN1-NEXT: s_waitcnt vmcnt(0)
2835 ; GCN1-NEXT: flat_store_dword v[0:1], v2
2836 ; GCN1-NEXT: s_endpgm
2838 ; GCN2-LABEL: atomic_min_i32_ret:
2839 ; GCN2: ; %bb.0: ; %entry
2840 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
2841 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x34
2842 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2843 ; GCN2-NEXT: v_mov_b32_e32 v0, s4
2844 ; GCN2-NEXT: v_mov_b32_e32 v1, s5
2845 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
2846 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2847 ; GCN2-NEXT: flat_atomic_smin v2, v[0:1], v2 glc
2848 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2849 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
2850 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
2851 ; GCN2-NEXT: s_waitcnt vmcnt(0)
2852 ; GCN2-NEXT: flat_store_dword v[0:1], v2
2853 ; GCN2-NEXT: s_endpgm
2855 ; GCN3-LABEL: atomic_min_i32_ret:
2856 ; GCN3: ; %bb.0: ; %entry
2857 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
2858 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x34
2859 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2860 ; GCN3-NEXT: v_mov_b32_e32 v0, s4
2861 ; GCN3-NEXT: v_mov_b32_e32 v1, s5
2862 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
2863 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2864 ; GCN3-NEXT: flat_atomic_smin v2, v[0:1], v2 glc
2865 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2866 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
2867 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
2868 ; GCN3-NEXT: s_waitcnt vmcnt(0)
2869 ; GCN3-NEXT: flat_store_dword v[0:1], v2
2870 ; GCN3-NEXT: s_endpgm
2872 %val = atomicrmw volatile min ptr %out, i32 %in syncscope("workgroup") seq_cst
2873 store i32 %val, ptr %out2
2877 define amdgpu_kernel void @atomic_min_i32_addr64(ptr %out, i32 %in, i64 %index) {
2878 ; GCN1-LABEL: atomic_min_i32_addr64:
2879 ; GCN1: ; %bb.0: ; %entry
2880 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xd
2881 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
2882 ; GCN1-NEXT: s_load_dword s6, s[0:1], 0xb
2883 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2884 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
2885 ; GCN1-NEXT: s_add_u32 s0, s4, s0
2886 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
2887 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
2888 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
2889 ; GCN1-NEXT: v_mov_b32_e32 v2, s6
2890 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2891 ; GCN1-NEXT: flat_atomic_smin v[0:1], v2
2892 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2893 ; GCN1-NEXT: s_endpgm
2895 ; GCN2-LABEL: atomic_min_i32_addr64:
2896 ; GCN2: ; %bb.0: ; %entry
2897 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
2898 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
2899 ; GCN2-NEXT: s_load_dword s6, s[0:1], 0x2c
2900 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2901 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
2902 ; GCN2-NEXT: s_add_u32 s0, s4, s0
2903 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
2904 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
2905 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
2906 ; GCN2-NEXT: v_mov_b32_e32 v2, s6
2907 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2908 ; GCN2-NEXT: flat_atomic_smin v[0:1], v2
2909 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2910 ; GCN2-NEXT: s_endpgm
2912 ; GCN3-LABEL: atomic_min_i32_addr64:
2913 ; GCN3: ; %bb.0: ; %entry
2914 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
2915 ; GCN3-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
2916 ; GCN3-NEXT: s_load_dword s6, s[0:1], 0x2c
2917 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2918 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
2919 ; GCN3-NEXT: s_add_u32 s0, s4, s0
2920 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
2921 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
2922 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
2923 ; GCN3-NEXT: v_mov_b32_e32 v2, s6
2924 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2925 ; GCN3-NEXT: flat_atomic_smin v[0:1], v2
2926 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2927 ; GCN3-NEXT: s_endpgm
2929 %ptr = getelementptr i32, ptr %out, i64 %index
2930 %val = atomicrmw volatile min ptr %ptr, i32 %in syncscope("workgroup") seq_cst
2934 define amdgpu_kernel void @atomic_min_i32_ret_addr64(ptr %out, ptr %out2, i32 %in, i64 %index) {
2935 ; GCN1-LABEL: atomic_min_i32_ret_addr64:
2936 ; GCN1: ; %bb.0: ; %entry
2937 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xf
2938 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
2939 ; GCN1-NEXT: s_load_dword s8, s[0:1], 0xd
2940 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2941 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
2942 ; GCN1-NEXT: s_add_u32 s0, s4, s0
2943 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
2944 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
2945 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
2946 ; GCN1-NEXT: v_mov_b32_e32 v2, s8
2947 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2948 ; GCN1-NEXT: flat_atomic_smin v2, v[0:1], v2 glc
2949 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
2950 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
2951 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
2952 ; GCN1-NEXT: s_waitcnt vmcnt(0)
2953 ; GCN1-NEXT: flat_store_dword v[0:1], v2
2954 ; GCN1-NEXT: s_endpgm
2956 ; GCN2-LABEL: atomic_min_i32_ret_addr64:
2957 ; GCN2: ; %bb.0: ; %entry
2958 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
2959 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
2960 ; GCN2-NEXT: s_load_dword s8, s[0:1], 0x34
2961 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2962 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
2963 ; GCN2-NEXT: s_add_u32 s0, s4, s0
2964 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
2965 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
2966 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
2967 ; GCN2-NEXT: v_mov_b32_e32 v2, s8
2968 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2969 ; GCN2-NEXT: flat_atomic_smin v2, v[0:1], v2 glc
2970 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
2971 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
2972 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
2973 ; GCN2-NEXT: s_waitcnt vmcnt(0)
2974 ; GCN2-NEXT: flat_store_dword v[0:1], v2
2975 ; GCN2-NEXT: s_endpgm
2977 ; GCN3-LABEL: atomic_min_i32_ret_addr64:
2978 ; GCN3: ; %bb.0: ; %entry
2979 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
2980 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
2981 ; GCN3-NEXT: s_load_dword s8, s[0:1], 0x34
2982 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2983 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
2984 ; GCN3-NEXT: s_add_u32 s0, s4, s0
2985 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
2986 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
2987 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
2988 ; GCN3-NEXT: v_mov_b32_e32 v2, s8
2989 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2990 ; GCN3-NEXT: flat_atomic_smin v2, v[0:1], v2 glc
2991 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
2992 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
2993 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
2994 ; GCN3-NEXT: s_waitcnt vmcnt(0)
2995 ; GCN3-NEXT: flat_store_dword v[0:1], v2
2996 ; GCN3-NEXT: s_endpgm
2998 %ptr = getelementptr i32, ptr %out, i64 %index
2999 %val = atomicrmw volatile min ptr %ptr, i32 %in syncscope("workgroup") seq_cst
3000 store i32 %val, ptr %out2
3004 define amdgpu_kernel void @atomic_umin_i32_offset(ptr %out, i32 %in) {
3005 ; GCN1-LABEL: atomic_umin_i32_offset:
3006 ; GCN1: ; %bb.0: ; %entry
3007 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
3008 ; GCN1-NEXT: s_load_dword s4, s[0:1], 0xb
3009 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3010 ; GCN1-NEXT: s_add_u32 s0, s2, 16
3011 ; GCN1-NEXT: s_addc_u32 s1, s3, 0
3012 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
3013 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
3014 ; GCN1-NEXT: v_mov_b32_e32 v2, s4
3015 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3016 ; GCN1-NEXT: flat_atomic_umin v[0:1], v2
3017 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3018 ; GCN1-NEXT: s_endpgm
3020 ; GCN2-LABEL: atomic_umin_i32_offset:
3021 ; GCN2: ; %bb.0: ; %entry
3022 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
3023 ; GCN2-NEXT: s_load_dword s4, s[0:1], 0x2c
3024 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3025 ; GCN2-NEXT: s_add_u32 s0, s2, 16
3026 ; GCN2-NEXT: s_addc_u32 s1, s3, 0
3027 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
3028 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
3029 ; GCN2-NEXT: v_mov_b32_e32 v2, s4
3030 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3031 ; GCN2-NEXT: flat_atomic_umin v[0:1], v2
3032 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3033 ; GCN2-NEXT: s_endpgm
3035 ; GCN3-LABEL: atomic_umin_i32_offset:
3036 ; GCN3: ; %bb.0: ; %entry
3037 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
3038 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
3039 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3040 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
3041 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
3042 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
3043 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3044 ; GCN3-NEXT: flat_atomic_umin v[0:1], v2 offset:16
3045 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3046 ; GCN3-NEXT: s_endpgm
3048 %gep = getelementptr i32, ptr %out, i32 4
3049 %val = atomicrmw volatile umin ptr %gep, i32 %in syncscope("workgroup") seq_cst
3053 define amdgpu_kernel void @atomic_umin_i32_ret_offset(ptr %out, ptr %out2, i32 %in) {
3054 ; GCN1-LABEL: atomic_umin_i32_ret_offset:
3055 ; GCN1: ; %bb.0: ; %entry
3056 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
3057 ; GCN1-NEXT: s_load_dword s2, s[0:1], 0xd
3058 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3059 ; GCN1-NEXT: s_add_u32 s0, s4, 16
3060 ; GCN1-NEXT: s_addc_u32 s1, s5, 0
3061 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
3062 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
3063 ; GCN1-NEXT: v_mov_b32_e32 v2, s2
3064 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3065 ; GCN1-NEXT: flat_atomic_umin v2, v[0:1], v2 glc
3066 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3067 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
3068 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
3069 ; GCN1-NEXT: s_waitcnt vmcnt(0)
3070 ; GCN1-NEXT: flat_store_dword v[0:1], v2
3071 ; GCN1-NEXT: s_endpgm
3073 ; GCN2-LABEL: atomic_umin_i32_ret_offset:
3074 ; GCN2: ; %bb.0: ; %entry
3075 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
3076 ; GCN2-NEXT: s_load_dword s2, s[0:1], 0x34
3077 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3078 ; GCN2-NEXT: s_add_u32 s0, s4, 16
3079 ; GCN2-NEXT: s_addc_u32 s1, s5, 0
3080 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
3081 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
3082 ; GCN2-NEXT: v_mov_b32_e32 v2, s2
3083 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3084 ; GCN2-NEXT: flat_atomic_umin v2, v[0:1], v2 glc
3085 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3086 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
3087 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
3088 ; GCN2-NEXT: s_waitcnt vmcnt(0)
3089 ; GCN2-NEXT: flat_store_dword v[0:1], v2
3090 ; GCN2-NEXT: s_endpgm
3092 ; GCN3-LABEL: atomic_umin_i32_ret_offset:
3093 ; GCN3: ; %bb.0: ; %entry
3094 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
3095 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x34
3096 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3097 ; GCN3-NEXT: v_mov_b32_e32 v0, s4
3098 ; GCN3-NEXT: v_mov_b32_e32 v1, s5
3099 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
3100 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3101 ; GCN3-NEXT: flat_atomic_umin v2, v[0:1], v2 offset:16 glc
3102 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3103 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
3104 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
3105 ; GCN3-NEXT: s_waitcnt vmcnt(0)
3106 ; GCN3-NEXT: flat_store_dword v[0:1], v2
3107 ; GCN3-NEXT: s_endpgm
3109 %gep = getelementptr i32, ptr %out, i32 4
3110 %val = atomicrmw volatile umin ptr %gep, i32 %in syncscope("workgroup") seq_cst
3111 store i32 %val, ptr %out2
3115 define amdgpu_kernel void @atomic_umin_i32_addr64_offset(ptr %out, i32 %in, i64 %index) {
3116 ; GCN1-LABEL: atomic_umin_i32_addr64_offset:
3117 ; GCN1: ; %bb.0: ; %entry
3118 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xd
3119 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
3120 ; GCN1-NEXT: s_load_dword s6, s[0:1], 0xb
3121 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3122 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
3123 ; GCN1-NEXT: s_add_u32 s0, s4, s0
3124 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
3125 ; GCN1-NEXT: s_add_u32 s0, s0, 16
3126 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
3127 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
3128 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
3129 ; GCN1-NEXT: v_mov_b32_e32 v2, s6
3130 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3131 ; GCN1-NEXT: flat_atomic_umin v[0:1], v2
3132 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3133 ; GCN1-NEXT: s_endpgm
3135 ; GCN2-LABEL: atomic_umin_i32_addr64_offset:
3136 ; GCN2: ; %bb.0: ; %entry
3137 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
3138 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
3139 ; GCN2-NEXT: s_load_dword s6, s[0:1], 0x2c
3140 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3141 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
3142 ; GCN2-NEXT: s_add_u32 s0, s4, s0
3143 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
3144 ; GCN2-NEXT: s_add_u32 s0, s0, 16
3145 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
3146 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
3147 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
3148 ; GCN2-NEXT: v_mov_b32_e32 v2, s6
3149 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3150 ; GCN2-NEXT: flat_atomic_umin v[0:1], v2
3151 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3152 ; GCN2-NEXT: s_endpgm
3154 ; GCN3-LABEL: atomic_umin_i32_addr64_offset:
3155 ; GCN3: ; %bb.0: ; %entry
3156 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
3157 ; GCN3-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
3158 ; GCN3-NEXT: s_load_dword s6, s[0:1], 0x2c
3159 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3160 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
3161 ; GCN3-NEXT: s_add_u32 s0, s4, s0
3162 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
3163 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
3164 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
3165 ; GCN3-NEXT: v_mov_b32_e32 v2, s6
3166 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3167 ; GCN3-NEXT: flat_atomic_umin v[0:1], v2 offset:16
3168 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3169 ; GCN3-NEXT: s_endpgm
3171 %ptr = getelementptr i32, ptr %out, i64 %index
3172 %gep = getelementptr i32, ptr %ptr, i32 4
3173 %val = atomicrmw volatile umin ptr %gep, i32 %in syncscope("workgroup") seq_cst
3177 define amdgpu_kernel void @atomic_umin_i32_ret_addr64_offset(ptr %out, ptr %out2, i32 %in, i64 %index) {
3178 ; GCN1-LABEL: atomic_umin_i32_ret_addr64_offset:
3179 ; GCN1: ; %bb.0: ; %entry
3180 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xf
3181 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
3182 ; GCN1-NEXT: s_load_dword s8, s[0:1], 0xd
3183 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3184 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
3185 ; GCN1-NEXT: s_add_u32 s0, s4, s0
3186 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
3187 ; GCN1-NEXT: s_add_u32 s0, s0, 16
3188 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
3189 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
3190 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
3191 ; GCN1-NEXT: v_mov_b32_e32 v2, s8
3192 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3193 ; GCN1-NEXT: flat_atomic_umin v2, v[0:1], v2 glc
3194 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3195 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
3196 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
3197 ; GCN1-NEXT: s_waitcnt vmcnt(0)
3198 ; GCN1-NEXT: flat_store_dword v[0:1], v2
3199 ; GCN1-NEXT: s_endpgm
3201 ; GCN2-LABEL: atomic_umin_i32_ret_addr64_offset:
3202 ; GCN2: ; %bb.0: ; %entry
3203 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
3204 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
3205 ; GCN2-NEXT: s_load_dword s8, s[0:1], 0x34
3206 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3207 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
3208 ; GCN2-NEXT: s_add_u32 s0, s4, s0
3209 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
3210 ; GCN2-NEXT: s_add_u32 s0, s0, 16
3211 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
3212 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
3213 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
3214 ; GCN2-NEXT: v_mov_b32_e32 v2, s8
3215 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3216 ; GCN2-NEXT: flat_atomic_umin v2, v[0:1], v2 glc
3217 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3218 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
3219 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
3220 ; GCN2-NEXT: s_waitcnt vmcnt(0)
3221 ; GCN2-NEXT: flat_store_dword v[0:1], v2
3222 ; GCN2-NEXT: s_endpgm
3224 ; GCN3-LABEL: atomic_umin_i32_ret_addr64_offset:
3225 ; GCN3: ; %bb.0: ; %entry
3226 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
3227 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
3228 ; GCN3-NEXT: s_load_dword s8, s[0:1], 0x34
3229 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3230 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
3231 ; GCN3-NEXT: s_add_u32 s0, s4, s0
3232 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
3233 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
3234 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
3235 ; GCN3-NEXT: v_mov_b32_e32 v2, s8
3236 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3237 ; GCN3-NEXT: flat_atomic_umin v2, v[0:1], v2 offset:16 glc
3238 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3239 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
3240 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
3241 ; GCN3-NEXT: s_waitcnt vmcnt(0)
3242 ; GCN3-NEXT: flat_store_dword v[0:1], v2
3243 ; GCN3-NEXT: s_endpgm
3245 %ptr = getelementptr i32, ptr %out, i64 %index
3246 %gep = getelementptr i32, ptr %ptr, i32 4
3247 %val = atomicrmw volatile umin ptr %gep, i32 %in syncscope("workgroup") seq_cst
3248 store i32 %val, ptr %out2
3252 define amdgpu_kernel void @atomic_umin_i32(ptr %out, i32 %in) {
3253 ; GCN1-LABEL: atomic_umin_i32:
3254 ; GCN1: ; %bb.0: ; %entry
3255 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
3256 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0xb
3257 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3258 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
3259 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
3260 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
3261 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3262 ; GCN1-NEXT: flat_atomic_umin v[0:1], v2
3263 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3264 ; GCN1-NEXT: s_endpgm
3266 ; GCN2-LABEL: atomic_umin_i32:
3267 ; GCN2: ; %bb.0: ; %entry
3268 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
3269 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x2c
3270 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3271 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
3272 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
3273 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
3274 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3275 ; GCN2-NEXT: flat_atomic_umin v[0:1], v2
3276 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3277 ; GCN2-NEXT: s_endpgm
3279 ; GCN3-LABEL: atomic_umin_i32:
3280 ; GCN3: ; %bb.0: ; %entry
3281 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
3282 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
3283 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3284 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
3285 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
3286 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
3287 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3288 ; GCN3-NEXT: flat_atomic_umin v[0:1], v2
3289 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3290 ; GCN3-NEXT: s_endpgm
3292 %val = atomicrmw volatile umin ptr %out, i32 %in syncscope("workgroup") seq_cst
3296 define amdgpu_kernel void @atomic_umin_i32_ret(ptr %out, ptr %out2, i32 %in) {
3297 ; GCN1-LABEL: atomic_umin_i32_ret:
3298 ; GCN1: ; %bb.0: ; %entry
3299 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
3300 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0xd
3301 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3302 ; GCN1-NEXT: v_mov_b32_e32 v0, s4
3303 ; GCN1-NEXT: v_mov_b32_e32 v1, s5
3304 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
3305 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3306 ; GCN1-NEXT: flat_atomic_umin v2, v[0:1], v2 glc
3307 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3308 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
3309 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
3310 ; GCN1-NEXT: s_waitcnt vmcnt(0)
3311 ; GCN1-NEXT: flat_store_dword v[0:1], v2
3312 ; GCN1-NEXT: s_endpgm
3314 ; GCN2-LABEL: atomic_umin_i32_ret:
3315 ; GCN2: ; %bb.0: ; %entry
3316 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
3317 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x34
3318 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3319 ; GCN2-NEXT: v_mov_b32_e32 v0, s4
3320 ; GCN2-NEXT: v_mov_b32_e32 v1, s5
3321 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
3322 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3323 ; GCN2-NEXT: flat_atomic_umin v2, v[0:1], v2 glc
3324 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3325 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
3326 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
3327 ; GCN2-NEXT: s_waitcnt vmcnt(0)
3328 ; GCN2-NEXT: flat_store_dword v[0:1], v2
3329 ; GCN2-NEXT: s_endpgm
3331 ; GCN3-LABEL: atomic_umin_i32_ret:
3332 ; GCN3: ; %bb.0: ; %entry
3333 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
3334 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x34
3335 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3336 ; GCN3-NEXT: v_mov_b32_e32 v0, s4
3337 ; GCN3-NEXT: v_mov_b32_e32 v1, s5
3338 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
3339 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3340 ; GCN3-NEXT: flat_atomic_umin v2, v[0:1], v2 glc
3341 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3342 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
3343 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
3344 ; GCN3-NEXT: s_waitcnt vmcnt(0)
3345 ; GCN3-NEXT: flat_store_dword v[0:1], v2
3346 ; GCN3-NEXT: s_endpgm
3348 %val = atomicrmw volatile umin ptr %out, i32 %in syncscope("workgroup") seq_cst
3349 store i32 %val, ptr %out2
3353 define amdgpu_kernel void @atomic_umin_i32_addr64(ptr %out, i32 %in, i64 %index) {
3354 ; GCN1-LABEL: atomic_umin_i32_addr64:
3355 ; GCN1: ; %bb.0: ; %entry
3356 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xd
3357 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
3358 ; GCN1-NEXT: s_load_dword s6, s[0:1], 0xb
3359 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3360 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
3361 ; GCN1-NEXT: s_add_u32 s0, s4, s0
3362 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
3363 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
3364 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
3365 ; GCN1-NEXT: v_mov_b32_e32 v2, s6
3366 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3367 ; GCN1-NEXT: flat_atomic_umin v[0:1], v2
3368 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3369 ; GCN1-NEXT: s_endpgm
3371 ; GCN2-LABEL: atomic_umin_i32_addr64:
3372 ; GCN2: ; %bb.0: ; %entry
3373 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
3374 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
3375 ; GCN2-NEXT: s_load_dword s6, s[0:1], 0x2c
3376 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3377 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
3378 ; GCN2-NEXT: s_add_u32 s0, s4, s0
3379 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
3380 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
3381 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
3382 ; GCN2-NEXT: v_mov_b32_e32 v2, s6
3383 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3384 ; GCN2-NEXT: flat_atomic_umin v[0:1], v2
3385 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3386 ; GCN2-NEXT: s_endpgm
3388 ; GCN3-LABEL: atomic_umin_i32_addr64:
3389 ; GCN3: ; %bb.0: ; %entry
3390 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
3391 ; GCN3-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
3392 ; GCN3-NEXT: s_load_dword s6, s[0:1], 0x2c
3393 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3394 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
3395 ; GCN3-NEXT: s_add_u32 s0, s4, s0
3396 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
3397 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
3398 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
3399 ; GCN3-NEXT: v_mov_b32_e32 v2, s6
3400 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3401 ; GCN3-NEXT: flat_atomic_umin v[0:1], v2
3402 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3403 ; GCN3-NEXT: s_endpgm
3405 %ptr = getelementptr i32, ptr %out, i64 %index
3406 %val = atomicrmw volatile umin ptr %ptr, i32 %in syncscope("workgroup") seq_cst
3410 define amdgpu_kernel void @atomic_umin_i32_ret_addr64(ptr %out, ptr %out2, i32 %in, i64 %index) {
3411 ; GCN1-LABEL: atomic_umin_i32_ret_addr64:
3412 ; GCN1: ; %bb.0: ; %entry
3413 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xf
3414 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
3415 ; GCN1-NEXT: s_load_dword s8, s[0:1], 0xd
3416 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3417 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
3418 ; GCN1-NEXT: s_add_u32 s0, s4, s0
3419 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
3420 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
3421 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
3422 ; GCN1-NEXT: v_mov_b32_e32 v2, s8
3423 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3424 ; GCN1-NEXT: flat_atomic_umin v2, v[0:1], v2 glc
3425 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3426 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
3427 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
3428 ; GCN1-NEXT: s_waitcnt vmcnt(0)
3429 ; GCN1-NEXT: flat_store_dword v[0:1], v2
3430 ; GCN1-NEXT: s_endpgm
3432 ; GCN2-LABEL: atomic_umin_i32_ret_addr64:
3433 ; GCN2: ; %bb.0: ; %entry
3434 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
3435 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
3436 ; GCN2-NEXT: s_load_dword s8, s[0:1], 0x34
3437 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3438 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
3439 ; GCN2-NEXT: s_add_u32 s0, s4, s0
3440 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
3441 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
3442 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
3443 ; GCN2-NEXT: v_mov_b32_e32 v2, s8
3444 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3445 ; GCN2-NEXT: flat_atomic_umin v2, v[0:1], v2 glc
3446 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3447 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
3448 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
3449 ; GCN2-NEXT: s_waitcnt vmcnt(0)
3450 ; GCN2-NEXT: flat_store_dword v[0:1], v2
3451 ; GCN2-NEXT: s_endpgm
3453 ; GCN3-LABEL: atomic_umin_i32_ret_addr64:
3454 ; GCN3: ; %bb.0: ; %entry
3455 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
3456 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
3457 ; GCN3-NEXT: s_load_dword s8, s[0:1], 0x34
3458 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3459 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
3460 ; GCN3-NEXT: s_add_u32 s0, s4, s0
3461 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
3462 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
3463 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
3464 ; GCN3-NEXT: v_mov_b32_e32 v2, s8
3465 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3466 ; GCN3-NEXT: flat_atomic_umin v2, v[0:1], v2 glc
3467 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3468 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
3469 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
3470 ; GCN3-NEXT: s_waitcnt vmcnt(0)
3471 ; GCN3-NEXT: flat_store_dword v[0:1], v2
3472 ; GCN3-NEXT: s_endpgm
3474 %ptr = getelementptr i32, ptr %out, i64 %index
3475 %val = atomicrmw volatile umin ptr %ptr, i32 %in syncscope("workgroup") seq_cst
3476 store i32 %val, ptr %out2
3480 define amdgpu_kernel void @atomic_or_i32_offset(ptr %out, i32 %in) {
3481 ; GCN1-LABEL: atomic_or_i32_offset:
3482 ; GCN1: ; %bb.0: ; %entry
3483 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
3484 ; GCN1-NEXT: s_load_dword s4, s[0:1], 0xb
3485 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3486 ; GCN1-NEXT: s_add_u32 s0, s2, 16
3487 ; GCN1-NEXT: s_addc_u32 s1, s3, 0
3488 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
3489 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
3490 ; GCN1-NEXT: v_mov_b32_e32 v2, s4
3491 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3492 ; GCN1-NEXT: flat_atomic_or v[0:1], v2
3493 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3494 ; GCN1-NEXT: buffer_wbinvl1_vol
3495 ; GCN1-NEXT: s_endpgm
3497 ; GCN2-LABEL: atomic_or_i32_offset:
3498 ; GCN2: ; %bb.0: ; %entry
3499 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
3500 ; GCN2-NEXT: s_load_dword s4, s[0:1], 0x2c
3501 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3502 ; GCN2-NEXT: s_add_u32 s0, s2, 16
3503 ; GCN2-NEXT: s_addc_u32 s1, s3, 0
3504 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
3505 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
3506 ; GCN2-NEXT: v_mov_b32_e32 v2, s4
3507 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3508 ; GCN2-NEXT: flat_atomic_or v[0:1], v2
3509 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3510 ; GCN2-NEXT: buffer_wbinvl1_vol
3511 ; GCN2-NEXT: s_endpgm
3513 ; GCN3-LABEL: atomic_or_i32_offset:
3514 ; GCN3: ; %bb.0: ; %entry
3515 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
3516 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
3517 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3518 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
3519 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
3520 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
3521 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3522 ; GCN3-NEXT: flat_atomic_or v[0:1], v2 offset:16
3523 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3524 ; GCN3-NEXT: buffer_wbinvl1_vol
3525 ; GCN3-NEXT: s_endpgm
3527 %gep = getelementptr i32, ptr %out, i32 4
3528 %val = atomicrmw volatile or ptr %gep, i32 %in syncscope("agent") seq_cst
3532 define amdgpu_kernel void @atomic_or_i32_ret_offset(ptr %out, ptr %out2, i32 %in) {
3533 ; GCN1-LABEL: atomic_or_i32_ret_offset:
3534 ; GCN1: ; %bb.0: ; %entry
3535 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
3536 ; GCN1-NEXT: s_load_dword s2, s[0:1], 0xd
3537 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3538 ; GCN1-NEXT: s_add_u32 s0, s4, 16
3539 ; GCN1-NEXT: s_addc_u32 s1, s5, 0
3540 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
3541 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
3542 ; GCN1-NEXT: v_mov_b32_e32 v2, s2
3543 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3544 ; GCN1-NEXT: flat_atomic_or v2, v[0:1], v2 glc
3545 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3546 ; GCN1-NEXT: buffer_wbinvl1_vol
3547 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
3548 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
3549 ; GCN1-NEXT: flat_store_dword v[0:1], v2
3550 ; GCN1-NEXT: s_endpgm
3552 ; GCN2-LABEL: atomic_or_i32_ret_offset:
3553 ; GCN2: ; %bb.0: ; %entry
3554 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
3555 ; GCN2-NEXT: s_load_dword s2, s[0:1], 0x34
3556 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3557 ; GCN2-NEXT: s_add_u32 s0, s4, 16
3558 ; GCN2-NEXT: s_addc_u32 s1, s5, 0
3559 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
3560 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
3561 ; GCN2-NEXT: v_mov_b32_e32 v2, s2
3562 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3563 ; GCN2-NEXT: flat_atomic_or v2, v[0:1], v2 glc
3564 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3565 ; GCN2-NEXT: buffer_wbinvl1_vol
3566 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
3567 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
3568 ; GCN2-NEXT: flat_store_dword v[0:1], v2
3569 ; GCN2-NEXT: s_endpgm
3571 ; GCN3-LABEL: atomic_or_i32_ret_offset:
3572 ; GCN3: ; %bb.0: ; %entry
3573 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
3574 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x34
3575 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3576 ; GCN3-NEXT: v_mov_b32_e32 v0, s4
3577 ; GCN3-NEXT: v_mov_b32_e32 v1, s5
3578 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
3579 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3580 ; GCN3-NEXT: flat_atomic_or v2, v[0:1], v2 offset:16 glc
3581 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3582 ; GCN3-NEXT: buffer_wbinvl1_vol
3583 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
3584 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
3585 ; GCN3-NEXT: flat_store_dword v[0:1], v2
3586 ; GCN3-NEXT: s_endpgm
3588 %gep = getelementptr i32, ptr %out, i32 4
3589 %val = atomicrmw volatile or ptr %gep, i32 %in syncscope("agent") seq_cst
3590 store i32 %val, ptr %out2
3594 define amdgpu_kernel void @atomic_or_i32_addr64_offset(ptr %out, i32 %in, i64 %index) {
3595 ; GCN1-LABEL: atomic_or_i32_addr64_offset:
3596 ; GCN1: ; %bb.0: ; %entry
3597 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xd
3598 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
3599 ; GCN1-NEXT: s_load_dword s6, s[0:1], 0xb
3600 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3601 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
3602 ; GCN1-NEXT: s_add_u32 s0, s4, s0
3603 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
3604 ; GCN1-NEXT: s_add_u32 s0, s0, 16
3605 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
3606 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
3607 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
3608 ; GCN1-NEXT: v_mov_b32_e32 v2, s6
3609 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3610 ; GCN1-NEXT: flat_atomic_or v[0:1], v2
3611 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3612 ; GCN1-NEXT: buffer_wbinvl1_vol
3613 ; GCN1-NEXT: s_endpgm
3615 ; GCN2-LABEL: atomic_or_i32_addr64_offset:
3616 ; GCN2: ; %bb.0: ; %entry
3617 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
3618 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
3619 ; GCN2-NEXT: s_load_dword s6, s[0:1], 0x2c
3620 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3621 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
3622 ; GCN2-NEXT: s_add_u32 s0, s4, s0
3623 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
3624 ; GCN2-NEXT: s_add_u32 s0, s0, 16
3625 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
3626 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
3627 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
3628 ; GCN2-NEXT: v_mov_b32_e32 v2, s6
3629 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3630 ; GCN2-NEXT: flat_atomic_or v[0:1], v2
3631 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3632 ; GCN2-NEXT: buffer_wbinvl1_vol
3633 ; GCN2-NEXT: s_endpgm
3635 ; GCN3-LABEL: atomic_or_i32_addr64_offset:
3636 ; GCN3: ; %bb.0: ; %entry
3637 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
3638 ; GCN3-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
3639 ; GCN3-NEXT: s_load_dword s6, s[0:1], 0x2c
3640 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3641 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
3642 ; GCN3-NEXT: s_add_u32 s0, s4, s0
3643 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
3644 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
3645 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
3646 ; GCN3-NEXT: v_mov_b32_e32 v2, s6
3647 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3648 ; GCN3-NEXT: flat_atomic_or v[0:1], v2 offset:16
3649 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3650 ; GCN3-NEXT: buffer_wbinvl1_vol
3651 ; GCN3-NEXT: s_endpgm
3653 %ptr = getelementptr i32, ptr %out, i64 %index
3654 %gep = getelementptr i32, ptr %ptr, i32 4
3655 %val = atomicrmw volatile or ptr %gep, i32 %in syncscope("agent") seq_cst
3659 define amdgpu_kernel void @atomic_or_i32_ret_addr64_offset(ptr %out, ptr %out2, i32 %in, i64 %index) {
3660 ; GCN1-LABEL: atomic_or_i32_ret_addr64_offset:
3661 ; GCN1: ; %bb.0: ; %entry
3662 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xf
3663 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
3664 ; GCN1-NEXT: s_load_dword s8, s[0:1], 0xd
3665 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3666 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
3667 ; GCN1-NEXT: s_add_u32 s0, s4, s0
3668 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
3669 ; GCN1-NEXT: s_add_u32 s0, s0, 16
3670 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
3671 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
3672 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
3673 ; GCN1-NEXT: v_mov_b32_e32 v2, s8
3674 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3675 ; GCN1-NEXT: flat_atomic_or v2, v[0:1], v2 glc
3676 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3677 ; GCN1-NEXT: buffer_wbinvl1_vol
3678 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
3679 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
3680 ; GCN1-NEXT: flat_store_dword v[0:1], v2
3681 ; GCN1-NEXT: s_endpgm
3683 ; GCN2-LABEL: atomic_or_i32_ret_addr64_offset:
3684 ; GCN2: ; %bb.0: ; %entry
3685 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
3686 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
3687 ; GCN2-NEXT: s_load_dword s8, s[0:1], 0x34
3688 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3689 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
3690 ; GCN2-NEXT: s_add_u32 s0, s4, s0
3691 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
3692 ; GCN2-NEXT: s_add_u32 s0, s0, 16
3693 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
3694 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
3695 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
3696 ; GCN2-NEXT: v_mov_b32_e32 v2, s8
3697 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3698 ; GCN2-NEXT: flat_atomic_or v2, v[0:1], v2 glc
3699 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3700 ; GCN2-NEXT: buffer_wbinvl1_vol
3701 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
3702 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
3703 ; GCN2-NEXT: flat_store_dword v[0:1], v2
3704 ; GCN2-NEXT: s_endpgm
3706 ; GCN3-LABEL: atomic_or_i32_ret_addr64_offset:
3707 ; GCN3: ; %bb.0: ; %entry
3708 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
3709 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
3710 ; GCN3-NEXT: s_load_dword s8, s[0:1], 0x34
3711 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3712 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
3713 ; GCN3-NEXT: s_add_u32 s0, s4, s0
3714 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
3715 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
3716 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
3717 ; GCN3-NEXT: v_mov_b32_e32 v2, s8
3718 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3719 ; GCN3-NEXT: flat_atomic_or v2, v[0:1], v2 offset:16 glc
3720 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3721 ; GCN3-NEXT: buffer_wbinvl1_vol
3722 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
3723 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
3724 ; GCN3-NEXT: flat_store_dword v[0:1], v2
3725 ; GCN3-NEXT: s_endpgm
3727 %ptr = getelementptr i32, ptr %out, i64 %index
3728 %gep = getelementptr i32, ptr %ptr, i32 4
3729 %val = atomicrmw volatile or ptr %gep, i32 %in syncscope("agent") seq_cst
3730 store i32 %val, ptr %out2
3734 define amdgpu_kernel void @atomic_or_i32(ptr %out, i32 %in) {
3735 ; GCN1-LABEL: atomic_or_i32:
3736 ; GCN1: ; %bb.0: ; %entry
3737 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
3738 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0xb
3739 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3740 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
3741 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
3742 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
3743 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3744 ; GCN1-NEXT: flat_atomic_or v[0:1], v2
3745 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3746 ; GCN1-NEXT: buffer_wbinvl1_vol
3747 ; GCN1-NEXT: s_endpgm
3749 ; GCN2-LABEL: atomic_or_i32:
3750 ; GCN2: ; %bb.0: ; %entry
3751 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
3752 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x2c
3753 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3754 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
3755 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
3756 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
3757 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3758 ; GCN2-NEXT: flat_atomic_or v[0:1], v2
3759 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3760 ; GCN2-NEXT: buffer_wbinvl1_vol
3761 ; GCN2-NEXT: s_endpgm
3763 ; GCN3-LABEL: atomic_or_i32:
3764 ; GCN3: ; %bb.0: ; %entry
3765 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
3766 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
3767 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3768 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
3769 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
3770 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
3771 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3772 ; GCN3-NEXT: flat_atomic_or v[0:1], v2
3773 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3774 ; GCN3-NEXT: buffer_wbinvl1_vol
3775 ; GCN3-NEXT: s_endpgm
3777 %val = atomicrmw volatile or ptr %out, i32 %in syncscope("agent") seq_cst
3781 define amdgpu_kernel void @atomic_or_i32_ret(ptr %out, ptr %out2, i32 %in) {
3782 ; GCN1-LABEL: atomic_or_i32_ret:
3783 ; GCN1: ; %bb.0: ; %entry
3784 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
3785 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0xd
3786 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3787 ; GCN1-NEXT: v_mov_b32_e32 v0, s4
3788 ; GCN1-NEXT: v_mov_b32_e32 v1, s5
3789 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
3790 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3791 ; GCN1-NEXT: flat_atomic_or v2, v[0:1], v2 glc
3792 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3793 ; GCN1-NEXT: buffer_wbinvl1_vol
3794 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
3795 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
3796 ; GCN1-NEXT: flat_store_dword v[0:1], v2
3797 ; GCN1-NEXT: s_endpgm
3799 ; GCN2-LABEL: atomic_or_i32_ret:
3800 ; GCN2: ; %bb.0: ; %entry
3801 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
3802 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x34
3803 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3804 ; GCN2-NEXT: v_mov_b32_e32 v0, s4
3805 ; GCN2-NEXT: v_mov_b32_e32 v1, s5
3806 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
3807 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3808 ; GCN2-NEXT: flat_atomic_or v2, v[0:1], v2 glc
3809 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3810 ; GCN2-NEXT: buffer_wbinvl1_vol
3811 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
3812 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
3813 ; GCN2-NEXT: flat_store_dword v[0:1], v2
3814 ; GCN2-NEXT: s_endpgm
3816 ; GCN3-LABEL: atomic_or_i32_ret:
3817 ; GCN3: ; %bb.0: ; %entry
3818 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
3819 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x34
3820 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3821 ; GCN3-NEXT: v_mov_b32_e32 v0, s4
3822 ; GCN3-NEXT: v_mov_b32_e32 v1, s5
3823 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
3824 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3825 ; GCN3-NEXT: flat_atomic_or v2, v[0:1], v2 glc
3826 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3827 ; GCN3-NEXT: buffer_wbinvl1_vol
3828 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
3829 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
3830 ; GCN3-NEXT: flat_store_dword v[0:1], v2
3831 ; GCN3-NEXT: s_endpgm
3833 %val = atomicrmw volatile or ptr %out, i32 %in syncscope("agent") seq_cst
3834 store i32 %val, ptr %out2
3838 define amdgpu_kernel void @atomic_or_i32_addr64(ptr %out, i32 %in, i64 %index) {
3839 ; GCN1-LABEL: atomic_or_i32_addr64:
3840 ; GCN1: ; %bb.0: ; %entry
3841 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xd
3842 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
3843 ; GCN1-NEXT: s_load_dword s6, s[0:1], 0xb
3844 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3845 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
3846 ; GCN1-NEXT: s_add_u32 s0, s4, s0
3847 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
3848 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
3849 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
3850 ; GCN1-NEXT: v_mov_b32_e32 v2, s6
3851 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3852 ; GCN1-NEXT: flat_atomic_or v[0:1], v2
3853 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3854 ; GCN1-NEXT: buffer_wbinvl1_vol
3855 ; GCN1-NEXT: s_endpgm
3857 ; GCN2-LABEL: atomic_or_i32_addr64:
3858 ; GCN2: ; %bb.0: ; %entry
3859 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
3860 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
3861 ; GCN2-NEXT: s_load_dword s6, s[0:1], 0x2c
3862 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3863 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
3864 ; GCN2-NEXT: s_add_u32 s0, s4, s0
3865 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
3866 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
3867 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
3868 ; GCN2-NEXT: v_mov_b32_e32 v2, s6
3869 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3870 ; GCN2-NEXT: flat_atomic_or v[0:1], v2
3871 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3872 ; GCN2-NEXT: buffer_wbinvl1_vol
3873 ; GCN2-NEXT: s_endpgm
3875 ; GCN3-LABEL: atomic_or_i32_addr64:
3876 ; GCN3: ; %bb.0: ; %entry
3877 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
3878 ; GCN3-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
3879 ; GCN3-NEXT: s_load_dword s6, s[0:1], 0x2c
3880 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3881 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
3882 ; GCN3-NEXT: s_add_u32 s0, s4, s0
3883 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
3884 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
3885 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
3886 ; GCN3-NEXT: v_mov_b32_e32 v2, s6
3887 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3888 ; GCN3-NEXT: flat_atomic_or v[0:1], v2
3889 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3890 ; GCN3-NEXT: buffer_wbinvl1_vol
3891 ; GCN3-NEXT: s_endpgm
3893 %ptr = getelementptr i32, ptr %out, i64 %index
3894 %val = atomicrmw volatile or ptr %ptr, i32 %in syncscope("agent") seq_cst
3898 define amdgpu_kernel void @atomic_or_i32_ret_addr64(ptr %out, ptr %out2, i32 %in, i64 %index) {
3899 ; GCN1-LABEL: atomic_or_i32_ret_addr64:
3900 ; GCN1: ; %bb.0: ; %entry
3901 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xf
3902 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
3903 ; GCN1-NEXT: s_load_dword s8, s[0:1], 0xd
3904 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3905 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
3906 ; GCN1-NEXT: s_add_u32 s0, s4, s0
3907 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
3908 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
3909 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
3910 ; GCN1-NEXT: v_mov_b32_e32 v2, s8
3911 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3912 ; GCN1-NEXT: flat_atomic_or v2, v[0:1], v2 glc
3913 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3914 ; GCN1-NEXT: buffer_wbinvl1_vol
3915 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
3916 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
3917 ; GCN1-NEXT: flat_store_dword v[0:1], v2
3918 ; GCN1-NEXT: s_endpgm
3920 ; GCN2-LABEL: atomic_or_i32_ret_addr64:
3921 ; GCN2: ; %bb.0: ; %entry
3922 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
3923 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
3924 ; GCN2-NEXT: s_load_dword s8, s[0:1], 0x34
3925 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3926 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
3927 ; GCN2-NEXT: s_add_u32 s0, s4, s0
3928 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
3929 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
3930 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
3931 ; GCN2-NEXT: v_mov_b32_e32 v2, s8
3932 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3933 ; GCN2-NEXT: flat_atomic_or v2, v[0:1], v2 glc
3934 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3935 ; GCN2-NEXT: buffer_wbinvl1_vol
3936 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
3937 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
3938 ; GCN2-NEXT: flat_store_dword v[0:1], v2
3939 ; GCN2-NEXT: s_endpgm
3941 ; GCN3-LABEL: atomic_or_i32_ret_addr64:
3942 ; GCN3: ; %bb.0: ; %entry
3943 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
3944 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
3945 ; GCN3-NEXT: s_load_dword s8, s[0:1], 0x34
3946 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
3947 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
3948 ; GCN3-NEXT: s_add_u32 s0, s4, s0
3949 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
3950 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
3951 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
3952 ; GCN3-NEXT: v_mov_b32_e32 v2, s8
3953 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3954 ; GCN3-NEXT: flat_atomic_or v2, v[0:1], v2 glc
3955 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3956 ; GCN3-NEXT: buffer_wbinvl1_vol
3957 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
3958 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
3959 ; GCN3-NEXT: flat_store_dword v[0:1], v2
3960 ; GCN3-NEXT: s_endpgm
3962 %ptr = getelementptr i32, ptr %out, i64 %index
3963 %val = atomicrmw volatile or ptr %ptr, i32 %in syncscope("agent") seq_cst
3964 store i32 %val, ptr %out2
3968 define amdgpu_kernel void @atomic_xchg_i32_offset(ptr %out, i32 %in) {
3969 ; GCN1-LABEL: atomic_xchg_i32_offset:
3970 ; GCN1: ; %bb.0: ; %entry
3971 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
3972 ; GCN1-NEXT: s_load_dword s4, s[0:1], 0xb
3973 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
3974 ; GCN1-NEXT: s_add_u32 s0, s2, 16
3975 ; GCN1-NEXT: s_addc_u32 s1, s3, 0
3976 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
3977 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
3978 ; GCN1-NEXT: v_mov_b32_e32 v2, s4
3979 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3980 ; GCN1-NEXT: flat_atomic_swap v[0:1], v2
3981 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3982 ; GCN1-NEXT: buffer_wbinvl1_vol
3983 ; GCN1-NEXT: s_endpgm
3985 ; GCN2-LABEL: atomic_xchg_i32_offset:
3986 ; GCN2: ; %bb.0: ; %entry
3987 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
3988 ; GCN2-NEXT: s_load_dword s4, s[0:1], 0x2c
3989 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
3990 ; GCN2-NEXT: s_add_u32 s0, s2, 16
3991 ; GCN2-NEXT: s_addc_u32 s1, s3, 0
3992 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
3993 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
3994 ; GCN2-NEXT: v_mov_b32_e32 v2, s4
3995 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3996 ; GCN2-NEXT: flat_atomic_swap v[0:1], v2
3997 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
3998 ; GCN2-NEXT: buffer_wbinvl1_vol
3999 ; GCN2-NEXT: s_endpgm
4001 ; GCN3-LABEL: atomic_xchg_i32_offset:
4002 ; GCN3: ; %bb.0: ; %entry
4003 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
4004 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
4005 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
4006 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
4007 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
4008 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
4009 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4010 ; GCN3-NEXT: flat_atomic_swap v[0:1], v2 offset:16
4011 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4012 ; GCN3-NEXT: buffer_wbinvl1_vol
4013 ; GCN3-NEXT: s_endpgm
4015 %gep = getelementptr i32, ptr %out, i32 4
4016 %val = atomicrmw volatile xchg ptr %gep, i32 %in syncscope("agent") seq_cst
4020 define amdgpu_kernel void @atomic_xchg_f32_offset(ptr %out, float %in) {
4021 ; GCN1-LABEL: atomic_xchg_f32_offset:
4022 ; GCN1: ; %bb.0: ; %entry
4023 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
4024 ; GCN1-NEXT: s_load_dword s4, s[0:1], 0xb
4025 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
4026 ; GCN1-NEXT: s_add_u32 s0, s2, 16
4027 ; GCN1-NEXT: s_addc_u32 s1, s3, 0
4028 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
4029 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
4030 ; GCN1-NEXT: v_mov_b32_e32 v2, s4
4031 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4032 ; GCN1-NEXT: flat_atomic_swap v[0:1], v2
4033 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4034 ; GCN1-NEXT: buffer_wbinvl1_vol
4035 ; GCN1-NEXT: s_endpgm
4037 ; GCN2-LABEL: atomic_xchg_f32_offset:
4038 ; GCN2: ; %bb.0: ; %entry
4039 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
4040 ; GCN2-NEXT: s_load_dword s4, s[0:1], 0x2c
4041 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
4042 ; GCN2-NEXT: s_add_u32 s0, s2, 16
4043 ; GCN2-NEXT: s_addc_u32 s1, s3, 0
4044 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
4045 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
4046 ; GCN2-NEXT: v_mov_b32_e32 v2, s4
4047 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4048 ; GCN2-NEXT: flat_atomic_swap v[0:1], v2
4049 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4050 ; GCN2-NEXT: buffer_wbinvl1_vol
4051 ; GCN2-NEXT: s_endpgm
4053 ; GCN3-LABEL: atomic_xchg_f32_offset:
4054 ; GCN3: ; %bb.0: ; %entry
4055 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
4056 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
4057 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
4058 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
4059 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
4060 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
4061 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4062 ; GCN3-NEXT: flat_atomic_swap v[0:1], v2 offset:16
4063 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4064 ; GCN3-NEXT: buffer_wbinvl1_vol
4065 ; GCN3-NEXT: s_endpgm
4067 %gep = getelementptr float, ptr %out, i32 4
4068 %val = atomicrmw volatile xchg ptr %gep, float %in syncscope("agent") seq_cst
4072 define amdgpu_kernel void @atomic_xchg_i32_ret_offset(ptr %out, ptr %out2, i32 %in) {
4073 ; GCN1-LABEL: atomic_xchg_i32_ret_offset:
4074 ; GCN1: ; %bb.0: ; %entry
4075 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
4076 ; GCN1-NEXT: s_load_dword s2, s[0:1], 0xd
4077 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
4078 ; GCN1-NEXT: s_add_u32 s0, s4, 16
4079 ; GCN1-NEXT: s_addc_u32 s1, s5, 0
4080 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
4081 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
4082 ; GCN1-NEXT: v_mov_b32_e32 v2, s2
4083 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4084 ; GCN1-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
4085 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4086 ; GCN1-NEXT: buffer_wbinvl1_vol
4087 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
4088 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
4089 ; GCN1-NEXT: flat_store_dword v[0:1], v2
4090 ; GCN1-NEXT: s_endpgm
4092 ; GCN2-LABEL: atomic_xchg_i32_ret_offset:
4093 ; GCN2: ; %bb.0: ; %entry
4094 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
4095 ; GCN2-NEXT: s_load_dword s2, s[0:1], 0x34
4096 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
4097 ; GCN2-NEXT: s_add_u32 s0, s4, 16
4098 ; GCN2-NEXT: s_addc_u32 s1, s5, 0
4099 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
4100 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
4101 ; GCN2-NEXT: v_mov_b32_e32 v2, s2
4102 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4103 ; GCN2-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
4104 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4105 ; GCN2-NEXT: buffer_wbinvl1_vol
4106 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
4107 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
4108 ; GCN2-NEXT: flat_store_dword v[0:1], v2
4109 ; GCN2-NEXT: s_endpgm
4111 ; GCN3-LABEL: atomic_xchg_i32_ret_offset:
4112 ; GCN3: ; %bb.0: ; %entry
4113 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
4114 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x34
4115 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
4116 ; GCN3-NEXT: v_mov_b32_e32 v0, s4
4117 ; GCN3-NEXT: v_mov_b32_e32 v1, s5
4118 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
4119 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4120 ; GCN3-NEXT: flat_atomic_swap v2, v[0:1], v2 offset:16 glc
4121 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4122 ; GCN3-NEXT: buffer_wbinvl1_vol
4123 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
4124 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
4125 ; GCN3-NEXT: flat_store_dword v[0:1], v2
4126 ; GCN3-NEXT: s_endpgm
4128 %gep = getelementptr i32, ptr %out, i32 4
4129 %val = atomicrmw volatile xchg ptr %gep, i32 %in syncscope("agent") seq_cst
4130 store i32 %val, ptr %out2
4134 define amdgpu_kernel void @atomic_xchg_i32_addr64_offset(ptr %out, i32 %in, i64 %index) {
4135 ; GCN1-LABEL: atomic_xchg_i32_addr64_offset:
4136 ; GCN1: ; %bb.0: ; %entry
4137 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xd
4138 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
4139 ; GCN1-NEXT: s_load_dword s6, s[0:1], 0xb
4140 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
4141 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
4142 ; GCN1-NEXT: s_add_u32 s0, s4, s0
4143 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
4144 ; GCN1-NEXT: s_add_u32 s0, s0, 16
4145 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
4146 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
4147 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
4148 ; GCN1-NEXT: v_mov_b32_e32 v2, s6
4149 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4150 ; GCN1-NEXT: flat_atomic_swap v[0:1], v2
4151 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4152 ; GCN1-NEXT: buffer_wbinvl1_vol
4153 ; GCN1-NEXT: s_endpgm
4155 ; GCN2-LABEL: atomic_xchg_i32_addr64_offset:
4156 ; GCN2: ; %bb.0: ; %entry
4157 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
4158 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
4159 ; GCN2-NEXT: s_load_dword s6, s[0:1], 0x2c
4160 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
4161 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
4162 ; GCN2-NEXT: s_add_u32 s0, s4, s0
4163 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
4164 ; GCN2-NEXT: s_add_u32 s0, s0, 16
4165 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
4166 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
4167 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
4168 ; GCN2-NEXT: v_mov_b32_e32 v2, s6
4169 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4170 ; GCN2-NEXT: flat_atomic_swap v[0:1], v2
4171 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4172 ; GCN2-NEXT: buffer_wbinvl1_vol
4173 ; GCN2-NEXT: s_endpgm
4175 ; GCN3-LABEL: atomic_xchg_i32_addr64_offset:
4176 ; GCN3: ; %bb.0: ; %entry
4177 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
4178 ; GCN3-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
4179 ; GCN3-NEXT: s_load_dword s6, s[0:1], 0x2c
4180 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
4181 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
4182 ; GCN3-NEXT: s_add_u32 s0, s4, s0
4183 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
4184 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
4185 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
4186 ; GCN3-NEXT: v_mov_b32_e32 v2, s6
4187 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4188 ; GCN3-NEXT: flat_atomic_swap v[0:1], v2 offset:16
4189 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4190 ; GCN3-NEXT: buffer_wbinvl1_vol
4191 ; GCN3-NEXT: s_endpgm
4193 %ptr = getelementptr i32, ptr %out, i64 %index
4194 %gep = getelementptr i32, ptr %ptr, i32 4
4195 %val = atomicrmw volatile xchg ptr %gep, i32 %in syncscope("agent") seq_cst
4199 define amdgpu_kernel void @atomic_xchg_i32_ret_addr64_offset(ptr %out, ptr %out2, i32 %in, i64 %index) {
4200 ; GCN1-LABEL: atomic_xchg_i32_ret_addr64_offset:
4201 ; GCN1: ; %bb.0: ; %entry
4202 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xf
4203 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
4204 ; GCN1-NEXT: s_load_dword s8, s[0:1], 0xd
4205 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
4206 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
4207 ; GCN1-NEXT: s_add_u32 s0, s4, s0
4208 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
4209 ; GCN1-NEXT: s_add_u32 s0, s0, 16
4210 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
4211 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
4212 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
4213 ; GCN1-NEXT: v_mov_b32_e32 v2, s8
4214 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4215 ; GCN1-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
4216 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4217 ; GCN1-NEXT: buffer_wbinvl1_vol
4218 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
4219 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
4220 ; GCN1-NEXT: flat_store_dword v[0:1], v2
4221 ; GCN1-NEXT: s_endpgm
4223 ; GCN2-LABEL: atomic_xchg_i32_ret_addr64_offset:
4224 ; GCN2: ; %bb.0: ; %entry
4225 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
4226 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
4227 ; GCN2-NEXT: s_load_dword s8, s[0:1], 0x34
4228 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
4229 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
4230 ; GCN2-NEXT: s_add_u32 s0, s4, s0
4231 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
4232 ; GCN2-NEXT: s_add_u32 s0, s0, 16
4233 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
4234 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
4235 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
4236 ; GCN2-NEXT: v_mov_b32_e32 v2, s8
4237 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4238 ; GCN2-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
4239 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4240 ; GCN2-NEXT: buffer_wbinvl1_vol
4241 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
4242 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
4243 ; GCN2-NEXT: flat_store_dword v[0:1], v2
4244 ; GCN2-NEXT: s_endpgm
4246 ; GCN3-LABEL: atomic_xchg_i32_ret_addr64_offset:
4247 ; GCN3: ; %bb.0: ; %entry
4248 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
4249 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
4250 ; GCN3-NEXT: s_load_dword s8, s[0:1], 0x34
4251 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
4252 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
4253 ; GCN3-NEXT: s_add_u32 s0, s4, s0
4254 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
4255 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
4256 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
4257 ; GCN3-NEXT: v_mov_b32_e32 v2, s8
4258 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4259 ; GCN3-NEXT: flat_atomic_swap v2, v[0:1], v2 offset:16 glc
4260 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4261 ; GCN3-NEXT: buffer_wbinvl1_vol
4262 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
4263 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
4264 ; GCN3-NEXT: flat_store_dword v[0:1], v2
4265 ; GCN3-NEXT: s_endpgm
4267 %ptr = getelementptr i32, ptr %out, i64 %index
4268 %gep = getelementptr i32, ptr %ptr, i32 4
4269 %val = atomicrmw volatile xchg ptr %gep, i32 %in syncscope("agent") seq_cst
4270 store i32 %val, ptr %out2
4274 define amdgpu_kernel void @atomic_xchg_i32(ptr %out, i32 %in) {
4275 ; GCN1-LABEL: atomic_xchg_i32:
4276 ; GCN1: ; %bb.0: ; %entry
4277 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
4278 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0xb
4279 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
4280 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
4281 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
4282 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
4283 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4284 ; GCN1-NEXT: flat_atomic_swap v[0:1], v2
4285 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4286 ; GCN1-NEXT: buffer_wbinvl1_vol
4287 ; GCN1-NEXT: s_endpgm
4289 ; GCN2-LABEL: atomic_xchg_i32:
4290 ; GCN2: ; %bb.0: ; %entry
4291 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
4292 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x2c
4293 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
4294 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
4295 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
4296 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
4297 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4298 ; GCN2-NEXT: flat_atomic_swap v[0:1], v2
4299 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4300 ; GCN2-NEXT: buffer_wbinvl1_vol
4301 ; GCN2-NEXT: s_endpgm
4303 ; GCN3-LABEL: atomic_xchg_i32:
4304 ; GCN3: ; %bb.0: ; %entry
4305 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
4306 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
4307 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
4308 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
4309 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
4310 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
4311 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4312 ; GCN3-NEXT: flat_atomic_swap v[0:1], v2
4313 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4314 ; GCN3-NEXT: buffer_wbinvl1_vol
4315 ; GCN3-NEXT: s_endpgm
4317 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("agent") seq_cst
4321 define amdgpu_kernel void @atomic_xchg_i32_ret(ptr %out, ptr %out2, i32 %in) {
4322 ; GCN1-LABEL: atomic_xchg_i32_ret:
4323 ; GCN1: ; %bb.0: ; %entry
4324 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
4325 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0xd
4326 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
4327 ; GCN1-NEXT: v_mov_b32_e32 v0, s4
4328 ; GCN1-NEXT: v_mov_b32_e32 v1, s5
4329 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
4330 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4331 ; GCN1-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
4332 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4333 ; GCN1-NEXT: buffer_wbinvl1_vol
4334 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
4335 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
4336 ; GCN1-NEXT: flat_store_dword v[0:1], v2
4337 ; GCN1-NEXT: s_endpgm
4339 ; GCN2-LABEL: atomic_xchg_i32_ret:
4340 ; GCN2: ; %bb.0: ; %entry
4341 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
4342 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x34
4343 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
4344 ; GCN2-NEXT: v_mov_b32_e32 v0, s4
4345 ; GCN2-NEXT: v_mov_b32_e32 v1, s5
4346 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
4347 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4348 ; GCN2-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
4349 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4350 ; GCN2-NEXT: buffer_wbinvl1_vol
4351 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
4352 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
4353 ; GCN2-NEXT: flat_store_dword v[0:1], v2
4354 ; GCN2-NEXT: s_endpgm
4356 ; GCN3-LABEL: atomic_xchg_i32_ret:
4357 ; GCN3: ; %bb.0: ; %entry
4358 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
4359 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x34
4360 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
4361 ; GCN3-NEXT: v_mov_b32_e32 v0, s4
4362 ; GCN3-NEXT: v_mov_b32_e32 v1, s5
4363 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
4364 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4365 ; GCN3-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
4366 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4367 ; GCN3-NEXT: buffer_wbinvl1_vol
4368 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
4369 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
4370 ; GCN3-NEXT: flat_store_dword v[0:1], v2
4371 ; GCN3-NEXT: s_endpgm
4373 %val = atomicrmw volatile xchg ptr %out, i32 %in syncscope("agent") seq_cst
4374 store i32 %val, ptr %out2
4378 define amdgpu_kernel void @atomic_xchg_i32_addr64(ptr %out, i32 %in, i64 %index) {
4379 ; GCN1-LABEL: atomic_xchg_i32_addr64:
4380 ; GCN1: ; %bb.0: ; %entry
4381 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xd
4382 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
4383 ; GCN1-NEXT: s_load_dword s6, s[0:1], 0xb
4384 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
4385 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
4386 ; GCN1-NEXT: s_add_u32 s0, s4, s0
4387 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
4388 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
4389 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
4390 ; GCN1-NEXT: v_mov_b32_e32 v2, s6
4391 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4392 ; GCN1-NEXT: flat_atomic_swap v[0:1], v2
4393 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4394 ; GCN1-NEXT: buffer_wbinvl1_vol
4395 ; GCN1-NEXT: s_endpgm
4397 ; GCN2-LABEL: atomic_xchg_i32_addr64:
4398 ; GCN2: ; %bb.0: ; %entry
4399 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
4400 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
4401 ; GCN2-NEXT: s_load_dword s6, s[0:1], 0x2c
4402 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
4403 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
4404 ; GCN2-NEXT: s_add_u32 s0, s4, s0
4405 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
4406 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
4407 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
4408 ; GCN2-NEXT: v_mov_b32_e32 v2, s6
4409 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4410 ; GCN2-NEXT: flat_atomic_swap v[0:1], v2
4411 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4412 ; GCN2-NEXT: buffer_wbinvl1_vol
4413 ; GCN2-NEXT: s_endpgm
4415 ; GCN3-LABEL: atomic_xchg_i32_addr64:
4416 ; GCN3: ; %bb.0: ; %entry
4417 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
4418 ; GCN3-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
4419 ; GCN3-NEXT: s_load_dword s6, s[0:1], 0x2c
4420 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
4421 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
4422 ; GCN3-NEXT: s_add_u32 s0, s4, s0
4423 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
4424 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
4425 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
4426 ; GCN3-NEXT: v_mov_b32_e32 v2, s6
4427 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4428 ; GCN3-NEXT: flat_atomic_swap v[0:1], v2
4429 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4430 ; GCN3-NEXT: buffer_wbinvl1_vol
4431 ; GCN3-NEXT: s_endpgm
4433 %ptr = getelementptr i32, ptr %out, i64 %index
4434 %val = atomicrmw volatile xchg ptr %ptr, i32 %in syncscope("agent") seq_cst
4438 define amdgpu_kernel void @atomic_xchg_i32_ret_addr64(ptr %out, ptr %out2, i32 %in, i64 %index) {
4439 ; GCN1-LABEL: atomic_xchg_i32_ret_addr64:
4440 ; GCN1: ; %bb.0: ; %entry
4441 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xf
4442 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
4443 ; GCN1-NEXT: s_load_dword s8, s[0:1], 0xd
4444 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
4445 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
4446 ; GCN1-NEXT: s_add_u32 s0, s4, s0
4447 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
4448 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
4449 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
4450 ; GCN1-NEXT: v_mov_b32_e32 v2, s8
4451 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4452 ; GCN1-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
4453 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4454 ; GCN1-NEXT: buffer_wbinvl1_vol
4455 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
4456 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
4457 ; GCN1-NEXT: flat_store_dword v[0:1], v2
4458 ; GCN1-NEXT: s_endpgm
4460 ; GCN2-LABEL: atomic_xchg_i32_ret_addr64:
4461 ; GCN2: ; %bb.0: ; %entry
4462 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
4463 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
4464 ; GCN2-NEXT: s_load_dword s8, s[0:1], 0x34
4465 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
4466 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
4467 ; GCN2-NEXT: s_add_u32 s0, s4, s0
4468 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
4469 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
4470 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
4471 ; GCN2-NEXT: v_mov_b32_e32 v2, s8
4472 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4473 ; GCN2-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
4474 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4475 ; GCN2-NEXT: buffer_wbinvl1_vol
4476 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
4477 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
4478 ; GCN2-NEXT: flat_store_dword v[0:1], v2
4479 ; GCN2-NEXT: s_endpgm
4481 ; GCN3-LABEL: atomic_xchg_i32_ret_addr64:
4482 ; GCN3: ; %bb.0: ; %entry
4483 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
4484 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
4485 ; GCN3-NEXT: s_load_dword s8, s[0:1], 0x34
4486 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
4487 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
4488 ; GCN3-NEXT: s_add_u32 s0, s4, s0
4489 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
4490 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
4491 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
4492 ; GCN3-NEXT: v_mov_b32_e32 v2, s8
4493 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4494 ; GCN3-NEXT: flat_atomic_swap v2, v[0:1], v2 glc
4495 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4496 ; GCN3-NEXT: buffer_wbinvl1_vol
4497 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
4498 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
4499 ; GCN3-NEXT: flat_store_dword v[0:1], v2
4500 ; GCN3-NEXT: s_endpgm
4502 %ptr = getelementptr i32, ptr %out, i64 %index
4503 %val = atomicrmw volatile xchg ptr %ptr, i32 %in syncscope("agent") seq_cst
4504 store i32 %val, ptr %out2
4510 define amdgpu_kernel void @atomic_cmpxchg_i32_offset(ptr %out, i32 %in, i32 %old) {
4511 ; GCN1-LABEL: atomic_cmpxchg_i32_offset:
4512 ; GCN1: ; %bb.0: ; %entry
4513 ; GCN1-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
4514 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
4515 ; GCN1-NEXT: s_add_u32 s0, s0, 16
4516 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
4517 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
4518 ; GCN1-NEXT: v_mov_b32_e32 v2, s2
4519 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
4520 ; GCN1-NEXT: v_mov_b32_e32 v3, s3
4521 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4522 ; GCN1-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4523 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4524 ; GCN1-NEXT: buffer_wbinvl1_vol
4525 ; GCN1-NEXT: s_endpgm
4527 ; GCN2-LABEL: atomic_cmpxchg_i32_offset:
4528 ; GCN2: ; %bb.0: ; %entry
4529 ; GCN2-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
4530 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
4531 ; GCN2-NEXT: s_add_u32 s0, s0, 16
4532 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
4533 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
4534 ; GCN2-NEXT: v_mov_b32_e32 v2, s2
4535 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
4536 ; GCN2-NEXT: v_mov_b32_e32 v3, s3
4537 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4538 ; GCN2-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4539 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4540 ; GCN2-NEXT: buffer_wbinvl1_vol
4541 ; GCN2-NEXT: s_endpgm
4543 ; GCN3-LABEL: atomic_cmpxchg_i32_offset:
4544 ; GCN3: ; %bb.0: ; %entry
4545 ; GCN3-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
4546 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
4547 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
4548 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
4549 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
4550 ; GCN3-NEXT: v_mov_b32_e32 v3, s3
4551 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4552 ; GCN3-NEXT: flat_atomic_cmpswap v[0:1], v[2:3] offset:16
4553 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4554 ; GCN3-NEXT: buffer_wbinvl1_vol
4555 ; GCN3-NEXT: s_endpgm
4557 %gep = getelementptr i32, ptr %out, i32 4
4558 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("agent") seq_cst seq_cst
4562 define amdgpu_kernel void @atomic_cmpxchg_i32_ret_offset(ptr %out, ptr %out2, i32 %in, i32 %old) {
4563 ; GCN1-LABEL: atomic_cmpxchg_i32_ret_offset:
4564 ; GCN1: ; %bb.0: ; %entry
4565 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
4566 ; GCN1-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xd
4567 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
4568 ; GCN1-NEXT: s_add_u32 s2, s4, 16
4569 ; GCN1-NEXT: s_addc_u32 s3, s5, 0
4570 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
4571 ; GCN1-NEXT: v_mov_b32_e32 v3, s1
4572 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
4573 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
4574 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4575 ; GCN1-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4576 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4577 ; GCN1-NEXT: buffer_wbinvl1_vol
4578 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
4579 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
4580 ; GCN1-NEXT: flat_store_dword v[0:1], v2
4581 ; GCN1-NEXT: s_endpgm
4583 ; GCN2-LABEL: atomic_cmpxchg_i32_ret_offset:
4584 ; GCN2: ; %bb.0: ; %entry
4585 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
4586 ; GCN2-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x34
4587 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
4588 ; GCN2-NEXT: s_add_u32 s2, s4, 16
4589 ; GCN2-NEXT: s_addc_u32 s3, s5, 0
4590 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
4591 ; GCN2-NEXT: v_mov_b32_e32 v3, s1
4592 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
4593 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
4594 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4595 ; GCN2-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4596 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4597 ; GCN2-NEXT: buffer_wbinvl1_vol
4598 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
4599 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
4600 ; GCN2-NEXT: flat_store_dword v[0:1], v2
4601 ; GCN2-NEXT: s_endpgm
4603 ; GCN3-LABEL: atomic_cmpxchg_i32_ret_offset:
4604 ; GCN3: ; %bb.0: ; %entry
4605 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
4606 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
4607 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
4608 ; GCN3-NEXT: v_mov_b32_e32 v0, s4
4609 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
4610 ; GCN3-NEXT: v_mov_b32_e32 v1, s5
4611 ; GCN3-NEXT: v_mov_b32_e32 v3, s3
4612 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4613 ; GCN3-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] offset:16 glc
4614 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4615 ; GCN3-NEXT: buffer_wbinvl1_vol
4616 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
4617 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
4618 ; GCN3-NEXT: flat_store_dword v[0:1], v2
4619 ; GCN3-NEXT: s_endpgm
4621 %gep = getelementptr i32, ptr %out, i32 4
4622 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("agent") seq_cst seq_cst
4623 %flag = extractvalue { i32, i1 } %val, 0
4624 store i32 %flag, ptr %out2
4628 define amdgpu_kernel void @atomic_cmpxchg_i32_addr64_offset(ptr %out, i32 %in, i64 %index, i32 %old) {
4629 ; GCN1-LABEL: atomic_cmpxchg_i32_addr64_offset:
4630 ; GCN1: ; %bb.0: ; %entry
4631 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xd
4632 ; GCN1-NEXT: s_load_dword s6, s[0:1], 0xb
4633 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
4634 ; GCN1-NEXT: s_load_dword s7, s[0:1], 0xf
4635 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
4636 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
4637 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
4638 ; GCN1-NEXT: s_add_u32 s0, s4, s0
4639 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
4640 ; GCN1-NEXT: s_add_u32 s0, s0, 16
4641 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
4642 ; GCN1-NEXT: v_mov_b32_e32 v3, s1
4643 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
4644 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
4645 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4646 ; GCN1-NEXT: flat_atomic_cmpswap v[2:3], v[0:1]
4647 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4648 ; GCN1-NEXT: buffer_wbinvl1_vol
4649 ; GCN1-NEXT: s_endpgm
4651 ; GCN2-LABEL: atomic_cmpxchg_i32_addr64_offset:
4652 ; GCN2: ; %bb.0: ; %entry
4653 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
4654 ; GCN2-NEXT: s_load_dword s6, s[0:1], 0x2c
4655 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
4656 ; GCN2-NEXT: s_load_dword s7, s[0:1], 0x3c
4657 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
4658 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
4659 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
4660 ; GCN2-NEXT: s_add_u32 s0, s4, s0
4661 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
4662 ; GCN2-NEXT: s_add_u32 s0, s0, 16
4663 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
4664 ; GCN2-NEXT: v_mov_b32_e32 v3, s1
4665 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
4666 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
4667 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4668 ; GCN2-NEXT: flat_atomic_cmpswap v[2:3], v[0:1]
4669 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4670 ; GCN2-NEXT: buffer_wbinvl1_vol
4671 ; GCN2-NEXT: s_endpgm
4673 ; GCN3-LABEL: atomic_cmpxchg_i32_addr64_offset:
4674 ; GCN3: ; %bb.0: ; %entry
4675 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
4676 ; GCN3-NEXT: s_load_dword s6, s[0:1], 0x2c
4677 ; GCN3-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
4678 ; GCN3-NEXT: s_load_dword s7, s[0:1], 0x3c
4679 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
4680 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
4681 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
4682 ; GCN3-NEXT: s_add_u32 s0, s4, s0
4683 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
4684 ; GCN3-NEXT: v_mov_b32_e32 v3, s1
4685 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
4686 ; GCN3-NEXT: v_mov_b32_e32 v2, s0
4687 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4688 ; GCN3-NEXT: flat_atomic_cmpswap v[2:3], v[0:1] offset:16
4689 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4690 ; GCN3-NEXT: buffer_wbinvl1_vol
4691 ; GCN3-NEXT: s_endpgm
4693 %ptr = getelementptr i32, ptr %out, i64 %index
4694 %gep = getelementptr i32, ptr %ptr, i32 4
4695 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("agent") seq_cst seq_cst
4699 define amdgpu_kernel void @atomic_cmpxchg_i32_ret_addr64_offset(ptr %out, ptr %out2, i32 %in, i64 %index, i32 %old) {
4700 ; GCN1-LABEL: atomic_cmpxchg_i32_ret_addr64_offset:
4701 ; GCN1: ; %bb.0: ; %entry
4702 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xf
4703 ; GCN1-NEXT: s_load_dword s8, s[0:1], 0xd
4704 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
4705 ; GCN1-NEXT: s_load_dword s9, s[0:1], 0x11
4706 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
4707 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
4708 ; GCN1-NEXT: v_mov_b32_e32 v0, s8
4709 ; GCN1-NEXT: s_add_u32 s0, s4, s0
4710 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
4711 ; GCN1-NEXT: s_add_u32 s0, s0, 16
4712 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
4713 ; GCN1-NEXT: v_mov_b32_e32 v3, s1
4714 ; GCN1-NEXT: v_mov_b32_e32 v1, s9
4715 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
4716 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4717 ; GCN1-NEXT: flat_atomic_cmpswap v2, v[2:3], v[0:1] glc
4718 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4719 ; GCN1-NEXT: buffer_wbinvl1_vol
4720 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
4721 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
4722 ; GCN1-NEXT: flat_store_dword v[0:1], v2
4723 ; GCN1-NEXT: s_endpgm
4725 ; GCN2-LABEL: atomic_cmpxchg_i32_ret_addr64_offset:
4726 ; GCN2: ; %bb.0: ; %entry
4727 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
4728 ; GCN2-NEXT: s_load_dword s8, s[0:1], 0x34
4729 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
4730 ; GCN2-NEXT: s_load_dword s9, s[0:1], 0x44
4731 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
4732 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
4733 ; GCN2-NEXT: v_mov_b32_e32 v0, s8
4734 ; GCN2-NEXT: s_add_u32 s0, s4, s0
4735 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
4736 ; GCN2-NEXT: s_add_u32 s0, s0, 16
4737 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
4738 ; GCN2-NEXT: v_mov_b32_e32 v3, s1
4739 ; GCN2-NEXT: v_mov_b32_e32 v1, s9
4740 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
4741 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4742 ; GCN2-NEXT: flat_atomic_cmpswap v2, v[2:3], v[0:1] glc
4743 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4744 ; GCN2-NEXT: buffer_wbinvl1_vol
4745 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
4746 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
4747 ; GCN2-NEXT: flat_store_dword v[0:1], v2
4748 ; GCN2-NEXT: s_endpgm
4750 ; GCN3-LABEL: atomic_cmpxchg_i32_ret_addr64_offset:
4751 ; GCN3: ; %bb.0: ; %entry
4752 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
4753 ; GCN3-NEXT: s_load_dword s8, s[0:1], 0x34
4754 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
4755 ; GCN3-NEXT: s_load_dword s9, s[0:1], 0x44
4756 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
4757 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
4758 ; GCN3-NEXT: v_mov_b32_e32 v0, s8
4759 ; GCN3-NEXT: s_add_u32 s0, s4, s0
4760 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
4761 ; GCN3-NEXT: v_mov_b32_e32 v3, s1
4762 ; GCN3-NEXT: v_mov_b32_e32 v1, s9
4763 ; GCN3-NEXT: v_mov_b32_e32 v2, s0
4764 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4765 ; GCN3-NEXT: flat_atomic_cmpswap v2, v[2:3], v[0:1] offset:16 glc
4766 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4767 ; GCN3-NEXT: buffer_wbinvl1_vol
4768 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
4769 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
4770 ; GCN3-NEXT: flat_store_dword v[0:1], v2
4771 ; GCN3-NEXT: s_endpgm
4773 %ptr = getelementptr i32, ptr %out, i64 %index
4774 %gep = getelementptr i32, ptr %ptr, i32 4
4775 %val = cmpxchg volatile ptr %gep, i32 %old, i32 %in syncscope("agent") seq_cst seq_cst
4776 %flag = extractvalue { i32, i1 } %val, 0
4777 store i32 %flag, ptr %out2
4781 define amdgpu_kernel void @atomic_cmpxchg_i32(ptr %out, i32 %in, i32 %old) {
4782 ; GCN1-LABEL: atomic_cmpxchg_i32:
4783 ; GCN1: ; %bb.0: ; %entry
4784 ; GCN1-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
4785 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
4786 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
4787 ; GCN1-NEXT: v_mov_b32_e32 v2, s2
4788 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
4789 ; GCN1-NEXT: v_mov_b32_e32 v3, s3
4790 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4791 ; GCN1-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4792 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4793 ; GCN1-NEXT: buffer_wbinvl1_vol
4794 ; GCN1-NEXT: s_endpgm
4796 ; GCN2-LABEL: atomic_cmpxchg_i32:
4797 ; GCN2: ; %bb.0: ; %entry
4798 ; GCN2-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
4799 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
4800 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
4801 ; GCN2-NEXT: v_mov_b32_e32 v2, s2
4802 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
4803 ; GCN2-NEXT: v_mov_b32_e32 v3, s3
4804 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4805 ; GCN2-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4806 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4807 ; GCN2-NEXT: buffer_wbinvl1_vol
4808 ; GCN2-NEXT: s_endpgm
4810 ; GCN3-LABEL: atomic_cmpxchg_i32:
4811 ; GCN3: ; %bb.0: ; %entry
4812 ; GCN3-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
4813 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
4814 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
4815 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
4816 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
4817 ; GCN3-NEXT: v_mov_b32_e32 v3, s3
4818 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4819 ; GCN3-NEXT: flat_atomic_cmpswap v[0:1], v[2:3]
4820 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4821 ; GCN3-NEXT: buffer_wbinvl1_vol
4822 ; GCN3-NEXT: s_endpgm
4824 %val = cmpxchg volatile ptr %out, i32 %old, i32 %in syncscope("agent") seq_cst seq_cst
4828 define amdgpu_kernel void @atomic_cmpxchg_i32_ret(ptr %out, ptr %out2, i32 %in, i32 %old) {
4829 ; GCN1-LABEL: atomic_cmpxchg_i32_ret:
4830 ; GCN1: ; %bb.0: ; %entry
4831 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
4832 ; GCN1-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xd
4833 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
4834 ; GCN1-NEXT: v_mov_b32_e32 v0, s4
4835 ; GCN1-NEXT: v_mov_b32_e32 v3, s1
4836 ; GCN1-NEXT: v_mov_b32_e32 v1, s5
4837 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
4838 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4839 ; GCN1-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4840 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4841 ; GCN1-NEXT: buffer_wbinvl1_vol
4842 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
4843 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
4844 ; GCN1-NEXT: flat_store_dword v[0:1], v2
4845 ; GCN1-NEXT: s_endpgm
4847 ; GCN2-LABEL: atomic_cmpxchg_i32_ret:
4848 ; GCN2: ; %bb.0: ; %entry
4849 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
4850 ; GCN2-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x34
4851 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
4852 ; GCN2-NEXT: v_mov_b32_e32 v0, s4
4853 ; GCN2-NEXT: v_mov_b32_e32 v3, s1
4854 ; GCN2-NEXT: v_mov_b32_e32 v1, s5
4855 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
4856 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4857 ; GCN2-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4858 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4859 ; GCN2-NEXT: buffer_wbinvl1_vol
4860 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
4861 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
4862 ; GCN2-NEXT: flat_store_dword v[0:1], v2
4863 ; GCN2-NEXT: s_endpgm
4865 ; GCN3-LABEL: atomic_cmpxchg_i32_ret:
4866 ; GCN3: ; %bb.0: ; %entry
4867 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
4868 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
4869 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
4870 ; GCN3-NEXT: v_mov_b32_e32 v0, s4
4871 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
4872 ; GCN3-NEXT: v_mov_b32_e32 v1, s5
4873 ; GCN3-NEXT: v_mov_b32_e32 v3, s3
4874 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4875 ; GCN3-NEXT: flat_atomic_cmpswap v2, v[0:1], v[2:3] glc
4876 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4877 ; GCN3-NEXT: buffer_wbinvl1_vol
4878 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
4879 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
4880 ; GCN3-NEXT: flat_store_dword v[0:1], v2
4881 ; GCN3-NEXT: s_endpgm
4883 %val = cmpxchg volatile ptr %out, i32 %old, i32 %in syncscope("agent") seq_cst seq_cst
4884 %flag = extractvalue { i32, i1 } %val, 0
4885 store i32 %flag, ptr %out2
4889 define amdgpu_kernel void @atomic_cmpxchg_i32_addr64(ptr %out, i32 %in, i64 %index, i32 %old) {
4890 ; GCN1-LABEL: atomic_cmpxchg_i32_addr64:
4891 ; GCN1: ; %bb.0: ; %entry
4892 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xd
4893 ; GCN1-NEXT: s_load_dword s6, s[0:1], 0xb
4894 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
4895 ; GCN1-NEXT: s_load_dword s7, s[0:1], 0xf
4896 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
4897 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
4898 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
4899 ; GCN1-NEXT: s_add_u32 s0, s4, s0
4900 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
4901 ; GCN1-NEXT: v_mov_b32_e32 v3, s1
4902 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
4903 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
4904 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4905 ; GCN1-NEXT: flat_atomic_cmpswap v[2:3], v[0:1]
4906 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4907 ; GCN1-NEXT: buffer_wbinvl1_vol
4908 ; GCN1-NEXT: s_endpgm
4910 ; GCN2-LABEL: atomic_cmpxchg_i32_addr64:
4911 ; GCN2: ; %bb.0: ; %entry
4912 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
4913 ; GCN2-NEXT: s_load_dword s6, s[0:1], 0x2c
4914 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
4915 ; GCN2-NEXT: s_load_dword s7, s[0:1], 0x3c
4916 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
4917 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
4918 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
4919 ; GCN2-NEXT: s_add_u32 s0, s4, s0
4920 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
4921 ; GCN2-NEXT: v_mov_b32_e32 v3, s1
4922 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
4923 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
4924 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4925 ; GCN2-NEXT: flat_atomic_cmpswap v[2:3], v[0:1]
4926 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4927 ; GCN2-NEXT: buffer_wbinvl1_vol
4928 ; GCN2-NEXT: s_endpgm
4930 ; GCN3-LABEL: atomic_cmpxchg_i32_addr64:
4931 ; GCN3: ; %bb.0: ; %entry
4932 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
4933 ; GCN3-NEXT: s_load_dword s6, s[0:1], 0x2c
4934 ; GCN3-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
4935 ; GCN3-NEXT: s_load_dword s7, s[0:1], 0x3c
4936 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
4937 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
4938 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
4939 ; GCN3-NEXT: s_add_u32 s0, s4, s0
4940 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
4941 ; GCN3-NEXT: v_mov_b32_e32 v3, s1
4942 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
4943 ; GCN3-NEXT: v_mov_b32_e32 v2, s0
4944 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4945 ; GCN3-NEXT: flat_atomic_cmpswap v[2:3], v[0:1]
4946 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4947 ; GCN3-NEXT: buffer_wbinvl1_vol
4948 ; GCN3-NEXT: s_endpgm
4950 %ptr = getelementptr i32, ptr %out, i64 %index
4951 %val = cmpxchg volatile ptr %ptr, i32 %old, i32 %in syncscope("agent") seq_cst seq_cst
4955 define amdgpu_kernel void @atomic_cmpxchg_i32_ret_addr64(ptr %out, ptr %out2, i32 %in, i64 %index, i32 %old) {
4956 ; GCN1-LABEL: atomic_cmpxchg_i32_ret_addr64:
4957 ; GCN1: ; %bb.0: ; %entry
4958 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xf
4959 ; GCN1-NEXT: s_load_dword s8, s[0:1], 0xd
4960 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
4961 ; GCN1-NEXT: s_load_dword s9, s[0:1], 0x11
4962 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
4963 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
4964 ; GCN1-NEXT: v_mov_b32_e32 v0, s8
4965 ; GCN1-NEXT: s_add_u32 s0, s4, s0
4966 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
4967 ; GCN1-NEXT: v_mov_b32_e32 v3, s1
4968 ; GCN1-NEXT: v_mov_b32_e32 v1, s9
4969 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
4970 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4971 ; GCN1-NEXT: flat_atomic_cmpswap v2, v[2:3], v[0:1] glc
4972 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4973 ; GCN1-NEXT: buffer_wbinvl1_vol
4974 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
4975 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
4976 ; GCN1-NEXT: flat_store_dword v[0:1], v2
4977 ; GCN1-NEXT: s_endpgm
4979 ; GCN2-LABEL: atomic_cmpxchg_i32_ret_addr64:
4980 ; GCN2: ; %bb.0: ; %entry
4981 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
4982 ; GCN2-NEXT: s_load_dword s8, s[0:1], 0x34
4983 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
4984 ; GCN2-NEXT: s_load_dword s9, s[0:1], 0x44
4985 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
4986 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
4987 ; GCN2-NEXT: v_mov_b32_e32 v0, s8
4988 ; GCN2-NEXT: s_add_u32 s0, s4, s0
4989 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
4990 ; GCN2-NEXT: v_mov_b32_e32 v3, s1
4991 ; GCN2-NEXT: v_mov_b32_e32 v1, s9
4992 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
4993 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4994 ; GCN2-NEXT: flat_atomic_cmpswap v2, v[2:3], v[0:1] glc
4995 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
4996 ; GCN2-NEXT: buffer_wbinvl1_vol
4997 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
4998 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
4999 ; GCN2-NEXT: flat_store_dword v[0:1], v2
5000 ; GCN2-NEXT: s_endpgm
5002 ; GCN3-LABEL: atomic_cmpxchg_i32_ret_addr64:
5003 ; GCN3: ; %bb.0: ; %entry
5004 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
5005 ; GCN3-NEXT: s_load_dword s8, s[0:1], 0x34
5006 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
5007 ; GCN3-NEXT: s_load_dword s9, s[0:1], 0x44
5008 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
5009 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
5010 ; GCN3-NEXT: v_mov_b32_e32 v0, s8
5011 ; GCN3-NEXT: s_add_u32 s0, s4, s0
5012 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
5013 ; GCN3-NEXT: v_mov_b32_e32 v3, s1
5014 ; GCN3-NEXT: v_mov_b32_e32 v1, s9
5015 ; GCN3-NEXT: v_mov_b32_e32 v2, s0
5016 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5017 ; GCN3-NEXT: flat_atomic_cmpswap v2, v[2:3], v[0:1] glc
5018 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5019 ; GCN3-NEXT: buffer_wbinvl1_vol
5020 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
5021 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
5022 ; GCN3-NEXT: flat_store_dword v[0:1], v2
5023 ; GCN3-NEXT: s_endpgm
5025 %ptr = getelementptr i32, ptr %out, i64 %index
5026 %val = cmpxchg volatile ptr %ptr, i32 %old, i32 %in syncscope("agent") seq_cst seq_cst
5027 %flag = extractvalue { i32, i1 } %val, 0
5028 store i32 %flag, ptr %out2
5032 define amdgpu_kernel void @atomic_xor_i32_offset(ptr %out, i32 %in) {
5033 ; GCN1-LABEL: atomic_xor_i32_offset:
5034 ; GCN1: ; %bb.0: ; %entry
5035 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
5036 ; GCN1-NEXT: s_load_dword s4, s[0:1], 0xb
5037 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
5038 ; GCN1-NEXT: s_add_u32 s0, s2, 16
5039 ; GCN1-NEXT: s_addc_u32 s1, s3, 0
5040 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
5041 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
5042 ; GCN1-NEXT: v_mov_b32_e32 v2, s4
5043 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5044 ; GCN1-NEXT: flat_atomic_xor v[0:1], v2
5045 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5046 ; GCN1-NEXT: buffer_wbinvl1_vol
5047 ; GCN1-NEXT: s_endpgm
5049 ; GCN2-LABEL: atomic_xor_i32_offset:
5050 ; GCN2: ; %bb.0: ; %entry
5051 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
5052 ; GCN2-NEXT: s_load_dword s4, s[0:1], 0x2c
5053 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
5054 ; GCN2-NEXT: s_add_u32 s0, s2, 16
5055 ; GCN2-NEXT: s_addc_u32 s1, s3, 0
5056 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
5057 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
5058 ; GCN2-NEXT: v_mov_b32_e32 v2, s4
5059 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5060 ; GCN2-NEXT: flat_atomic_xor v[0:1], v2
5061 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5062 ; GCN2-NEXT: buffer_wbinvl1_vol
5063 ; GCN2-NEXT: s_endpgm
5065 ; GCN3-LABEL: atomic_xor_i32_offset:
5066 ; GCN3: ; %bb.0: ; %entry
5067 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
5068 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
5069 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
5070 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
5071 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
5072 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
5073 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5074 ; GCN3-NEXT: flat_atomic_xor v[0:1], v2 offset:16
5075 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5076 ; GCN3-NEXT: buffer_wbinvl1_vol
5077 ; GCN3-NEXT: s_endpgm
5079 %gep = getelementptr i32, ptr %out, i32 4
5080 %val = atomicrmw volatile xor ptr %gep, i32 %in syncscope("agent") seq_cst
5084 define amdgpu_kernel void @atomic_xor_i32_ret_offset(ptr %out, ptr %out2, i32 %in) {
5085 ; GCN1-LABEL: atomic_xor_i32_ret_offset:
5086 ; GCN1: ; %bb.0: ; %entry
5087 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
5088 ; GCN1-NEXT: s_load_dword s2, s[0:1], 0xd
5089 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
5090 ; GCN1-NEXT: s_add_u32 s0, s4, 16
5091 ; GCN1-NEXT: s_addc_u32 s1, s5, 0
5092 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
5093 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
5094 ; GCN1-NEXT: v_mov_b32_e32 v2, s2
5095 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5096 ; GCN1-NEXT: flat_atomic_xor v2, v[0:1], v2 glc
5097 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5098 ; GCN1-NEXT: buffer_wbinvl1_vol
5099 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
5100 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
5101 ; GCN1-NEXT: flat_store_dword v[0:1], v2
5102 ; GCN1-NEXT: s_endpgm
5104 ; GCN2-LABEL: atomic_xor_i32_ret_offset:
5105 ; GCN2: ; %bb.0: ; %entry
5106 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
5107 ; GCN2-NEXT: s_load_dword s2, s[0:1], 0x34
5108 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
5109 ; GCN2-NEXT: s_add_u32 s0, s4, 16
5110 ; GCN2-NEXT: s_addc_u32 s1, s5, 0
5111 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
5112 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
5113 ; GCN2-NEXT: v_mov_b32_e32 v2, s2
5114 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5115 ; GCN2-NEXT: flat_atomic_xor v2, v[0:1], v2 glc
5116 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5117 ; GCN2-NEXT: buffer_wbinvl1_vol
5118 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
5119 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
5120 ; GCN2-NEXT: flat_store_dword v[0:1], v2
5121 ; GCN2-NEXT: s_endpgm
5123 ; GCN3-LABEL: atomic_xor_i32_ret_offset:
5124 ; GCN3: ; %bb.0: ; %entry
5125 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
5126 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x34
5127 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
5128 ; GCN3-NEXT: v_mov_b32_e32 v0, s4
5129 ; GCN3-NEXT: v_mov_b32_e32 v1, s5
5130 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
5131 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5132 ; GCN3-NEXT: flat_atomic_xor v2, v[0:1], v2 offset:16 glc
5133 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5134 ; GCN3-NEXT: buffer_wbinvl1_vol
5135 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
5136 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
5137 ; GCN3-NEXT: flat_store_dword v[0:1], v2
5138 ; GCN3-NEXT: s_endpgm
5140 %gep = getelementptr i32, ptr %out, i32 4
5141 %val = atomicrmw volatile xor ptr %gep, i32 %in syncscope("agent") seq_cst
5142 store i32 %val, ptr %out2
5146 define amdgpu_kernel void @atomic_xor_i32_addr64_offset(ptr %out, i32 %in, i64 %index) {
5147 ; GCN1-LABEL: atomic_xor_i32_addr64_offset:
5148 ; GCN1: ; %bb.0: ; %entry
5149 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xd
5150 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
5151 ; GCN1-NEXT: s_load_dword s6, s[0:1], 0xb
5152 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
5153 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
5154 ; GCN1-NEXT: s_add_u32 s0, s4, s0
5155 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
5156 ; GCN1-NEXT: s_add_u32 s0, s0, 16
5157 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
5158 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
5159 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
5160 ; GCN1-NEXT: v_mov_b32_e32 v2, s6
5161 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5162 ; GCN1-NEXT: flat_atomic_xor v[0:1], v2
5163 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5164 ; GCN1-NEXT: buffer_wbinvl1_vol
5165 ; GCN1-NEXT: s_endpgm
5167 ; GCN2-LABEL: atomic_xor_i32_addr64_offset:
5168 ; GCN2: ; %bb.0: ; %entry
5169 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
5170 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
5171 ; GCN2-NEXT: s_load_dword s6, s[0:1], 0x2c
5172 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
5173 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
5174 ; GCN2-NEXT: s_add_u32 s0, s4, s0
5175 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
5176 ; GCN2-NEXT: s_add_u32 s0, s0, 16
5177 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
5178 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
5179 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
5180 ; GCN2-NEXT: v_mov_b32_e32 v2, s6
5181 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5182 ; GCN2-NEXT: flat_atomic_xor v[0:1], v2
5183 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5184 ; GCN2-NEXT: buffer_wbinvl1_vol
5185 ; GCN2-NEXT: s_endpgm
5187 ; GCN3-LABEL: atomic_xor_i32_addr64_offset:
5188 ; GCN3: ; %bb.0: ; %entry
5189 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
5190 ; GCN3-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
5191 ; GCN3-NEXT: s_load_dword s6, s[0:1], 0x2c
5192 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
5193 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
5194 ; GCN3-NEXT: s_add_u32 s0, s4, s0
5195 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
5196 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
5197 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
5198 ; GCN3-NEXT: v_mov_b32_e32 v2, s6
5199 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5200 ; GCN3-NEXT: flat_atomic_xor v[0:1], v2 offset:16
5201 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5202 ; GCN3-NEXT: buffer_wbinvl1_vol
5203 ; GCN3-NEXT: s_endpgm
5205 %ptr = getelementptr i32, ptr %out, i64 %index
5206 %gep = getelementptr i32, ptr %ptr, i32 4
5207 %val = atomicrmw volatile xor ptr %gep, i32 %in syncscope("agent") seq_cst
5211 define amdgpu_kernel void @atomic_xor_i32_ret_addr64_offset(ptr %out, ptr %out2, i32 %in, i64 %index) {
5212 ; GCN1-LABEL: atomic_xor_i32_ret_addr64_offset:
5213 ; GCN1: ; %bb.0: ; %entry
5214 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xf
5215 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
5216 ; GCN1-NEXT: s_load_dword s8, s[0:1], 0xd
5217 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
5218 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
5219 ; GCN1-NEXT: s_add_u32 s0, s4, s0
5220 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
5221 ; GCN1-NEXT: s_add_u32 s0, s0, 16
5222 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
5223 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
5224 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
5225 ; GCN1-NEXT: v_mov_b32_e32 v2, s8
5226 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5227 ; GCN1-NEXT: flat_atomic_xor v2, v[0:1], v2 glc
5228 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5229 ; GCN1-NEXT: buffer_wbinvl1_vol
5230 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
5231 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
5232 ; GCN1-NEXT: flat_store_dword v[0:1], v2
5233 ; GCN1-NEXT: s_endpgm
5235 ; GCN2-LABEL: atomic_xor_i32_ret_addr64_offset:
5236 ; GCN2: ; %bb.0: ; %entry
5237 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
5238 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
5239 ; GCN2-NEXT: s_load_dword s8, s[0:1], 0x34
5240 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
5241 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
5242 ; GCN2-NEXT: s_add_u32 s0, s4, s0
5243 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
5244 ; GCN2-NEXT: s_add_u32 s0, s0, 16
5245 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
5246 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
5247 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
5248 ; GCN2-NEXT: v_mov_b32_e32 v2, s8
5249 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5250 ; GCN2-NEXT: flat_atomic_xor v2, v[0:1], v2 glc
5251 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5252 ; GCN2-NEXT: buffer_wbinvl1_vol
5253 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
5254 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
5255 ; GCN2-NEXT: flat_store_dword v[0:1], v2
5256 ; GCN2-NEXT: s_endpgm
5258 ; GCN3-LABEL: atomic_xor_i32_ret_addr64_offset:
5259 ; GCN3: ; %bb.0: ; %entry
5260 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
5261 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
5262 ; GCN3-NEXT: s_load_dword s8, s[0:1], 0x34
5263 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
5264 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
5265 ; GCN3-NEXT: s_add_u32 s0, s4, s0
5266 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
5267 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
5268 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
5269 ; GCN3-NEXT: v_mov_b32_e32 v2, s8
5270 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5271 ; GCN3-NEXT: flat_atomic_xor v2, v[0:1], v2 offset:16 glc
5272 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5273 ; GCN3-NEXT: buffer_wbinvl1_vol
5274 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
5275 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
5276 ; GCN3-NEXT: flat_store_dword v[0:1], v2
5277 ; GCN3-NEXT: s_endpgm
5279 %ptr = getelementptr i32, ptr %out, i64 %index
5280 %gep = getelementptr i32, ptr %ptr, i32 4
5281 %val = atomicrmw volatile xor ptr %gep, i32 %in syncscope("agent") seq_cst
5282 store i32 %val, ptr %out2
5286 define amdgpu_kernel void @atomic_xor_i32(ptr %out, i32 %in) {
5287 ; GCN1-LABEL: atomic_xor_i32:
5288 ; GCN1: ; %bb.0: ; %entry
5289 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
5290 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0xb
5291 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
5292 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
5293 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
5294 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
5295 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5296 ; GCN1-NEXT: flat_atomic_xor v[0:1], v2
5297 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5298 ; GCN1-NEXT: buffer_wbinvl1_vol
5299 ; GCN1-NEXT: s_endpgm
5301 ; GCN2-LABEL: atomic_xor_i32:
5302 ; GCN2: ; %bb.0: ; %entry
5303 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
5304 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x2c
5305 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
5306 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
5307 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
5308 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
5309 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5310 ; GCN2-NEXT: flat_atomic_xor v[0:1], v2
5311 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5312 ; GCN2-NEXT: buffer_wbinvl1_vol
5313 ; GCN2-NEXT: s_endpgm
5315 ; GCN3-LABEL: atomic_xor_i32:
5316 ; GCN3: ; %bb.0: ; %entry
5317 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
5318 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
5319 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
5320 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
5321 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
5322 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
5323 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5324 ; GCN3-NEXT: flat_atomic_xor v[0:1], v2
5325 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5326 ; GCN3-NEXT: buffer_wbinvl1_vol
5327 ; GCN3-NEXT: s_endpgm
5329 %val = atomicrmw volatile xor ptr %out, i32 %in syncscope("agent") seq_cst
5333 define amdgpu_kernel void @atomic_xor_i32_ret(ptr %out, ptr %out2, i32 %in) {
5334 ; GCN1-LABEL: atomic_xor_i32_ret:
5335 ; GCN1: ; %bb.0: ; %entry
5336 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
5337 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0xd
5338 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
5339 ; GCN1-NEXT: v_mov_b32_e32 v0, s4
5340 ; GCN1-NEXT: v_mov_b32_e32 v1, s5
5341 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
5342 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5343 ; GCN1-NEXT: flat_atomic_xor v2, v[0:1], v2 glc
5344 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5345 ; GCN1-NEXT: buffer_wbinvl1_vol
5346 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
5347 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
5348 ; GCN1-NEXT: flat_store_dword v[0:1], v2
5349 ; GCN1-NEXT: s_endpgm
5351 ; GCN2-LABEL: atomic_xor_i32_ret:
5352 ; GCN2: ; %bb.0: ; %entry
5353 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
5354 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x34
5355 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
5356 ; GCN2-NEXT: v_mov_b32_e32 v0, s4
5357 ; GCN2-NEXT: v_mov_b32_e32 v1, s5
5358 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
5359 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5360 ; GCN2-NEXT: flat_atomic_xor v2, v[0:1], v2 glc
5361 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5362 ; GCN2-NEXT: buffer_wbinvl1_vol
5363 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
5364 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
5365 ; GCN2-NEXT: flat_store_dword v[0:1], v2
5366 ; GCN2-NEXT: s_endpgm
5368 ; GCN3-LABEL: atomic_xor_i32_ret:
5369 ; GCN3: ; %bb.0: ; %entry
5370 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
5371 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x34
5372 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
5373 ; GCN3-NEXT: v_mov_b32_e32 v0, s4
5374 ; GCN3-NEXT: v_mov_b32_e32 v1, s5
5375 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
5376 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5377 ; GCN3-NEXT: flat_atomic_xor v2, v[0:1], v2 glc
5378 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5379 ; GCN3-NEXT: buffer_wbinvl1_vol
5380 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
5381 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
5382 ; GCN3-NEXT: flat_store_dword v[0:1], v2
5383 ; GCN3-NEXT: s_endpgm
5385 %val = atomicrmw volatile xor ptr %out, i32 %in syncscope("agent") seq_cst
5386 store i32 %val, ptr %out2
5390 define amdgpu_kernel void @atomic_xor_i32_addr64(ptr %out, i32 %in, i64 %index) {
5391 ; GCN1-LABEL: atomic_xor_i32_addr64:
5392 ; GCN1: ; %bb.0: ; %entry
5393 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xd
5394 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
5395 ; GCN1-NEXT: s_load_dword s6, s[0:1], 0xb
5396 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
5397 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
5398 ; GCN1-NEXT: s_add_u32 s0, s4, s0
5399 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
5400 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
5401 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
5402 ; GCN1-NEXT: v_mov_b32_e32 v2, s6
5403 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5404 ; GCN1-NEXT: flat_atomic_xor v[0:1], v2
5405 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5406 ; GCN1-NEXT: buffer_wbinvl1_vol
5407 ; GCN1-NEXT: s_endpgm
5409 ; GCN2-LABEL: atomic_xor_i32_addr64:
5410 ; GCN2: ; %bb.0: ; %entry
5411 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
5412 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
5413 ; GCN2-NEXT: s_load_dword s6, s[0:1], 0x2c
5414 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
5415 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
5416 ; GCN2-NEXT: s_add_u32 s0, s4, s0
5417 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
5418 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
5419 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
5420 ; GCN2-NEXT: v_mov_b32_e32 v2, s6
5421 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5422 ; GCN2-NEXT: flat_atomic_xor v[0:1], v2
5423 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5424 ; GCN2-NEXT: buffer_wbinvl1_vol
5425 ; GCN2-NEXT: s_endpgm
5427 ; GCN3-LABEL: atomic_xor_i32_addr64:
5428 ; GCN3: ; %bb.0: ; %entry
5429 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
5430 ; GCN3-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
5431 ; GCN3-NEXT: s_load_dword s6, s[0:1], 0x2c
5432 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
5433 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
5434 ; GCN3-NEXT: s_add_u32 s0, s4, s0
5435 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
5436 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
5437 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
5438 ; GCN3-NEXT: v_mov_b32_e32 v2, s6
5439 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5440 ; GCN3-NEXT: flat_atomic_xor v[0:1], v2
5441 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5442 ; GCN3-NEXT: buffer_wbinvl1_vol
5443 ; GCN3-NEXT: s_endpgm
5445 %ptr = getelementptr i32, ptr %out, i64 %index
5446 %val = atomicrmw volatile xor ptr %ptr, i32 %in syncscope("agent") seq_cst
5450 define amdgpu_kernel void @atomic_xor_i32_ret_addr64(ptr %out, ptr %out2, i32 %in, i64 %index) {
5451 ; GCN1-LABEL: atomic_xor_i32_ret_addr64:
5452 ; GCN1: ; %bb.0: ; %entry
5453 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xf
5454 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
5455 ; GCN1-NEXT: s_load_dword s8, s[0:1], 0xd
5456 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
5457 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
5458 ; GCN1-NEXT: s_add_u32 s0, s4, s0
5459 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
5460 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
5461 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
5462 ; GCN1-NEXT: v_mov_b32_e32 v2, s8
5463 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5464 ; GCN1-NEXT: flat_atomic_xor v2, v[0:1], v2 glc
5465 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5466 ; GCN1-NEXT: buffer_wbinvl1_vol
5467 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
5468 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
5469 ; GCN1-NEXT: flat_store_dword v[0:1], v2
5470 ; GCN1-NEXT: s_endpgm
5472 ; GCN2-LABEL: atomic_xor_i32_ret_addr64:
5473 ; GCN2: ; %bb.0: ; %entry
5474 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
5475 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
5476 ; GCN2-NEXT: s_load_dword s8, s[0:1], 0x34
5477 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
5478 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
5479 ; GCN2-NEXT: s_add_u32 s0, s4, s0
5480 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
5481 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
5482 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
5483 ; GCN2-NEXT: v_mov_b32_e32 v2, s8
5484 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5485 ; GCN2-NEXT: flat_atomic_xor v2, v[0:1], v2 glc
5486 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5487 ; GCN2-NEXT: buffer_wbinvl1_vol
5488 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
5489 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
5490 ; GCN2-NEXT: flat_store_dword v[0:1], v2
5491 ; GCN2-NEXT: s_endpgm
5493 ; GCN3-LABEL: atomic_xor_i32_ret_addr64:
5494 ; GCN3: ; %bb.0: ; %entry
5495 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
5496 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
5497 ; GCN3-NEXT: s_load_dword s8, s[0:1], 0x34
5498 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
5499 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
5500 ; GCN3-NEXT: s_add_u32 s0, s4, s0
5501 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
5502 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
5503 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
5504 ; GCN3-NEXT: v_mov_b32_e32 v2, s8
5505 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5506 ; GCN3-NEXT: flat_atomic_xor v2, v[0:1], v2 glc
5507 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5508 ; GCN3-NEXT: buffer_wbinvl1_vol
5509 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
5510 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
5511 ; GCN3-NEXT: flat_store_dword v[0:1], v2
5512 ; GCN3-NEXT: s_endpgm
5514 %ptr = getelementptr i32, ptr %out, i64 %index
5515 %val = atomicrmw volatile xor ptr %ptr, i32 %in syncscope("agent") seq_cst
5516 store i32 %val, ptr %out2
5520 define amdgpu_kernel void @atomic_load_i32_offset(ptr %in, ptr %out) {
5521 ; GCN1-LABEL: atomic_load_i32_offset:
5522 ; GCN1: ; %bb.0: ; %entry
5523 ; GCN1-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
5524 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
5525 ; GCN1-NEXT: s_add_u32 s0, s0, 16
5526 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
5527 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
5528 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
5529 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5530 ; GCN1-NEXT: flat_load_dword v2, v[0:1] glc
5531 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5532 ; GCN1-NEXT: buffer_wbinvl1_vol
5533 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
5534 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
5535 ; GCN1-NEXT: flat_store_dword v[0:1], v2
5536 ; GCN1-NEXT: s_endpgm
5538 ; GCN2-LABEL: atomic_load_i32_offset:
5539 ; GCN2: ; %bb.0: ; %entry
5540 ; GCN2-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
5541 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
5542 ; GCN2-NEXT: s_add_u32 s0, s0, 16
5543 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
5544 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
5545 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
5546 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5547 ; GCN2-NEXT: flat_load_dword v2, v[0:1] glc
5548 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5549 ; GCN2-NEXT: buffer_wbinvl1_vol
5550 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
5551 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
5552 ; GCN2-NEXT: flat_store_dword v[0:1], v2
5553 ; GCN2-NEXT: s_endpgm
5555 ; GCN3-LABEL: atomic_load_i32_offset:
5556 ; GCN3: ; %bb.0: ; %entry
5557 ; GCN3-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
5558 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
5559 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
5560 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
5561 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5562 ; GCN3-NEXT: flat_load_dword v2, v[0:1] offset:16 glc
5563 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5564 ; GCN3-NEXT: buffer_wbinvl1_vol
5565 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
5566 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
5567 ; GCN3-NEXT: flat_store_dword v[0:1], v2
5568 ; GCN3-NEXT: s_endpgm
5570 %gep = getelementptr i32, ptr %in, i32 4
5571 %val = load atomic i32, ptr %gep seq_cst, align 4
5572 store i32 %val, ptr %out
5576 define amdgpu_kernel void @atomic_load_i32(ptr %in, ptr %out) {
5577 ; GCN1-LABEL: atomic_load_i32:
5578 ; GCN1: ; %bb.0: ; %entry
5579 ; GCN1-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
5580 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
5581 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
5582 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
5583 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5584 ; GCN1-NEXT: flat_load_dword v2, v[0:1] glc
5585 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5586 ; GCN1-NEXT: buffer_wbinvl1_vol
5587 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
5588 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
5589 ; GCN1-NEXT: flat_store_dword v[0:1], v2
5590 ; GCN1-NEXT: s_endpgm
5592 ; GCN2-LABEL: atomic_load_i32:
5593 ; GCN2: ; %bb.0: ; %entry
5594 ; GCN2-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
5595 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
5596 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
5597 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
5598 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5599 ; GCN2-NEXT: flat_load_dword v2, v[0:1] glc
5600 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5601 ; GCN2-NEXT: buffer_wbinvl1_vol
5602 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
5603 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
5604 ; GCN2-NEXT: flat_store_dword v[0:1], v2
5605 ; GCN2-NEXT: s_endpgm
5607 ; GCN3-LABEL: atomic_load_i32:
5608 ; GCN3: ; %bb.0: ; %entry
5609 ; GCN3-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
5610 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
5611 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
5612 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
5613 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5614 ; GCN3-NEXT: flat_load_dword v2, v[0:1] glc
5615 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5616 ; GCN3-NEXT: buffer_wbinvl1_vol
5617 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
5618 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
5619 ; GCN3-NEXT: flat_store_dword v[0:1], v2
5620 ; GCN3-NEXT: s_endpgm
5622 %val = load atomic i32, ptr %in seq_cst, align 4
5623 store i32 %val, ptr %out
5627 define amdgpu_kernel void @atomic_load_i32_addr64_offset(ptr %in, ptr %out, i64 %index) {
5628 ; GCN1-LABEL: atomic_load_i32_addr64_offset:
5629 ; GCN1: ; %bb.0: ; %entry
5630 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0xd
5631 ; GCN1-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
5632 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
5633 ; GCN1-NEXT: s_lshl_b64 s[4:5], s[4:5], 2
5634 ; GCN1-NEXT: s_add_u32 s0, s0, s4
5635 ; GCN1-NEXT: s_addc_u32 s1, s1, s5
5636 ; GCN1-NEXT: s_add_u32 s0, s0, 16
5637 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
5638 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
5639 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
5640 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5641 ; GCN1-NEXT: flat_load_dword v2, v[0:1] glc
5642 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5643 ; GCN1-NEXT: buffer_wbinvl1_vol
5644 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
5645 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
5646 ; GCN1-NEXT: flat_store_dword v[0:1], v2
5647 ; GCN1-NEXT: s_endpgm
5649 ; GCN2-LABEL: atomic_load_i32_addr64_offset:
5650 ; GCN2: ; %bb.0: ; %entry
5651 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x34
5652 ; GCN2-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
5653 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
5654 ; GCN2-NEXT: s_lshl_b64 s[4:5], s[4:5], 2
5655 ; GCN2-NEXT: s_add_u32 s0, s0, s4
5656 ; GCN2-NEXT: s_addc_u32 s1, s1, s5
5657 ; GCN2-NEXT: s_add_u32 s0, s0, 16
5658 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
5659 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
5660 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
5661 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5662 ; GCN2-NEXT: flat_load_dword v2, v[0:1] glc
5663 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5664 ; GCN2-NEXT: buffer_wbinvl1_vol
5665 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
5666 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
5667 ; GCN2-NEXT: flat_store_dword v[0:1], v2
5668 ; GCN2-NEXT: s_endpgm
5670 ; GCN3-LABEL: atomic_load_i32_addr64_offset:
5671 ; GCN3: ; %bb.0: ; %entry
5672 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
5673 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
5674 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
5675 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
5676 ; GCN3-NEXT: s_add_u32 s0, s4, s0
5677 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
5678 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
5679 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
5680 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5681 ; GCN3-NEXT: flat_load_dword v2, v[0:1] offset:16 glc
5682 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5683 ; GCN3-NEXT: buffer_wbinvl1_vol
5684 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
5685 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
5686 ; GCN3-NEXT: flat_store_dword v[0:1], v2
5687 ; GCN3-NEXT: s_endpgm
5689 %ptr = getelementptr i32, ptr %in, i64 %index
5690 %gep = getelementptr i32, ptr %ptr, i32 4
5691 %val = load atomic i32, ptr %gep seq_cst, align 4
5692 store i32 %val, ptr %out
5696 define amdgpu_kernel void @atomic_load_i32_addr64(ptr %in, ptr %out, i64 %index) {
5697 ; GCN1-LABEL: atomic_load_i32_addr64:
5698 ; GCN1: ; %bb.0: ; %entry
5699 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0xd
5700 ; GCN1-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
5701 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
5702 ; GCN1-NEXT: s_lshl_b64 s[4:5], s[4:5], 2
5703 ; GCN1-NEXT: s_add_u32 s0, s0, s4
5704 ; GCN1-NEXT: s_addc_u32 s1, s1, s5
5705 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
5706 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
5707 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5708 ; GCN1-NEXT: flat_load_dword v2, v[0:1] glc
5709 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5710 ; GCN1-NEXT: buffer_wbinvl1_vol
5711 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
5712 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
5713 ; GCN1-NEXT: flat_store_dword v[0:1], v2
5714 ; GCN1-NEXT: s_endpgm
5716 ; GCN2-LABEL: atomic_load_i32_addr64:
5717 ; GCN2: ; %bb.0: ; %entry
5718 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x34
5719 ; GCN2-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
5720 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
5721 ; GCN2-NEXT: s_lshl_b64 s[4:5], s[4:5], 2
5722 ; GCN2-NEXT: s_add_u32 s0, s0, s4
5723 ; GCN2-NEXT: s_addc_u32 s1, s1, s5
5724 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
5725 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
5726 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5727 ; GCN2-NEXT: flat_load_dword v2, v[0:1] glc
5728 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5729 ; GCN2-NEXT: buffer_wbinvl1_vol
5730 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
5731 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
5732 ; GCN2-NEXT: flat_store_dword v[0:1], v2
5733 ; GCN2-NEXT: s_endpgm
5735 ; GCN3-LABEL: atomic_load_i32_addr64:
5736 ; GCN3: ; %bb.0: ; %entry
5737 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
5738 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
5739 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
5740 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
5741 ; GCN3-NEXT: s_add_u32 s0, s4, s0
5742 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
5743 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
5744 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
5745 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5746 ; GCN3-NEXT: flat_load_dword v2, v[0:1] glc
5747 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5748 ; GCN3-NEXT: buffer_wbinvl1_vol
5749 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
5750 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
5751 ; GCN3-NEXT: flat_store_dword v[0:1], v2
5752 ; GCN3-NEXT: s_endpgm
5754 %ptr = getelementptr i32, ptr %in, i64 %index
5755 %val = load atomic i32, ptr %ptr seq_cst, align 4
5756 store i32 %val, ptr %out
5760 define amdgpu_kernel void @atomic_store_i32_offset(i32 %in, ptr %out) {
5761 ; GCN1-LABEL: atomic_store_i32_offset:
5762 ; GCN1: ; %bb.0: ; %entry
5763 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xb
5764 ; GCN1-NEXT: s_load_dword s4, s[0:1], 0x9
5765 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
5766 ; GCN1-NEXT: s_add_u32 s0, s2, 16
5767 ; GCN1-NEXT: s_addc_u32 s1, s3, 0
5768 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
5769 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
5770 ; GCN1-NEXT: v_mov_b32_e32 v2, s4
5771 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5772 ; GCN1-NEXT: flat_store_dword v[0:1], v2
5773 ; GCN1-NEXT: s_endpgm
5775 ; GCN2-LABEL: atomic_store_i32_offset:
5776 ; GCN2: ; %bb.0: ; %entry
5777 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x2c
5778 ; GCN2-NEXT: s_load_dword s4, s[0:1], 0x24
5779 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
5780 ; GCN2-NEXT: s_add_u32 s0, s2, 16
5781 ; GCN2-NEXT: s_addc_u32 s1, s3, 0
5782 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
5783 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
5784 ; GCN2-NEXT: v_mov_b32_e32 v2, s4
5785 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5786 ; GCN2-NEXT: flat_store_dword v[0:1], v2
5787 ; GCN2-NEXT: s_endpgm
5789 ; GCN3-LABEL: atomic_store_i32_offset:
5790 ; GCN3: ; %bb.0: ; %entry
5791 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x2c
5792 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x24
5793 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
5794 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
5795 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
5796 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
5797 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5798 ; GCN3-NEXT: flat_store_dword v[0:1], v2 offset:16
5799 ; GCN3-NEXT: s_endpgm
5801 %gep = getelementptr i32, ptr %out, i32 4
5802 store atomic i32 %in, ptr %gep seq_cst, align 4
5806 define amdgpu_kernel void @atomic_store_i32(i32 %in, ptr %out) {
5807 ; GCN1-LABEL: atomic_store_i32:
5808 ; GCN1: ; %bb.0: ; %entry
5809 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xb
5810 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0x9
5811 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
5812 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
5813 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
5814 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
5815 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5816 ; GCN1-NEXT: flat_store_dword v[0:1], v2
5817 ; GCN1-NEXT: s_endpgm
5819 ; GCN2-LABEL: atomic_store_i32:
5820 ; GCN2: ; %bb.0: ; %entry
5821 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x2c
5822 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x24
5823 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
5824 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
5825 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
5826 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
5827 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5828 ; GCN2-NEXT: flat_store_dword v[0:1], v2
5829 ; GCN2-NEXT: s_endpgm
5831 ; GCN3-LABEL: atomic_store_i32:
5832 ; GCN3: ; %bb.0: ; %entry
5833 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x2c
5834 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x24
5835 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
5836 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
5837 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
5838 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
5839 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5840 ; GCN3-NEXT: flat_store_dword v[0:1], v2
5841 ; GCN3-NEXT: s_endpgm
5843 store atomic i32 %in, ptr %out seq_cst, align 4
5847 define amdgpu_kernel void @atomic_store_i32_addr64_offset(i32 %in, ptr %out, i64 %index) {
5848 ; GCN1-LABEL: atomic_store_i32_addr64_offset:
5849 ; GCN1: ; %bb.0: ; %entry
5850 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0xb
5851 ; GCN1-NEXT: s_load_dword s2, s[0:1], 0x9
5852 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
5853 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[6:7], 2
5854 ; GCN1-NEXT: s_add_u32 s0, s4, s0
5855 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
5856 ; GCN1-NEXT: s_add_u32 s0, s0, 16
5857 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
5858 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
5859 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
5860 ; GCN1-NEXT: v_mov_b32_e32 v2, s2
5861 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5862 ; GCN1-NEXT: flat_store_dword v[0:1], v2
5863 ; GCN1-NEXT: s_endpgm
5865 ; GCN2-LABEL: atomic_store_i32_addr64_offset:
5866 ; GCN2: ; %bb.0: ; %entry
5867 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x2c
5868 ; GCN2-NEXT: s_load_dword s2, s[0:1], 0x24
5869 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
5870 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[6:7], 2
5871 ; GCN2-NEXT: s_add_u32 s0, s4, s0
5872 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
5873 ; GCN2-NEXT: s_add_u32 s0, s0, 16
5874 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
5875 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
5876 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
5877 ; GCN2-NEXT: v_mov_b32_e32 v2, s2
5878 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5879 ; GCN2-NEXT: flat_store_dword v[0:1], v2
5880 ; GCN2-NEXT: s_endpgm
5882 ; GCN3-LABEL: atomic_store_i32_addr64_offset:
5883 ; GCN3: ; %bb.0: ; %entry
5884 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x2c
5885 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x24
5886 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
5887 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[6:7], 2
5888 ; GCN3-NEXT: s_add_u32 s0, s4, s0
5889 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
5890 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
5891 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
5892 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
5893 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5894 ; GCN3-NEXT: flat_store_dword v[0:1], v2 offset:16
5895 ; GCN3-NEXT: s_endpgm
5897 %ptr = getelementptr i32, ptr %out, i64 %index
5898 %gep = getelementptr i32, ptr %ptr, i32 4
5899 store atomic i32 %in, ptr %gep seq_cst, align 4
5903 define amdgpu_kernel void @atomic_store_i32_addr64(i32 %in, ptr %out, i64 %index) {
5904 ; GCN1-LABEL: atomic_store_i32_addr64:
5905 ; GCN1: ; %bb.0: ; %entry
5906 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0xb
5907 ; GCN1-NEXT: s_load_dword s2, s[0:1], 0x9
5908 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
5909 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[6:7], 2
5910 ; GCN1-NEXT: s_add_u32 s0, s4, s0
5911 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
5912 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
5913 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
5914 ; GCN1-NEXT: v_mov_b32_e32 v2, s2
5915 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5916 ; GCN1-NEXT: flat_store_dword v[0:1], v2
5917 ; GCN1-NEXT: s_endpgm
5919 ; GCN2-LABEL: atomic_store_i32_addr64:
5920 ; GCN2: ; %bb.0: ; %entry
5921 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x2c
5922 ; GCN2-NEXT: s_load_dword s2, s[0:1], 0x24
5923 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
5924 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[6:7], 2
5925 ; GCN2-NEXT: s_add_u32 s0, s4, s0
5926 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
5927 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
5928 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
5929 ; GCN2-NEXT: v_mov_b32_e32 v2, s2
5930 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5931 ; GCN2-NEXT: flat_store_dword v[0:1], v2
5932 ; GCN2-NEXT: s_endpgm
5934 ; GCN3-LABEL: atomic_store_i32_addr64:
5935 ; GCN3: ; %bb.0: ; %entry
5936 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x2c
5937 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x24
5938 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
5939 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[6:7], 2
5940 ; GCN3-NEXT: s_add_u32 s0, s4, s0
5941 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
5942 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
5943 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
5944 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
5945 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5946 ; GCN3-NEXT: flat_store_dword v[0:1], v2
5947 ; GCN3-NEXT: s_endpgm
5949 %ptr = getelementptr i32, ptr %out, i64 %index
5950 store atomic i32 %in, ptr %ptr seq_cst, align 4
5954 define amdgpu_kernel void @atomic_load_f32_offset(ptr %in, ptr %out) {
5955 ; GCN1-LABEL: atomic_load_f32_offset:
5956 ; GCN1: ; %bb.0: ; %entry
5957 ; GCN1-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
5958 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
5959 ; GCN1-NEXT: s_add_u32 s0, s0, 16
5960 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
5961 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
5962 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
5963 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5964 ; GCN1-NEXT: flat_load_dword v2, v[0:1] glc
5965 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5966 ; GCN1-NEXT: buffer_wbinvl1_vol
5967 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
5968 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
5969 ; GCN1-NEXT: flat_store_dword v[0:1], v2
5970 ; GCN1-NEXT: s_endpgm
5972 ; GCN2-LABEL: atomic_load_f32_offset:
5973 ; GCN2: ; %bb.0: ; %entry
5974 ; GCN2-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
5975 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
5976 ; GCN2-NEXT: s_add_u32 s0, s0, 16
5977 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
5978 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
5979 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
5980 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5981 ; GCN2-NEXT: flat_load_dword v2, v[0:1] glc
5982 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5983 ; GCN2-NEXT: buffer_wbinvl1_vol
5984 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
5985 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
5986 ; GCN2-NEXT: flat_store_dword v[0:1], v2
5987 ; GCN2-NEXT: s_endpgm
5989 ; GCN3-LABEL: atomic_load_f32_offset:
5990 ; GCN3: ; %bb.0: ; %entry
5991 ; GCN3-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
5992 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
5993 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
5994 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
5995 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5996 ; GCN3-NEXT: flat_load_dword v2, v[0:1] offset:16 glc
5997 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
5998 ; GCN3-NEXT: buffer_wbinvl1_vol
5999 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
6000 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
6001 ; GCN3-NEXT: flat_store_dword v[0:1], v2
6002 ; GCN3-NEXT: s_endpgm
6004 %gep = getelementptr float, ptr %in, i32 4
6005 %val = load atomic float, ptr %gep seq_cst, align 4
6006 store float %val, ptr %out
6010 define amdgpu_kernel void @atomic_load_f32(ptr %in, ptr %out) {
6011 ; GCN1-LABEL: atomic_load_f32:
6012 ; GCN1: ; %bb.0: ; %entry
6013 ; GCN1-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
6014 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
6015 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
6016 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
6017 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6018 ; GCN1-NEXT: flat_load_dword v2, v[0:1] glc
6019 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6020 ; GCN1-NEXT: buffer_wbinvl1_vol
6021 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
6022 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
6023 ; GCN1-NEXT: flat_store_dword v[0:1], v2
6024 ; GCN1-NEXT: s_endpgm
6026 ; GCN2-LABEL: atomic_load_f32:
6027 ; GCN2: ; %bb.0: ; %entry
6028 ; GCN2-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
6029 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
6030 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
6031 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
6032 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6033 ; GCN2-NEXT: flat_load_dword v2, v[0:1] glc
6034 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6035 ; GCN2-NEXT: buffer_wbinvl1_vol
6036 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
6037 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
6038 ; GCN2-NEXT: flat_store_dword v[0:1], v2
6039 ; GCN2-NEXT: s_endpgm
6041 ; GCN3-LABEL: atomic_load_f32:
6042 ; GCN3: ; %bb.0: ; %entry
6043 ; GCN3-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
6044 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
6045 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
6046 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
6047 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6048 ; GCN3-NEXT: flat_load_dword v2, v[0:1] glc
6049 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6050 ; GCN3-NEXT: buffer_wbinvl1_vol
6051 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
6052 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
6053 ; GCN3-NEXT: flat_store_dword v[0:1], v2
6054 ; GCN3-NEXT: s_endpgm
6056 %val = load atomic float, ptr %in seq_cst, align 4
6057 store float %val, ptr %out
6061 define amdgpu_kernel void @atomic_load_f32_addr64_offset(ptr %in, ptr %out, i64 %index) {
6062 ; GCN1-LABEL: atomic_load_f32_addr64_offset:
6063 ; GCN1: ; %bb.0: ; %entry
6064 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0xd
6065 ; GCN1-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
6066 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
6067 ; GCN1-NEXT: s_lshl_b64 s[4:5], s[4:5], 2
6068 ; GCN1-NEXT: s_add_u32 s0, s0, s4
6069 ; GCN1-NEXT: s_addc_u32 s1, s1, s5
6070 ; GCN1-NEXT: s_add_u32 s0, s0, 16
6071 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
6072 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
6073 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
6074 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6075 ; GCN1-NEXT: flat_load_dword v2, v[0:1] glc
6076 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6077 ; GCN1-NEXT: buffer_wbinvl1_vol
6078 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
6079 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
6080 ; GCN1-NEXT: flat_store_dword v[0:1], v2
6081 ; GCN1-NEXT: s_endpgm
6083 ; GCN2-LABEL: atomic_load_f32_addr64_offset:
6084 ; GCN2: ; %bb.0: ; %entry
6085 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x34
6086 ; GCN2-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
6087 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
6088 ; GCN2-NEXT: s_lshl_b64 s[4:5], s[4:5], 2
6089 ; GCN2-NEXT: s_add_u32 s0, s0, s4
6090 ; GCN2-NEXT: s_addc_u32 s1, s1, s5
6091 ; GCN2-NEXT: s_add_u32 s0, s0, 16
6092 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
6093 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
6094 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
6095 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6096 ; GCN2-NEXT: flat_load_dword v2, v[0:1] glc
6097 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6098 ; GCN2-NEXT: buffer_wbinvl1_vol
6099 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
6100 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
6101 ; GCN2-NEXT: flat_store_dword v[0:1], v2
6102 ; GCN2-NEXT: s_endpgm
6104 ; GCN3-LABEL: atomic_load_f32_addr64_offset:
6105 ; GCN3: ; %bb.0: ; %entry
6106 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
6107 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
6108 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
6109 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
6110 ; GCN3-NEXT: s_add_u32 s0, s4, s0
6111 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
6112 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
6113 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
6114 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6115 ; GCN3-NEXT: flat_load_dword v2, v[0:1] offset:16 glc
6116 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6117 ; GCN3-NEXT: buffer_wbinvl1_vol
6118 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
6119 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
6120 ; GCN3-NEXT: flat_store_dword v[0:1], v2
6121 ; GCN3-NEXT: s_endpgm
6123 %ptr = getelementptr float, ptr %in, i64 %index
6124 %gep = getelementptr float, ptr %ptr, i32 4
6125 %val = load atomic float, ptr %gep seq_cst, align 4
6126 store float %val, ptr %out
6130 define amdgpu_kernel void @atomic_load_f32_addr64(ptr %in, ptr %out, i64 %index) {
6131 ; GCN1-LABEL: atomic_load_f32_addr64:
6132 ; GCN1: ; %bb.0: ; %entry
6133 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0xd
6134 ; GCN1-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
6135 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
6136 ; GCN1-NEXT: s_lshl_b64 s[4:5], s[4:5], 2
6137 ; GCN1-NEXT: s_add_u32 s0, s0, s4
6138 ; GCN1-NEXT: s_addc_u32 s1, s1, s5
6139 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
6140 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
6141 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6142 ; GCN1-NEXT: flat_load_dword v2, v[0:1] glc
6143 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6144 ; GCN1-NEXT: buffer_wbinvl1_vol
6145 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
6146 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
6147 ; GCN1-NEXT: flat_store_dword v[0:1], v2
6148 ; GCN1-NEXT: s_endpgm
6150 ; GCN2-LABEL: atomic_load_f32_addr64:
6151 ; GCN2: ; %bb.0: ; %entry
6152 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x34
6153 ; GCN2-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
6154 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
6155 ; GCN2-NEXT: s_lshl_b64 s[4:5], s[4:5], 2
6156 ; GCN2-NEXT: s_add_u32 s0, s0, s4
6157 ; GCN2-NEXT: s_addc_u32 s1, s1, s5
6158 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
6159 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
6160 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6161 ; GCN2-NEXT: flat_load_dword v2, v[0:1] glc
6162 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6163 ; GCN2-NEXT: buffer_wbinvl1_vol
6164 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
6165 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
6166 ; GCN2-NEXT: flat_store_dword v[0:1], v2
6167 ; GCN2-NEXT: s_endpgm
6169 ; GCN3-LABEL: atomic_load_f32_addr64:
6170 ; GCN3: ; %bb.0: ; %entry
6171 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
6172 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
6173 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
6174 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
6175 ; GCN3-NEXT: s_add_u32 s0, s4, s0
6176 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
6177 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
6178 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
6179 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6180 ; GCN3-NEXT: flat_load_dword v2, v[0:1] glc
6181 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6182 ; GCN3-NEXT: buffer_wbinvl1_vol
6183 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
6184 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
6185 ; GCN3-NEXT: flat_store_dword v[0:1], v2
6186 ; GCN3-NEXT: s_endpgm
6188 %ptr = getelementptr float, ptr %in, i64 %index
6189 %val = load atomic float, ptr %ptr seq_cst, align 4
6190 store float %val, ptr %out
6194 define amdgpu_kernel void @atomic_store_f32_offset(float %in, ptr %out) {
6195 ; GCN1-LABEL: atomic_store_f32_offset:
6196 ; GCN1: ; %bb.0: ; %entry
6197 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xb
6198 ; GCN1-NEXT: s_load_dword s4, s[0:1], 0x9
6199 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
6200 ; GCN1-NEXT: s_add_u32 s0, s2, 16
6201 ; GCN1-NEXT: s_addc_u32 s1, s3, 0
6202 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
6203 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
6204 ; GCN1-NEXT: v_mov_b32_e32 v2, s4
6205 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6206 ; GCN1-NEXT: flat_store_dword v[0:1], v2
6207 ; GCN1-NEXT: s_endpgm
6209 ; GCN2-LABEL: atomic_store_f32_offset:
6210 ; GCN2: ; %bb.0: ; %entry
6211 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x2c
6212 ; GCN2-NEXT: s_load_dword s4, s[0:1], 0x24
6213 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
6214 ; GCN2-NEXT: s_add_u32 s0, s2, 16
6215 ; GCN2-NEXT: s_addc_u32 s1, s3, 0
6216 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
6217 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
6218 ; GCN2-NEXT: v_mov_b32_e32 v2, s4
6219 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6220 ; GCN2-NEXT: flat_store_dword v[0:1], v2
6221 ; GCN2-NEXT: s_endpgm
6223 ; GCN3-LABEL: atomic_store_f32_offset:
6224 ; GCN3: ; %bb.0: ; %entry
6225 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x2c
6226 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x24
6227 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
6228 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
6229 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
6230 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
6231 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6232 ; GCN3-NEXT: flat_store_dword v[0:1], v2 offset:16
6233 ; GCN3-NEXT: s_endpgm
6235 %gep = getelementptr float, ptr %out, i32 4
6236 store atomic float %in, ptr %gep seq_cst, align 4
6240 define amdgpu_kernel void @atomic_store_f32(float %in, ptr %out) {
6241 ; GCN1-LABEL: atomic_store_f32:
6242 ; GCN1: ; %bb.0: ; %entry
6243 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xb
6244 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0x9
6245 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
6246 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
6247 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
6248 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
6249 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6250 ; GCN1-NEXT: flat_store_dword v[0:1], v2
6251 ; GCN1-NEXT: s_endpgm
6253 ; GCN2-LABEL: atomic_store_f32:
6254 ; GCN2: ; %bb.0: ; %entry
6255 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x2c
6256 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x24
6257 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
6258 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
6259 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
6260 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
6261 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6262 ; GCN2-NEXT: flat_store_dword v[0:1], v2
6263 ; GCN2-NEXT: s_endpgm
6265 ; GCN3-LABEL: atomic_store_f32:
6266 ; GCN3: ; %bb.0: ; %entry
6267 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x2c
6268 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x24
6269 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
6270 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
6271 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
6272 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
6273 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6274 ; GCN3-NEXT: flat_store_dword v[0:1], v2
6275 ; GCN3-NEXT: s_endpgm
6277 store atomic float %in, ptr %out seq_cst, align 4
6281 define amdgpu_kernel void @atomic_store_f32_addr64_offset(float %in, ptr %out, i64 %index) {
6282 ; GCN1-LABEL: atomic_store_f32_addr64_offset:
6283 ; GCN1: ; %bb.0: ; %entry
6284 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0xb
6285 ; GCN1-NEXT: s_load_dword s2, s[0:1], 0x9
6286 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
6287 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[6:7], 2
6288 ; GCN1-NEXT: s_add_u32 s0, s4, s0
6289 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
6290 ; GCN1-NEXT: s_add_u32 s0, s0, 16
6291 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
6292 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
6293 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
6294 ; GCN1-NEXT: v_mov_b32_e32 v2, s2
6295 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6296 ; GCN1-NEXT: flat_store_dword v[0:1], v2
6297 ; GCN1-NEXT: s_endpgm
6299 ; GCN2-LABEL: atomic_store_f32_addr64_offset:
6300 ; GCN2: ; %bb.0: ; %entry
6301 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x2c
6302 ; GCN2-NEXT: s_load_dword s2, s[0:1], 0x24
6303 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
6304 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[6:7], 2
6305 ; GCN2-NEXT: s_add_u32 s0, s4, s0
6306 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
6307 ; GCN2-NEXT: s_add_u32 s0, s0, 16
6308 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
6309 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
6310 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
6311 ; GCN2-NEXT: v_mov_b32_e32 v2, s2
6312 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6313 ; GCN2-NEXT: flat_store_dword v[0:1], v2
6314 ; GCN2-NEXT: s_endpgm
6316 ; GCN3-LABEL: atomic_store_f32_addr64_offset:
6317 ; GCN3: ; %bb.0: ; %entry
6318 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x2c
6319 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x24
6320 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
6321 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[6:7], 2
6322 ; GCN3-NEXT: s_add_u32 s0, s4, s0
6323 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
6324 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
6325 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
6326 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
6327 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6328 ; GCN3-NEXT: flat_store_dword v[0:1], v2 offset:16
6329 ; GCN3-NEXT: s_endpgm
6331 %ptr = getelementptr float, ptr %out, i64 %index
6332 %gep = getelementptr float, ptr %ptr, i32 4
6333 store atomic float %in, ptr %gep seq_cst, align 4
6337 define amdgpu_kernel void @atomic_store_f32_addr64(float %in, ptr %out, i64 %index) {
6338 ; GCN1-LABEL: atomic_store_f32_addr64:
6339 ; GCN1: ; %bb.0: ; %entry
6340 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0xb
6341 ; GCN1-NEXT: s_load_dword s2, s[0:1], 0x9
6342 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
6343 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[6:7], 2
6344 ; GCN1-NEXT: s_add_u32 s0, s4, s0
6345 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
6346 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
6347 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
6348 ; GCN1-NEXT: v_mov_b32_e32 v2, s2
6349 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6350 ; GCN1-NEXT: flat_store_dword v[0:1], v2
6351 ; GCN1-NEXT: s_endpgm
6353 ; GCN2-LABEL: atomic_store_f32_addr64:
6354 ; GCN2: ; %bb.0: ; %entry
6355 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x2c
6356 ; GCN2-NEXT: s_load_dword s2, s[0:1], 0x24
6357 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
6358 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[6:7], 2
6359 ; GCN2-NEXT: s_add_u32 s0, s4, s0
6360 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
6361 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
6362 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
6363 ; GCN2-NEXT: v_mov_b32_e32 v2, s2
6364 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6365 ; GCN2-NEXT: flat_store_dword v[0:1], v2
6366 ; GCN2-NEXT: s_endpgm
6368 ; GCN3-LABEL: atomic_store_f32_addr64:
6369 ; GCN3: ; %bb.0: ; %entry
6370 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x2c
6371 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x24
6372 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
6373 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[6:7], 2
6374 ; GCN3-NEXT: s_add_u32 s0, s4, s0
6375 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
6376 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
6377 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
6378 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
6379 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6380 ; GCN3-NEXT: flat_store_dword v[0:1], v2
6381 ; GCN3-NEXT: s_endpgm
6383 %ptr = getelementptr float, ptr %out, i64 %index
6384 store atomic float %in, ptr %ptr seq_cst, align 4
6388 define amdgpu_kernel void @atomic_load_i8_offset(ptr %in, ptr %out) {
6389 ; GCN1-LABEL: atomic_load_i8_offset:
6390 ; GCN1: ; %bb.0: ; %entry
6391 ; GCN1-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
6392 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
6393 ; GCN1-NEXT: s_add_u32 s0, s0, 16
6394 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
6395 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
6396 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
6397 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6398 ; GCN1-NEXT: flat_load_ubyte v2, v[0:1] glc
6399 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6400 ; GCN1-NEXT: buffer_wbinvl1_vol
6401 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
6402 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
6403 ; GCN1-NEXT: flat_store_byte v[0:1], v2
6404 ; GCN1-NEXT: s_endpgm
6406 ; GCN2-LABEL: atomic_load_i8_offset:
6407 ; GCN2: ; %bb.0: ; %entry
6408 ; GCN2-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
6409 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
6410 ; GCN2-NEXT: s_add_u32 s0, s0, 16
6411 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
6412 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
6413 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
6414 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6415 ; GCN2-NEXT: flat_load_ubyte v2, v[0:1] glc
6416 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6417 ; GCN2-NEXT: buffer_wbinvl1_vol
6418 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
6419 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
6420 ; GCN2-NEXT: flat_store_byte v[0:1], v2
6421 ; GCN2-NEXT: s_endpgm
6423 ; GCN3-LABEL: atomic_load_i8_offset:
6424 ; GCN3: ; %bb.0: ; %entry
6425 ; GCN3-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
6426 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
6427 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
6428 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
6429 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6430 ; GCN3-NEXT: flat_load_ubyte v2, v[0:1] offset:16 glc
6431 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6432 ; GCN3-NEXT: buffer_wbinvl1_vol
6433 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
6434 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
6435 ; GCN3-NEXT: flat_store_byte v[0:1], v2
6436 ; GCN3-NEXT: s_endpgm
6438 %gep = getelementptr i8, ptr %in, i64 16
6439 %val = load atomic i8, ptr %gep seq_cst, align 1
6440 store i8 %val, ptr %out
6444 define amdgpu_kernel void @atomic_load_i8(ptr %in, ptr %out) {
6445 ; GCN1-LABEL: atomic_load_i8:
6446 ; GCN1: ; %bb.0: ; %entry
6447 ; GCN1-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
6448 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
6449 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
6450 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
6451 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6452 ; GCN1-NEXT: flat_load_ubyte v2, v[0:1] glc
6453 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6454 ; GCN1-NEXT: buffer_wbinvl1_vol
6455 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
6456 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
6457 ; GCN1-NEXT: flat_store_byte v[0:1], v2
6458 ; GCN1-NEXT: s_endpgm
6460 ; GCN2-LABEL: atomic_load_i8:
6461 ; GCN2: ; %bb.0: ; %entry
6462 ; GCN2-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
6463 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
6464 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
6465 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
6466 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6467 ; GCN2-NEXT: flat_load_ubyte v2, v[0:1] glc
6468 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6469 ; GCN2-NEXT: buffer_wbinvl1_vol
6470 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
6471 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
6472 ; GCN2-NEXT: flat_store_byte v[0:1], v2
6473 ; GCN2-NEXT: s_endpgm
6475 ; GCN3-LABEL: atomic_load_i8:
6476 ; GCN3: ; %bb.0: ; %entry
6477 ; GCN3-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
6478 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
6479 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
6480 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
6481 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6482 ; GCN3-NEXT: flat_load_ubyte v2, v[0:1] glc
6483 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6484 ; GCN3-NEXT: buffer_wbinvl1_vol
6485 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
6486 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
6487 ; GCN3-NEXT: flat_store_byte v[0:1], v2
6488 ; GCN3-NEXT: s_endpgm
6490 %val = load atomic i8, ptr %in seq_cst, align 1
6491 store i8 %val, ptr %out
6495 define amdgpu_kernel void @atomic_load_i8_addr64_offset(ptr %in, ptr %out, i64 %index) {
6496 ; GCN1-LABEL: atomic_load_i8_addr64_offset:
6497 ; GCN1: ; %bb.0: ; %entry
6498 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
6499 ; GCN1-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xd
6500 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
6501 ; GCN1-NEXT: s_add_u32 s0, s4, s0
6502 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
6503 ; GCN1-NEXT: s_add_u32 s0, s0, 16
6504 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
6505 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
6506 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
6507 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6508 ; GCN1-NEXT: flat_load_ubyte v2, v[0:1] glc
6509 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6510 ; GCN1-NEXT: buffer_wbinvl1_vol
6511 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
6512 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
6513 ; GCN1-NEXT: flat_store_byte v[0:1], v2
6514 ; GCN1-NEXT: s_endpgm
6516 ; GCN2-LABEL: atomic_load_i8_addr64_offset:
6517 ; GCN2: ; %bb.0: ; %entry
6518 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
6519 ; GCN2-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x34
6520 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
6521 ; GCN2-NEXT: s_add_u32 s0, s4, s0
6522 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
6523 ; GCN2-NEXT: s_add_u32 s0, s0, 16
6524 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
6525 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
6526 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
6527 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6528 ; GCN2-NEXT: flat_load_ubyte v2, v[0:1] glc
6529 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6530 ; GCN2-NEXT: buffer_wbinvl1_vol
6531 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
6532 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
6533 ; GCN2-NEXT: flat_store_byte v[0:1], v2
6534 ; GCN2-NEXT: s_endpgm
6536 ; GCN3-LABEL: atomic_load_i8_addr64_offset:
6537 ; GCN3: ; %bb.0: ; %entry
6538 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
6539 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
6540 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
6541 ; GCN3-NEXT: s_add_u32 s0, s4, s2
6542 ; GCN3-NEXT: s_addc_u32 s1, s5, s3
6543 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
6544 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
6545 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6546 ; GCN3-NEXT: flat_load_ubyte v2, v[0:1] offset:16 glc
6547 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6548 ; GCN3-NEXT: buffer_wbinvl1_vol
6549 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
6550 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
6551 ; GCN3-NEXT: flat_store_byte v[0:1], v2
6552 ; GCN3-NEXT: s_endpgm
6554 %ptr = getelementptr i8, ptr %in, i64 %index
6555 %gep = getelementptr i8, ptr %ptr, i64 16
6556 %val = load atomic i8, ptr %gep seq_cst, align 1
6557 store i8 %val, ptr %out
6561 define amdgpu_kernel void @atomic_store_i8_offset(i8 %in, ptr %out) {
6562 ; GCN1-LABEL: atomic_store_i8_offset:
6563 ; GCN1: ; %bb.0: ; %entry
6564 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xb
6565 ; GCN1-NEXT: s_load_dword s4, s[0:1], 0x9
6566 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
6567 ; GCN1-NEXT: s_add_u32 s0, s2, 16
6568 ; GCN1-NEXT: s_addc_u32 s1, s3, 0
6569 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
6570 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
6571 ; GCN1-NEXT: v_mov_b32_e32 v2, s4
6572 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6573 ; GCN1-NEXT: flat_store_byte v[0:1], v2
6574 ; GCN1-NEXT: s_endpgm
6576 ; GCN2-LABEL: atomic_store_i8_offset:
6577 ; GCN2: ; %bb.0: ; %entry
6578 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x2c
6579 ; GCN2-NEXT: s_load_dword s4, s[0:1], 0x24
6580 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
6581 ; GCN2-NEXT: s_add_u32 s0, s2, 16
6582 ; GCN2-NEXT: s_addc_u32 s1, s3, 0
6583 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
6584 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
6585 ; GCN2-NEXT: v_mov_b32_e32 v2, s4
6586 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6587 ; GCN2-NEXT: flat_store_byte v[0:1], v2
6588 ; GCN2-NEXT: s_endpgm
6590 ; GCN3-LABEL: atomic_store_i8_offset:
6591 ; GCN3: ; %bb.0: ; %entry
6592 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x2c
6593 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x24
6594 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
6595 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
6596 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
6597 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
6598 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6599 ; GCN3-NEXT: flat_store_byte v[0:1], v2 offset:16
6600 ; GCN3-NEXT: s_endpgm
6602 %gep = getelementptr i8, ptr %out, i64 16
6603 store atomic i8 %in, ptr %gep seq_cst, align 1
6607 define amdgpu_kernel void @atomic_store_i8(i8 %in, ptr %out) {
6608 ; GCN1-LABEL: atomic_store_i8:
6609 ; GCN1: ; %bb.0: ; %entry
6610 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xb
6611 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0x9
6612 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
6613 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
6614 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
6615 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
6616 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6617 ; GCN1-NEXT: flat_store_byte v[0:1], v2
6618 ; GCN1-NEXT: s_endpgm
6620 ; GCN2-LABEL: atomic_store_i8:
6621 ; GCN2: ; %bb.0: ; %entry
6622 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x2c
6623 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x24
6624 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
6625 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
6626 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
6627 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
6628 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6629 ; GCN2-NEXT: flat_store_byte v[0:1], v2
6630 ; GCN2-NEXT: s_endpgm
6632 ; GCN3-LABEL: atomic_store_i8:
6633 ; GCN3: ; %bb.0: ; %entry
6634 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x2c
6635 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x24
6636 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
6637 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
6638 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
6639 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
6640 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6641 ; GCN3-NEXT: flat_store_byte v[0:1], v2
6642 ; GCN3-NEXT: s_endpgm
6644 store atomic i8 %in, ptr %out seq_cst, align 1
6648 define amdgpu_kernel void @atomic_store_i8_addr64_offset(i8 %in, ptr %out, i64 %index) {
6649 ; GCN1-LABEL: atomic_store_i8_addr64_offset:
6650 ; GCN1: ; %bb.0: ; %entry
6651 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0xb
6652 ; GCN1-NEXT: s_load_dword s2, s[0:1], 0x9
6653 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
6654 ; GCN1-NEXT: s_add_u32 s0, s4, s6
6655 ; GCN1-NEXT: s_addc_u32 s1, s5, s7
6656 ; GCN1-NEXT: s_add_u32 s0, s0, 16
6657 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
6658 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
6659 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
6660 ; GCN1-NEXT: v_mov_b32_e32 v2, s2
6661 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6662 ; GCN1-NEXT: flat_store_byte v[0:1], v2
6663 ; GCN1-NEXT: s_endpgm
6665 ; GCN2-LABEL: atomic_store_i8_addr64_offset:
6666 ; GCN2: ; %bb.0: ; %entry
6667 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x2c
6668 ; GCN2-NEXT: s_load_dword s2, s[0:1], 0x24
6669 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
6670 ; GCN2-NEXT: s_add_u32 s0, s4, s6
6671 ; GCN2-NEXT: s_addc_u32 s1, s5, s7
6672 ; GCN2-NEXT: s_add_u32 s0, s0, 16
6673 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
6674 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
6675 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
6676 ; GCN2-NEXT: v_mov_b32_e32 v2, s2
6677 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6678 ; GCN2-NEXT: flat_store_byte v[0:1], v2
6679 ; GCN2-NEXT: s_endpgm
6681 ; GCN3-LABEL: atomic_store_i8_addr64_offset:
6682 ; GCN3: ; %bb.0: ; %entry
6683 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x2c
6684 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x24
6685 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
6686 ; GCN3-NEXT: s_add_u32 s0, s4, s6
6687 ; GCN3-NEXT: s_addc_u32 s1, s5, s7
6688 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
6689 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
6690 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
6691 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6692 ; GCN3-NEXT: flat_store_byte v[0:1], v2 offset:16
6693 ; GCN3-NEXT: s_endpgm
6695 %ptr = getelementptr i8, ptr %out, i64 %index
6696 %gep = getelementptr i8, ptr %ptr, i64 16
6697 store atomic i8 %in, ptr %gep seq_cst, align 1
6701 define amdgpu_kernel void @atomic_load_i16_offset(ptr %in, ptr %out) {
6702 ; GCN1-LABEL: atomic_load_i16_offset:
6703 ; GCN1: ; %bb.0: ; %entry
6704 ; GCN1-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
6705 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
6706 ; GCN1-NEXT: s_add_u32 s0, s0, 16
6707 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
6708 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
6709 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
6710 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6711 ; GCN1-NEXT: flat_load_ushort v2, v[0:1] glc
6712 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6713 ; GCN1-NEXT: buffer_wbinvl1_vol
6714 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
6715 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
6716 ; GCN1-NEXT: flat_store_short v[0:1], v2
6717 ; GCN1-NEXT: s_endpgm
6719 ; GCN2-LABEL: atomic_load_i16_offset:
6720 ; GCN2: ; %bb.0: ; %entry
6721 ; GCN2-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
6722 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
6723 ; GCN2-NEXT: s_add_u32 s0, s0, 16
6724 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
6725 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
6726 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
6727 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6728 ; GCN2-NEXT: flat_load_ushort v2, v[0:1] glc
6729 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6730 ; GCN2-NEXT: buffer_wbinvl1_vol
6731 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
6732 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
6733 ; GCN2-NEXT: flat_store_short v[0:1], v2
6734 ; GCN2-NEXT: s_endpgm
6736 ; GCN3-LABEL: atomic_load_i16_offset:
6737 ; GCN3: ; %bb.0: ; %entry
6738 ; GCN3-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
6739 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
6740 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
6741 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
6742 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6743 ; GCN3-NEXT: flat_load_ushort v2, v[0:1] offset:16 glc
6744 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6745 ; GCN3-NEXT: buffer_wbinvl1_vol
6746 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
6747 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
6748 ; GCN3-NEXT: flat_store_short v[0:1], v2
6749 ; GCN3-NEXT: s_endpgm
6751 %gep = getelementptr i16, ptr %in, i64 8
6752 %val = load atomic i16, ptr %gep seq_cst, align 2
6753 store i16 %val, ptr %out
6757 define amdgpu_kernel void @atomic_load_i16(ptr %in, ptr %out) {
6758 ; GCN1-LABEL: atomic_load_i16:
6759 ; GCN1: ; %bb.0: ; %entry
6760 ; GCN1-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
6761 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
6762 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
6763 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
6764 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6765 ; GCN1-NEXT: flat_load_ushort v2, v[0:1] glc
6766 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6767 ; GCN1-NEXT: buffer_wbinvl1_vol
6768 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
6769 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
6770 ; GCN1-NEXT: flat_store_short v[0:1], v2
6771 ; GCN1-NEXT: s_endpgm
6773 ; GCN2-LABEL: atomic_load_i16:
6774 ; GCN2: ; %bb.0: ; %entry
6775 ; GCN2-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
6776 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
6777 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
6778 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
6779 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6780 ; GCN2-NEXT: flat_load_ushort v2, v[0:1] glc
6781 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6782 ; GCN2-NEXT: buffer_wbinvl1_vol
6783 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
6784 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
6785 ; GCN2-NEXT: flat_store_short v[0:1], v2
6786 ; GCN2-NEXT: s_endpgm
6788 ; GCN3-LABEL: atomic_load_i16:
6789 ; GCN3: ; %bb.0: ; %entry
6790 ; GCN3-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
6791 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
6792 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
6793 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
6794 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6795 ; GCN3-NEXT: flat_load_ushort v2, v[0:1] glc
6796 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6797 ; GCN3-NEXT: buffer_wbinvl1_vol
6798 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
6799 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
6800 ; GCN3-NEXT: flat_store_short v[0:1], v2
6801 ; GCN3-NEXT: s_endpgm
6803 %val = load atomic i16, ptr %in seq_cst, align 2
6804 store i16 %val, ptr %out
6808 define amdgpu_kernel void @atomic_load_i16_addr64_offset(ptr %in, ptr %out, i64 %index) {
6809 ; GCN1-LABEL: atomic_load_i16_addr64_offset:
6810 ; GCN1: ; %bb.0: ; %entry
6811 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0xd
6812 ; GCN1-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
6813 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
6814 ; GCN1-NEXT: s_lshl_b64 s[4:5], s[4:5], 1
6815 ; GCN1-NEXT: s_add_u32 s0, s0, s4
6816 ; GCN1-NEXT: s_addc_u32 s1, s1, s5
6817 ; GCN1-NEXT: s_add_u32 s0, s0, 16
6818 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
6819 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
6820 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
6821 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6822 ; GCN1-NEXT: flat_load_ushort v2, v[0:1] glc
6823 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6824 ; GCN1-NEXT: buffer_wbinvl1_vol
6825 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
6826 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
6827 ; GCN1-NEXT: flat_store_short v[0:1], v2
6828 ; GCN1-NEXT: s_endpgm
6830 ; GCN2-LABEL: atomic_load_i16_addr64_offset:
6831 ; GCN2: ; %bb.0: ; %entry
6832 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x34
6833 ; GCN2-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
6834 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
6835 ; GCN2-NEXT: s_lshl_b64 s[4:5], s[4:5], 1
6836 ; GCN2-NEXT: s_add_u32 s0, s0, s4
6837 ; GCN2-NEXT: s_addc_u32 s1, s1, s5
6838 ; GCN2-NEXT: s_add_u32 s0, s0, 16
6839 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
6840 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
6841 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
6842 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6843 ; GCN2-NEXT: flat_load_ushort v2, v[0:1] glc
6844 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6845 ; GCN2-NEXT: buffer_wbinvl1_vol
6846 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
6847 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
6848 ; GCN2-NEXT: flat_store_short v[0:1], v2
6849 ; GCN2-NEXT: s_endpgm
6851 ; GCN3-LABEL: atomic_load_i16_addr64_offset:
6852 ; GCN3: ; %bb.0: ; %entry
6853 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
6854 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
6855 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
6856 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 1
6857 ; GCN3-NEXT: s_add_u32 s0, s4, s0
6858 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
6859 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
6860 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
6861 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6862 ; GCN3-NEXT: flat_load_ushort v2, v[0:1] offset:16 glc
6863 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6864 ; GCN3-NEXT: buffer_wbinvl1_vol
6865 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
6866 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
6867 ; GCN3-NEXT: flat_store_short v[0:1], v2
6868 ; GCN3-NEXT: s_endpgm
6870 %ptr = getelementptr i16, ptr %in, i64 %index
6871 %gep = getelementptr i16, ptr %ptr, i64 8
6872 %val = load atomic i16, ptr %gep seq_cst, align 2
6873 store i16 %val, ptr %out
6877 define amdgpu_kernel void @atomic_store_i16_offset(i16 %in, ptr %out) {
6878 ; GCN1-LABEL: atomic_store_i16_offset:
6879 ; GCN1: ; %bb.0: ; %entry
6880 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xb
6881 ; GCN1-NEXT: s_load_dword s4, s[0:1], 0x9
6882 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
6883 ; GCN1-NEXT: s_add_u32 s0, s2, 16
6884 ; GCN1-NEXT: s_addc_u32 s1, s3, 0
6885 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
6886 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
6887 ; GCN1-NEXT: v_mov_b32_e32 v2, s4
6888 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6889 ; GCN1-NEXT: flat_store_short v[0:1], v2
6890 ; GCN1-NEXT: s_endpgm
6892 ; GCN2-LABEL: atomic_store_i16_offset:
6893 ; GCN2: ; %bb.0: ; %entry
6894 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x2c
6895 ; GCN2-NEXT: s_load_dword s4, s[0:1], 0x24
6896 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
6897 ; GCN2-NEXT: s_add_u32 s0, s2, 16
6898 ; GCN2-NEXT: s_addc_u32 s1, s3, 0
6899 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
6900 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
6901 ; GCN2-NEXT: v_mov_b32_e32 v2, s4
6902 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6903 ; GCN2-NEXT: flat_store_short v[0:1], v2
6904 ; GCN2-NEXT: s_endpgm
6906 ; GCN3-LABEL: atomic_store_i16_offset:
6907 ; GCN3: ; %bb.0: ; %entry
6908 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x2c
6909 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x24
6910 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
6911 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
6912 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
6913 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
6914 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6915 ; GCN3-NEXT: flat_store_short v[0:1], v2 offset:16
6916 ; GCN3-NEXT: s_endpgm
6918 %gep = getelementptr i16, ptr %out, i64 8
6919 store atomic i16 %in, ptr %gep seq_cst, align 2
6923 define amdgpu_kernel void @atomic_store_i16(i16 %in, ptr %out) {
6924 ; GCN1-LABEL: atomic_store_i16:
6925 ; GCN1: ; %bb.0: ; %entry
6926 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xb
6927 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0x9
6928 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
6929 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
6930 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
6931 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
6932 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6933 ; GCN1-NEXT: flat_store_short v[0:1], v2
6934 ; GCN1-NEXT: s_endpgm
6936 ; GCN2-LABEL: atomic_store_i16:
6937 ; GCN2: ; %bb.0: ; %entry
6938 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x2c
6939 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x24
6940 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
6941 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
6942 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
6943 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
6944 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6945 ; GCN2-NEXT: flat_store_short v[0:1], v2
6946 ; GCN2-NEXT: s_endpgm
6948 ; GCN3-LABEL: atomic_store_i16:
6949 ; GCN3: ; %bb.0: ; %entry
6950 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x2c
6951 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x24
6952 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
6953 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
6954 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
6955 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
6956 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6957 ; GCN3-NEXT: flat_store_short v[0:1], v2
6958 ; GCN3-NEXT: s_endpgm
6960 store atomic i16 %in, ptr %out seq_cst, align 2
6964 define amdgpu_kernel void @atomic_store_i16_addr64_offset(i16 %in, ptr %out, i64 %index) {
6965 ; GCN1-LABEL: atomic_store_i16_addr64_offset:
6966 ; GCN1: ; %bb.0: ; %entry
6967 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0xb
6968 ; GCN1-NEXT: s_load_dword s2, s[0:1], 0x9
6969 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
6970 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[6:7], 1
6971 ; GCN1-NEXT: s_add_u32 s0, s4, s0
6972 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
6973 ; GCN1-NEXT: s_add_u32 s0, s0, 16
6974 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
6975 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
6976 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
6977 ; GCN1-NEXT: v_mov_b32_e32 v2, s2
6978 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6979 ; GCN1-NEXT: flat_store_short v[0:1], v2
6980 ; GCN1-NEXT: s_endpgm
6982 ; GCN2-LABEL: atomic_store_i16_addr64_offset:
6983 ; GCN2: ; %bb.0: ; %entry
6984 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x2c
6985 ; GCN2-NEXT: s_load_dword s2, s[0:1], 0x24
6986 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
6987 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[6:7], 1
6988 ; GCN2-NEXT: s_add_u32 s0, s4, s0
6989 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
6990 ; GCN2-NEXT: s_add_u32 s0, s0, 16
6991 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
6992 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
6993 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
6994 ; GCN2-NEXT: v_mov_b32_e32 v2, s2
6995 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
6996 ; GCN2-NEXT: flat_store_short v[0:1], v2
6997 ; GCN2-NEXT: s_endpgm
6999 ; GCN3-LABEL: atomic_store_i16_addr64_offset:
7000 ; GCN3: ; %bb.0: ; %entry
7001 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x2c
7002 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x24
7003 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
7004 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[6:7], 1
7005 ; GCN3-NEXT: s_add_u32 s0, s4, s0
7006 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
7007 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
7008 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
7009 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
7010 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7011 ; GCN3-NEXT: flat_store_short v[0:1], v2 offset:16
7012 ; GCN3-NEXT: s_endpgm
7014 %ptr = getelementptr i16, ptr %out, i64 %index
7015 %gep = getelementptr i16, ptr %ptr, i64 8
7016 store atomic i16 %in, ptr %gep seq_cst, align 2
7020 define amdgpu_kernel void @atomic_store_f16_offset(half %in, ptr %out) {
7021 ; GCN1-LABEL: atomic_store_f16_offset:
7022 ; GCN1: ; %bb.0: ; %entry
7023 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xb
7024 ; GCN1-NEXT: s_load_dword s4, s[0:1], 0x9
7025 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
7026 ; GCN1-NEXT: s_add_u32 s0, s2, 16
7027 ; GCN1-NEXT: s_addc_u32 s1, s3, 0
7028 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
7029 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
7030 ; GCN1-NEXT: v_mov_b32_e32 v2, s4
7031 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7032 ; GCN1-NEXT: flat_store_short v[0:1], v2
7033 ; GCN1-NEXT: s_endpgm
7035 ; GCN2-LABEL: atomic_store_f16_offset:
7036 ; GCN2: ; %bb.0: ; %entry
7037 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x2c
7038 ; GCN2-NEXT: s_load_dword s4, s[0:1], 0x24
7039 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
7040 ; GCN2-NEXT: s_add_u32 s0, s2, 16
7041 ; GCN2-NEXT: s_addc_u32 s1, s3, 0
7042 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
7043 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
7044 ; GCN2-NEXT: v_mov_b32_e32 v2, s4
7045 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7046 ; GCN2-NEXT: flat_store_short v[0:1], v2
7047 ; GCN2-NEXT: s_endpgm
7049 ; GCN3-LABEL: atomic_store_f16_offset:
7050 ; GCN3: ; %bb.0: ; %entry
7051 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x2c
7052 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x24
7053 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
7054 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
7055 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
7056 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
7057 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7058 ; GCN3-NEXT: flat_store_short v[0:1], v2 offset:16
7059 ; GCN3-NEXT: s_endpgm
7061 %gep = getelementptr half, ptr %out, i64 8
7062 store atomic half %in, ptr %gep seq_cst, align 2
7066 define amdgpu_kernel void @atomic_store_f16(half %in, ptr %out) {
7067 ; GCN1-LABEL: atomic_store_f16:
7068 ; GCN1: ; %bb.0: ; %entry
7069 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xb
7070 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0x9
7071 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
7072 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
7073 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
7074 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
7075 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7076 ; GCN1-NEXT: flat_store_short v[0:1], v2
7077 ; GCN1-NEXT: s_endpgm
7079 ; GCN2-LABEL: atomic_store_f16:
7080 ; GCN2: ; %bb.0: ; %entry
7081 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x2c
7082 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x24
7083 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
7084 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
7085 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
7086 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
7087 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7088 ; GCN2-NEXT: flat_store_short v[0:1], v2
7089 ; GCN2-NEXT: s_endpgm
7091 ; GCN3-LABEL: atomic_store_f16:
7092 ; GCN3: ; %bb.0: ; %entry
7093 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x2c
7094 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x24
7095 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
7096 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
7097 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
7098 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
7099 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7100 ; GCN3-NEXT: flat_store_short v[0:1], v2
7101 ; GCN3-NEXT: s_endpgm
7103 store atomic half %in, ptr %out seq_cst, align 2
7107 define amdgpu_kernel void @atomic_inc_i32_offset(ptr %out, i32 %in) {
7108 ; GCN1-LABEL: atomic_inc_i32_offset:
7109 ; GCN1: ; %bb.0: ; %entry
7110 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
7111 ; GCN1-NEXT: s_load_dword s4, s[0:1], 0xb
7112 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
7113 ; GCN1-NEXT: s_add_u32 s0, s2, 16
7114 ; GCN1-NEXT: s_addc_u32 s1, s3, 0
7115 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
7116 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
7117 ; GCN1-NEXT: v_mov_b32_e32 v2, s4
7118 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7119 ; GCN1-NEXT: flat_atomic_inc v[0:1], v2
7120 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7121 ; GCN1-NEXT: buffer_wbinvl1_vol
7122 ; GCN1-NEXT: s_endpgm
7124 ; GCN2-LABEL: atomic_inc_i32_offset:
7125 ; GCN2: ; %bb.0: ; %entry
7126 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
7127 ; GCN2-NEXT: s_load_dword s4, s[0:1], 0x2c
7128 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
7129 ; GCN2-NEXT: s_add_u32 s0, s2, 16
7130 ; GCN2-NEXT: s_addc_u32 s1, s3, 0
7131 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
7132 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
7133 ; GCN2-NEXT: v_mov_b32_e32 v2, s4
7134 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7135 ; GCN2-NEXT: flat_atomic_inc v[0:1], v2
7136 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7137 ; GCN2-NEXT: buffer_wbinvl1_vol
7138 ; GCN2-NEXT: s_endpgm
7140 ; GCN3-LABEL: atomic_inc_i32_offset:
7141 ; GCN3: ; %bb.0: ; %entry
7142 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
7143 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
7144 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
7145 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
7146 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
7147 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
7148 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7149 ; GCN3-NEXT: flat_atomic_inc v[0:1], v2 offset:16
7150 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7151 ; GCN3-NEXT: buffer_wbinvl1_vol
7152 ; GCN3-NEXT: s_endpgm
7154 %gep = getelementptr i32, ptr %out, i32 4
7155 %val = atomicrmw volatile uinc_wrap ptr %gep, i32 %in syncscope("agent") seq_cst
7159 define amdgpu_kernel void @atomic_inc_i32_max_offset(ptr %out, i32 %in) {
7160 ; GCN1-LABEL: atomic_inc_i32_max_offset:
7161 ; GCN1: ; %bb.0: ; %entry
7162 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
7163 ; GCN1-NEXT: s_load_dword s4, s[0:1], 0xb
7164 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
7165 ; GCN1-NEXT: s_add_u32 s0, s2, 0xffc
7166 ; GCN1-NEXT: s_addc_u32 s1, s3, 0
7167 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
7168 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
7169 ; GCN1-NEXT: v_mov_b32_e32 v2, s4
7170 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7171 ; GCN1-NEXT: flat_atomic_inc v[0:1], v2
7172 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7173 ; GCN1-NEXT: buffer_wbinvl1_vol
7174 ; GCN1-NEXT: s_endpgm
7176 ; GCN2-LABEL: atomic_inc_i32_max_offset:
7177 ; GCN2: ; %bb.0: ; %entry
7178 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
7179 ; GCN2-NEXT: s_load_dword s4, s[0:1], 0x2c
7180 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
7181 ; GCN2-NEXT: s_add_u32 s0, s2, 0xffc
7182 ; GCN2-NEXT: s_addc_u32 s1, s3, 0
7183 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
7184 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
7185 ; GCN2-NEXT: v_mov_b32_e32 v2, s4
7186 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7187 ; GCN2-NEXT: flat_atomic_inc v[0:1], v2
7188 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7189 ; GCN2-NEXT: buffer_wbinvl1_vol
7190 ; GCN2-NEXT: s_endpgm
7192 ; GCN3-LABEL: atomic_inc_i32_max_offset:
7193 ; GCN3: ; %bb.0: ; %entry
7194 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
7195 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
7196 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
7197 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
7198 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
7199 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
7200 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7201 ; GCN3-NEXT: flat_atomic_inc v[0:1], v2 offset:4092
7202 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7203 ; GCN3-NEXT: buffer_wbinvl1_vol
7204 ; GCN3-NEXT: s_endpgm
7206 %gep = getelementptr i32, ptr %out, i32 1023
7207 %val = atomicrmw volatile uinc_wrap ptr %gep, i32 %in syncscope("agent") seq_cst
7211 define amdgpu_kernel void @atomic_inc_i32_max_offset_p1(ptr %out, i32 %in) {
7212 ; GCN1-LABEL: atomic_inc_i32_max_offset_p1:
7213 ; GCN1: ; %bb.0: ; %entry
7214 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
7215 ; GCN1-NEXT: s_load_dword s4, s[0:1], 0xb
7216 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
7217 ; GCN1-NEXT: s_add_u32 s0, s2, 0x1000
7218 ; GCN1-NEXT: s_addc_u32 s1, s3, 0
7219 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
7220 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
7221 ; GCN1-NEXT: v_mov_b32_e32 v2, s4
7222 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7223 ; GCN1-NEXT: flat_atomic_inc v[0:1], v2
7224 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7225 ; GCN1-NEXT: buffer_wbinvl1_vol
7226 ; GCN1-NEXT: s_endpgm
7228 ; GCN2-LABEL: atomic_inc_i32_max_offset_p1:
7229 ; GCN2: ; %bb.0: ; %entry
7230 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
7231 ; GCN2-NEXT: s_load_dword s4, s[0:1], 0x2c
7232 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
7233 ; GCN2-NEXT: s_add_u32 s0, s2, 0x1000
7234 ; GCN2-NEXT: s_addc_u32 s1, s3, 0
7235 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
7236 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
7237 ; GCN2-NEXT: v_mov_b32_e32 v2, s4
7238 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7239 ; GCN2-NEXT: flat_atomic_inc v[0:1], v2
7240 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7241 ; GCN2-NEXT: buffer_wbinvl1_vol
7242 ; GCN2-NEXT: s_endpgm
7244 ; GCN3-LABEL: atomic_inc_i32_max_offset_p1:
7245 ; GCN3: ; %bb.0: ; %entry
7246 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
7247 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
7248 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
7249 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
7250 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
7251 ; GCN3-NEXT: v_add_co_u32_e32 v0, vcc, 0x1000, v0
7252 ; GCN3-NEXT: v_addc_co_u32_e32 v1, vcc, 0, v1, vcc
7253 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
7254 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7255 ; GCN3-NEXT: flat_atomic_inc v[0:1], v2
7256 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7257 ; GCN3-NEXT: buffer_wbinvl1_vol
7258 ; GCN3-NEXT: s_endpgm
7260 %gep = getelementptr i32, ptr %out, i32 1024
7261 %val = atomicrmw volatile uinc_wrap ptr %gep, i32 %in syncscope("agent") seq_cst
7265 define amdgpu_kernel void @atomic_inc_i32_ret_offset(ptr %out, ptr %out2, i32 %in) {
7266 ; GCN1-LABEL: atomic_inc_i32_ret_offset:
7267 ; GCN1: ; %bb.0: ; %entry
7268 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
7269 ; GCN1-NEXT: s_load_dword s2, s[0:1], 0xd
7270 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
7271 ; GCN1-NEXT: s_add_u32 s0, s4, 16
7272 ; GCN1-NEXT: s_addc_u32 s1, s5, 0
7273 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
7274 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
7275 ; GCN1-NEXT: v_mov_b32_e32 v2, s2
7276 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7277 ; GCN1-NEXT: flat_atomic_inc v2, v[0:1], v2 glc
7278 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7279 ; GCN1-NEXT: buffer_wbinvl1_vol
7280 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
7281 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
7282 ; GCN1-NEXT: flat_store_dword v[0:1], v2
7283 ; GCN1-NEXT: s_endpgm
7285 ; GCN2-LABEL: atomic_inc_i32_ret_offset:
7286 ; GCN2: ; %bb.0: ; %entry
7287 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
7288 ; GCN2-NEXT: s_load_dword s2, s[0:1], 0x34
7289 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
7290 ; GCN2-NEXT: s_add_u32 s0, s4, 16
7291 ; GCN2-NEXT: s_addc_u32 s1, s5, 0
7292 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
7293 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
7294 ; GCN2-NEXT: v_mov_b32_e32 v2, s2
7295 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7296 ; GCN2-NEXT: flat_atomic_inc v2, v[0:1], v2 glc
7297 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7298 ; GCN2-NEXT: buffer_wbinvl1_vol
7299 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
7300 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
7301 ; GCN2-NEXT: flat_store_dword v[0:1], v2
7302 ; GCN2-NEXT: s_endpgm
7304 ; GCN3-LABEL: atomic_inc_i32_ret_offset:
7305 ; GCN3: ; %bb.0: ; %entry
7306 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
7307 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x34
7308 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
7309 ; GCN3-NEXT: v_mov_b32_e32 v0, s4
7310 ; GCN3-NEXT: v_mov_b32_e32 v1, s5
7311 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
7312 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7313 ; GCN3-NEXT: flat_atomic_inc v2, v[0:1], v2 offset:16 glc
7314 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7315 ; GCN3-NEXT: buffer_wbinvl1_vol
7316 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
7317 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
7318 ; GCN3-NEXT: flat_store_dword v[0:1], v2
7319 ; GCN3-NEXT: s_endpgm
7321 %gep = getelementptr i32, ptr %out, i32 4
7322 %val = atomicrmw volatile uinc_wrap ptr %gep, i32 %in syncscope("agent") seq_cst
7323 store i32 %val, ptr %out2
7327 define amdgpu_kernel void @atomic_inc_i32_incr64_offset(ptr %out, i32 %in, i64 %index) {
7328 ; GCN1-LABEL: atomic_inc_i32_incr64_offset:
7329 ; GCN1: ; %bb.0: ; %entry
7330 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xd
7331 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
7332 ; GCN1-NEXT: s_load_dword s6, s[0:1], 0xb
7333 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
7334 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
7335 ; GCN1-NEXT: s_add_u32 s0, s4, s0
7336 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
7337 ; GCN1-NEXT: s_add_u32 s0, s0, 16
7338 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
7339 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
7340 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
7341 ; GCN1-NEXT: v_mov_b32_e32 v2, s6
7342 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7343 ; GCN1-NEXT: flat_atomic_inc v[0:1], v2
7344 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7345 ; GCN1-NEXT: buffer_wbinvl1_vol
7346 ; GCN1-NEXT: s_endpgm
7348 ; GCN2-LABEL: atomic_inc_i32_incr64_offset:
7349 ; GCN2: ; %bb.0: ; %entry
7350 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
7351 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
7352 ; GCN2-NEXT: s_load_dword s6, s[0:1], 0x2c
7353 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
7354 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
7355 ; GCN2-NEXT: s_add_u32 s0, s4, s0
7356 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
7357 ; GCN2-NEXT: s_add_u32 s0, s0, 16
7358 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
7359 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
7360 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
7361 ; GCN2-NEXT: v_mov_b32_e32 v2, s6
7362 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7363 ; GCN2-NEXT: flat_atomic_inc v[0:1], v2
7364 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7365 ; GCN2-NEXT: buffer_wbinvl1_vol
7366 ; GCN2-NEXT: s_endpgm
7368 ; GCN3-LABEL: atomic_inc_i32_incr64_offset:
7369 ; GCN3: ; %bb.0: ; %entry
7370 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
7371 ; GCN3-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
7372 ; GCN3-NEXT: s_load_dword s6, s[0:1], 0x2c
7373 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
7374 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
7375 ; GCN3-NEXT: s_add_u32 s0, s4, s0
7376 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
7377 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
7378 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
7379 ; GCN3-NEXT: v_mov_b32_e32 v2, s6
7380 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7381 ; GCN3-NEXT: flat_atomic_inc v[0:1], v2 offset:16
7382 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7383 ; GCN3-NEXT: buffer_wbinvl1_vol
7384 ; GCN3-NEXT: s_endpgm
7386 %ptr = getelementptr i32, ptr %out, i64 %index
7387 %gep = getelementptr i32, ptr %ptr, i32 4
7388 %val = atomicrmw volatile uinc_wrap ptr %gep, i32 %in syncscope("agent") seq_cst
7392 define amdgpu_kernel void @atomic_inc_i32_ret_incr64_offset(ptr %out, ptr %out2, i32 %in, i64 %index) {
7393 ; GCN1-LABEL: atomic_inc_i32_ret_incr64_offset:
7394 ; GCN1: ; %bb.0: ; %entry
7395 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xf
7396 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
7397 ; GCN1-NEXT: s_load_dword s8, s[0:1], 0xd
7398 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
7399 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
7400 ; GCN1-NEXT: s_add_u32 s0, s4, s0
7401 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
7402 ; GCN1-NEXT: s_add_u32 s0, s0, 16
7403 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
7404 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
7405 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
7406 ; GCN1-NEXT: v_mov_b32_e32 v2, s8
7407 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7408 ; GCN1-NEXT: flat_atomic_inc v2, v[0:1], v2 glc
7409 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7410 ; GCN1-NEXT: buffer_wbinvl1_vol
7411 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
7412 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
7413 ; GCN1-NEXT: flat_store_dword v[0:1], v2
7414 ; GCN1-NEXT: s_endpgm
7416 ; GCN2-LABEL: atomic_inc_i32_ret_incr64_offset:
7417 ; GCN2: ; %bb.0: ; %entry
7418 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
7419 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
7420 ; GCN2-NEXT: s_load_dword s8, s[0:1], 0x34
7421 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
7422 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
7423 ; GCN2-NEXT: s_add_u32 s0, s4, s0
7424 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
7425 ; GCN2-NEXT: s_add_u32 s0, s0, 16
7426 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
7427 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
7428 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
7429 ; GCN2-NEXT: v_mov_b32_e32 v2, s8
7430 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7431 ; GCN2-NEXT: flat_atomic_inc v2, v[0:1], v2 glc
7432 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7433 ; GCN2-NEXT: buffer_wbinvl1_vol
7434 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
7435 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
7436 ; GCN2-NEXT: flat_store_dword v[0:1], v2
7437 ; GCN2-NEXT: s_endpgm
7439 ; GCN3-LABEL: atomic_inc_i32_ret_incr64_offset:
7440 ; GCN3: ; %bb.0: ; %entry
7441 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
7442 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
7443 ; GCN3-NEXT: s_load_dword s8, s[0:1], 0x34
7444 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
7445 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
7446 ; GCN3-NEXT: s_add_u32 s0, s4, s0
7447 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
7448 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
7449 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
7450 ; GCN3-NEXT: v_mov_b32_e32 v2, s8
7451 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7452 ; GCN3-NEXT: flat_atomic_inc v2, v[0:1], v2 offset:16 glc
7453 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7454 ; GCN3-NEXT: buffer_wbinvl1_vol
7455 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
7456 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
7457 ; GCN3-NEXT: flat_store_dword v[0:1], v2
7458 ; GCN3-NEXT: s_endpgm
7460 %ptr = getelementptr i32, ptr %out, i64 %index
7461 %gep = getelementptr i32, ptr %ptr, i32 4
7462 %val = atomicrmw volatile uinc_wrap ptr %gep, i32 %in syncscope("agent") seq_cst
7463 store i32 %val, ptr %out2
7467 define amdgpu_kernel void @atomic_inc_i32(ptr %out, i32 %in) {
7468 ; GCN1-LABEL: atomic_inc_i32:
7469 ; GCN1: ; %bb.0: ; %entry
7470 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
7471 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0xb
7472 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
7473 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
7474 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
7475 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
7476 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7477 ; GCN1-NEXT: flat_atomic_inc v[0:1], v2
7478 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7479 ; GCN1-NEXT: buffer_wbinvl1_vol
7480 ; GCN1-NEXT: s_endpgm
7482 ; GCN2-LABEL: atomic_inc_i32:
7483 ; GCN2: ; %bb.0: ; %entry
7484 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
7485 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x2c
7486 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
7487 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
7488 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
7489 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
7490 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7491 ; GCN2-NEXT: flat_atomic_inc v[0:1], v2
7492 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7493 ; GCN2-NEXT: buffer_wbinvl1_vol
7494 ; GCN2-NEXT: s_endpgm
7496 ; GCN3-LABEL: atomic_inc_i32:
7497 ; GCN3: ; %bb.0: ; %entry
7498 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
7499 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
7500 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
7501 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
7502 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
7503 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
7504 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7505 ; GCN3-NEXT: flat_atomic_inc v[0:1], v2
7506 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7507 ; GCN3-NEXT: buffer_wbinvl1_vol
7508 ; GCN3-NEXT: s_endpgm
7510 %val = atomicrmw volatile uinc_wrap ptr %out, i32 %in syncscope("agent") seq_cst
7514 define amdgpu_kernel void @atomic_inc_i32_ret(ptr %out, ptr %out2, i32 %in) {
7515 ; GCN1-LABEL: atomic_inc_i32_ret:
7516 ; GCN1: ; %bb.0: ; %entry
7517 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
7518 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0xd
7519 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
7520 ; GCN1-NEXT: v_mov_b32_e32 v0, s4
7521 ; GCN1-NEXT: v_mov_b32_e32 v1, s5
7522 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
7523 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7524 ; GCN1-NEXT: flat_atomic_inc v2, v[0:1], v2 glc
7525 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7526 ; GCN1-NEXT: buffer_wbinvl1_vol
7527 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
7528 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
7529 ; GCN1-NEXT: flat_store_dword v[0:1], v2
7530 ; GCN1-NEXT: s_endpgm
7532 ; GCN2-LABEL: atomic_inc_i32_ret:
7533 ; GCN2: ; %bb.0: ; %entry
7534 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
7535 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x34
7536 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
7537 ; GCN2-NEXT: v_mov_b32_e32 v0, s4
7538 ; GCN2-NEXT: v_mov_b32_e32 v1, s5
7539 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
7540 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7541 ; GCN2-NEXT: flat_atomic_inc v2, v[0:1], v2 glc
7542 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7543 ; GCN2-NEXT: buffer_wbinvl1_vol
7544 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
7545 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
7546 ; GCN2-NEXT: flat_store_dword v[0:1], v2
7547 ; GCN2-NEXT: s_endpgm
7549 ; GCN3-LABEL: atomic_inc_i32_ret:
7550 ; GCN3: ; %bb.0: ; %entry
7551 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
7552 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x34
7553 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
7554 ; GCN3-NEXT: v_mov_b32_e32 v0, s4
7555 ; GCN3-NEXT: v_mov_b32_e32 v1, s5
7556 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
7557 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7558 ; GCN3-NEXT: flat_atomic_inc v2, v[0:1], v2 glc
7559 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7560 ; GCN3-NEXT: buffer_wbinvl1_vol
7561 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
7562 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
7563 ; GCN3-NEXT: flat_store_dword v[0:1], v2
7564 ; GCN3-NEXT: s_endpgm
7566 %val = atomicrmw volatile uinc_wrap ptr %out, i32 %in syncscope("agent") seq_cst
7567 store i32 %val, ptr %out2
7571 define amdgpu_kernel void @atomic_inc_i32_incr64(ptr %out, i32 %in, i64 %index) {
7572 ; GCN1-LABEL: atomic_inc_i32_incr64:
7573 ; GCN1: ; %bb.0: ; %entry
7574 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xd
7575 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
7576 ; GCN1-NEXT: s_load_dword s6, s[0:1], 0xb
7577 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
7578 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
7579 ; GCN1-NEXT: s_add_u32 s0, s4, s0
7580 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
7581 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
7582 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
7583 ; GCN1-NEXT: v_mov_b32_e32 v2, s6
7584 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7585 ; GCN1-NEXT: flat_atomic_inc v[0:1], v2
7586 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7587 ; GCN1-NEXT: buffer_wbinvl1_vol
7588 ; GCN1-NEXT: s_endpgm
7590 ; GCN2-LABEL: atomic_inc_i32_incr64:
7591 ; GCN2: ; %bb.0: ; %entry
7592 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
7593 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
7594 ; GCN2-NEXT: s_load_dword s6, s[0:1], 0x2c
7595 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
7596 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
7597 ; GCN2-NEXT: s_add_u32 s0, s4, s0
7598 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
7599 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
7600 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
7601 ; GCN2-NEXT: v_mov_b32_e32 v2, s6
7602 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7603 ; GCN2-NEXT: flat_atomic_inc v[0:1], v2
7604 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7605 ; GCN2-NEXT: buffer_wbinvl1_vol
7606 ; GCN2-NEXT: s_endpgm
7608 ; GCN3-LABEL: atomic_inc_i32_incr64:
7609 ; GCN3: ; %bb.0: ; %entry
7610 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
7611 ; GCN3-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
7612 ; GCN3-NEXT: s_load_dword s6, s[0:1], 0x2c
7613 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
7614 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
7615 ; GCN3-NEXT: s_add_u32 s0, s4, s0
7616 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
7617 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
7618 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
7619 ; GCN3-NEXT: v_mov_b32_e32 v2, s6
7620 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7621 ; GCN3-NEXT: flat_atomic_inc v[0:1], v2
7622 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7623 ; GCN3-NEXT: buffer_wbinvl1_vol
7624 ; GCN3-NEXT: s_endpgm
7626 %ptr = getelementptr i32, ptr %out, i64 %index
7627 %val = atomicrmw volatile uinc_wrap ptr %ptr, i32 %in syncscope("agent") seq_cst
7631 define amdgpu_kernel void @atomic_inc_i32_ret_incr64(ptr %out, ptr %out2, i32 %in, i64 %index) {
7632 ; GCN1-LABEL: atomic_inc_i32_ret_incr64:
7633 ; GCN1: ; %bb.0: ; %entry
7634 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xf
7635 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
7636 ; GCN1-NEXT: s_load_dword s8, s[0:1], 0xd
7637 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
7638 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
7639 ; GCN1-NEXT: s_add_u32 s0, s4, s0
7640 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
7641 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
7642 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
7643 ; GCN1-NEXT: v_mov_b32_e32 v2, s8
7644 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7645 ; GCN1-NEXT: flat_atomic_inc v2, v[0:1], v2 glc
7646 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7647 ; GCN1-NEXT: buffer_wbinvl1_vol
7648 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
7649 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
7650 ; GCN1-NEXT: flat_store_dword v[0:1], v2
7651 ; GCN1-NEXT: s_endpgm
7653 ; GCN2-LABEL: atomic_inc_i32_ret_incr64:
7654 ; GCN2: ; %bb.0: ; %entry
7655 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
7656 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
7657 ; GCN2-NEXT: s_load_dword s8, s[0:1], 0x34
7658 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
7659 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
7660 ; GCN2-NEXT: s_add_u32 s0, s4, s0
7661 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
7662 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
7663 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
7664 ; GCN2-NEXT: v_mov_b32_e32 v2, s8
7665 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7666 ; GCN2-NEXT: flat_atomic_inc v2, v[0:1], v2 glc
7667 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7668 ; GCN2-NEXT: buffer_wbinvl1_vol
7669 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
7670 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
7671 ; GCN2-NEXT: flat_store_dword v[0:1], v2
7672 ; GCN2-NEXT: s_endpgm
7674 ; GCN3-LABEL: atomic_inc_i32_ret_incr64:
7675 ; GCN3: ; %bb.0: ; %entry
7676 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
7677 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
7678 ; GCN3-NEXT: s_load_dword s8, s[0:1], 0x34
7679 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
7680 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
7681 ; GCN3-NEXT: s_add_u32 s0, s4, s0
7682 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
7683 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
7684 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
7685 ; GCN3-NEXT: v_mov_b32_e32 v2, s8
7686 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7687 ; GCN3-NEXT: flat_atomic_inc v2, v[0:1], v2 glc
7688 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7689 ; GCN3-NEXT: buffer_wbinvl1_vol
7690 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
7691 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
7692 ; GCN3-NEXT: flat_store_dword v[0:1], v2
7693 ; GCN3-NEXT: s_endpgm
7695 %ptr = getelementptr i32, ptr %out, i64 %index
7696 %val = atomicrmw volatile uinc_wrap ptr %ptr, i32 %in syncscope("agent") seq_cst
7697 store i32 %val, ptr %out2
7701 define amdgpu_kernel void @atomic_dec_i32_offset(ptr %out, i32 %in) {
7702 ; GCN1-LABEL: atomic_dec_i32_offset:
7703 ; GCN1: ; %bb.0: ; %entry
7704 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
7705 ; GCN1-NEXT: s_load_dword s4, s[0:1], 0xb
7706 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
7707 ; GCN1-NEXT: s_add_u32 s0, s2, 16
7708 ; GCN1-NEXT: s_addc_u32 s1, s3, 0
7709 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
7710 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
7711 ; GCN1-NEXT: v_mov_b32_e32 v2, s4
7712 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7713 ; GCN1-NEXT: flat_atomic_dec v[0:1], v2
7714 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7715 ; GCN1-NEXT: buffer_wbinvl1_vol
7716 ; GCN1-NEXT: s_endpgm
7718 ; GCN2-LABEL: atomic_dec_i32_offset:
7719 ; GCN2: ; %bb.0: ; %entry
7720 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
7721 ; GCN2-NEXT: s_load_dword s4, s[0:1], 0x2c
7722 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
7723 ; GCN2-NEXT: s_add_u32 s0, s2, 16
7724 ; GCN2-NEXT: s_addc_u32 s1, s3, 0
7725 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
7726 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
7727 ; GCN2-NEXT: v_mov_b32_e32 v2, s4
7728 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7729 ; GCN2-NEXT: flat_atomic_dec v[0:1], v2
7730 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7731 ; GCN2-NEXT: buffer_wbinvl1_vol
7732 ; GCN2-NEXT: s_endpgm
7734 ; GCN3-LABEL: atomic_dec_i32_offset:
7735 ; GCN3: ; %bb.0: ; %entry
7736 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
7737 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
7738 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
7739 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
7740 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
7741 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
7742 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7743 ; GCN3-NEXT: flat_atomic_dec v[0:1], v2 offset:16
7744 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7745 ; GCN3-NEXT: buffer_wbinvl1_vol
7746 ; GCN3-NEXT: s_endpgm
7748 %gep = getelementptr i32, ptr %out, i32 4
7749 %val = atomicrmw volatile udec_wrap ptr %gep, i32 %in syncscope("agent") seq_cst
7753 define amdgpu_kernel void @atomic_dec_i32_max_offset(ptr %out, i32 %in) {
7754 ; GCN1-LABEL: atomic_dec_i32_max_offset:
7755 ; GCN1: ; %bb.0: ; %entry
7756 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
7757 ; GCN1-NEXT: s_load_dword s4, s[0:1], 0xb
7758 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
7759 ; GCN1-NEXT: s_add_u32 s0, s2, 0xffc
7760 ; GCN1-NEXT: s_addc_u32 s1, s3, 0
7761 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
7762 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
7763 ; GCN1-NEXT: v_mov_b32_e32 v2, s4
7764 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7765 ; GCN1-NEXT: flat_atomic_dec v[0:1], v2
7766 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7767 ; GCN1-NEXT: buffer_wbinvl1_vol
7768 ; GCN1-NEXT: s_endpgm
7770 ; GCN2-LABEL: atomic_dec_i32_max_offset:
7771 ; GCN2: ; %bb.0: ; %entry
7772 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
7773 ; GCN2-NEXT: s_load_dword s4, s[0:1], 0x2c
7774 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
7775 ; GCN2-NEXT: s_add_u32 s0, s2, 0xffc
7776 ; GCN2-NEXT: s_addc_u32 s1, s3, 0
7777 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
7778 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
7779 ; GCN2-NEXT: v_mov_b32_e32 v2, s4
7780 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7781 ; GCN2-NEXT: flat_atomic_dec v[0:1], v2
7782 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7783 ; GCN2-NEXT: buffer_wbinvl1_vol
7784 ; GCN2-NEXT: s_endpgm
7786 ; GCN3-LABEL: atomic_dec_i32_max_offset:
7787 ; GCN3: ; %bb.0: ; %entry
7788 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
7789 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
7790 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
7791 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
7792 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
7793 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
7794 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7795 ; GCN3-NEXT: flat_atomic_dec v[0:1], v2 offset:4092
7796 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7797 ; GCN3-NEXT: buffer_wbinvl1_vol
7798 ; GCN3-NEXT: s_endpgm
7800 %gep = getelementptr i32, ptr %out, i32 1023
7801 %val = atomicrmw volatile udec_wrap ptr %gep, i32 %in syncscope("agent") seq_cst
7805 define amdgpu_kernel void @atomic_dec_i32_max_offset_p1(ptr %out, i32 %in) {
7806 ; GCN1-LABEL: atomic_dec_i32_max_offset_p1:
7807 ; GCN1: ; %bb.0: ; %entry
7808 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
7809 ; GCN1-NEXT: s_load_dword s4, s[0:1], 0xb
7810 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
7811 ; GCN1-NEXT: s_add_u32 s0, s2, 0x1000
7812 ; GCN1-NEXT: s_addc_u32 s1, s3, 0
7813 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
7814 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
7815 ; GCN1-NEXT: v_mov_b32_e32 v2, s4
7816 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7817 ; GCN1-NEXT: flat_atomic_dec v[0:1], v2
7818 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7819 ; GCN1-NEXT: buffer_wbinvl1_vol
7820 ; GCN1-NEXT: s_endpgm
7822 ; GCN2-LABEL: atomic_dec_i32_max_offset_p1:
7823 ; GCN2: ; %bb.0: ; %entry
7824 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
7825 ; GCN2-NEXT: s_load_dword s4, s[0:1], 0x2c
7826 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
7827 ; GCN2-NEXT: s_add_u32 s0, s2, 0x1000
7828 ; GCN2-NEXT: s_addc_u32 s1, s3, 0
7829 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
7830 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
7831 ; GCN2-NEXT: v_mov_b32_e32 v2, s4
7832 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7833 ; GCN2-NEXT: flat_atomic_dec v[0:1], v2
7834 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7835 ; GCN2-NEXT: buffer_wbinvl1_vol
7836 ; GCN2-NEXT: s_endpgm
7838 ; GCN3-LABEL: atomic_dec_i32_max_offset_p1:
7839 ; GCN3: ; %bb.0: ; %entry
7840 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
7841 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
7842 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
7843 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
7844 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
7845 ; GCN3-NEXT: v_add_co_u32_e32 v0, vcc, 0x1000, v0
7846 ; GCN3-NEXT: v_addc_co_u32_e32 v1, vcc, 0, v1, vcc
7847 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
7848 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7849 ; GCN3-NEXT: flat_atomic_dec v[0:1], v2
7850 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7851 ; GCN3-NEXT: buffer_wbinvl1_vol
7852 ; GCN3-NEXT: s_endpgm
7854 %gep = getelementptr i32, ptr %out, i32 1024
7855 %val = atomicrmw volatile udec_wrap ptr %gep, i32 %in syncscope("agent") seq_cst
7859 define amdgpu_kernel void @atomic_dec_i32_ret_offset(ptr %out, ptr %out2, i32 %in) {
7860 ; GCN1-LABEL: atomic_dec_i32_ret_offset:
7861 ; GCN1: ; %bb.0: ; %entry
7862 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
7863 ; GCN1-NEXT: s_load_dword s2, s[0:1], 0xd
7864 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
7865 ; GCN1-NEXT: s_add_u32 s0, s4, 16
7866 ; GCN1-NEXT: s_addc_u32 s1, s5, 0
7867 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
7868 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
7869 ; GCN1-NEXT: v_mov_b32_e32 v2, s2
7870 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7871 ; GCN1-NEXT: flat_atomic_dec v2, v[0:1], v2 glc
7872 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7873 ; GCN1-NEXT: buffer_wbinvl1_vol
7874 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
7875 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
7876 ; GCN1-NEXT: flat_store_dword v[0:1], v2
7877 ; GCN1-NEXT: s_endpgm
7879 ; GCN2-LABEL: atomic_dec_i32_ret_offset:
7880 ; GCN2: ; %bb.0: ; %entry
7881 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
7882 ; GCN2-NEXT: s_load_dword s2, s[0:1], 0x34
7883 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
7884 ; GCN2-NEXT: s_add_u32 s0, s4, 16
7885 ; GCN2-NEXT: s_addc_u32 s1, s5, 0
7886 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
7887 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
7888 ; GCN2-NEXT: v_mov_b32_e32 v2, s2
7889 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7890 ; GCN2-NEXT: flat_atomic_dec v2, v[0:1], v2 glc
7891 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7892 ; GCN2-NEXT: buffer_wbinvl1_vol
7893 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
7894 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
7895 ; GCN2-NEXT: flat_store_dword v[0:1], v2
7896 ; GCN2-NEXT: s_endpgm
7898 ; GCN3-LABEL: atomic_dec_i32_ret_offset:
7899 ; GCN3: ; %bb.0: ; %entry
7900 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
7901 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x34
7902 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
7903 ; GCN3-NEXT: v_mov_b32_e32 v0, s4
7904 ; GCN3-NEXT: v_mov_b32_e32 v1, s5
7905 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
7906 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7907 ; GCN3-NEXT: flat_atomic_dec v2, v[0:1], v2 offset:16 glc
7908 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7909 ; GCN3-NEXT: buffer_wbinvl1_vol
7910 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
7911 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
7912 ; GCN3-NEXT: flat_store_dword v[0:1], v2
7913 ; GCN3-NEXT: s_endpgm
7915 %gep = getelementptr i32, ptr %out, i32 4
7916 %val = atomicrmw volatile udec_wrap ptr %gep, i32 %in syncscope("agent") seq_cst
7917 store i32 %val, ptr %out2
7921 define amdgpu_kernel void @atomic_dec_i32_decr64_offset(ptr %out, i32 %in, i64 %index) {
7922 ; GCN1-LABEL: atomic_dec_i32_decr64_offset:
7923 ; GCN1: ; %bb.0: ; %entry
7924 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xd
7925 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
7926 ; GCN1-NEXT: s_load_dword s6, s[0:1], 0xb
7927 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
7928 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
7929 ; GCN1-NEXT: s_add_u32 s0, s4, s0
7930 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
7931 ; GCN1-NEXT: s_add_u32 s0, s0, 16
7932 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
7933 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
7934 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
7935 ; GCN1-NEXT: v_mov_b32_e32 v2, s6
7936 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7937 ; GCN1-NEXT: flat_atomic_dec v[0:1], v2
7938 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7939 ; GCN1-NEXT: buffer_wbinvl1_vol
7940 ; GCN1-NEXT: s_endpgm
7942 ; GCN2-LABEL: atomic_dec_i32_decr64_offset:
7943 ; GCN2: ; %bb.0: ; %entry
7944 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
7945 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
7946 ; GCN2-NEXT: s_load_dword s6, s[0:1], 0x2c
7947 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
7948 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
7949 ; GCN2-NEXT: s_add_u32 s0, s4, s0
7950 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
7951 ; GCN2-NEXT: s_add_u32 s0, s0, 16
7952 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
7953 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
7954 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
7955 ; GCN2-NEXT: v_mov_b32_e32 v2, s6
7956 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7957 ; GCN2-NEXT: flat_atomic_dec v[0:1], v2
7958 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7959 ; GCN2-NEXT: buffer_wbinvl1_vol
7960 ; GCN2-NEXT: s_endpgm
7962 ; GCN3-LABEL: atomic_dec_i32_decr64_offset:
7963 ; GCN3: ; %bb.0: ; %entry
7964 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
7965 ; GCN3-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
7966 ; GCN3-NEXT: s_load_dword s6, s[0:1], 0x2c
7967 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
7968 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
7969 ; GCN3-NEXT: s_add_u32 s0, s4, s0
7970 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
7971 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
7972 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
7973 ; GCN3-NEXT: v_mov_b32_e32 v2, s6
7974 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7975 ; GCN3-NEXT: flat_atomic_dec v[0:1], v2 offset:16
7976 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
7977 ; GCN3-NEXT: buffer_wbinvl1_vol
7978 ; GCN3-NEXT: s_endpgm
7980 %ptr = getelementptr i32, ptr %out, i64 %index
7981 %gep = getelementptr i32, ptr %ptr, i32 4
7982 %val = atomicrmw volatile udec_wrap ptr %gep, i32 %in syncscope("agent") seq_cst
7986 define amdgpu_kernel void @atomic_dec_i32_ret_decr64_offset(ptr %out, ptr %out2, i32 %in, i64 %index) {
7987 ; GCN1-LABEL: atomic_dec_i32_ret_decr64_offset:
7988 ; GCN1: ; %bb.0: ; %entry
7989 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xf
7990 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
7991 ; GCN1-NEXT: s_load_dword s8, s[0:1], 0xd
7992 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
7993 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
7994 ; GCN1-NEXT: s_add_u32 s0, s4, s0
7995 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
7996 ; GCN1-NEXT: s_add_u32 s0, s0, 16
7997 ; GCN1-NEXT: s_addc_u32 s1, s1, 0
7998 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
7999 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
8000 ; GCN1-NEXT: v_mov_b32_e32 v2, s8
8001 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8002 ; GCN1-NEXT: flat_atomic_dec v2, v[0:1], v2 glc
8003 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8004 ; GCN1-NEXT: buffer_wbinvl1_vol
8005 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
8006 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
8007 ; GCN1-NEXT: flat_store_dword v[0:1], v2
8008 ; GCN1-NEXT: s_endpgm
8010 ; GCN2-LABEL: atomic_dec_i32_ret_decr64_offset:
8011 ; GCN2: ; %bb.0: ; %entry
8012 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
8013 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
8014 ; GCN2-NEXT: s_load_dword s8, s[0:1], 0x34
8015 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
8016 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
8017 ; GCN2-NEXT: s_add_u32 s0, s4, s0
8018 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
8019 ; GCN2-NEXT: s_add_u32 s0, s0, 16
8020 ; GCN2-NEXT: s_addc_u32 s1, s1, 0
8021 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
8022 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
8023 ; GCN2-NEXT: v_mov_b32_e32 v2, s8
8024 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8025 ; GCN2-NEXT: flat_atomic_dec v2, v[0:1], v2 glc
8026 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8027 ; GCN2-NEXT: buffer_wbinvl1_vol
8028 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
8029 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
8030 ; GCN2-NEXT: flat_store_dword v[0:1], v2
8031 ; GCN2-NEXT: s_endpgm
8033 ; GCN3-LABEL: atomic_dec_i32_ret_decr64_offset:
8034 ; GCN3: ; %bb.0: ; %entry
8035 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
8036 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
8037 ; GCN3-NEXT: s_load_dword s8, s[0:1], 0x34
8038 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
8039 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
8040 ; GCN3-NEXT: s_add_u32 s0, s4, s0
8041 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
8042 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
8043 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
8044 ; GCN3-NEXT: v_mov_b32_e32 v2, s8
8045 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8046 ; GCN3-NEXT: flat_atomic_dec v2, v[0:1], v2 offset:16 glc
8047 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8048 ; GCN3-NEXT: buffer_wbinvl1_vol
8049 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
8050 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
8051 ; GCN3-NEXT: flat_store_dword v[0:1], v2
8052 ; GCN3-NEXT: s_endpgm
8054 %ptr = getelementptr i32, ptr %out, i64 %index
8055 %gep = getelementptr i32, ptr %ptr, i32 4
8056 %val = atomicrmw volatile udec_wrap ptr %gep, i32 %in syncscope("agent") seq_cst
8057 store i32 %val, ptr %out2
8061 define amdgpu_kernel void @atomic_dec_i32(ptr %out, i32 %in) {
8062 ; GCN1-LABEL: atomic_dec_i32:
8063 ; GCN1: ; %bb.0: ; %entry
8064 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x9
8065 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0xb
8066 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
8067 ; GCN1-NEXT: v_mov_b32_e32 v0, s2
8068 ; GCN1-NEXT: v_mov_b32_e32 v1, s3
8069 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
8070 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8071 ; GCN1-NEXT: flat_atomic_dec v[0:1], v2
8072 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8073 ; GCN1-NEXT: buffer_wbinvl1_vol
8074 ; GCN1-NEXT: s_endpgm
8076 ; GCN2-LABEL: atomic_dec_i32:
8077 ; GCN2: ; %bb.0: ; %entry
8078 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
8079 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x2c
8080 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
8081 ; GCN2-NEXT: v_mov_b32_e32 v0, s2
8082 ; GCN2-NEXT: v_mov_b32_e32 v1, s3
8083 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
8084 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8085 ; GCN2-NEXT: flat_atomic_dec v[0:1], v2
8086 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8087 ; GCN2-NEXT: buffer_wbinvl1_vol
8088 ; GCN2-NEXT: s_endpgm
8090 ; GCN3-LABEL: atomic_dec_i32:
8091 ; GCN3: ; %bb.0: ; %entry
8092 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
8093 ; GCN3-NEXT: s_load_dword s4, s[0:1], 0x2c
8094 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
8095 ; GCN3-NEXT: v_mov_b32_e32 v0, s2
8096 ; GCN3-NEXT: v_mov_b32_e32 v1, s3
8097 ; GCN3-NEXT: v_mov_b32_e32 v2, s4
8098 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8099 ; GCN3-NEXT: flat_atomic_dec v[0:1], v2
8100 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8101 ; GCN3-NEXT: buffer_wbinvl1_vol
8102 ; GCN3-NEXT: s_endpgm
8104 %val = atomicrmw volatile udec_wrap ptr %out, i32 %in syncscope("agent") seq_cst
8108 define amdgpu_kernel void @atomic_dec_i32_ret(ptr %out, ptr %out2, i32 %in) {
8109 ; GCN1-LABEL: atomic_dec_i32_ret:
8110 ; GCN1: ; %bb.0: ; %entry
8111 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
8112 ; GCN1-NEXT: s_load_dword s0, s[0:1], 0xd
8113 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
8114 ; GCN1-NEXT: v_mov_b32_e32 v0, s4
8115 ; GCN1-NEXT: v_mov_b32_e32 v1, s5
8116 ; GCN1-NEXT: v_mov_b32_e32 v2, s0
8117 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8118 ; GCN1-NEXT: flat_atomic_dec v2, v[0:1], v2 glc
8119 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8120 ; GCN1-NEXT: buffer_wbinvl1_vol
8121 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
8122 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
8123 ; GCN1-NEXT: flat_store_dword v[0:1], v2
8124 ; GCN1-NEXT: s_endpgm
8126 ; GCN2-LABEL: atomic_dec_i32_ret:
8127 ; GCN2: ; %bb.0: ; %entry
8128 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
8129 ; GCN2-NEXT: s_load_dword s0, s[0:1], 0x34
8130 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
8131 ; GCN2-NEXT: v_mov_b32_e32 v0, s4
8132 ; GCN2-NEXT: v_mov_b32_e32 v1, s5
8133 ; GCN2-NEXT: v_mov_b32_e32 v2, s0
8134 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8135 ; GCN2-NEXT: flat_atomic_dec v2, v[0:1], v2 glc
8136 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8137 ; GCN2-NEXT: buffer_wbinvl1_vol
8138 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
8139 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
8140 ; GCN2-NEXT: flat_store_dword v[0:1], v2
8141 ; GCN2-NEXT: s_endpgm
8143 ; GCN3-LABEL: atomic_dec_i32_ret:
8144 ; GCN3: ; %bb.0: ; %entry
8145 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
8146 ; GCN3-NEXT: s_load_dword s2, s[0:1], 0x34
8147 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
8148 ; GCN3-NEXT: v_mov_b32_e32 v0, s4
8149 ; GCN3-NEXT: v_mov_b32_e32 v1, s5
8150 ; GCN3-NEXT: v_mov_b32_e32 v2, s2
8151 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8152 ; GCN3-NEXT: flat_atomic_dec v2, v[0:1], v2 glc
8153 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8154 ; GCN3-NEXT: buffer_wbinvl1_vol
8155 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
8156 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
8157 ; GCN3-NEXT: flat_store_dword v[0:1], v2
8158 ; GCN3-NEXT: s_endpgm
8160 %val = atomicrmw volatile udec_wrap ptr %out, i32 %in syncscope("agent") seq_cst
8161 store i32 %val, ptr %out2
8165 define amdgpu_kernel void @atomic_dec_i32_decr64(ptr %out, i32 %in, i64 %index) {
8166 ; GCN1-LABEL: atomic_dec_i32_decr64:
8167 ; GCN1: ; %bb.0: ; %entry
8168 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xd
8169 ; GCN1-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
8170 ; GCN1-NEXT: s_load_dword s6, s[0:1], 0xb
8171 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
8172 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
8173 ; GCN1-NEXT: s_add_u32 s0, s4, s0
8174 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
8175 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
8176 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
8177 ; GCN1-NEXT: v_mov_b32_e32 v2, s6
8178 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8179 ; GCN1-NEXT: flat_atomic_dec v[0:1], v2
8180 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8181 ; GCN1-NEXT: buffer_wbinvl1_vol
8182 ; GCN1-NEXT: s_endpgm
8184 ; GCN2-LABEL: atomic_dec_i32_decr64:
8185 ; GCN2: ; %bb.0: ; %entry
8186 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
8187 ; GCN2-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
8188 ; GCN2-NEXT: s_load_dword s6, s[0:1], 0x2c
8189 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
8190 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
8191 ; GCN2-NEXT: s_add_u32 s0, s4, s0
8192 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
8193 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
8194 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
8195 ; GCN2-NEXT: v_mov_b32_e32 v2, s6
8196 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8197 ; GCN2-NEXT: flat_atomic_dec v[0:1], v2
8198 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8199 ; GCN2-NEXT: buffer_wbinvl1_vol
8200 ; GCN2-NEXT: s_endpgm
8202 ; GCN3-LABEL: atomic_dec_i32_decr64:
8203 ; GCN3: ; %bb.0: ; %entry
8204 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
8205 ; GCN3-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
8206 ; GCN3-NEXT: s_load_dword s6, s[0:1], 0x2c
8207 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
8208 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
8209 ; GCN3-NEXT: s_add_u32 s0, s4, s0
8210 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
8211 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
8212 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
8213 ; GCN3-NEXT: v_mov_b32_e32 v2, s6
8214 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8215 ; GCN3-NEXT: flat_atomic_dec v[0:1], v2
8216 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8217 ; GCN3-NEXT: buffer_wbinvl1_vol
8218 ; GCN3-NEXT: s_endpgm
8220 %ptr = getelementptr i32, ptr %out, i64 %index
8221 %val = atomicrmw volatile udec_wrap ptr %ptr, i32 %in syncscope("agent") seq_cst
8225 define amdgpu_kernel void @atomic_dec_i32_ret_decr64(ptr %out, ptr %out2, i32 %in, i64 %index) {
8226 ; GCN1-LABEL: atomic_dec_i32_ret_decr64:
8227 ; GCN1: ; %bb.0: ; %entry
8228 ; GCN1-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0xf
8229 ; GCN1-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
8230 ; GCN1-NEXT: s_load_dword s8, s[0:1], 0xd
8231 ; GCN1-NEXT: s_waitcnt lgkmcnt(0)
8232 ; GCN1-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
8233 ; GCN1-NEXT: s_add_u32 s0, s4, s0
8234 ; GCN1-NEXT: s_addc_u32 s1, s5, s1
8235 ; GCN1-NEXT: v_mov_b32_e32 v0, s0
8236 ; GCN1-NEXT: v_mov_b32_e32 v1, s1
8237 ; GCN1-NEXT: v_mov_b32_e32 v2, s8
8238 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8239 ; GCN1-NEXT: flat_atomic_dec v2, v[0:1], v2 glc
8240 ; GCN1-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8241 ; GCN1-NEXT: buffer_wbinvl1_vol
8242 ; GCN1-NEXT: v_mov_b32_e32 v0, s6
8243 ; GCN1-NEXT: v_mov_b32_e32 v1, s7
8244 ; GCN1-NEXT: flat_store_dword v[0:1], v2
8245 ; GCN1-NEXT: s_endpgm
8247 ; GCN2-LABEL: atomic_dec_i32_ret_decr64:
8248 ; GCN2: ; %bb.0: ; %entry
8249 ; GCN2-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
8250 ; GCN2-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
8251 ; GCN2-NEXT: s_load_dword s8, s[0:1], 0x34
8252 ; GCN2-NEXT: s_waitcnt lgkmcnt(0)
8253 ; GCN2-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
8254 ; GCN2-NEXT: s_add_u32 s0, s4, s0
8255 ; GCN2-NEXT: s_addc_u32 s1, s5, s1
8256 ; GCN2-NEXT: v_mov_b32_e32 v0, s0
8257 ; GCN2-NEXT: v_mov_b32_e32 v1, s1
8258 ; GCN2-NEXT: v_mov_b32_e32 v2, s8
8259 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8260 ; GCN2-NEXT: flat_atomic_dec v2, v[0:1], v2 glc
8261 ; GCN2-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8262 ; GCN2-NEXT: buffer_wbinvl1_vol
8263 ; GCN2-NEXT: v_mov_b32_e32 v0, s6
8264 ; GCN2-NEXT: v_mov_b32_e32 v1, s7
8265 ; GCN2-NEXT: flat_store_dword v[0:1], v2
8266 ; GCN2-NEXT: s_endpgm
8268 ; GCN3-LABEL: atomic_dec_i32_ret_decr64:
8269 ; GCN3: ; %bb.0: ; %entry
8270 ; GCN3-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x3c
8271 ; GCN3-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
8272 ; GCN3-NEXT: s_load_dword s8, s[0:1], 0x34
8273 ; GCN3-NEXT: s_waitcnt lgkmcnt(0)
8274 ; GCN3-NEXT: s_lshl_b64 s[0:1], s[2:3], 2
8275 ; GCN3-NEXT: s_add_u32 s0, s4, s0
8276 ; GCN3-NEXT: s_addc_u32 s1, s5, s1
8277 ; GCN3-NEXT: v_mov_b32_e32 v0, s0
8278 ; GCN3-NEXT: v_mov_b32_e32 v1, s1
8279 ; GCN3-NEXT: v_mov_b32_e32 v2, s8
8280 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8281 ; GCN3-NEXT: flat_atomic_dec v2, v[0:1], v2 glc
8282 ; GCN3-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
8283 ; GCN3-NEXT: buffer_wbinvl1_vol
8284 ; GCN3-NEXT: v_mov_b32_e32 v0, s6
8285 ; GCN3-NEXT: v_mov_b32_e32 v1, s7
8286 ; GCN3-NEXT: flat_store_dword v[0:1], v2
8287 ; GCN3-NEXT: s_endpgm
8289 %ptr = getelementptr i32, ptr %out, i64 %index
8290 %val = atomicrmw volatile udec_wrap ptr %ptr, i32 %in syncscope("agent") seq_cst
8291 store i32 %val, ptr %out2