1 ; RUN: llc -march=amdgcn -mcpu=bonaire -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,CI,CIVI %s
2 ; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN,VI,CIVI %s
3 ; RUN: llc -march=amdgcn -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN,GFX9 %s
5 declare i32 @llvm.amdgcn.atomic.dec.i32.p1i32(i32 addrspace(1)* nocapture, i32, i32, i32, i1) #2
6 declare i32 @llvm.amdgcn.atomic.dec.i32.p3i32(i32 addrspace(3)* nocapture, i32, i32, i32, i1) #2
7 declare i32 @llvm.amdgcn.atomic.dec.i32.p0i32(i32* nocapture, i32, i32, i32, i1) #2
9 declare i64 @llvm.amdgcn.atomic.dec.i64.p1i64(i64 addrspace(1)* nocapture, i64, i32, i32, i1) #2
10 declare i64 @llvm.amdgcn.atomic.dec.i64.p3i64(i64 addrspace(3)* nocapture, i64, i32, i32, i1) #2
11 declare i64 @llvm.amdgcn.atomic.dec.i64.p0i64(i64* nocapture, i64, i32, i32, i1) #2
13 declare i32 @llvm.amdgcn.workitem.id.x() #1
15 ; GCN-LABEL: {{^}}lds_atomic_dec_ret_i32:
16 ; CIVI-DAG: s_mov_b32 m0
19 ; GCN-DAG: v_mov_b32_e32 [[K:v[0-9]+]], 42
20 ; GCN: ds_dec_rtn_u32 v{{[0-9]+}}, v{{[0-9]+}}, [[K]]
21 define amdgpu_kernel void @lds_atomic_dec_ret_i32(i32 addrspace(1)* %out, i32 addrspace(3)* %ptr) #0 {
22 %result = call i32 @llvm.amdgcn.atomic.dec.i32.p3i32(i32 addrspace(3)* %ptr, i32 42, i32 0, i32 0, i1 false)
23 store i32 %result, i32 addrspace(1)* %out
27 ; GCN-LABEL: {{^}}lds_atomic_dec_ret_i32_offset:
28 ; CIVI-DAG: s_mov_b32 m0
31 ; GCN-DAG: v_mov_b32_e32 [[K:v[0-9]+]], 42
32 ; GCN: ds_dec_rtn_u32 v{{[0-9]+}}, v{{[0-9]+}}, [[K]] offset:16
33 define amdgpu_kernel void @lds_atomic_dec_ret_i32_offset(i32 addrspace(1)* %out, i32 addrspace(3)* %ptr) #0 {
34 %gep = getelementptr i32, i32 addrspace(3)* %ptr, i32 4
35 %result = call i32 @llvm.amdgcn.atomic.dec.i32.p3i32(i32 addrspace(3)* %gep, i32 42, i32 0, i32 0, i1 false)
36 store i32 %result, i32 addrspace(1)* %out
40 ; GCN-LABEL: {{^}}lds_atomic_dec_noret_i32:
41 ; CIVI-DAG: s_mov_b32 m0
44 ; GCN-DAG: s_load_dword [[SPTR:s[0-9]+]],
45 ; GCN-DAG: v_mov_b32_e32 [[DATA:v[0-9]+]], 4
46 ; GCN-DAG: v_mov_b32_e32 [[VPTR:v[0-9]+]], [[SPTR]]
47 ; GCN: ds_dec_u32 [[VPTR]], [[DATA]]
48 define amdgpu_kernel void @lds_atomic_dec_noret_i32(i32 addrspace(3)* %ptr) nounwind {
49 %result = call i32 @llvm.amdgcn.atomic.dec.i32.p3i32(i32 addrspace(3)* %ptr, i32 42, i32 0, i32 0, i1 false)
53 ; GCN-LABEL: {{^}}lds_atomic_dec_noret_i32_offset:
54 ; CIVI-DAG: s_mov_b32 m0
57 ; GCN-DAG: v_mov_b32_e32 [[K:v[0-9]+]], 42
58 ; GCN: ds_dec_u32 v{{[0-9]+}}, [[K]] offset:16
59 define amdgpu_kernel void @lds_atomic_dec_noret_i32_offset(i32 addrspace(3)* %ptr) nounwind {
60 %gep = getelementptr i32, i32 addrspace(3)* %ptr, i32 4
61 %result = call i32 @llvm.amdgcn.atomic.dec.i32.p3i32(i32 addrspace(3)* %gep, i32 42, i32 0, i32 0, i1 false)
65 ; GCN-LABEL: {{^}}global_atomic_dec_ret_i32:
66 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 42
67 ; CIVI: buffer_atomic_dec [[K]], off, s{{\[[0-9]+:[0-9]+\]}}, 0 glc{{$}}
68 ; GFX9: global_atomic_dec v{{[0-9]+}}, v{{\[[0-9]+:[0-9]+\]}}, [[K]], off glc{{$}}
69 define amdgpu_kernel void @global_atomic_dec_ret_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %ptr) #0 {
70 %result = call i32 @llvm.amdgcn.atomic.dec.i32.p1i32(i32 addrspace(1)* %ptr, i32 42, i32 0, i32 0, i1 false)
71 store i32 %result, i32 addrspace(1)* %out
75 ; GCN-LABEL: {{^}}global_atomic_dec_ret_i32_offset:
76 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 42
77 ; CIVI: buffer_atomic_dec [[K]], off, s{{\[[0-9]+:[0-9]+\]}}, 0 offset:16 glc{{$}}
78 ; GFX9: global_atomic_dec v{{[0-9]+}}, v{{\[[0-9]+:[0-9]+\]}}, [[K]], off offset:16 glc{{$}}
79 define amdgpu_kernel void @global_atomic_dec_ret_i32_offset(i32 addrspace(1)* %out, i32 addrspace(1)* %ptr) #0 {
80 %gep = getelementptr i32, i32 addrspace(1)* %ptr, i32 4
81 %result = call i32 @llvm.amdgcn.atomic.dec.i32.p1i32(i32 addrspace(1)* %gep, i32 42, i32 0, i32 0, i1 false)
82 store i32 %result, i32 addrspace(1)* %out
86 ; GCN-LABEL: {{^}}global_atomic_dec_noret_i32:
87 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 42
88 ; CIVI: buffer_atomic_dec [[K]], off, s{{\[[0-9]+:[0-9]+\]}}, 0{{$}}
89 ; GFX9: global_atomic_dec v{{\[[0-9]+:[0-9]+\]}}, [[K]], off{{$}}
90 define amdgpu_kernel void @global_atomic_dec_noret_i32(i32 addrspace(1)* %ptr) nounwind {
91 %result = call i32 @llvm.amdgcn.atomic.dec.i32.p1i32(i32 addrspace(1)* %ptr, i32 42, i32 0, i32 0, i1 false)
95 ; GCN-LABEL: {{^}}global_atomic_dec_noret_i32_offset:
96 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 42
97 ; CIVI: buffer_atomic_dec [[K]], off, s{{\[[0-9]+:[0-9]+\]}}, 0 offset:16{{$}}
98 ; GFX9: global_atomic_dec v{{\[[0-9]+:[0-9]+\]}}, [[K]], off offset:16{{$}}
99 define amdgpu_kernel void @global_atomic_dec_noret_i32_offset(i32 addrspace(1)* %ptr) nounwind {
100 %gep = getelementptr i32, i32 addrspace(1)* %ptr, i32 4
101 %result = call i32 @llvm.amdgcn.atomic.dec.i32.p1i32(i32 addrspace(1)* %gep, i32 42, i32 0, i32 0, i1 false)
105 ; GCN-LABEL: {{^}}global_atomic_dec_ret_i32_offset_addr64:
106 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 42
107 ; CI: buffer_atomic_dec [[K]], v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64 offset:20 glc{{$}}
108 ; VI: flat_atomic_dec v{{[0-9]+}}, v{{\[[0-9]+:[0-9]+\]}}, [[K]] glc{{$}}
109 define amdgpu_kernel void @global_atomic_dec_ret_i32_offset_addr64(i32 addrspace(1)* %out, i32 addrspace(1)* %ptr) #0 {
110 %id = call i32 @llvm.amdgcn.workitem.id.x()
111 %gep.tid = getelementptr i32, i32 addrspace(1)* %ptr, i32 %id
112 %out.gep = getelementptr i32, i32 addrspace(1)* %out, i32 %id
113 %gep = getelementptr i32, i32 addrspace(1)* %gep.tid, i32 5
114 %result = call i32 @llvm.amdgcn.atomic.dec.i32.p1i32(i32 addrspace(1)* %gep, i32 42, i32 0, i32 0, i1 false)
115 store i32 %result, i32 addrspace(1)* %out.gep
119 ; GCN-LABEL: {{^}}global_atomic_dec_noret_i32_offset_addr64:
120 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 42
121 ; CI: buffer_atomic_dec [[K]], v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64 offset:20{{$}}
122 ; VI: flat_atomic_dec v{{\[[0-9]+:[0-9]+\]}}, [[K]]{{$}}
123 define amdgpu_kernel void @global_atomic_dec_noret_i32_offset_addr64(i32 addrspace(1)* %ptr) #0 {
124 %id = call i32 @llvm.amdgcn.workitem.id.x()
125 %gep.tid = getelementptr i32, i32 addrspace(1)* %ptr, i32 %id
126 %gep = getelementptr i32, i32 addrspace(1)* %gep.tid, i32 5
127 %result = call i32 @llvm.amdgcn.atomic.dec.i32.p1i32(i32 addrspace(1)* %gep, i32 42, i32 0, i32 0, i1 false)
131 ; GCN-LABEL: {{^}}flat_atomic_dec_ret_i32:
132 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 42
133 ; GCN: flat_atomic_dec v{{[0-9]+}}, v{{\[[0-9]+:[0-9]+\]}}, [[K]] glc{{$}}
134 define amdgpu_kernel void @flat_atomic_dec_ret_i32(i32* %out, i32* %ptr) #0 {
135 %result = call i32 @llvm.amdgcn.atomic.dec.i32.p0i32(i32* %ptr, i32 42, i32 0, i32 0, i1 false)
136 store i32 %result, i32* %out
140 ; GCN-LABEL: {{^}}flat_atomic_dec_ret_i32_offset:
141 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 42
142 ; CIVI: flat_atomic_dec v{{[0-9]+}}, v{{\[[0-9]+:[0-9]+\]}}, [[K]] glc{{$}}
143 ; GFX9: flat_atomic_dec v{{[0-9]+}}, v{{\[[0-9]+:[0-9]+\]}}, [[K]] offset:16 glc{{$}}
144 define amdgpu_kernel void @flat_atomic_dec_ret_i32_offset(i32* %out, i32* %ptr) #0 {
145 %gep = getelementptr i32, i32* %ptr, i32 4
146 %result = call i32 @llvm.amdgcn.atomic.dec.i32.p0i32(i32* %gep, i32 42, i32 0, i32 0, i1 false)
147 store i32 %result, i32* %out
151 ; GCN-LABEL: {{^}}flat_atomic_dec_noret_i32:
152 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 42
153 ; GCN: flat_atomic_dec v{{\[[0-9]+:[0-9]+\]}}, [[K]]{{$}}
154 define amdgpu_kernel void @flat_atomic_dec_noret_i32(i32* %ptr) nounwind {
155 %result = call i32 @llvm.amdgcn.atomic.dec.i32.p0i32(i32* %ptr, i32 42, i32 0, i32 0, i1 false)
159 ; GCN-LABEL: {{^}}flat_atomic_dec_noret_i32_offset:
160 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 42
161 ; CIVI: flat_atomic_dec v{{\[[0-9]+:[0-9]+\]}}, [[K]]{{$}}
162 ; GFX9: flat_atomic_dec v{{\[[0-9]+:[0-9]+\]}}, [[K]] offset:16{{$}}
163 define amdgpu_kernel void @flat_atomic_dec_noret_i32_offset(i32* %ptr) nounwind {
164 %gep = getelementptr i32, i32* %ptr, i32 4
165 %result = call i32 @llvm.amdgcn.atomic.dec.i32.p0i32(i32* %gep, i32 42, i32 0, i32 0, i1 false)
169 ; GCN-LABEL: {{^}}flat_atomic_dec_ret_i32_offset_addr64:
170 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 42
171 ; CIVI: flat_atomic_dec v{{[0-9]+}}, v{{\[[0-9]+:[0-9]+\]}}, [[K]] glc{{$}}
172 ; GFX9: flat_atomic_dec v{{[0-9]+}}, v{{\[[0-9]+:[0-9]+\]}}, [[K]] offset:20 glc{{$}}
173 define amdgpu_kernel void @flat_atomic_dec_ret_i32_offset_addr64(i32* %out, i32* %ptr) #0 {
174 %id = call i32 @llvm.amdgcn.workitem.id.x()
175 %gep.tid = getelementptr i32, i32* %ptr, i32 %id
176 %out.gep = getelementptr i32, i32* %out, i32 %id
177 %gep = getelementptr i32, i32* %gep.tid, i32 5
178 %result = call i32 @llvm.amdgcn.atomic.dec.i32.p0i32(i32* %gep, i32 42, i32 0, i32 0, i1 false)
179 store i32 %result, i32* %out.gep
183 ; GCN-LABEL: {{^}}flat_atomic_dec_noret_i32_offset_addr64:
184 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 42
185 ; CIVI: flat_atomic_dec v{{\[[0-9]+:[0-9]+\]}}, [[K]]{{$}}
186 ; GFX9: flat_atomic_dec v{{\[[0-9]+:[0-9]+\]}}, [[K]] offset:20{{$}}
187 define amdgpu_kernel void @flat_atomic_dec_noret_i32_offset_addr64(i32* %ptr) #0 {
188 %id = call i32 @llvm.amdgcn.workitem.id.x()
189 %gep.tid = getelementptr i32, i32* %ptr, i32 %id
190 %gep = getelementptr i32, i32* %gep.tid, i32 5
191 %result = call i32 @llvm.amdgcn.atomic.dec.i32.p0i32(i32* %gep, i32 42, i32 0, i32 0, i1 false)
195 ; GCN-LABEL: {{^}}flat_atomic_dec_ret_i64:
196 ; GCN-DAG: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
197 ; GCN-DAG: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
198 ; GCN: flat_atomic_dec_x2 v{{\[[0-9]+:[0-9]+\]}}, v{{\[[0-9]+:[0-9]+\]}}, v{{\[}}[[KLO]]:[[KHI]]{{\]}} glc{{$}}
199 define amdgpu_kernel void @flat_atomic_dec_ret_i64(i64* %out, i64* %ptr) #0 {
200 %result = call i64 @llvm.amdgcn.atomic.dec.i64.p0i64(i64* %ptr, i64 42, i32 0, i32 0, i1 false)
201 store i64 %result, i64* %out
205 ; GCN-LABEL: {{^}}flat_atomic_dec_ret_i64_offset:
206 ; GCN-DAG: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
207 ; GCN-DAG: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
208 ; CIVI: flat_atomic_dec_x2 v{{\[[0-9]+:[0-9]+\]}}, v{{\[[0-9]+:[0-9]+\]}}, v{{\[}}[[KLO]]:[[KHI]]{{\]}} glc{{$}}
209 ; GFX9: flat_atomic_dec_x2 v{{\[[0-9]+:[0-9]+\]}}, v{{\[[0-9]+:[0-9]+\]}}, v{{\[}}[[KLO]]:[[KHI]]{{\]}} offset:32 glc{{$}}
210 define amdgpu_kernel void @flat_atomic_dec_ret_i64_offset(i64* %out, i64* %ptr) #0 {
211 %gep = getelementptr i64, i64* %ptr, i32 4
212 %result = call i64 @llvm.amdgcn.atomic.dec.i64.p0i64(i64* %gep, i64 42, i32 0, i32 0, i1 false)
213 store i64 %result, i64* %out
217 ; GCN-LABEL: {{^}}flat_atomic_dec_noret_i64:
218 ; GCN-DAG: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
219 ; GCN-DAG: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
220 ; GCN: flat_atomic_dec_x2 v{{\[[0-9]+:[0-9]+\]}}, v{{\[}}[[KLO]]:[[KHI]]{{\]$}}
221 define amdgpu_kernel void @flat_atomic_dec_noret_i64(i64* %ptr) nounwind {
222 %result = call i64 @llvm.amdgcn.atomic.dec.i64.p0i64(i64* %ptr, i64 42, i32 0, i32 0, i1 false)
226 ; GCN-LABEL: {{^}}flat_atomic_dec_noret_i64_offset:
227 ; GCN-DAG: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
228 ; GCN-DAG: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
229 ; CIVI: flat_atomic_dec_x2 v{{\[[0-9]+:[0-9]+\]}}, v{{\[}}[[KLO]]:[[KHI]]{{\]$}}
230 ; GFX9: flat_atomic_dec_x2 v{{\[[0-9]+:[0-9]+\]}}, v{{\[}}[[KLO]]:[[KHI]]{{\]}} offset:32{{$}}
231 define amdgpu_kernel void @flat_atomic_dec_noret_i64_offset(i64* %ptr) nounwind {
232 %gep = getelementptr i64, i64* %ptr, i32 4
233 %result = call i64 @llvm.amdgcn.atomic.dec.i64.p0i64(i64* %gep, i64 42, i32 0, i32 0, i1 false)
237 ; GCN-LABEL: {{^}}flat_atomic_dec_ret_i64_offset_addr64:
238 ; GCN: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
239 ; GCN: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
240 ; CIVI: flat_atomic_dec_x2 v{{\[[0-9]+:[0-9]+\]}}, v{{\[[0-9]+:[0-9]+\]}}, v{{\[}}[[KLO]]:[[KHI]]{{\]}} glc{{$}}
241 ; GFX9: flat_atomic_dec_x2 v{{\[[0-9]+:[0-9]+\]}}, v{{\[[0-9]+:[0-9]+\]}}, v{{\[}}[[KLO]]:[[KHI]]{{\]}} offset:40 glc{{$}}
242 define amdgpu_kernel void @flat_atomic_dec_ret_i64_offset_addr64(i64* %out, i64* %ptr) #0 {
243 %id = call i32 @llvm.amdgcn.workitem.id.x()
244 %gep.tid = getelementptr i64, i64* %ptr, i32 %id
245 %out.gep = getelementptr i64, i64* %out, i32 %id
246 %gep = getelementptr i64, i64* %gep.tid, i32 5
247 %result = call i64 @llvm.amdgcn.atomic.dec.i64.p0i64(i64* %gep, i64 42, i32 0, i32 0, i1 false)
248 store i64 %result, i64* %out.gep
252 ; GCN-LABEL: {{^}}flat_atomic_dec_noret_i64_offset_addr64:
253 ; GCN: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
254 ; GCN: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
255 ; CIVI: flat_atomic_dec_x2 v{{\[[0-9]+:[0-9]+\]}}, v{{\[}}[[KLO]]:[[KHI]]{{\]$}}
256 ; GFX9: flat_atomic_dec_x2 v{{\[[0-9]+:[0-9]+\]}}, v{{\[}}[[KLO]]:[[KHI]]{{\]}} offset:40{{$}}
257 define amdgpu_kernel void @flat_atomic_dec_noret_i64_offset_addr64(i64* %ptr) #0 {
258 %id = call i32 @llvm.amdgcn.workitem.id.x()
259 %gep.tid = getelementptr i64, i64* %ptr, i32 %id
260 %gep = getelementptr i64, i64* %gep.tid, i32 5
261 %result = call i64 @llvm.amdgcn.atomic.dec.i64.p0i64(i64* %gep, i64 42, i32 0, i32 0, i1 false)
265 @lds0 = addrspace(3) global [512 x i32] undef
267 ; GCN-LABEL: {{^}}atomic_dec_shl_base_lds_0:
268 ; CIVI-DAG: s_mov_b32 m0
271 ; CIVI-DAG: v_lshlrev_b32_e32 [[OFS:v[0-9]+]], 2, {{v[0-9]+}}
272 ; CIVI-DAG: v_add_{{[ui]}}32_e32 [[PTR:v[0-9]+]], vcc, lds0@abs32@lo, [[OFS]]
273 ; GFX9-DAG: s_mov_b32 [[BASE:s[0-9]+]], lds0@abs32@lo
274 ; GFX9-DAG: v_lshl_add_u32 [[PTR:v[0-9]+]], {{v[0-9]+}}, 2, [[BASE]]
276 ; GCN: ds_dec_rtn_u32 {{v[0-9]+}}, [[PTR]], {{v[0-9]+}} offset:8
277 define amdgpu_kernel void @atomic_dec_shl_base_lds_0(i32 addrspace(1)* %out, i32 addrspace(1)* %add_use) #0 {
278 %tid.x = tail call i32 @llvm.amdgcn.workitem.id.x() #1
279 %idx.0 = add nsw i32 %tid.x, 2
280 %arrayidx0 = getelementptr inbounds [512 x i32], [512 x i32] addrspace(3)* @lds0, i32 0, i32 %idx.0
281 %val0 = call i32 @llvm.amdgcn.atomic.dec.i32.p3i32(i32 addrspace(3)* %arrayidx0, i32 9, i32 0, i32 0, i1 false)
282 store i32 %idx.0, i32 addrspace(1)* %add_use
283 store i32 %val0, i32 addrspace(1)* %out
287 ; GCN-LABEL: {{^}}lds_atomic_dec_ret_i64:
288 ; CIVI-DAG: s_mov_b32 m0
291 ; GCN-DAG: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
292 ; GCN-DAG: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
293 ; GCN: ds_dec_rtn_u64 v{{\[[0-9]+:[0-9]+\]}}, v{{[0-9]+}}, v{{\[}}[[KLO]]:[[KHI]]{{\]}}{{$}}
294 define amdgpu_kernel void @lds_atomic_dec_ret_i64(i64 addrspace(1)* %out, i64 addrspace(3)* %ptr) #0 {
295 %result = call i64 @llvm.amdgcn.atomic.dec.i64.p3i64(i64 addrspace(3)* %ptr, i64 42, i32 0, i32 0, i1 false)
296 store i64 %result, i64 addrspace(1)* %out
300 ; GCN-LABEL: {{^}}lds_atomic_dec_ret_i64_offset:
301 ; CIVI-DAG: s_mov_b32 m0
304 ; GCN-DAG: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
305 ; GCN-DAG: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
306 ; GCN: ds_dec_rtn_u64 v{{\[[0-9]+:[0-9]+\]}}, v{{[0-9]+}}, v{{\[}}[[KLO]]:[[KHI]]{{\]}} offset:32
307 define amdgpu_kernel void @lds_atomic_dec_ret_i64_offset(i64 addrspace(1)* %out, i64 addrspace(3)* %ptr) #0 {
308 %gep = getelementptr i64, i64 addrspace(3)* %ptr, i32 4
309 %result = call i64 @llvm.amdgcn.atomic.dec.i64.p3i64(i64 addrspace(3)* %gep, i64 42, i32 0, i32 0, i1 false)
310 store i64 %result, i64 addrspace(1)* %out
314 ; GCN-LABEL: {{^}}lds_atomic_dec_noret_i64:
315 ; CIVI-DAG: s_mov_b32 m0
318 ; GCN-DAG: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
319 ; GCN-DAG: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
320 ; GCN: ds_dec_u64 v{{[0-9]+}}, v{{\[}}[[KLO]]:[[KHI]]{{\]}}{{$}}
321 define amdgpu_kernel void @lds_atomic_dec_noret_i64(i64 addrspace(3)* %ptr) nounwind {
322 %result = call i64 @llvm.amdgcn.atomic.dec.i64.p3i64(i64 addrspace(3)* %ptr, i64 42, i32 0, i32 0, i1 false)
326 ; GCN-LABEL: {{^}}lds_atomic_dec_noret_i64_offset:
327 ; CIVI-DAG: s_mov_b32 m0
330 ; GCN-DAG: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
331 ; GCN-DAG: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
332 ; GCN: ds_dec_u64 v{{[0-9]+}}, v{{\[}}[[KLO]]:[[KHI]]{{\]}} offset:32{{$}}
333 define amdgpu_kernel void @lds_atomic_dec_noret_i64_offset(i64 addrspace(3)* %ptr) nounwind {
334 %gep = getelementptr i64, i64 addrspace(3)* %ptr, i32 4
335 %result = call i64 @llvm.amdgcn.atomic.dec.i64.p3i64(i64 addrspace(3)* %gep, i64 42, i32 0, i32 0, i1 false)
339 ; GCN-LABEL: {{^}}global_atomic_dec_ret_i64:
340 ; GCN-DAG: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
341 ; GCN-DAG: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
342 ; CIVI: buffer_atomic_dec_x2 v{{\[}}[[KLO]]:[[KHI]]{{\]}}, off, s{{\[[0-9]+:[0-9]+\]}}, 0 glc{{$}}
343 ; GFX9: global_atomic_dec_x2 v{{\[[0-9]+:[0-9]+\]}}, v{{\[[0-9]+:[0-9]+\]}}, v{{\[}}[[KLO]]:[[KHI]]{{\]}}, off glc{{$}}
344 define amdgpu_kernel void @global_atomic_dec_ret_i64(i64 addrspace(1)* %out, i64 addrspace(1)* %ptr) #0 {
345 %result = call i64 @llvm.amdgcn.atomic.dec.i64.p1i64(i64 addrspace(1)* %ptr, i64 42, i32 0, i32 0, i1 false)
346 store i64 %result, i64 addrspace(1)* %out
350 ; GCN-LABEL: {{^}}global_atomic_dec_ret_i64_offset:
351 ; GCN-DAG: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
352 ; GCN-DAG: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
353 ; CIVI: buffer_atomic_dec_x2 v{{\[}}[[KLO]]:[[KHI]]{{\]}}, off, s{{\[[0-9]+:[0-9]+\]}}, 0 offset:32 glc{{$}}
354 ; GFX9: global_atomic_dec_x2 v{{\[[0-9]+:[0-9]+\]}}, v{{\[[0-9]+:[0-9]+\]}}, v{{\[}}[[KLO]]:[[KHI]]{{\]}}, off offset:32 glc{{$}}
355 define amdgpu_kernel void @global_atomic_dec_ret_i64_offset(i64 addrspace(1)* %out, i64 addrspace(1)* %ptr) #0 {
356 %gep = getelementptr i64, i64 addrspace(1)* %ptr, i32 4
357 %result = call i64 @llvm.amdgcn.atomic.dec.i64.p1i64(i64 addrspace(1)* %gep, i64 42, i32 0, i32 0, i1 false)
358 store i64 %result, i64 addrspace(1)* %out
362 ; GCN-LABEL: {{^}}global_atomic_dec_noret_i64:
363 ; GCN-DAG: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
364 ; GCN-DAG: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
365 ; CIVI: buffer_atomic_dec_x2 v{{\[}}[[KLO]]:[[KHI]]{{\]}}, off, s{{\[[0-9]+:[0-9]+\]}}, 0{{$}}
366 ; GFX9: global_atomic_dec_x2 v{{\[[0-9]+:[0-9]+\]}}, v{{\[}}[[KLO]]:[[KHI]]{{\]}}, off{{$}}
367 define amdgpu_kernel void @global_atomic_dec_noret_i64(i64 addrspace(1)* %ptr) nounwind {
368 %result = call i64 @llvm.amdgcn.atomic.dec.i64.p1i64(i64 addrspace(1)* %ptr, i64 42, i32 0, i32 0, i1 false)
372 ; GCN-LABEL: {{^}}global_atomic_dec_noret_i64_offset:
373 ; GCN-DAG: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
374 ; GCN-DAG: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
375 ; CIVI: buffer_atomic_dec_x2 v{{\[}}[[KLO]]:[[KHI]]{{\]}}, off, s{{\[[0-9]+:[0-9]+\]}}, 0 offset:32{{$}}
376 ; GFX9: global_atomic_dec_x2 v{{\[[0-9]+:[0-9]+\]}}, v{{\[}}[[KLO]]:[[KHI]]{{\]}}, off offset:32{{$}}
377 define amdgpu_kernel void @global_atomic_dec_noret_i64_offset(i64 addrspace(1)* %ptr) nounwind {
378 %gep = getelementptr i64, i64 addrspace(1)* %ptr, i32 4
379 %result = call i64 @llvm.amdgcn.atomic.dec.i64.p1i64(i64 addrspace(1)* %gep, i64 42, i32 0, i32 0, i1 false)
383 ; GCN-LABEL: {{^}}global_atomic_dec_ret_i64_offset_addr64:
384 ; GCN: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
385 ; CI: v_mov_b32_e32 v{{[0-9]+}}, 0{{$}}
386 ; GCN: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
387 ; CI: buffer_atomic_dec_x2 v{{\[}}[[KLO]]:[[KHI]]{{\]}}, v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64 offset:40 glc{{$}}
388 ; VI: flat_atomic_dec_x2 v{{\[[0-9]+:[0-9]+\]}}, v{{\[[0-9]+:[0-9]+\]}}, v{{\[}}[[KLO]]:[[KHI]]{{\]}} glc{{$}}
389 define amdgpu_kernel void @global_atomic_dec_ret_i64_offset_addr64(i64 addrspace(1)* %out, i64 addrspace(1)* %ptr) #0 {
390 %id = call i32 @llvm.amdgcn.workitem.id.x()
391 %gep.tid = getelementptr i64, i64 addrspace(1)* %ptr, i32 %id
392 %out.gep = getelementptr i64, i64 addrspace(1)* %out, i32 %id
393 %gep = getelementptr i64, i64 addrspace(1)* %gep.tid, i32 5
394 %result = call i64 @llvm.amdgcn.atomic.dec.i64.p1i64(i64 addrspace(1)* %gep, i64 42, i32 0, i32 0, i1 false)
395 store i64 %result, i64 addrspace(1)* %out.gep
399 ; GCN-LABEL: {{^}}global_atomic_dec_noret_i64_offset_addr64:
400 ; GCN: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
401 ; CI: v_mov_b32_e32 v{{[0-9]+}}, 0{{$}}
402 ; GCN: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
403 ; CI: buffer_atomic_dec_x2 v{{\[}}[[KLO]]:[[KHI]]{{\]}}, v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64 offset:40{{$}}
404 ; VI: flat_atomic_dec_x2 v{{\[[0-9]+:[0-9]+\]}}, v{{\[}}[[KLO]]:[[KHI]]{{\]}}{{$}}
405 define amdgpu_kernel void @global_atomic_dec_noret_i64_offset_addr64(i64 addrspace(1)* %ptr) #0 {
406 %id = call i32 @llvm.amdgcn.workitem.id.x()
407 %gep.tid = getelementptr i64, i64 addrspace(1)* %ptr, i32 %id
408 %gep = getelementptr i64, i64 addrspace(1)* %gep.tid, i32 5
409 %result = call i64 @llvm.amdgcn.atomic.dec.i64.p1i64(i64 addrspace(1)* %gep, i64 42, i32 0, i32 0, i1 false)
413 @lds1 = addrspace(3) global [512 x i64] undef, align 8
415 ; GCN-LABEL: {{^}}atomic_dec_shl_base_lds_0_i64:
416 ; CIVI-DAG: s_mov_b32 m0
419 ; CIVI-DAG: v_lshlrev_b32_e32 [[OFS:v[0-9]+]], 3, {{v[0-9]+}}
420 ; CIVI-DAG: v_add_{{[ui]}}32_e32 [[PTR:v[0-9]+]], vcc, lds1@abs32@lo, [[OFS]]
421 ; GFX9-DAG: v_mov_b32_e32 [[BASE:v[0-9]+]], lds1@abs32@lo
422 ; GFX9-DAG: v_lshl_add_u32 [[PTR:v[0-9]+]], {{v[0-9]+}}, 3, [[BASE]]
424 ; GCN: ds_dec_rtn_u64 v{{\[[0-9]+:[0-9]+\]}}, [[PTR]], v{{\[[0-9]+:[0-9]+\]}} offset:16
425 define amdgpu_kernel void @atomic_dec_shl_base_lds_0_i64(i64 addrspace(1)* %out, i32 addrspace(1)* %add_use) #0 {
426 %tid.x = tail call i32 @llvm.amdgcn.workitem.id.x() #1
427 %idx.0 = add nsw i32 %tid.x, 2
428 %arrayidx0 = getelementptr inbounds [512 x i64], [512 x i64] addrspace(3)* @lds1, i32 0, i32 %idx.0
429 %val0 = call i64 @llvm.amdgcn.atomic.dec.i64.p3i64(i64 addrspace(3)* %arrayidx0, i64 9, i32 0, i32 0, i1 false)
430 store i32 %idx.0, i32 addrspace(1)* %add_use
431 store i64 %val0, i64 addrspace(1)* %out
435 attributes #0 = { nounwind }
436 attributes #1 = { nounwind readnone }
437 attributes #2 = { nounwind argmemonly }