1 ; RUN: llc -mtriple=amdgcn -mcpu=bonaire -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,CI,CIVI %s
2 ; RUN: llc -mtriple=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,VI,CIVI %s
3 ; RUN: llc -mtriple=amdgcn -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GFX9 %s
5 declare i32 @llvm.amdgcn.atomic.inc.i32.p1(ptr addrspace(1) nocapture, i32, i32, i32, i1) #2
6 declare i32 @llvm.amdgcn.atomic.inc.i32.p3(ptr addrspace(3) nocapture, i32, i32, i32, i1) #2
7 declare i32 @llvm.amdgcn.atomic.inc.i32.p0(ptr nocapture, i32, i32, i32, i1) #2
9 declare i64 @llvm.amdgcn.atomic.inc.i64.p1(ptr addrspace(1) nocapture, i64, i32, i32, i1) #2
10 declare i64 @llvm.amdgcn.atomic.inc.i64.p3(ptr addrspace(3) nocapture, i64, i32, i32, i1) #2
11 declare i64 @llvm.amdgcn.atomic.inc.i64.p0(ptr nocapture, i64, i32, i32, i1) #2
13 declare i32 @llvm.amdgcn.workitem.id.x() #1
15 ; GCN-LABEL: {{^}}lds_atomic_inc_ret_i32:
16 ; CIVI-DAG: s_mov_b32 m0
19 ; GCN-DAG: v_mov_b32_e32 [[K:v[0-9]+]], 42
20 ; GCN: ds_inc_rtn_u32 v{{[0-9]+}}, v{{[0-9]+}}, [[K]]
21 define amdgpu_kernel void @lds_atomic_inc_ret_i32(ptr addrspace(1) %out, ptr addrspace(3) %ptr) #0 {
22 %result = call i32 @llvm.amdgcn.atomic.inc.i32.p3(ptr addrspace(3) %ptr, i32 42, i32 0, i32 0, i1 false)
23 store i32 %result, ptr addrspace(1) %out
27 ; GCN-LABEL: {{^}}lds_atomic_inc_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_inc_rtn_u32 v{{[0-9]+}}, v{{[0-9]+}}, [[K]] offset:16
33 define amdgpu_kernel void @lds_atomic_inc_ret_i32_offset(ptr addrspace(1) %out, ptr addrspace(3) %ptr) #0 {
34 %gep = getelementptr i32, ptr addrspace(3) %ptr, i32 4
35 %result = call i32 @llvm.amdgcn.atomic.inc.i32.p3(ptr addrspace(3) %gep, i32 42, i32 0, i32 0, i1 false)
36 store i32 %result, ptr addrspace(1) %out
40 ; GCN-LABEL: {{^}}lds_atomic_inc_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_inc_u32 [[VPTR]], [[DATA]]
48 define amdgpu_kernel void @lds_atomic_inc_noret_i32(ptr addrspace(3) %ptr) nounwind {
49 %result = call i32 @llvm.amdgcn.atomic.inc.i32.p3(ptr addrspace(3) %ptr, i32 42, i32 0, i32 0, i1 false)
53 ; GCN-LABEL: {{^}}lds_atomic_inc_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_inc_u32 v{{[0-9]+}}, [[K]] offset:16
59 define amdgpu_kernel void @lds_atomic_inc_noret_i32_offset(ptr addrspace(3) %ptr) nounwind {
60 %gep = getelementptr i32, ptr addrspace(3) %ptr, i32 4
61 %result = call i32 @llvm.amdgcn.atomic.inc.i32.p3(ptr addrspace(3) %gep, i32 42, i32 0, i32 0, i1 false)
65 ; GCN-LABEL: {{^}}global_atomic_inc_ret_i32:
66 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 42
67 ; CIVI: buffer_atomic_inc [[K]], off, s{{\[[0-9]+:[0-9]+\]}}, 0 glc{{$}}
68 ; GFX9: global_atomic_inc v{{[0-9]+}}, v{{[0-9]+}}, [[K]], s{{\[[0-9]+:[0-9]+\]}} glc{{$}}
69 define amdgpu_kernel void @global_atomic_inc_ret_i32(ptr addrspace(1) %out, ptr addrspace(1) %ptr) #0 {
70 %result = call i32 @llvm.amdgcn.atomic.inc.i32.p1(ptr addrspace(1) %ptr, i32 42, i32 0, i32 0, i1 false)
71 store i32 %result, ptr addrspace(1) %out
75 ; GCN-LABEL: {{^}}global_atomic_inc_ret_i32_offset:
76 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 42
77 ; CIVI: buffer_atomic_inc [[K]], off, s{{\[[0-9]+:[0-9]+\]}}, 0 offset:16 glc{{$}}
78 ; GFX9: global_atomic_inc v{{[0-9]+}}, v{{[0-9]+}}, [[K]], s{{\[[0-9]+:[0-9]+\]}} offset:16 glc{{$}}
79 define amdgpu_kernel void @global_atomic_inc_ret_i32_offset(ptr addrspace(1) %out, ptr addrspace(1) %ptr) #0 {
80 %gep = getelementptr i32, ptr addrspace(1) %ptr, i32 4
81 %result = call i32 @llvm.amdgcn.atomic.inc.i32.p1(ptr addrspace(1) %gep, i32 42, i32 0, i32 0, i1 false)
82 store i32 %result, ptr addrspace(1) %out
86 ; GCN-LABEL: {{^}}global_atomic_inc_noret_i32:
87 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 42
88 ; CIVI: buffer_atomic_inc [[K]], off, s{{\[[0-9]+:[0-9]+\]}}, 0{{$}}
89 ; GFX9: global_atomic_inc v{{[0-9]+}}, [[K]], s{{\[[0-9]+:[0-9]+\]$}}
90 define amdgpu_kernel void @global_atomic_inc_noret_i32(ptr addrspace(1) %ptr) nounwind {
91 %result = call i32 @llvm.amdgcn.atomic.inc.i32.p1(ptr addrspace(1) %ptr, i32 42, i32 0, i32 0, i1 false)
95 ; GCN-LABEL: {{^}}global_atomic_inc_noret_i32_offset:
96 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 42
97 ; CIVI: buffer_atomic_inc [[K]], off, s{{\[[0-9]+:[0-9]+\]}}, 0 offset:16{{$}}
98 ; GFX9: global_atomic_inc v{{[0-9]+}}, [[K]], s{{\[[0-9]+:[0-9]+\]}} offset:16{{$}}
99 define amdgpu_kernel void @global_atomic_inc_noret_i32_offset(ptr addrspace(1) %ptr) nounwind {
100 %gep = getelementptr i32, ptr addrspace(1) %ptr, i32 4
101 %result = call i32 @llvm.amdgcn.atomic.inc.i32.p1(ptr addrspace(1) %gep, i32 42, i32 0, i32 0, i1 false)
105 ; GCN-LABEL: {{^}}global_atomic_inc_ret_i32_offset_addr64:
106 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 42
107 ; CI: buffer_atomic_inc [[K]], v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64 offset:20 glc{{$}}
108 ; VI: flat_atomic_inc v{{[0-9]+}}, v{{\[[0-9]+:[0-9]+\]}}, [[K]] glc{{$}}
109 define amdgpu_kernel void @global_atomic_inc_ret_i32_offset_addr64(ptr addrspace(1) %out, ptr addrspace(1) %ptr) #0 {
110 %id = call i32 @llvm.amdgcn.workitem.id.x()
111 %gep.tid = getelementptr i32, ptr addrspace(1) %ptr, i32 %id
112 %out.gep = getelementptr i32, ptr addrspace(1) %out, i32 %id
113 %gep = getelementptr i32, ptr addrspace(1) %gep.tid, i32 5
114 %result = call i32 @llvm.amdgcn.atomic.inc.i32.p1(ptr addrspace(1) %gep, i32 42, i32 0, i32 0, i1 false)
115 store i32 %result, ptr addrspace(1) %out.gep
119 ; GCN-LABEL: {{^}}global_atomic_inc_noret_i32_offset_addr64:
120 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 42
121 ; CI: buffer_atomic_inc [[K]], v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64 offset:20{{$}}
122 ; VI: flat_atomic_inc v{{\[[0-9]+:[0-9]+\]}}, [[K]]{{$}}
123 define amdgpu_kernel void @global_atomic_inc_noret_i32_offset_addr64(ptr addrspace(1) %ptr) #0 {
124 %id = call i32 @llvm.amdgcn.workitem.id.x()
125 %gep.tid = getelementptr i32, ptr addrspace(1) %ptr, i32 %id
126 %gep = getelementptr i32, ptr addrspace(1) %gep.tid, i32 5
127 %result = call i32 @llvm.amdgcn.atomic.inc.i32.p1(ptr addrspace(1) %gep, i32 42, i32 0, i32 0, i1 false)
131 @lds0 = addrspace(3) global [512 x i32] undef, align 4
133 ; GCN-LABEL: {{^}}atomic_inc_shl_base_lds_0_i32:
134 ; GCN: v_lshlrev_b32_e32 [[PTR:v[0-9]+]], 2, {{v[0-9]+}}
135 ; GCN: ds_inc_rtn_u32 {{v[0-9]+}}, [[PTR]], {{v[0-9]+}} offset:8
136 define amdgpu_kernel void @atomic_inc_shl_base_lds_0_i32(ptr addrspace(1) %out, ptr addrspace(1) %add_use) #0 {
137 %tid.x = tail call i32 @llvm.amdgcn.workitem.id.x() #1
138 %idx.0 = add nsw i32 %tid.x, 2
139 %arrayidx0 = getelementptr inbounds [512 x i32], ptr addrspace(3) @lds0, i32 0, i32 %idx.0
140 %val0 = call i32 @llvm.amdgcn.atomic.inc.i32.p3(ptr addrspace(3) %arrayidx0, i32 9, i32 0, i32 0, i1 false)
141 store i32 %idx.0, ptr addrspace(1) %add_use
142 store i32 %val0, ptr addrspace(1) %out
146 ; GCN-LABEL: {{^}}lds_atomic_inc_ret_i64:
147 ; GCN-DAG: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
148 ; GCN-DAG: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
149 ; GCN: ds_inc_rtn_u64 v{{\[[0-9]+:[0-9]+\]}}, v{{[0-9]+}}, v[[[KLO]]:[[KHI]]]{{$}}
150 define amdgpu_kernel void @lds_atomic_inc_ret_i64(ptr addrspace(1) %out, ptr addrspace(3) %ptr) #0 {
151 %result = call i64 @llvm.amdgcn.atomic.inc.i64.p3(ptr addrspace(3) %ptr, i64 42, i32 0, i32 0, i1 false)
152 store i64 %result, ptr addrspace(1) %out
156 ; GCN-LABEL: {{^}}lds_atomic_inc_ret_i64_offset:
157 ; GCN-DAG: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
158 ; GCN-DAG: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
159 ; GCN: ds_inc_rtn_u64 v{{\[[0-9]+:[0-9]+\]}}, v{{[0-9]+}}, v[[[KLO]]:[[KHI]]] offset:32
160 define amdgpu_kernel void @lds_atomic_inc_ret_i64_offset(ptr addrspace(1) %out, ptr addrspace(3) %ptr) #0 {
161 %gep = getelementptr i64, ptr addrspace(3) %ptr, i32 4
162 %result = call i64 @llvm.amdgcn.atomic.inc.i64.p3(ptr addrspace(3) %gep, i64 42, i32 0, i32 0, i1 false)
163 store i64 %result, ptr addrspace(1) %out
167 ; GCN-LABEL: {{^}}lds_atomic_inc_noret_i64:
168 ; GCN-DAG: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
169 ; GCN-DAG: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
170 ; GCN: ds_inc_u64 v{{[0-9]+}}, v[[[KLO]]:[[KHI]]]{{$}}
171 define amdgpu_kernel void @lds_atomic_inc_noret_i64(ptr addrspace(3) %ptr) nounwind {
172 %result = call i64 @llvm.amdgcn.atomic.inc.i64.p3(ptr addrspace(3) %ptr, i64 42, i32 0, i32 0, i1 false)
176 ; GCN-LABEL: {{^}}lds_atomic_inc_noret_i64_offset:
177 ; GCN-DAG: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
178 ; GCN-DAG: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
179 ; GCN: ds_inc_u64 v{{[0-9]+}}, v[[[KLO]]:[[KHI]]] offset:32{{$}}
180 define amdgpu_kernel void @lds_atomic_inc_noret_i64_offset(ptr addrspace(3) %ptr) nounwind {
181 %gep = getelementptr i64, ptr addrspace(3) %ptr, i32 4
182 %result = call i64 @llvm.amdgcn.atomic.inc.i64.p3(ptr addrspace(3) %gep, i64 42, i32 0, i32 0, i1 false)
186 ; GCN-LABEL: {{^}}global_atomic_inc_ret_i64:
187 ; GCN-DAG: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
188 ; GCN-DAG: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
189 ; GFX9: v_mov_b32_e32 v[[ZERO:[0-9]+]], 0{{$}}
190 ; CIVI: buffer_atomic_inc_x2 v[[[KLO]]:[[KHI]]], off, s{{\[[0-9]+:[0-9]+\]}}, 0 glc{{$}}
191 ; GFX9: global_atomic_inc_x2 v{{\[[0-9]+:[0-9]+\]}}, v[[ZERO]], v[[[KLO]]:[[KHI]]], s{{\[[0-9]+:[0-9]+\]}} glc{{$}}
192 define amdgpu_kernel void @global_atomic_inc_ret_i64(ptr addrspace(1) %out, ptr addrspace(1) %ptr) #0 {
193 %result = call i64 @llvm.amdgcn.atomic.inc.i64.p1(ptr addrspace(1) %ptr, i64 42, i32 0, i32 0, i1 false)
194 store i64 %result, ptr addrspace(1) %out
198 ; GCN-LABEL: {{^}}global_atomic_inc_ret_i64_offset:
199 ; GCN: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
200 ; GCN: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
201 ; GFX9: v_mov_b32_e32 v[[ZERO:[0-9]+]], 0{{$}}
202 ; CIVI: buffer_atomic_inc_x2 v[[[KLO]]:[[KHI]]], off, s{{\[[0-9]+:[0-9]+\]}}, 0 offset:32 glc{{$}}
203 ; GFX9: global_atomic_inc_x2 v{{\[[0-9]+:[0-9]+\]}}, v[[ZERO]], v[[[KLO]]:[[KHI]]], s{{\[[0-9]+:[0-9]+\]}} offset:32 glc{{$}}
204 define amdgpu_kernel void @global_atomic_inc_ret_i64_offset(ptr addrspace(1) %out, ptr addrspace(1) %ptr) #0 {
205 %gep = getelementptr i64, ptr addrspace(1) %ptr, i32 4
206 %result = call i64 @llvm.amdgcn.atomic.inc.i64.p1(ptr addrspace(1) %gep, i64 42, i32 0, i32 0, i1 false)
207 store i64 %result, ptr addrspace(1) %out
211 ; GCN-LABEL: {{^}}global_atomic_inc_noret_i64:
212 ; GCN-DAG: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
213 ; GCN-DAG: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
214 ; GFX9: v_mov_b32_e32 v[[ZERO:[0-9]+]], 0{{$}}
215 ; CIVI: buffer_atomic_inc_x2 v[[[KLO]]:[[KHI]]], off, s{{\[[0-9]+:[0-9]+\]}}, 0{{$}}
217 ; GFX9: global_atomic_inc_x2 v[[ZERO]], v[[[KLO]]:[[KHI]]], s{{\[[0-9]+:[0-9]+\]$}}
218 define amdgpu_kernel void @global_atomic_inc_noret_i64(ptr addrspace(1) %ptr) nounwind {
219 %result = call i64 @llvm.amdgcn.atomic.inc.i64.p1(ptr addrspace(1) %ptr, i64 42, i32 0, i32 0, i1 false)
223 ; GCN-LABEL: {{^}}global_atomic_inc_noret_i64_offset:
224 ; GCN-DAG: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
225 ; GCN-DAG: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
226 ; GFX9: v_mov_b32_e32 v[[ZERO:[0-9]+]], 0{{$}}
227 ; CIVI: buffer_atomic_inc_x2 v[[[KLO]]:[[KHI]]], off, s{{\[[0-9]+:[0-9]+\]}}, 0 offset:32{{$}}
228 ; GFX9: global_atomic_inc_x2 v[[ZERO]], v[[[KLO]]:[[KHI]]], s{{\[[0-9]+:[0-9]+\]}} offset:32{{$}}
229 define amdgpu_kernel void @global_atomic_inc_noret_i64_offset(ptr addrspace(1) %ptr) nounwind {
230 %gep = getelementptr i64, ptr addrspace(1) %ptr, i32 4
231 %result = call i64 @llvm.amdgcn.atomic.inc.i64.p1(ptr addrspace(1) %gep, i64 42, i32 0, i32 0, i1 false)
235 ; GCN-LABEL: {{^}}global_atomic_inc_ret_i64_offset_addr64:
236 ; GCN: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
237 ; CI: v_mov_b32_e32 v{{[0-9]+}}, 0{{$}}
238 ; GCN: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
239 ; CI: buffer_atomic_inc_x2 v[[[KLO]]:[[KHI]]], v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64 offset:40 glc{{$}}
240 ; VI: flat_atomic_inc_x2 v{{\[[0-9]+:[0-9]+\]}}, v{{\[[0-9]+:[0-9]+\]}}, v[[[KLO]]:[[KHI]]] glc{{$}}
241 define amdgpu_kernel void @global_atomic_inc_ret_i64_offset_addr64(ptr addrspace(1) %out, ptr addrspace(1) %ptr) #0 {
242 %id = call i32 @llvm.amdgcn.workitem.id.x()
243 %gep.tid = getelementptr i64, ptr addrspace(1) %ptr, i32 %id
244 %out.gep = getelementptr i64, ptr addrspace(1) %out, i32 %id
245 %gep = getelementptr i64, ptr addrspace(1) %gep.tid, i32 5
246 %result = call i64 @llvm.amdgcn.atomic.inc.i64.p1(ptr addrspace(1) %gep, i64 42, i32 0, i32 0, i1 false)
247 store i64 %result, ptr addrspace(1) %out.gep
251 ; GCN-LABEL: {{^}}global_atomic_inc_noret_i64_offset_addr64:
252 ; GCN: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
253 ; CI: v_mov_b32_e32 v{{[0-9]+}}, 0{{$}}
254 ; GCN: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
255 ; CI: buffer_atomic_inc_x2 v[[[KLO]]:[[KHI]]], v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64 offset:40{{$}}
256 ; VI: flat_atomic_inc_x2 v{{\[[0-9]+:[0-9]+\]}}, v[[[KLO]]:[[KHI]]]{{$}}
257 define amdgpu_kernel void @global_atomic_inc_noret_i64_offset_addr64(ptr addrspace(1) %ptr) #0 {
258 %id = call i32 @llvm.amdgcn.workitem.id.x()
259 %gep.tid = getelementptr i64, ptr addrspace(1) %ptr, i32 %id
260 %gep = getelementptr i64, ptr addrspace(1) %gep.tid, i32 5
261 %result = call i64 @llvm.amdgcn.atomic.inc.i64.p1(ptr addrspace(1) %gep, i64 42, i32 0, i32 0, i1 false)
265 ; GCN-LABEL: {{^}}flat_atomic_inc_ret_i32:
266 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 42
267 ; GCN: flat_atomic_inc v{{[0-9]+}}, v{{\[[0-9]+:[0-9]+\]}}, [[K]] glc{{$}}
268 define amdgpu_kernel void @flat_atomic_inc_ret_i32(ptr %out, ptr %ptr) #0 {
269 %result = call i32 @llvm.amdgcn.atomic.inc.i32.p0(ptr %ptr, i32 42, i32 0, i32 0, i1 false)
270 store i32 %result, ptr %out
274 ; GCN-LABEL: {{^}}flat_atomic_inc_ret_i32_offset:
275 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 42
276 ; CIVI: flat_atomic_inc v{{[0-9]+}}, v{{\[[0-9]+:[0-9]+\]}}, [[K]] glc{{$}}
277 ; GFX9: flat_atomic_inc v{{[0-9]+}}, v{{\[[0-9]+:[0-9]+\]}}, [[K]] offset:16 glc{{$}}
278 define amdgpu_kernel void @flat_atomic_inc_ret_i32_offset(ptr %out, ptr %ptr) #0 {
279 %gep = getelementptr i32, ptr %ptr, i32 4
280 %result = call i32 @llvm.amdgcn.atomic.inc.i32.p0(ptr %gep, i32 42, i32 0, i32 0, i1 false)
281 store i32 %result, ptr %out
285 ; GCN-LABEL: {{^}}flat_atomic_inc_noret_i32:
286 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 42
287 ; GCN: flat_atomic_inc v{{\[[0-9]+:[0-9]+\]}}, [[K]]{{$}}
288 define amdgpu_kernel void @flat_atomic_inc_noret_i32(ptr %ptr) nounwind {
289 %result = call i32 @llvm.amdgcn.atomic.inc.i32.p0(ptr %ptr, i32 42, i32 0, i32 0, i1 false)
293 ; GCN-LABEL: {{^}}flat_atomic_inc_noret_i32_offset:
294 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 42
295 ; CIVI: flat_atomic_inc v{{\[[0-9]+:[0-9]+\]}}, [[K]]{{$}}
296 ; GFX9: flat_atomic_inc v{{\[[0-9]+:[0-9]+\]}}, [[K]] offset:16{{$}}
297 define amdgpu_kernel void @flat_atomic_inc_noret_i32_offset(ptr %ptr) nounwind {
298 %gep = getelementptr i32, ptr %ptr, i32 4
299 %result = call i32 @llvm.amdgcn.atomic.inc.i32.p0(ptr %gep, i32 42, i32 0, i32 0, i1 false)
303 ; GCN-LABEL: {{^}}flat_atomic_inc_ret_i32_offset_addr64:
304 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 42
305 ; CIVI: flat_atomic_inc v{{[0-9]+}}, v{{\[[0-9]+:[0-9]+\]}}, [[K]] glc{{$}}
306 ; GFX9: flat_atomic_inc v{{[0-9]+}}, v{{\[[0-9]+:[0-9]+\]}}, [[K]] offset:20 glc{{$}}
307 define amdgpu_kernel void @flat_atomic_inc_ret_i32_offset_addr64(ptr %out, ptr %ptr) #0 {
308 %id = call i32 @llvm.amdgcn.workitem.id.x()
309 %gep.tid = getelementptr i32, ptr %ptr, i32 %id
310 %out.gep = getelementptr i32, ptr %out, i32 %id
311 %gep = getelementptr i32, ptr %gep.tid, i32 5
312 %result = call i32 @llvm.amdgcn.atomic.inc.i32.p0(ptr %gep, i32 42, i32 0, i32 0, i1 false)
313 store i32 %result, ptr %out.gep
317 ; GCN-LABEL: {{^}}flat_atomic_inc_noret_i32_offset_addr64:
318 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 42
319 ; CIVI: flat_atomic_inc v{{\[[0-9]+:[0-9]+\]}}, [[K]]{{$}}
320 ; GFX9: flat_atomic_inc v{{\[[0-9]+:[0-9]+\]}}, [[K]] offset:20{{$}}
321 define amdgpu_kernel void @flat_atomic_inc_noret_i32_offset_addr64(ptr %ptr) #0 {
322 %id = call i32 @llvm.amdgcn.workitem.id.x()
323 %gep.tid = getelementptr i32, ptr %ptr, i32 %id
324 %gep = getelementptr i32, ptr %gep.tid, i32 5
325 %result = call i32 @llvm.amdgcn.atomic.inc.i32.p0(ptr %gep, i32 42, i32 0, i32 0, i1 false)
329 @lds1 = addrspace(3) global [512 x i64] undef, align 8
331 ; GCN-LABEL: {{^}}atomic_inc_shl_base_lds_0_i64:
332 ; GCN: v_lshlrev_b32_e32 [[PTR:v[0-9]+]], 3, {{v[0-9]+}}
333 ; GCN: ds_inc_rtn_u64 v{{\[[0-9]+:[0-9]+\]}}, [[PTR]], v{{\[[0-9]+:[0-9]+\]}} offset:16
334 define amdgpu_kernel void @atomic_inc_shl_base_lds_0_i64(ptr addrspace(1) %out, ptr addrspace(1) %add_use) #0 {
335 %tid.x = tail call i32 @llvm.amdgcn.workitem.id.x() #1
336 %idx.0 = add nsw i32 %tid.x, 2
337 %arrayidx0 = getelementptr inbounds [512 x i64], ptr addrspace(3) @lds1, i32 0, i32 %idx.0
338 %val0 = call i64 @llvm.amdgcn.atomic.inc.i64.p3(ptr addrspace(3) %arrayidx0, i64 9, i32 0, i32 0, i1 false)
339 store i32 %idx.0, ptr addrspace(1) %add_use
340 store i64 %val0, ptr addrspace(1) %out
344 ; GCN-LABEL: {{^}}flat_atomic_inc_ret_i64:
345 ; GCN-DAG: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
346 ; GCN-DAG: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
347 ; GCN: flat_atomic_inc_x2 v{{\[[0-9]+:[0-9]+\]}}, v{{\[[0-9]+:[0-9]+\]}}, v[[[KLO]]:[[KHI]]] glc{{$}}
348 define amdgpu_kernel void @flat_atomic_inc_ret_i64(ptr %out, ptr %ptr) #0 {
349 %result = call i64 @llvm.amdgcn.atomic.inc.i64.p0(ptr %ptr, i64 42, i32 0, i32 0, i1 false)
350 store i64 %result, ptr %out
354 ; GCN-LABEL: {{^}}flat_atomic_inc_ret_i64_offset:
355 ; GCN-DAG: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
356 ; GCN-DAG: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
357 ; CIVI: flat_atomic_inc_x2 v{{\[[0-9]+:[0-9]+\]}}, v{{\[[0-9]+:[0-9]+\]}}, v[[[KLO]]:[[KHI]]] glc{{$}}
358 ; GFX9: flat_atomic_inc_x2 v{{\[[0-9]+:[0-9]+\]}}, v{{\[[0-9]+:[0-9]+\]}}, v[[[KLO]]:[[KHI]]] offset:32 glc{{$}}
359 define amdgpu_kernel void @flat_atomic_inc_ret_i64_offset(ptr %out, ptr %ptr) #0 {
360 %gep = getelementptr i64, ptr %ptr, i32 4
361 %result = call i64 @llvm.amdgcn.atomic.inc.i64.p0(ptr %gep, i64 42, i32 0, i32 0, i1 false)
362 store i64 %result, ptr %out
366 ; GCN-LABEL: {{^}}flat_atomic_inc_noret_i64:
367 ; GCN-DAG: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
368 ; GCN-DAG: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
369 ; GCN: flat_atomic_inc_x2 v{{\[[0-9]+:[0-9]+\]}}, v[[[KLO]]:[[KHI]]{{\]$}}
370 define amdgpu_kernel void @flat_atomic_inc_noret_i64(ptr %ptr) nounwind {
371 %result = call i64 @llvm.amdgcn.atomic.inc.i64.p0(ptr %ptr, i64 42, i32 0, i32 0, i1 false)
375 ; GCN-LABEL: {{^}}flat_atomic_inc_noret_i64_offset:
376 ; GCN-DAG: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
377 ; GCN-DAG: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
378 ; CIVI: flat_atomic_inc_x2 v{{\[[0-9]+:[0-9]+\]}}, v[[[KLO]]:[[KHI]]{{\]$}}
379 ; GFX9: flat_atomic_inc_x2 v{{\[[0-9]+:[0-9]+\]}}, v[[[KLO]]:[[KHI]]] offset:32{{$}}
380 define amdgpu_kernel void @flat_atomic_inc_noret_i64_offset(ptr %ptr) nounwind {
381 %gep = getelementptr i64, ptr %ptr, i32 4
382 %result = call i64 @llvm.amdgcn.atomic.inc.i64.p0(ptr %gep, i64 42, i32 0, i32 0, i1 false)
386 ; GCN-LABEL: {{^}}flat_atomic_inc_ret_i64_offset_addr64:
387 ; GCN: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
388 ; GCN: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
389 ; CIVI: flat_atomic_inc_x2 v{{\[[0-9]+:[0-9]+\]}}, v{{\[[0-9]+:[0-9]+\]}}, v[[[KLO]]:[[KHI]]] glc{{$}}
390 ; GFX9: flat_atomic_inc_x2 v{{\[[0-9]+:[0-9]+\]}}, v{{\[[0-9]+:[0-9]+\]}}, v[[[KLO]]:[[KHI]]] offset:40 glc{{$}}
391 define amdgpu_kernel void @flat_atomic_inc_ret_i64_offset_addr64(ptr %out, ptr %ptr) #0 {
392 %id = call i32 @llvm.amdgcn.workitem.id.x()
393 %gep.tid = getelementptr i64, ptr %ptr, i32 %id
394 %out.gep = getelementptr i64, ptr %out, i32 %id
395 %gep = getelementptr i64, ptr %gep.tid, i32 5
396 %result = call i64 @llvm.amdgcn.atomic.inc.i64.p0(ptr %gep, i64 42, i32 0, i32 0, i1 false)
397 store i64 %result, ptr %out.gep
401 ; GCN-LABEL: {{^}}flat_atomic_inc_noret_i64_offset_addr64:
402 ; GCN: v_mov_b32_e32 v[[KLO:[0-9]+]], 42
403 ; GCN: v_mov_b32_e32 v[[KHI:[0-9]+]], 0{{$}}
404 ; CIVI: flat_atomic_inc_x2 v{{\[[0-9]+:[0-9]+\]}}, v[[[KLO]]:[[KHI]]{{\]$}}
405 ; GFX9: flat_atomic_inc_x2 v{{\[[0-9]+:[0-9]+\]}}, v[[[KLO]]:[[KHI]]] offset:40{{$}}
406 define amdgpu_kernel void @flat_atomic_inc_noret_i64_offset_addr64(ptr %ptr) #0 {
407 %id = call i32 @llvm.amdgcn.workitem.id.x()
408 %gep.tid = getelementptr i64, ptr %ptr, i32 %id
409 %gep = getelementptr i64, ptr %gep.tid, i32 5
410 %result = call i64 @llvm.amdgcn.atomic.inc.i64.p0(ptr %gep, i64 42, i32 0, i32 0, i1 false)
414 ; GCN-LABEL: {{^}}nocse_lds_atomic_inc_ret_i32:
415 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 42
416 ; GCN: ds_inc_rtn_u32 v{{[0-9]+}}, v{{[0-9]+}}, [[K]]
417 ; GCN: ds_inc_rtn_u32 v{{[0-9]+}}, v{{[0-9]+}}, [[K]]
418 define amdgpu_kernel void @nocse_lds_atomic_inc_ret_i32(ptr addrspace(1) %out0, ptr addrspace(1) %out1, ptr addrspace(3) %ptr) #0 {
419 %result0 = call i32 @llvm.amdgcn.atomic.inc.i32.p3(ptr addrspace(3) %ptr, i32 42, i32 0, i32 0, i1 false)
420 %result1 = call i32 @llvm.amdgcn.atomic.inc.i32.p3(ptr addrspace(3) %ptr, i32 42, i32 0, i32 0, i1 false)
422 store i32 %result0, ptr addrspace(1) %out0
423 store i32 %result1, ptr addrspace(1) %out1
427 attributes #0 = { nounwind }
428 attributes #1 = { nounwind readnone }
429 attributes #2 = { nounwind argmemonly }