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 %s
3 ; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx900 -mattr=-architected-sgprs -global-isel=1 -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX9 %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 ; GFX9ARCH-SDAG-LABEL: _amdgpu_cs_main:
16 ; GFX9ARCH-SDAG: ; %bb.0: ; %.entry
17 ; GFX9ARCH-SDAG-NEXT: s_lshr_b32 s0, ttmp7, 16
18 ; GFX9ARCH-SDAG-NEXT: s_and_b32 s1, ttmp7, 0xffff
19 ; GFX9ARCH-SDAG-NEXT: v_mov_b32_e32 v0, ttmp9
20 ; GFX9ARCH-SDAG-NEXT: v_mov_b32_e32 v1, s1
21 ; GFX9ARCH-SDAG-NEXT: v_mov_b32_e32 v2, s0
22 ; GFX9ARCH-SDAG-NEXT: buffer_store_dwordx3 v[0:2], off, s[0:3], 0
23 ; GFX9ARCH-SDAG-NEXT: s_endpgm
25 ; GFX9ARCH-GISEL-LABEL: _amdgpu_cs_main:
26 ; GFX9ARCH-GISEL: ; %bb.0: ; %.entry
27 ; GFX9ARCH-GISEL-NEXT: s_mov_b32 s0, ttmp9
28 ; GFX9ARCH-GISEL-NEXT: s_and_b32 s1, ttmp7, 0xffff
29 ; GFX9ARCH-GISEL-NEXT: s_lshr_b32 s2, ttmp7, 16
30 ; GFX9ARCH-GISEL-NEXT: v_mov_b32_e32 v0, s0
31 ; GFX9ARCH-GISEL-NEXT: v_mov_b32_e32 v1, s1
32 ; GFX9ARCH-GISEL-NEXT: v_mov_b32_e32 v2, s2
33 ; GFX9ARCH-GISEL-NEXT: buffer_store_dwordx3 v[0:2], off, s[0:3], 0
34 ; GFX9ARCH-GISEL-NEXT: s_endpgm
36 ; GFX12-SDAG-LABEL: _amdgpu_cs_main:
37 ; GFX12-SDAG: ; %bb.0: ; %.entry
38 ; GFX12-SDAG-NEXT: s_and_b32 s0, ttmp7, 0xffff
39 ; GFX12-SDAG-NEXT: s_lshr_b32 s1, ttmp7, 16
40 ; GFX12-SDAG-NEXT: v_dual_mov_b32 v0, ttmp9 :: v_dual_mov_b32 v1, s0
41 ; GFX12-SDAG-NEXT: v_mov_b32_e32 v2, s1
42 ; GFX12-SDAG-NEXT: buffer_store_b96 v[0:2], off, s[0:3], null
43 ; GFX12-SDAG-NEXT: s_nop 0
44 ; GFX12-SDAG-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
45 ; GFX12-SDAG-NEXT: s_endpgm
47 ; GFX12-GISEL-LABEL: _amdgpu_cs_main:
48 ; GFX12-GISEL: ; %bb.0: ; %.entry
49 ; GFX12-GISEL-NEXT: s_mov_b32 s0, ttmp9
50 ; GFX12-GISEL-NEXT: s_and_b32 s1, ttmp7, 0xffff
51 ; GFX12-GISEL-NEXT: s_lshr_b32 s2, ttmp7, 16
52 ; GFX12-GISEL-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
53 ; GFX12-GISEL-NEXT: v_mov_b32_e32 v2, s2
54 ; GFX12-GISEL-NEXT: buffer_store_b96 v[0:2], off, s[0:3], null
55 ; GFX12-GISEL-NEXT: s_nop 0
56 ; GFX12-GISEL-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
57 ; GFX12-GISEL-NEXT: s_endpgm
59 %idx = call i32 @llvm.amdgcn.workgroup.id.x()
60 %idy = call i32 @llvm.amdgcn.workgroup.id.y()
61 %idz = call i32 @llvm.amdgcn.workgroup.id.z()
62 %ielemx = insertelement <3 x i32> undef, i32 %idx, i64 0
63 %ielemy = insertelement <3 x i32> %ielemx, i32 %idy, i64 1
64 %ielemz = insertelement <3 x i32> %ielemy, i32 %idz, i64 2
65 call void @llvm.amdgcn.raw.ptr.buffer.store.v3i32(<3 x i32> %ielemz, ptr addrspace(8) undef, i32 0, i32 0, i32 0)
69 define amdgpu_cs void @caller() {
70 ; GFX9ARCH-SDAG-LABEL: caller:
71 ; GFX9ARCH-SDAG: ; %bb.0:
72 ; GFX9ARCH-SDAG-NEXT: s_getpc_b64 s[8:9]
73 ; GFX9ARCH-SDAG-NEXT: s_mov_b32 s8, s0
74 ; GFX9ARCH-SDAG-NEXT: s_load_dwordx4 s[8:11], s[8:9], 0x10
75 ; GFX9ARCH-SDAG-NEXT: s_mov_b32 s5, callee@abs32@hi
76 ; GFX9ARCH-SDAG-NEXT: s_mov_b32 s4, callee@abs32@lo
77 ; GFX9ARCH-SDAG-NEXT: v_mov_b32_e32 v0, ttmp9
78 ; GFX9ARCH-SDAG-NEXT: s_mov_b32 s32, 0
79 ; GFX9ARCH-SDAG-NEXT: s_waitcnt lgkmcnt(0)
80 ; GFX9ARCH-SDAG-NEXT: s_add_u32 s8, s8, s0
81 ; GFX9ARCH-SDAG-NEXT: s_addc_u32 s9, s9, 0
82 ; GFX9ARCH-SDAG-NEXT: s_mov_b64 s[0:1], s[8:9]
83 ; GFX9ARCH-SDAG-NEXT: s_mov_b64 s[2:3], s[10:11]
84 ; GFX9ARCH-SDAG-NEXT: s_swappc_b64 s[30:31], s[4:5]
85 ; GFX9ARCH-SDAG-NEXT: s_endpgm
87 ; GFX9ARCH-GISEL-LABEL: caller:
88 ; GFX9ARCH-GISEL: ; %bb.0:
89 ; GFX9ARCH-GISEL-NEXT: s_getpc_b64 s[8:9]
90 ; GFX9ARCH-GISEL-NEXT: s_mov_b32 s8, s0
91 ; GFX9ARCH-GISEL-NEXT: s_load_dwordx4 s[8:11], s[8:9], 0x10
92 ; GFX9ARCH-GISEL-NEXT: s_mov_b32 s4, callee@abs32@lo
93 ; GFX9ARCH-GISEL-NEXT: s_mov_b32 s5, callee@abs32@hi
94 ; GFX9ARCH-GISEL-NEXT: v_mov_b32_e32 v0, ttmp9
95 ; GFX9ARCH-GISEL-NEXT: s_mov_b32 s32, 0
96 ; GFX9ARCH-GISEL-NEXT: s_waitcnt lgkmcnt(0)
97 ; GFX9ARCH-GISEL-NEXT: s_add_u32 s8, s8, s0
98 ; GFX9ARCH-GISEL-NEXT: s_addc_u32 s9, s9, 0
99 ; GFX9ARCH-GISEL-NEXT: s_mov_b64 s[0:1], s[8:9]
100 ; GFX9ARCH-GISEL-NEXT: s_mov_b64 s[2:3], s[10:11]
101 ; GFX9ARCH-GISEL-NEXT: s_swappc_b64 s[30:31], s[4:5]
102 ; GFX9ARCH-GISEL-NEXT: s_endpgm
104 ; GFX12-SDAG-LABEL: caller:
105 ; GFX12-SDAG: ; %bb.0:
106 ; GFX12-SDAG-NEXT: v_mov_b32_e32 v0, ttmp9
107 ; GFX12-SDAG-NEXT: s_mov_b32 s1, callee@abs32@hi
108 ; GFX12-SDAG-NEXT: s_mov_b32 s0, callee@abs32@lo
109 ; GFX12-SDAG-NEXT: s_mov_b32 s32, 0
110 ; GFX12-SDAG-NEXT: s_swappc_b64 s[30:31], s[0:1]
111 ; GFX12-SDAG-NEXT: s_endpgm
113 ; GFX12-GISEL-LABEL: caller:
114 ; GFX12-GISEL: ; %bb.0:
115 ; GFX12-GISEL-NEXT: v_mov_b32_e32 v0, ttmp9
116 ; GFX12-GISEL-NEXT: s_mov_b32 s0, callee@abs32@lo
117 ; GFX12-GISEL-NEXT: s_mov_b32 s1, callee@abs32@hi
118 ; GFX12-GISEL-NEXT: s_mov_b32 s32, 0
119 ; GFX12-GISEL-NEXT: s_swappc_b64 s[30:31], s[0:1]
120 ; GFX12-GISEL-NEXT: s_endpgm
121 %idx = call i32 @llvm.amdgcn.workgroup.id.x()
122 call amdgpu_gfx void @callee(i32 %idx)
126 declare amdgpu_gfx void @callee(i32)
128 define amdgpu_gfx void @workgroup_ids_gfx(ptr addrspace(1) %outx, ptr addrspace(1) %outy, ptr addrspace(1) %outz) {
129 ; GFX9-LABEL: workgroup_ids_gfx:
131 ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
132 ; GFX9-NEXT: s_setpc_b64 s[30:31]
134 ; GFX9ARCH-SDAG-LABEL: workgroup_ids_gfx:
135 ; GFX9ARCH-SDAG: ; %bb.0:
136 ; GFX9ARCH-SDAG-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
137 ; GFX9ARCH-SDAG-NEXT: v_mov_b32_e32 v6, ttmp9
138 ; GFX9ARCH-SDAG-NEXT: s_and_b32 s34, ttmp7, 0xffff
139 ; GFX9ARCH-SDAG-NEXT: global_store_dword v[0:1], v6, off
140 ; GFX9ARCH-SDAG-NEXT: s_waitcnt vmcnt(0)
141 ; GFX9ARCH-SDAG-NEXT: v_mov_b32_e32 v0, s34
142 ; GFX9ARCH-SDAG-NEXT: s_lshr_b32 s34, ttmp7, 16
143 ; GFX9ARCH-SDAG-NEXT: global_store_dword v[2:3], v0, off
144 ; GFX9ARCH-SDAG-NEXT: s_waitcnt vmcnt(0)
145 ; GFX9ARCH-SDAG-NEXT: v_mov_b32_e32 v0, s34
146 ; GFX9ARCH-SDAG-NEXT: global_store_dword v[4:5], v0, off
147 ; GFX9ARCH-SDAG-NEXT: s_waitcnt vmcnt(0)
148 ; GFX9ARCH-SDAG-NEXT: s_setpc_b64 s[30:31]
150 ; GFX9ARCH-GISEL-LABEL: workgroup_ids_gfx:
151 ; GFX9ARCH-GISEL: ; %bb.0:
152 ; GFX9ARCH-GISEL-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
153 ; GFX9ARCH-GISEL-NEXT: v_mov_b32_e32 v6, ttmp9
154 ; GFX9ARCH-GISEL-NEXT: s_and_b32 s34, ttmp7, 0xffff
155 ; GFX9ARCH-GISEL-NEXT: s_lshr_b32 s35, ttmp7, 16
156 ; GFX9ARCH-GISEL-NEXT: global_store_dword v[0:1], v6, off
157 ; GFX9ARCH-GISEL-NEXT: s_waitcnt vmcnt(0)
158 ; GFX9ARCH-GISEL-NEXT: v_mov_b32_e32 v0, s34
159 ; GFX9ARCH-GISEL-NEXT: global_store_dword v[2:3], v0, off
160 ; GFX9ARCH-GISEL-NEXT: s_waitcnt vmcnt(0)
161 ; GFX9ARCH-GISEL-NEXT: v_mov_b32_e32 v0, s35
162 ; GFX9ARCH-GISEL-NEXT: global_store_dword v[4:5], v0, off
163 ; GFX9ARCH-GISEL-NEXT: s_waitcnt vmcnt(0)
164 ; GFX9ARCH-GISEL-NEXT: s_setpc_b64 s[30:31]
166 ; GFX12-LABEL: workgroup_ids_gfx:
168 ; GFX12-NEXT: s_wait_loadcnt_dscnt 0x0
169 ; GFX12-NEXT: s_wait_expcnt 0x0
170 ; GFX12-NEXT: s_wait_samplecnt 0x0
171 ; GFX12-NEXT: s_wait_bvhcnt 0x0
172 ; GFX12-NEXT: s_wait_kmcnt 0x0
173 ; GFX12-NEXT: s_and_b32 s0, ttmp7, 0xffff
174 ; GFX12-NEXT: s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
175 ; GFX12-NEXT: v_dual_mov_b32 v6, ttmp9 :: v_dual_mov_b32 v7, s0
176 ; GFX12-NEXT: s_lshr_b32 s1, ttmp7, 16
177 ; GFX12-NEXT: v_mov_b32_e32 v8, s1
178 ; GFX12-NEXT: s_wait_storecnt 0x0
179 ; GFX12-NEXT: global_store_b32 v[0:1], v6, off scope:SCOPE_SYS
180 ; GFX12-NEXT: s_wait_storecnt 0x0
181 ; GFX12-NEXT: global_store_b32 v[2:3], v7, off scope:SCOPE_SYS
182 ; GFX12-NEXT: s_wait_storecnt 0x0
183 ; GFX12-NEXT: global_store_b32 v[4:5], v8, off scope:SCOPE_SYS
184 ; GFX12-NEXT: s_wait_storecnt 0x0
185 ; GFX12-NEXT: s_setpc_b64 s[30:31]
186 %id.x = call i32 @llvm.amdgcn.workgroup.id.x()
187 %id.y = call i32 @llvm.amdgcn.workgroup.id.y()
188 %id.z = call i32 @llvm.amdgcn.workgroup.id.z()
189 store volatile i32 %id.x, ptr addrspace(1) %outx
190 store volatile i32 %id.y, ptr addrspace(1) %outy
191 store volatile i32 %id.z, ptr addrspace(1) %outz