1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -global-isel -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1030 -verify-machineinstrs < %s | FileCheck %s -check-prefix=GFX10
3 ; RUN: llc -global-isel -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1031 -verify-machineinstrs < %s | FileCheck %s -check-prefix=GFX10
4 ; RUN: llc -global-isel -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1100 -verify-machineinstrs < %s | FileCheck %s -check-prefix=GFX11
5 ; RUN: llc -global-isel -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1200 -verify-machineinstrs < %s | FileCheck %s -check-prefix=GFX12
7 define i32 @global_atomic_csub(ptr addrspace(1) %ptr, i32 %data) {
8 ; GFX10-LABEL: global_atomic_csub:
10 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
11 ; GFX10-NEXT: global_atomic_csub v0, v[0:1], v2, off glc
12 ; GFX10-NEXT: s_waitcnt vmcnt(0)
13 ; GFX10-NEXT: s_setpc_b64 s[30:31]
15 ; GFX11-LABEL: global_atomic_csub:
17 ; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
18 ; GFX11-NEXT: global_atomic_csub_u32 v0, v[0:1], v2, off glc
19 ; GFX11-NEXT: s_waitcnt vmcnt(0)
20 ; GFX11-NEXT: s_setpc_b64 s[30:31]
22 ; GFX12-LABEL: global_atomic_csub:
24 ; GFX12-NEXT: s_wait_loadcnt_dscnt 0x0
25 ; GFX12-NEXT: s_wait_expcnt 0x0
26 ; GFX12-NEXT: s_wait_samplecnt 0x0
27 ; GFX12-NEXT: s_wait_bvhcnt 0x0
28 ; GFX12-NEXT: s_wait_kmcnt 0x0
29 ; GFX12-NEXT: global_atomic_sub_clamp_u32 v0, v[0:1], v2, off th:TH_ATOMIC_RETURN
30 ; GFX12-NEXT: s_wait_loadcnt 0x0
31 ; GFX12-NEXT: s_setpc_b64 s[30:31]
32 %ret = call i32 @llvm.amdgcn.global.atomic.csub.p1(ptr addrspace(1) %ptr, i32 %data)
36 define i32 @global_atomic_csub_offset(ptr addrspace(1) %ptr, i32 %data) {
37 ; GFX10-LABEL: global_atomic_csub_offset:
39 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
40 ; GFX10-NEXT: v_add_co_u32 v0, vcc_lo, 0x1000, v0
41 ; GFX10-NEXT: v_add_co_ci_u32_e32 v1, vcc_lo, 0, v1, vcc_lo
42 ; GFX10-NEXT: global_atomic_csub v0, v[0:1], v2, off glc
43 ; GFX10-NEXT: s_waitcnt vmcnt(0)
44 ; GFX10-NEXT: s_setpc_b64 s[30:31]
46 ; GFX11-LABEL: global_atomic_csub_offset:
48 ; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
49 ; GFX11-NEXT: v_add_co_u32 v0, vcc_lo, 0x1000, v0
50 ; GFX11-NEXT: v_add_co_ci_u32_e32 v1, vcc_lo, 0, v1, vcc_lo
51 ; GFX11-NEXT: global_atomic_csub_u32 v0, v[0:1], v2, off glc
52 ; GFX11-NEXT: s_waitcnt vmcnt(0)
53 ; GFX11-NEXT: s_setpc_b64 s[30:31]
55 ; GFX12-LABEL: global_atomic_csub_offset:
57 ; GFX12-NEXT: s_wait_loadcnt_dscnt 0x0
58 ; GFX12-NEXT: s_wait_expcnt 0x0
59 ; GFX12-NEXT: s_wait_samplecnt 0x0
60 ; GFX12-NEXT: s_wait_bvhcnt 0x0
61 ; GFX12-NEXT: s_wait_kmcnt 0x0
62 ; GFX12-NEXT: global_atomic_sub_clamp_u32 v0, v[0:1], v2, off offset:4096 th:TH_ATOMIC_RETURN
63 ; GFX12-NEXT: s_wait_loadcnt 0x0
64 ; GFX12-NEXT: s_setpc_b64 s[30:31]
65 %gep = getelementptr i32, ptr addrspace(1) %ptr, i64 1024
66 %ret = call i32 @llvm.amdgcn.global.atomic.csub.p1(ptr addrspace(1) %gep, i32 %data)
70 define void @global_atomic_csub_nortn(ptr addrspace(1) %ptr, i32 %data) {
71 ; GFX10-LABEL: global_atomic_csub_nortn:
73 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
74 ; GFX10-NEXT: global_atomic_csub v0, v[0:1], v2, off glc
75 ; GFX10-NEXT: s_waitcnt vmcnt(0)
76 ; GFX10-NEXT: s_setpc_b64 s[30:31]
78 ; GFX11-LABEL: global_atomic_csub_nortn:
80 ; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
81 ; GFX11-NEXT: global_atomic_csub_u32 v0, v[0:1], v2, off glc
82 ; GFX11-NEXT: s_waitcnt vmcnt(0)
83 ; GFX11-NEXT: s_setpc_b64 s[30:31]
85 ; GFX12-LABEL: global_atomic_csub_nortn:
87 ; GFX12-NEXT: s_wait_loadcnt_dscnt 0x0
88 ; GFX12-NEXT: s_wait_expcnt 0x0
89 ; GFX12-NEXT: s_wait_samplecnt 0x0
90 ; GFX12-NEXT: s_wait_bvhcnt 0x0
91 ; GFX12-NEXT: s_wait_kmcnt 0x0
92 ; GFX12-NEXT: global_atomic_sub_clamp_u32 v0, v[0:1], v2, off th:TH_ATOMIC_RETURN
93 ; GFX12-NEXT: s_wait_loadcnt 0x0
94 ; GFX12-NEXT: s_setpc_b64 s[30:31]
95 %ret = call i32 @llvm.amdgcn.global.atomic.csub.p1(ptr addrspace(1) %ptr, i32 %data)
99 define void @global_atomic_csub_offset_nortn(ptr addrspace(1) %ptr, i32 %data) {
100 ; GFX10-LABEL: global_atomic_csub_offset_nortn:
102 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
103 ; GFX10-NEXT: v_add_co_u32 v0, vcc_lo, 0x1000, v0
104 ; GFX10-NEXT: v_add_co_ci_u32_e32 v1, vcc_lo, 0, v1, vcc_lo
105 ; GFX10-NEXT: global_atomic_csub v0, v[0:1], v2, off glc
106 ; GFX10-NEXT: s_waitcnt vmcnt(0)
107 ; GFX10-NEXT: s_setpc_b64 s[30:31]
109 ; GFX11-LABEL: global_atomic_csub_offset_nortn:
111 ; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
112 ; GFX11-NEXT: v_add_co_u32 v0, vcc_lo, 0x1000, v0
113 ; GFX11-NEXT: v_add_co_ci_u32_e32 v1, vcc_lo, 0, v1, vcc_lo
114 ; GFX11-NEXT: global_atomic_csub_u32 v0, v[0:1], v2, off glc
115 ; GFX11-NEXT: s_waitcnt vmcnt(0)
116 ; GFX11-NEXT: s_setpc_b64 s[30:31]
118 ; GFX12-LABEL: global_atomic_csub_offset_nortn:
120 ; GFX12-NEXT: s_wait_loadcnt_dscnt 0x0
121 ; GFX12-NEXT: s_wait_expcnt 0x0
122 ; GFX12-NEXT: s_wait_samplecnt 0x0
123 ; GFX12-NEXT: s_wait_bvhcnt 0x0
124 ; GFX12-NEXT: s_wait_kmcnt 0x0
125 ; GFX12-NEXT: global_atomic_sub_clamp_u32 v0, v[0:1], v2, off offset:4096 th:TH_ATOMIC_RETURN
126 ; GFX12-NEXT: s_wait_loadcnt 0x0
127 ; GFX12-NEXT: s_setpc_b64 s[30:31]
128 %gep = getelementptr i32, ptr addrspace(1) %ptr, i64 1024
129 %ret = call i32 @llvm.amdgcn.global.atomic.csub.p1(ptr addrspace(1) %gep, i32 %data)
133 define amdgpu_kernel void @global_atomic_csub_sgpr_base_offset(ptr addrspace(1) %ptr, i32 %data) {
134 ; GFX10-LABEL: global_atomic_csub_sgpr_base_offset:
136 ; GFX10-NEXT: s_clause 0x1
137 ; GFX10-NEXT: s_load_dword s2, s[6:7], 0x8
138 ; GFX10-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
139 ; GFX10-NEXT: v_mov_b32_e32 v1, 0x1000
140 ; GFX10-NEXT: s_waitcnt lgkmcnt(0)
141 ; GFX10-NEXT: v_mov_b32_e32 v0, s2
142 ; GFX10-NEXT: global_atomic_csub v0, v1, v0, s[0:1] glc
143 ; GFX10-NEXT: s_waitcnt vmcnt(0)
144 ; GFX10-NEXT: global_store_dword v[0:1], v0, off
145 ; GFX10-NEXT: s_endpgm
147 ; GFX11-LABEL: global_atomic_csub_sgpr_base_offset:
149 ; GFX11-NEXT: s_clause 0x1
150 ; GFX11-NEXT: s_load_b32 s4, s[2:3], 0x8
151 ; GFX11-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
152 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
153 ; GFX11-NEXT: v_dual_mov_b32 v1, 0x1000 :: v_dual_mov_b32 v0, s4
154 ; GFX11-NEXT: global_atomic_csub_u32 v0, v1, v0, s[0:1] glc
155 ; GFX11-NEXT: s_waitcnt vmcnt(0)
156 ; GFX11-NEXT: global_store_b32 v[0:1], v0, off
157 ; GFX11-NEXT: s_nop 0
158 ; GFX11-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
159 ; GFX11-NEXT: s_endpgm
161 ; GFX12-LABEL: global_atomic_csub_sgpr_base_offset:
163 ; GFX12-NEXT: s_load_b96 s[0:2], s[2:3], 0x0
164 ; GFX12-NEXT: s_wait_kmcnt 0x0
165 ; GFX12-NEXT: v_dual_mov_b32 v1, 0 :: v_dual_mov_b32 v0, s2
166 ; GFX12-NEXT: global_atomic_sub_clamp_u32 v0, v1, v0, s[0:1] offset:4096 th:TH_ATOMIC_RETURN
167 ; GFX12-NEXT: s_wait_loadcnt 0x0
168 ; GFX12-NEXT: global_store_b32 v[0:1], v0, off
169 ; GFX12-NEXT: s_nop 0
170 ; GFX12-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
171 ; GFX12-NEXT: s_endpgm
172 %gep = getelementptr i32, ptr addrspace(1) %ptr, i64 1024
173 %ret = call i32 @llvm.amdgcn.global.atomic.csub.p1(ptr addrspace(1) %gep, i32 %data)
174 store i32 %ret, ptr addrspace(1) undef
178 define amdgpu_kernel void @global_atomic_csub_sgpr_base_offset_nortn(ptr addrspace(1) %ptr, i32 %data) {
179 ; GFX10-LABEL: global_atomic_csub_sgpr_base_offset_nortn:
181 ; GFX10-NEXT: s_clause 0x1
182 ; GFX10-NEXT: s_load_dword s2, s[6:7], 0x8
183 ; GFX10-NEXT: s_load_dwordx2 s[0:1], s[6:7], 0x0
184 ; GFX10-NEXT: v_mov_b32_e32 v1, 0x1000
185 ; GFX10-NEXT: s_waitcnt lgkmcnt(0)
186 ; GFX10-NEXT: v_mov_b32_e32 v0, s2
187 ; GFX10-NEXT: global_atomic_csub v0, v1, v0, s[0:1] glc
188 ; GFX10-NEXT: s_endpgm
190 ; GFX11-LABEL: global_atomic_csub_sgpr_base_offset_nortn:
192 ; GFX11-NEXT: s_clause 0x1
193 ; GFX11-NEXT: s_load_b32 s4, s[2:3], 0x8
194 ; GFX11-NEXT: s_load_b64 s[0:1], s[2:3], 0x0
195 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
196 ; GFX11-NEXT: v_dual_mov_b32 v1, 0x1000 :: v_dual_mov_b32 v0, s4
197 ; GFX11-NEXT: global_atomic_csub_u32 v0, v1, v0, s[0:1] glc
198 ; GFX11-NEXT: s_endpgm
200 ; GFX12-LABEL: global_atomic_csub_sgpr_base_offset_nortn:
202 ; GFX12-NEXT: s_load_b96 s[0:2], s[2:3], 0x0
203 ; GFX12-NEXT: s_wait_kmcnt 0x0
204 ; GFX12-NEXT: v_dual_mov_b32 v1, 0 :: v_dual_mov_b32 v0, s2
205 ; GFX12-NEXT: global_atomic_sub_clamp_u32 v0, v1, v0, s[0:1] offset:4096 th:TH_ATOMIC_RETURN
206 ; GFX12-NEXT: s_endpgm
207 %gep = getelementptr i32, ptr addrspace(1) %ptr, i64 1024
208 %ret = call i32 @llvm.amdgcn.global.atomic.csub.p1(ptr addrspace(1) %gep, i32 %data)
212 declare i32 @llvm.amdgcn.global.atomic.csub.p1(ptr addrspace(1) nocapture, i32) #1
214 attributes #0 = { nounwind willreturn }
215 attributes #1 = { argmemonly nounwind }