1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx900 -mattr=-architected-sgprs -global-isel=0 -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX9-SDAG %s
3 ; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx900 -mattr=-architected-sgprs -global-isel=1 -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX9-GISEL %s
4 ; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx900 -mattr=+architected-sgprs -global-isel=0 -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX9ARCH-SDAG %s
5 ; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx900 -mattr=+architected-sgprs -global-isel=1 -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX9ARCH-GISEL %s
6 ; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx1200 -global-isel=0 -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX12,GFX12-SDAG %s
7 ; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx1200 -global-isel=1 -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX12,GFX12-GISEL %s
9 define amdgpu_cs void @_amdgpu_cs_main() {
10 ; GFX9-LABEL: _amdgpu_cs_main:
11 ; GFX9: ; %bb.0: ; %.entry
12 ; GFX9-NEXT: buffer_store_dwordx3 v[0:2], off, s[0:3], 0
15 ; GFX9-SDAG-LABEL: _amdgpu_cs_main:
16 ; GFX9-SDAG: ; %bb.0: ; %.entry
17 ; GFX9-SDAG-NEXT: buffer_store_dwordx3 v[0:2], off, s[0:3], 0
18 ; GFX9-SDAG-NEXT: s_endpgm
20 ; GFX9-GISEL-LABEL: _amdgpu_cs_main:
21 ; GFX9-GISEL: ; %bb.0: ; %.entry
22 ; GFX9-GISEL-NEXT: buffer_store_dwordx3 v[0:2], off, s[0:3], 0
23 ; GFX9-GISEL-NEXT: s_endpgm
25 ; GFX9ARCH-SDAG-LABEL: _amdgpu_cs_main:
26 ; GFX9ARCH-SDAG: ; %bb.0: ; %.entry
27 ; GFX9ARCH-SDAG-NEXT: s_lshr_b32 s0, ttmp7, 16
28 ; GFX9ARCH-SDAG-NEXT: s_and_b32 s1, ttmp7, 0xffff
29 ; GFX9ARCH-SDAG-NEXT: v_mov_b32_e32 v0, ttmp9
30 ; GFX9ARCH-SDAG-NEXT: v_mov_b32_e32 v1, s1
31 ; GFX9ARCH-SDAG-NEXT: v_mov_b32_e32 v2, s0
32 ; GFX9ARCH-SDAG-NEXT: buffer_store_dwordx3 v[0:2], off, s[0:3], 0
33 ; GFX9ARCH-SDAG-NEXT: s_endpgm
35 ; GFX9ARCH-GISEL-LABEL: _amdgpu_cs_main:
36 ; GFX9ARCH-GISEL: ; %bb.0: ; %.entry
37 ; GFX9ARCH-GISEL-NEXT: s_mov_b32 s0, ttmp9
38 ; GFX9ARCH-GISEL-NEXT: s_and_b32 s1, ttmp7, 0xffff
39 ; GFX9ARCH-GISEL-NEXT: s_lshr_b32 s2, ttmp7, 16
40 ; GFX9ARCH-GISEL-NEXT: v_mov_b32_e32 v0, s0
41 ; GFX9ARCH-GISEL-NEXT: v_mov_b32_e32 v1, s1
42 ; GFX9ARCH-GISEL-NEXT: v_mov_b32_e32 v2, s2
43 ; GFX9ARCH-GISEL-NEXT: buffer_store_dwordx3 v[0:2], off, s[0:3], 0
44 ; GFX9ARCH-GISEL-NEXT: s_endpgm
46 ; GFX12-SDAG-LABEL: _amdgpu_cs_main:
47 ; GFX12-SDAG: ; %bb.0: ; %.entry
48 ; GFX12-SDAG-NEXT: s_and_b32 s0, ttmp7, 0xffff
49 ; GFX12-SDAG-NEXT: s_lshr_b32 s1, ttmp7, 16
50 ; GFX12-SDAG-NEXT: v_dual_mov_b32 v0, ttmp9 :: v_dual_mov_b32 v1, s0
51 ; GFX12-SDAG-NEXT: v_mov_b32_e32 v2, s1
52 ; GFX12-SDAG-NEXT: buffer_store_b96 v[0:2], off, s[0:3], null
53 ; GFX12-SDAG-NEXT: s_endpgm
55 ; GFX12-GISEL-LABEL: _amdgpu_cs_main:
56 ; GFX12-GISEL: ; %bb.0: ; %.entry
57 ; GFX12-GISEL-NEXT: s_mov_b32 s0, ttmp9
58 ; GFX12-GISEL-NEXT: s_and_b32 s1, ttmp7, 0xffff
59 ; GFX12-GISEL-NEXT: s_lshr_b32 s2, ttmp7, 16
60 ; GFX12-GISEL-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
61 ; GFX12-GISEL-NEXT: v_mov_b32_e32 v2, s2
62 ; GFX12-GISEL-NEXT: buffer_store_b96 v[0:2], off, s[0:3], null
63 ; GFX12-GISEL-NEXT: s_endpgm
65 %idx = call i32 @llvm.amdgcn.workgroup.id.x()
66 %idy = call i32 @llvm.amdgcn.workgroup.id.y()
67 %idz = call i32 @llvm.amdgcn.workgroup.id.z()
68 %ielemx = insertelement <3 x i32> undef, i32 %idx, i64 0
69 %ielemy = insertelement <3 x i32> %ielemx, i32 %idy, i64 1
70 %ielemz = insertelement <3 x i32> %ielemy, i32 %idz, i64 2
71 call void @llvm.amdgcn.raw.ptr.buffer.store.v3i32(<3 x i32> %ielemz, ptr addrspace(8) undef, i32 0, i32 0, i32 0)
75 define amdgpu_cs void @caller() {
76 ; GFX9-SDAG-LABEL: caller:
78 ; GFX9-SDAG-NEXT: s_getpc_b64 s[8:9]
79 ; GFX9-SDAG-NEXT: s_mov_b32 s8, s0
80 ; GFX9-SDAG-NEXT: s_load_dwordx4 s[8:11], s[8:9], 0x10
81 ; GFX9-SDAG-NEXT: s_mov_b32 s5, callee@abs32@hi
82 ; GFX9-SDAG-NEXT: s_mov_b32 s4, callee@abs32@lo
83 ; GFX9-SDAG-NEXT: s_mov_b32 s32, 0
84 ; GFX9-SDAG-NEXT: s_waitcnt lgkmcnt(0)
85 ; GFX9-SDAG-NEXT: s_add_u32 s8, s8, s0
86 ; GFX9-SDAG-NEXT: s_addc_u32 s9, s9, 0
87 ; GFX9-SDAG-NEXT: s_mov_b64 s[0:1], s[8:9]
88 ; GFX9-SDAG-NEXT: s_mov_b64 s[2:3], s[10:11]
89 ; GFX9-SDAG-NEXT: s_swappc_b64 s[30:31], s[4:5]
90 ; GFX9-SDAG-NEXT: s_endpgm
92 ; GFX9-GISEL-LABEL: caller:
93 ; GFX9-GISEL: ; %bb.0:
94 ; GFX9-GISEL-NEXT: s_getpc_b64 s[8:9]
95 ; GFX9-GISEL-NEXT: s_mov_b32 s8, s0
96 ; GFX9-GISEL-NEXT: s_load_dwordx4 s[8:11], s[8:9], 0x10
97 ; GFX9-GISEL-NEXT: s_mov_b32 s4, callee@abs32@lo
98 ; GFX9-GISEL-NEXT: s_mov_b32 s5, callee@abs32@hi
99 ; GFX9-GISEL-NEXT: s_mov_b32 s32, 0
100 ; GFX9-GISEL-NEXT: s_waitcnt lgkmcnt(0)
101 ; GFX9-GISEL-NEXT: s_add_u32 s8, s8, s0
102 ; GFX9-GISEL-NEXT: s_addc_u32 s9, s9, 0
103 ; GFX9-GISEL-NEXT: s_mov_b64 s[0:1], s[8:9]
104 ; GFX9-GISEL-NEXT: s_mov_b64 s[2:3], s[10:11]
105 ; GFX9-GISEL-NEXT: s_swappc_b64 s[30:31], s[4:5]
106 ; GFX9-GISEL-NEXT: s_endpgm
108 ; GFX9ARCH-SDAG-LABEL: caller:
109 ; GFX9ARCH-SDAG: ; %bb.0:
110 ; GFX9ARCH-SDAG-NEXT: s_getpc_b64 s[8:9]
111 ; GFX9ARCH-SDAG-NEXT: s_mov_b32 s8, s0
112 ; GFX9ARCH-SDAG-NEXT: s_load_dwordx4 s[8:11], s[8:9], 0x10
113 ; GFX9ARCH-SDAG-NEXT: s_mov_b32 s5, callee@abs32@hi
114 ; GFX9ARCH-SDAG-NEXT: s_mov_b32 s4, callee@abs32@lo
115 ; GFX9ARCH-SDAG-NEXT: v_mov_b32_e32 v0, ttmp9
116 ; GFX9ARCH-SDAG-NEXT: s_mov_b32 s32, 0
117 ; GFX9ARCH-SDAG-NEXT: s_waitcnt lgkmcnt(0)
118 ; GFX9ARCH-SDAG-NEXT: s_add_u32 s8, s8, s0
119 ; GFX9ARCH-SDAG-NEXT: s_addc_u32 s9, s9, 0
120 ; GFX9ARCH-SDAG-NEXT: s_mov_b64 s[0:1], s[8:9]
121 ; GFX9ARCH-SDAG-NEXT: s_mov_b64 s[2:3], s[10:11]
122 ; GFX9ARCH-SDAG-NEXT: s_swappc_b64 s[30:31], s[4:5]
123 ; GFX9ARCH-SDAG-NEXT: s_endpgm
125 ; GFX9ARCH-GISEL-LABEL: caller:
126 ; GFX9ARCH-GISEL: ; %bb.0:
127 ; GFX9ARCH-GISEL-NEXT: s_getpc_b64 s[8:9]
128 ; GFX9ARCH-GISEL-NEXT: s_mov_b32 s8, s0
129 ; GFX9ARCH-GISEL-NEXT: s_load_dwordx4 s[8:11], s[8:9], 0x10
130 ; GFX9ARCH-GISEL-NEXT: s_mov_b32 s4, callee@abs32@lo
131 ; GFX9ARCH-GISEL-NEXT: s_mov_b32 s5, callee@abs32@hi
132 ; GFX9ARCH-GISEL-NEXT: v_mov_b32_e32 v0, ttmp9
133 ; GFX9ARCH-GISEL-NEXT: s_mov_b32 s32, 0
134 ; GFX9ARCH-GISEL-NEXT: s_waitcnt lgkmcnt(0)
135 ; GFX9ARCH-GISEL-NEXT: s_add_u32 s8, s8, s0
136 ; GFX9ARCH-GISEL-NEXT: s_addc_u32 s9, s9, 0
137 ; GFX9ARCH-GISEL-NEXT: s_mov_b64 s[0:1], s[8:9]
138 ; GFX9ARCH-GISEL-NEXT: s_mov_b64 s[2:3], s[10:11]
139 ; GFX9ARCH-GISEL-NEXT: s_swappc_b64 s[30:31], s[4:5]
140 ; GFX9ARCH-GISEL-NEXT: s_endpgm
142 ; GFX12-SDAG-LABEL: caller:
143 ; GFX12-SDAG: ; %bb.0:
144 ; GFX12-SDAG-NEXT: v_mov_b32_e32 v0, ttmp9
145 ; GFX12-SDAG-NEXT: s_mov_b32 s1, callee@abs32@hi
146 ; GFX12-SDAG-NEXT: s_mov_b32 s0, callee@abs32@lo
147 ; GFX12-SDAG-NEXT: s_mov_b32 s32, 0
148 ; GFX12-SDAG-NEXT: s_wait_alu 0xfffe
149 ; GFX12-SDAG-NEXT: s_swappc_b64 s[30:31], s[0:1]
150 ; GFX12-SDAG-NEXT: s_endpgm
152 ; GFX12-GISEL-LABEL: caller:
153 ; GFX12-GISEL: ; %bb.0:
154 ; GFX12-GISEL-NEXT: v_mov_b32_e32 v0, ttmp9
155 ; GFX12-GISEL-NEXT: s_mov_b32 s0, callee@abs32@lo
156 ; GFX12-GISEL-NEXT: s_mov_b32 s1, callee@abs32@hi
157 ; GFX12-GISEL-NEXT: s_mov_b32 s32, 0
158 ; GFX12-GISEL-NEXT: s_wait_alu 0xfffe
159 ; GFX12-GISEL-NEXT: s_swappc_b64 s[30:31], s[0:1]
160 ; GFX12-GISEL-NEXT: s_endpgm
161 %idx = call i32 @llvm.amdgcn.workgroup.id.x()
162 call amdgpu_gfx void @callee(i32 %idx)
166 declare amdgpu_gfx void @callee(i32)
168 define amdgpu_gfx void @workgroup_ids_gfx(ptr addrspace(1) %outx, ptr addrspace(1) %outy, ptr addrspace(1) %outz) {
169 ; GFX9-SDAG-LABEL: workgroup_ids_gfx:
170 ; GFX9-SDAG: ; %bb.0:
171 ; GFX9-SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
172 ; GFX9-SDAG-NEXT: global_store_dword v[0:1], v0, off
173 ; GFX9-SDAG-NEXT: s_waitcnt vmcnt(0)
174 ; GFX9-SDAG-NEXT: global_store_dword v[2:3], v0, off
175 ; GFX9-SDAG-NEXT: s_waitcnt vmcnt(0)
176 ; GFX9-SDAG-NEXT: global_store_dword v[4:5], v0, off
177 ; GFX9-SDAG-NEXT: s_waitcnt vmcnt(0)
178 ; GFX9-SDAG-NEXT: s_setpc_b64 s[30:31]
180 ; GFX9-GISEL-LABEL: workgroup_ids_gfx:
181 ; GFX9-GISEL: ; %bb.0:
182 ; GFX9-GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
183 ; GFX9-GISEL-NEXT: s_setpc_b64 s[30:31]
185 ; GFX9ARCH-SDAG-LABEL: workgroup_ids_gfx:
186 ; GFX9ARCH-SDAG: ; %bb.0:
187 ; GFX9ARCH-SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
188 ; GFX9ARCH-SDAG-NEXT: v_mov_b32_e32 v6, ttmp9
189 ; GFX9ARCH-SDAG-NEXT: s_and_b32 s34, ttmp7, 0xffff
190 ; GFX9ARCH-SDAG-NEXT: global_store_dword v[0:1], v6, off
191 ; GFX9ARCH-SDAG-NEXT: s_waitcnt vmcnt(0)
192 ; GFX9ARCH-SDAG-NEXT: v_mov_b32_e32 v0, s34
193 ; GFX9ARCH-SDAG-NEXT: s_lshr_b32 s34, ttmp7, 16
194 ; GFX9ARCH-SDAG-NEXT: global_store_dword v[2:3], v0, off
195 ; GFX9ARCH-SDAG-NEXT: s_waitcnt vmcnt(0)
196 ; GFX9ARCH-SDAG-NEXT: v_mov_b32_e32 v0, s34
197 ; GFX9ARCH-SDAG-NEXT: global_store_dword v[4:5], v0, off
198 ; GFX9ARCH-SDAG-NEXT: s_waitcnt vmcnt(0)
199 ; GFX9ARCH-SDAG-NEXT: s_setpc_b64 s[30:31]
201 ; GFX9ARCH-GISEL-LABEL: workgroup_ids_gfx:
202 ; GFX9ARCH-GISEL: ; %bb.0:
203 ; GFX9ARCH-GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
204 ; GFX9ARCH-GISEL-NEXT: v_mov_b32_e32 v6, ttmp9
205 ; GFX9ARCH-GISEL-NEXT: s_and_b32 s34, ttmp7, 0xffff
206 ; GFX9ARCH-GISEL-NEXT: s_lshr_b32 s35, ttmp7, 16
207 ; GFX9ARCH-GISEL-NEXT: global_store_dword v[0:1], v6, off
208 ; GFX9ARCH-GISEL-NEXT: s_waitcnt vmcnt(0)
209 ; GFX9ARCH-GISEL-NEXT: v_mov_b32_e32 v0, s34
210 ; GFX9ARCH-GISEL-NEXT: global_store_dword v[2:3], v0, off
211 ; GFX9ARCH-GISEL-NEXT: s_waitcnt vmcnt(0)
212 ; GFX9ARCH-GISEL-NEXT: v_mov_b32_e32 v0, s35
213 ; GFX9ARCH-GISEL-NEXT: global_store_dword v[4:5], v0, off
214 ; GFX9ARCH-GISEL-NEXT: s_waitcnt vmcnt(0)
215 ; GFX9ARCH-GISEL-NEXT: s_setpc_b64 s[30:31]
217 ; GFX12-LABEL: workgroup_ids_gfx:
219 ; GFX12-NEXT: s_wait_loadcnt_dscnt 0x0
220 ; GFX12-NEXT: s_wait_expcnt 0x0
221 ; GFX12-NEXT: s_wait_samplecnt 0x0
222 ; GFX12-NEXT: s_wait_bvhcnt 0x0
223 ; GFX12-NEXT: s_wait_kmcnt 0x0
224 ; GFX12-NEXT: s_and_b32 s0, ttmp7, 0xffff
225 ; GFX12-NEXT: s_wait_alu 0xfffe
226 ; GFX12-NEXT: v_dual_mov_b32 v6, ttmp9 :: v_dual_mov_b32 v7, s0
227 ; GFX12-NEXT: s_lshr_b32 s1, ttmp7, 16
228 ; GFX12-NEXT: s_wait_alu 0xfffe
229 ; GFX12-NEXT: v_mov_b32_e32 v8, s1
230 ; GFX12-NEXT: s_wait_storecnt 0x0
231 ; GFX12-NEXT: global_store_b32 v[0:1], v6, off scope:SCOPE_SYS
232 ; GFX12-NEXT: s_wait_storecnt 0x0
233 ; GFX12-NEXT: global_store_b32 v[2:3], v7, off scope:SCOPE_SYS
234 ; GFX12-NEXT: s_wait_storecnt 0x0
235 ; GFX12-NEXT: global_store_b32 v[4:5], v8, off scope:SCOPE_SYS
236 ; GFX12-NEXT: s_wait_storecnt 0x0
237 ; GFX12-NEXT: s_setpc_b64 s[30:31]
238 %id.x = call i32 @llvm.amdgcn.workgroup.id.x()
239 %id.y = call i32 @llvm.amdgcn.workgroup.id.y()
240 %id.z = call i32 @llvm.amdgcn.workgroup.id.z()
241 store volatile i32 %id.x, ptr addrspace(1) %outx
242 store volatile i32 %id.y, ptr addrspace(1) %outy
243 store volatile i32 %id.z, ptr addrspace(1) %outz