1; RUN: llc < %s -march=amdgcn -mcpu=gfx1030 -verify-machineinstrs | FileCheck %s -check-prefix=GCN
2; RUN: llc < %s -march=amdgcn -mcpu=gfx1031 -verify-machineinstrs | FileCheck %s -check-prefix=GCN
3
4declare i32 @llvm.amdgcn.buffer.atomic.csub(i32, <4 x i32>, i32, i32, i1)
5declare i32 @llvm.amdgcn.global.atomic.csub(i32 addrspace(1)*, i32)
6
7; GCN-LABEL: {{^}}buffer_atomic_csub:
8; GCN: buffer_atomic_csub v0, v1, s[0:3], 0 idxen glc
9define amdgpu_ps void @buffer_atomic_csub(<4 x i32> inreg %rsrc, i32 %data, i32 %vindex) {
10main_body:
11  %ret = call i32 @llvm.amdgcn.buffer.atomic.csub(i32 %data, <4 x i32> %rsrc, i32 %vindex, i32 0, i1 0)
12  ret void
13}
14
15; GCN-LABEL: {{^}}buffer_atomic_csub_off4_slc:
16; GCN: buffer_atomic_csub v0, v1, s[0:3], 0 idxen offset:4 glc slc
17define amdgpu_ps void @buffer_atomic_csub_off4_slc(<4 x i32> inreg %rsrc, i32 %data, i32 %vindex) {
18main_body:
19  %ret = call i32 @llvm.amdgcn.buffer.atomic.csub(i32 %data, <4 x i32> %rsrc, i32 %vindex, i32 4, i1 1)
20  ret void
21}
22
23; GCN-LABEL: {{^}}global_atomic_csub:
24; GCN: global_atomic_csub v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9:]+}}, s{{\[[0-9]+:[0-9]+\]}} glc
25define amdgpu_kernel void @global_atomic_csub(i32 addrspace(1)* %ptr, i32 %data) {
26main_body:
27  %ret = call i32 @llvm.amdgcn.global.atomic.csub(i32 addrspace(1)* %ptr, i32 %data)
28  ret void
29}
30
31; GCN-LABEL: {{^}}global_atomic_csub_off4:
32; GCN: global_atomic_csub v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}, s{{\[[0-9]+:[0-9]+\]}} offset:4 glc
33define amdgpu_kernel void @global_atomic_csub_off4(i32 addrspace(1)* %ptr, i32 %data) {
34main_body:
35  %p = getelementptr i32, i32 addrspace(1)* %ptr, i64 1
36  %ret = call i32 @llvm.amdgcn.global.atomic.csub(i32 addrspace(1)* %p, i32 %data)
37  ret void
38}
39