1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2 ; RUN: llc -mtriple=amdgcn-- -verify-machineinstrs < %s | FileCheck -check-prefixes=SI %s
3 ; RUN: llc -mtriple=amdgcn-- -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -check-prefixes=VI %s
4 ; RUN: llc -mtriple=amdgcn-- -mcpu=gfx1100 -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -check-prefixes=GFX11 %s
6 define amdgpu_kernel void @extract_vector_elt_v2f16(ptr addrspace(1) %out, ptr addrspace(4) %vec.ptr) #0 {
7 ; SI-LABEL: extract_vector_elt_v2f16:
9 ; SI-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
10 ; SI-NEXT: s_waitcnt lgkmcnt(0)
11 ; SI-NEXT: s_load_dword s4, s[2:3], 0x0
12 ; SI-NEXT: s_mov_b32 s3, 0xf000
13 ; SI-NEXT: s_waitcnt lgkmcnt(0)
14 ; SI-NEXT: s_lshr_b32 s5, s4, 16
15 ; SI-NEXT: s_mov_b32 s2, -1
16 ; SI-NEXT: v_mov_b32_e32 v0, s4
17 ; SI-NEXT: v_mov_b32_e32 v1, s5
18 ; SI-NEXT: buffer_store_short v1, off, s[0:3], 0
19 ; SI-NEXT: buffer_store_short v0, off, s[0:3], 0 offset:20
22 ; VI-LABEL: extract_vector_elt_v2f16:
24 ; VI-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
25 ; VI-NEXT: s_waitcnt lgkmcnt(0)
26 ; VI-NEXT: s_load_dword s4, s[2:3], 0x0
27 ; VI-NEXT: s_mov_b32 s3, 0xf000
28 ; VI-NEXT: s_mov_b32 s2, -1
29 ; VI-NEXT: s_waitcnt lgkmcnt(0)
30 ; VI-NEXT: s_lshr_b32 s5, s4, 16
31 ; VI-NEXT: v_mov_b32_e32 v1, s5
32 ; VI-NEXT: v_mov_b32_e32 v0, s4
33 ; VI-NEXT: buffer_store_short v1, off, s[0:3], 0
34 ; VI-NEXT: buffer_store_short v0, off, s[0:3], 0 offset:20
37 ; GFX11-LABEL: extract_vector_elt_v2f16:
39 ; GFX11-NEXT: s_load_b128 s[0:3], s[0:1], 0x24
40 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
41 ; GFX11-NEXT: s_load_b32 s2, s[2:3], 0x0
42 ; GFX11-NEXT: v_mov_b32_e32 v0, 0
43 ; GFX11-NEXT: s_mov_b32 s3, 0x31016000
44 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
45 ; GFX11-NEXT: v_mov_b32_e32 v1, s2
46 ; GFX11-NEXT: s_mov_b32 s2, -1
47 ; GFX11-NEXT: s_clause 0x1
48 ; GFX11-NEXT: global_store_d16_hi_b16 v0, v1, s[0:1]
49 ; GFX11-NEXT: buffer_store_b16 v1, off, s[0:3], 0 offset:20
51 ; GFX11-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
52 ; GFX11-NEXT: s_endpgm
53 %vec = load <2 x half>, ptr addrspace(4) %vec.ptr
54 %p0 = extractelement <2 x half> %vec, i32 0
55 %p1 = extractelement <2 x half> %vec, i32 1
56 %out1 = getelementptr half, ptr addrspace(1) %out, i32 10
57 store half %p1, ptr addrspace(1) %out, align 2
58 store half %p0, ptr addrspace(1) %out1, align 2
62 define amdgpu_kernel void @extract_vector_elt_v2f16_dynamic_sgpr(ptr addrspace(1) %out, ptr addrspace(4) %vec.ptr, i32 %idx) #0 {
63 ; SI-LABEL: extract_vector_elt_v2f16_dynamic_sgpr:
65 ; SI-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
66 ; SI-NEXT: s_load_dword s0, s[0:1], 0xd
67 ; SI-NEXT: s_waitcnt lgkmcnt(0)
68 ; SI-NEXT: s_load_dword s1, s[6:7], 0x0
69 ; SI-NEXT: s_mov_b32 s7, 0xf000
70 ; SI-NEXT: s_lshl_b32 s0, s0, 4
71 ; SI-NEXT: s_waitcnt lgkmcnt(0)
72 ; SI-NEXT: s_lshr_b32 s0, s1, s0
73 ; SI-NEXT: s_mov_b32 s6, -1
74 ; SI-NEXT: v_mov_b32_e32 v0, s0
75 ; SI-NEXT: buffer_store_short v0, off, s[4:7], 0
78 ; VI-LABEL: extract_vector_elt_v2f16_dynamic_sgpr:
80 ; VI-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
81 ; VI-NEXT: s_load_dword s8, s[0:1], 0x34
82 ; VI-NEXT: s_mov_b32 s3, 0xf000
83 ; VI-NEXT: s_mov_b32 s2, -1
84 ; VI-NEXT: s_waitcnt lgkmcnt(0)
85 ; VI-NEXT: s_load_dword s6, s[6:7], 0x0
86 ; VI-NEXT: s_mov_b32 s0, s4
87 ; VI-NEXT: s_lshl_b32 s4, s8, 4
88 ; VI-NEXT: s_mov_b32 s1, s5
89 ; VI-NEXT: s_waitcnt lgkmcnt(0)
90 ; VI-NEXT: s_lshr_b32 s4, s6, s4
91 ; VI-NEXT: v_mov_b32_e32 v0, s4
92 ; VI-NEXT: buffer_store_short v0, off, s[0:3], 0
95 ; GFX11-LABEL: extract_vector_elt_v2f16_dynamic_sgpr:
97 ; GFX11-NEXT: s_clause 0x1
98 ; GFX11-NEXT: s_load_b128 s[4:7], s[0:1], 0x24
99 ; GFX11-NEXT: s_load_b32 s0, s[0:1], 0x34
100 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
101 ; GFX11-NEXT: s_load_b32 s1, s[6:7], 0x0
102 ; GFX11-NEXT: s_lshl_b32 s0, s0, 4
103 ; GFX11-NEXT: s_mov_b32 s7, 0x31016000
104 ; GFX11-NEXT: s_mov_b32 s6, -1
105 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
106 ; GFX11-NEXT: s_lshr_b32 s0, s1, s0
107 ; GFX11-NEXT: s_delay_alu instid0(SALU_CYCLE_1)
108 ; GFX11-NEXT: v_mov_b32_e32 v0, s0
109 ; GFX11-NEXT: buffer_store_b16 v0, off, s[4:7], 0
110 ; GFX11-NEXT: s_nop 0
111 ; GFX11-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
112 ; GFX11-NEXT: s_endpgm
113 %vec = load <2 x half>, ptr addrspace(4) %vec.ptr
114 %elt = extractelement <2 x half> %vec, i32 %idx
115 store half %elt, ptr addrspace(1) %out, align 2
119 define amdgpu_kernel void @extract_vector_elt_v2f16_dynamic_vgpr(ptr addrspace(1) %out, ptr addrspace(4) %vec.ptr, ptr addrspace(1) %idx.ptr) #0 {
120 ; SI-LABEL: extract_vector_elt_v2f16_dynamic_vgpr:
122 ; SI-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
123 ; SI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xd
124 ; SI-NEXT: s_mov_b32 s3, 0xf000
125 ; SI-NEXT: s_mov_b32 s2, 0
126 ; SI-NEXT: v_lshlrev_b32_e32 v1, 2, v0
127 ; SI-NEXT: v_mov_b32_e32 v2, 0
128 ; SI-NEXT: s_waitcnt lgkmcnt(0)
129 ; SI-NEXT: buffer_load_dword v3, v[1:2], s[0:3], 0 addr64
130 ; SI-NEXT: s_load_dword s6, s[6:7], 0x0
131 ; SI-NEXT: s_mov_b64 s[0:1], s[4:5]
132 ; SI-NEXT: v_lshlrev_b32_e32 v1, 1, v0
133 ; SI-NEXT: s_waitcnt vmcnt(0)
134 ; SI-NEXT: v_lshlrev_b32_e32 v0, 4, v3
135 ; SI-NEXT: s_waitcnt lgkmcnt(0)
136 ; SI-NEXT: v_lshr_b32_e32 v0, s6, v0
137 ; SI-NEXT: buffer_store_short v0, v[1:2], s[0:3], 0 addr64
140 ; VI-LABEL: extract_vector_elt_v2f16_dynamic_vgpr:
142 ; VI-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
143 ; VI-NEXT: v_lshlrev_b32_e32 v1, 2, v0
144 ; VI-NEXT: v_lshlrev_b32_e32 v0, 1, v0
145 ; VI-NEXT: s_waitcnt lgkmcnt(0)
146 ; VI-NEXT: v_mov_b32_e32 v2, s3
147 ; VI-NEXT: v_add_u32_e32 v1, vcc, s2, v1
148 ; VI-NEXT: v_addc_u32_e32 v2, vcc, 0, v2, vcc
149 ; VI-NEXT: flat_load_dword v2, v[1:2]
150 ; VI-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
151 ; VI-NEXT: s_waitcnt lgkmcnt(0)
152 ; VI-NEXT: v_mov_b32_e32 v1, s1
153 ; VI-NEXT: s_load_dword s1, s[2:3], 0x0
154 ; VI-NEXT: v_add_u32_e32 v0, vcc, s0, v0
155 ; VI-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
156 ; VI-NEXT: s_waitcnt vmcnt(0)
157 ; VI-NEXT: v_lshlrev_b32_e32 v2, 4, v2
158 ; VI-NEXT: s_waitcnt lgkmcnt(0)
159 ; VI-NEXT: v_lshrrev_b32_e64 v2, v2, s1
160 ; VI-NEXT: flat_store_short v[0:1], v2
163 ; GFX11-LABEL: extract_vector_elt_v2f16_dynamic_vgpr:
165 ; GFX11-NEXT: s_load_b64 s[2:3], s[0:1], 0x34
166 ; GFX11-NEXT: v_lshlrev_b32_e32 v1, 2, v0
167 ; GFX11-NEXT: v_lshlrev_b32_e32 v0, 1, v0
168 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
169 ; GFX11-NEXT: global_load_b32 v1, v1, s[2:3]
170 ; GFX11-NEXT: s_load_b128 s[0:3], s[0:1], 0x24
171 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
172 ; GFX11-NEXT: s_load_b32 s2, s[2:3], 0x0
173 ; GFX11-NEXT: s_waitcnt vmcnt(0)
174 ; GFX11-NEXT: v_lshlrev_b32_e32 v1, 4, v1
175 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
176 ; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1)
177 ; GFX11-NEXT: v_lshrrev_b32_e64 v1, v1, s2
178 ; GFX11-NEXT: global_store_b16 v0, v1, s[0:1]
179 ; GFX11-NEXT: s_nop 0
180 ; GFX11-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
181 ; GFX11-NEXT: s_endpgm
182 %tid = call i32 @llvm.amdgcn.workitem.id.x()
183 %tid.ext = sext i32 %tid to i64
184 %gep = getelementptr inbounds i32, ptr addrspace(1) %idx.ptr, i64 %tid.ext
185 %out.gep = getelementptr inbounds half, ptr addrspace(1) %out, i64 %tid.ext
186 %vec = load <2 x half>, ptr addrspace(4) %vec.ptr
187 %idx = load i32, ptr addrspace(1) %gep
188 %elt = extractelement <2 x half> %vec, i32 %idx
189 store half %elt, ptr addrspace(1) %out.gep, align 2
193 define amdgpu_kernel void @extract_vector_elt_v3f16(ptr addrspace(1) %out, <3 x half> %foo) #0 {
194 ; SI-LABEL: extract_vector_elt_v3f16:
196 ; SI-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
197 ; SI-NEXT: s_mov_b32 s7, 0xf000
198 ; SI-NEXT: s_mov_b32 s6, -1
199 ; SI-NEXT: s_waitcnt lgkmcnt(0)
200 ; SI-NEXT: s_mov_b32 s4, s0
201 ; SI-NEXT: s_mov_b32 s5, s1
202 ; SI-NEXT: v_mov_b32_e32 v0, s3
203 ; SI-NEXT: buffer_store_short v0, off, s[4:7], 0
204 ; SI-NEXT: s_waitcnt expcnt(0)
205 ; SI-NEXT: v_mov_b32_e32 v0, s2
206 ; SI-NEXT: buffer_store_short v0, off, s[4:7], 0 offset:2
209 ; VI-LABEL: extract_vector_elt_v3f16:
211 ; VI-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
212 ; VI-NEXT: s_mov_b32 s7, 0xf000
213 ; VI-NEXT: s_mov_b32 s6, -1
214 ; VI-NEXT: s_waitcnt lgkmcnt(0)
215 ; VI-NEXT: s_mov_b32 s4, s0
216 ; VI-NEXT: s_mov_b32 s5, s1
217 ; VI-NEXT: v_mov_b32_e32 v0, s3
218 ; VI-NEXT: buffer_store_short v0, off, s[4:7], 0
219 ; VI-NEXT: v_mov_b32_e32 v0, s2
220 ; VI-NEXT: buffer_store_short v0, off, s[4:7], 0 offset:2
223 ; GFX11-LABEL: extract_vector_elt_v3f16:
225 ; GFX11-NEXT: s_load_b128 s[0:3], s[0:1], 0x24
226 ; GFX11-NEXT: s_mov_b32 s7, 0x31016000
227 ; GFX11-NEXT: s_mov_b32 s6, -1
228 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
229 ; GFX11-NEXT: v_dual_mov_b32 v0, s3 :: v_dual_mov_b32 v1, s2
230 ; GFX11-NEXT: s_mov_b32 s4, s0
231 ; GFX11-NEXT: s_mov_b32 s5, s1
232 ; GFX11-NEXT: s_clause 0x1
233 ; GFX11-NEXT: buffer_store_b16 v0, off, s[4:7], 0
234 ; GFX11-NEXT: buffer_store_b16 v1, off, s[4:7], 0 offset:2
235 ; GFX11-NEXT: s_nop 0
236 ; GFX11-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
237 ; GFX11-NEXT: s_endpgm
238 %p0 = extractelement <3 x half> %foo, i32 0
239 %p1 = extractelement <3 x half> %foo, i32 2
240 %out1 = getelementptr half, ptr addrspace(1) %out, i32 1
241 store half %p1, ptr addrspace(1) %out, align 2
242 store half %p0, ptr addrspace(1) %out1, align 2
246 ; FIXME: Why sometimes vector shift?
247 define amdgpu_kernel void @dynamic_extract_vector_elt_v3f16(ptr addrspace(1) %out, <3 x half> %foo, i32 %idx) #0 {
248 ; SI-LABEL: dynamic_extract_vector_elt_v3f16:
250 ; SI-NEXT: s_load_dword s4, s[0:1], 0xd
251 ; SI-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
252 ; SI-NEXT: s_mov_b32 s7, 0xf000
253 ; SI-NEXT: s_waitcnt lgkmcnt(0)
254 ; SI-NEXT: s_lshl_b32 s4, s4, 4
255 ; SI-NEXT: s_lshr_b64 s[2:3], s[2:3], s4
256 ; SI-NEXT: s_mov_b32 s6, -1
257 ; SI-NEXT: s_mov_b32 s4, s0
258 ; SI-NEXT: s_mov_b32 s5, s1
259 ; SI-NEXT: v_mov_b32_e32 v0, s2
260 ; SI-NEXT: buffer_store_short v0, off, s[4:7], 0
263 ; VI-LABEL: dynamic_extract_vector_elt_v3f16:
265 ; VI-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
266 ; VI-NEXT: s_load_dword s8, s[0:1], 0x34
267 ; VI-NEXT: s_mov_b32 s3, 0xf000
268 ; VI-NEXT: s_mov_b32 s2, -1
269 ; VI-NEXT: s_waitcnt lgkmcnt(0)
270 ; VI-NEXT: s_mov_b32 s0, s4
271 ; VI-NEXT: s_lshl_b32 s4, s8, 4
272 ; VI-NEXT: s_mov_b32 s1, s5
273 ; VI-NEXT: s_lshr_b64 s[4:5], s[6:7], s4
274 ; VI-NEXT: v_mov_b32_e32 v0, s4
275 ; VI-NEXT: buffer_store_short v0, off, s[0:3], 0
278 ; GFX11-LABEL: dynamic_extract_vector_elt_v3f16:
280 ; GFX11-NEXT: s_clause 0x1
281 ; GFX11-NEXT: s_load_b32 s4, s[0:1], 0x34
282 ; GFX11-NEXT: s_load_b128 s[0:3], s[0:1], 0x24
283 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
284 ; GFX11-NEXT: s_lshl_b32 s4, s4, 4
285 ; GFX11-NEXT: s_delay_alu instid0(SALU_CYCLE_1)
286 ; GFX11-NEXT: s_lshr_b64 s[2:3], s[2:3], s4
287 ; GFX11-NEXT: s_mov_b32 s3, 0x31016000
288 ; GFX11-NEXT: v_mov_b32_e32 v0, s2
289 ; GFX11-NEXT: s_mov_b32 s2, -1
290 ; GFX11-NEXT: buffer_store_b16 v0, off, s[0:3], 0
291 ; GFX11-NEXT: s_nop 0
292 ; GFX11-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
293 ; GFX11-NEXT: s_endpgm
294 %p0 = extractelement <3 x half> %foo, i32 %idx
295 %out1 = getelementptr half, ptr addrspace(1) %out, i32 1
296 store half %p0, ptr addrspace(1) %out
300 define amdgpu_kernel void @v_extractelement_v4f16_2(ptr addrspace(1) %out, ptr addrspace(1) %in) #0 {
301 ; SI-LABEL: v_extractelement_v4f16_2:
303 ; SI-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
304 ; SI-NEXT: v_lshlrev_b32_e32 v1, 3, v0
305 ; SI-NEXT: s_mov_b32 s6, 0
306 ; SI-NEXT: s_mov_b32 s7, 0xf000
307 ; SI-NEXT: v_mov_b32_e32 v2, 0
308 ; SI-NEXT: s_mov_b64 s[10:11], s[6:7]
309 ; SI-NEXT: s_waitcnt lgkmcnt(0)
310 ; SI-NEXT: s_mov_b64 s[8:9], s[2:3]
311 ; SI-NEXT: buffer_load_dword v3, v[1:2], s[8:11], 0 addr64 offset:4
312 ; SI-NEXT: s_mov_b64 s[4:5], s[0:1]
313 ; SI-NEXT: v_lshlrev_b32_e32 v1, 1, v0
314 ; SI-NEXT: s_waitcnt vmcnt(0)
315 ; SI-NEXT: buffer_store_short v3, v[1:2], s[4:7], 0 addr64
318 ; VI-LABEL: v_extractelement_v4f16_2:
320 ; VI-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
321 ; VI-NEXT: v_lshlrev_b32_e32 v1, 3, v0
322 ; VI-NEXT: v_lshlrev_b32_e32 v0, 1, v0
323 ; VI-NEXT: s_waitcnt lgkmcnt(0)
324 ; VI-NEXT: v_mov_b32_e32 v2, s3
325 ; VI-NEXT: v_add_u32_e32 v1, vcc, s2, v1
326 ; VI-NEXT: v_addc_u32_e32 v2, vcc, 0, v2, vcc
327 ; VI-NEXT: v_add_u32_e32 v1, vcc, 4, v1
328 ; VI-NEXT: v_addc_u32_e32 v2, vcc, 0, v2, vcc
329 ; VI-NEXT: flat_load_dword v2, v[1:2]
330 ; VI-NEXT: v_mov_b32_e32 v1, s1
331 ; VI-NEXT: v_add_u32_e32 v0, vcc, s0, v0
332 ; VI-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
333 ; VI-NEXT: s_waitcnt vmcnt(0)
334 ; VI-NEXT: flat_store_short v[0:1], v2
337 ; GFX11-LABEL: v_extractelement_v4f16_2:
339 ; GFX11-NEXT: s_load_b128 s[0:3], s[0:1], 0x24
340 ; GFX11-NEXT: v_lshlrev_b32_e32 v1, 3, v0
341 ; GFX11-NEXT: v_lshlrev_b32_e32 v0, 1, v0
342 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
343 ; GFX11-NEXT: global_load_b32 v1, v1, s[2:3] offset:4
344 ; GFX11-NEXT: s_waitcnt vmcnt(0)
345 ; GFX11-NEXT: global_store_b16 v0, v1, s[0:1]
346 ; GFX11-NEXT: s_nop 0
347 ; GFX11-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
348 ; GFX11-NEXT: s_endpgm
349 %tid = call i32 @llvm.amdgcn.workitem.id.x() #1
350 %tid.ext = sext i32 %tid to i64
351 %in.gep = getelementptr inbounds <4 x half>, ptr addrspace(1) %in, i64 %tid.ext
352 %out.gep = getelementptr inbounds half, ptr addrspace(1) %out, i64 %tid.ext
353 %vec = load <4 x half>, ptr addrspace(1) %in.gep
354 %vec.extract = extractelement <4 x half> %vec, i32 2
355 store half %vec.extract, ptr addrspace(1) %out.gep
359 define amdgpu_kernel void @v_insertelement_v4f16_dynamic_vgpr(ptr addrspace(1) %out, ptr addrspace(1) %in) #0 {
360 ; SI-LABEL: v_insertelement_v4f16_dynamic_vgpr:
362 ; SI-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
363 ; SI-NEXT: s_mov_b32 s6, 0
364 ; SI-NEXT: s_mov_b32 s7, 0xf000
365 ; SI-NEXT: v_lshlrev_b32_e32 v1, 3, v0
366 ; SI-NEXT: v_mov_b32_e32 v2, 0
367 ; SI-NEXT: s_mov_b32 s10, -1
368 ; SI-NEXT: s_mov_b32 s11, s7
369 ; SI-NEXT: buffer_load_dword v5, off, s[8:11], 0 glc
370 ; SI-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
371 ; SI-NEXT: s_mov_b64 s[4:5], s[2:3]
372 ; SI-NEXT: buffer_load_dwordx2 v[3:4], v[1:2], s[4:7], 0 addr64
373 ; SI-NEXT: s_mov_b64 s[2:3], s[6:7]
374 ; SI-NEXT: v_lshlrev_b32_e32 v1, 1, v0
375 ; SI-NEXT: v_lshlrev_b32_e32 v0, 4, v5
376 ; SI-NEXT: s_waitcnt vmcnt(0)
377 ; SI-NEXT: v_lshr_b64 v[3:4], v[3:4], v0
378 ; SI-NEXT: buffer_store_short v3, v[1:2], s[0:3], 0 addr64
381 ; VI-LABEL: v_insertelement_v4f16_dynamic_vgpr:
383 ; VI-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
384 ; VI-NEXT: v_lshlrev_b32_e32 v1, 3, v0
385 ; VI-NEXT: v_lshlrev_b32_e32 v4, 1, v0
386 ; VI-NEXT: s_waitcnt lgkmcnt(0)
387 ; VI-NEXT: v_mov_b32_e32 v2, s3
388 ; VI-NEXT: v_add_u32_e32 v1, vcc, s2, v1
389 ; VI-NEXT: s_mov_b32 s3, 0xf000
390 ; VI-NEXT: s_mov_b32 s2, -1
391 ; VI-NEXT: v_addc_u32_e32 v2, vcc, 0, v2, vcc
392 ; VI-NEXT: buffer_load_dword v3, off, s[0:3], 0 glc
393 ; VI-NEXT: s_waitcnt vmcnt(0)
394 ; VI-NEXT: flat_load_dwordx2 v[1:2], v[1:2]
395 ; VI-NEXT: v_mov_b32_e32 v5, s1
396 ; VI-NEXT: v_lshlrev_b32_e32 v0, 4, v3
397 ; VI-NEXT: s_waitcnt vmcnt(0)
398 ; VI-NEXT: v_lshrrev_b64 v[0:1], v0, v[1:2]
399 ; VI-NEXT: v_add_u32_e32 v1, vcc, s0, v4
400 ; VI-NEXT: v_addc_u32_e32 v2, vcc, 0, v5, vcc
401 ; VI-NEXT: flat_store_short v[1:2], v0
404 ; GFX11-LABEL: v_insertelement_v4f16_dynamic_vgpr:
406 ; GFX11-NEXT: s_load_b128 s[0:3], s[0:1], 0x24
407 ; GFX11-NEXT: s_mov_b32 s7, 0x31016000
408 ; GFX11-NEXT: s_mov_b32 s6, -1
409 ; GFX11-NEXT: v_lshlrev_b32_e32 v1, 3, v0
410 ; GFX11-NEXT: buffer_load_b32 v3, off, s[4:7], 0 glc dlc
411 ; GFX11-NEXT: s_waitcnt vmcnt(0)
412 ; GFX11-NEXT: v_lshlrev_b32_e32 v0, 1, v0
413 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
414 ; GFX11-NEXT: global_load_b64 v[1:2], v1, s[2:3]
415 ; GFX11-NEXT: v_lshlrev_b32_e32 v3, 4, v3
416 ; GFX11-NEXT: s_waitcnt vmcnt(0)
417 ; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1)
418 ; GFX11-NEXT: v_lshrrev_b64 v[1:2], v3, v[1:2]
419 ; GFX11-NEXT: global_store_b16 v0, v1, s[0:1]
420 ; GFX11-NEXT: s_nop 0
421 ; GFX11-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
422 ; GFX11-NEXT: s_endpgm
423 %tid = call i32 @llvm.amdgcn.workitem.id.x() #1
424 %tid.ext = sext i32 %tid to i64
425 %in.gep = getelementptr inbounds <4 x half>, ptr addrspace(1) %in, i64 %tid.ext
426 %out.gep = getelementptr inbounds half, ptr addrspace(1) %out, i64 %tid.ext
427 %idx.val = load volatile i32, ptr addrspace(1) undef
428 %vec = load <4 x half>, ptr addrspace(1) %in.gep
429 %vec.extract = extractelement <4 x half> %vec, i32 %idx.val
430 store half %vec.extract, ptr addrspace(1) %out.gep
434 define amdgpu_kernel void @reduce_load_vector_v8f16_extract_01(ptr addrspace(4) %ptr) #0 {
435 ; SI-LABEL: reduce_load_vector_v8f16_extract_01:
437 ; SI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x9
438 ; SI-NEXT: s_waitcnt lgkmcnt(0)
439 ; SI-NEXT: s_load_dword s0, s[0:1], 0x0
440 ; SI-NEXT: s_mov_b32 s3, 0xf000
441 ; SI-NEXT: s_mov_b32 s2, -1
442 ; SI-NEXT: s_waitcnt lgkmcnt(0)
443 ; SI-NEXT: s_lshr_b32 s1, s0, 16
444 ; SI-NEXT: v_mov_b32_e32 v0, s0
445 ; SI-NEXT: buffer_store_short v0, off, s[0:3], 0
446 ; SI-NEXT: s_waitcnt vmcnt(0) expcnt(0)
447 ; SI-NEXT: v_mov_b32_e32 v0, s1
448 ; SI-NEXT: buffer_store_short v0, off, s[0:3], 0
449 ; SI-NEXT: s_waitcnt vmcnt(0)
452 ; VI-LABEL: reduce_load_vector_v8f16_extract_01:
454 ; VI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x24
455 ; VI-NEXT: s_mov_b32 s3, 0xf000
456 ; VI-NEXT: s_mov_b32 s2, -1
457 ; VI-NEXT: s_waitcnt lgkmcnt(0)
458 ; VI-NEXT: s_load_dword s0, s[0:1], 0x0
459 ; VI-NEXT: s_waitcnt lgkmcnt(0)
460 ; VI-NEXT: s_lshr_b32 s1, s0, 16
461 ; VI-NEXT: v_mov_b32_e32 v0, s0
462 ; VI-NEXT: buffer_store_short v0, off, s[0:3], 0
463 ; VI-NEXT: s_waitcnt vmcnt(0)
464 ; VI-NEXT: v_mov_b32_e32 v0, s1
465 ; VI-NEXT: buffer_store_short v0, off, s[0:3], 0
466 ; VI-NEXT: s_waitcnt vmcnt(0)
469 ; GFX11-LABEL: reduce_load_vector_v8f16_extract_01:
471 ; GFX11-NEXT: s_load_b64 s[0:1], s[0:1], 0x24
472 ; GFX11-NEXT: s_mov_b32 s3, 0x31016000
473 ; GFX11-NEXT: s_mov_b32 s2, -1
474 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
475 ; GFX11-NEXT: s_load_b32 s0, s[0:1], 0x0
476 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
477 ; GFX11-NEXT: s_lshr_b32 s1, s0, 16
478 ; GFX11-NEXT: s_delay_alu instid0(SALU_CYCLE_1)
479 ; GFX11-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
480 ; GFX11-NEXT: buffer_store_b16 v0, off, s[0:3], 0 dlc
481 ; GFX11-NEXT: s_waitcnt_vscnt null, 0x0
482 ; GFX11-NEXT: buffer_store_b16 v1, off, s[0:3], 0 dlc
483 ; GFX11-NEXT: s_waitcnt_vscnt null, 0x0
484 ; GFX11-NEXT: s_nop 0
485 ; GFX11-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
486 ; GFX11-NEXT: s_endpgm
487 %load = load <16 x half>, ptr addrspace(4) %ptr
488 %elt0 = extractelement <16 x half> %load, i32 0
489 %elt1 = extractelement <16 x half> %load, i32 1
490 store volatile half %elt0, ptr addrspace(1) undef, align 2
491 store volatile half %elt1, ptr addrspace(1) undef, align 2
495 define amdgpu_kernel void @reduce_load_vector_v8f16_extract_23(ptr addrspace(4) %ptr) #0 {
496 ; SI-LABEL: reduce_load_vector_v8f16_extract_23:
498 ; SI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x9
499 ; SI-NEXT: s_waitcnt lgkmcnt(0)
500 ; SI-NEXT: s_load_dword s0, s[0:1], 0x1
501 ; SI-NEXT: s_mov_b32 s3, 0xf000
502 ; SI-NEXT: s_mov_b32 s2, -1
503 ; SI-NEXT: s_waitcnt lgkmcnt(0)
504 ; SI-NEXT: s_lshr_b32 s1, s0, 16
505 ; SI-NEXT: v_mov_b32_e32 v0, s0
506 ; SI-NEXT: buffer_store_short v0, off, s[0:3], 0
507 ; SI-NEXT: s_waitcnt vmcnt(0) expcnt(0)
508 ; SI-NEXT: v_mov_b32_e32 v0, s1
509 ; SI-NEXT: buffer_store_short v0, off, s[0:3], 0
510 ; SI-NEXT: s_waitcnt vmcnt(0)
513 ; VI-LABEL: reduce_load_vector_v8f16_extract_23:
515 ; VI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x24
516 ; VI-NEXT: s_mov_b32 s3, 0xf000
517 ; VI-NEXT: s_mov_b32 s2, -1
518 ; VI-NEXT: s_waitcnt lgkmcnt(0)
519 ; VI-NEXT: s_load_dword s0, s[0:1], 0x4
520 ; VI-NEXT: s_waitcnt lgkmcnt(0)
521 ; VI-NEXT: s_lshr_b32 s1, s0, 16
522 ; VI-NEXT: v_mov_b32_e32 v0, s0
523 ; VI-NEXT: buffer_store_short v0, off, s[0:3], 0
524 ; VI-NEXT: s_waitcnt vmcnt(0)
525 ; VI-NEXT: v_mov_b32_e32 v0, s1
526 ; VI-NEXT: buffer_store_short v0, off, s[0:3], 0
527 ; VI-NEXT: s_waitcnt vmcnt(0)
530 ; GFX11-LABEL: reduce_load_vector_v8f16_extract_23:
532 ; GFX11-NEXT: s_load_b64 s[0:1], s[0:1], 0x24
533 ; GFX11-NEXT: s_mov_b32 s3, 0x31016000
534 ; GFX11-NEXT: s_mov_b32 s2, -1
535 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
536 ; GFX11-NEXT: s_load_b32 s0, s[0:1], 0x4
537 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
538 ; GFX11-NEXT: s_lshr_b32 s1, s0, 16
539 ; GFX11-NEXT: s_delay_alu instid0(SALU_CYCLE_1)
540 ; GFX11-NEXT: v_dual_mov_b32 v0, s0 :: v_dual_mov_b32 v1, s1
541 ; GFX11-NEXT: buffer_store_b16 v0, off, s[0:3], 0 dlc
542 ; GFX11-NEXT: s_waitcnt_vscnt null, 0x0
543 ; GFX11-NEXT: buffer_store_b16 v1, off, s[0:3], 0 dlc
544 ; GFX11-NEXT: s_waitcnt_vscnt null, 0x0
545 ; GFX11-NEXT: s_nop 0
546 ; GFX11-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
547 ; GFX11-NEXT: s_endpgm
548 %load = load <16 x half>, ptr addrspace(4) %ptr
549 %elt2 = extractelement <16 x half> %load, i32 2
550 %elt3 = extractelement <16 x half> %load, i32 3
551 store volatile half %elt2, ptr addrspace(1) undef, align 2
552 store volatile half %elt3, ptr addrspace(1) undef, align 2
556 define amdgpu_kernel void @v_extractelement_v8f16_dynamic_sgpr(ptr addrspace(1) %out, ptr addrspace(1) %in, i32 %n) #0 {
557 ; SI-LABEL: v_extractelement_v8f16_dynamic_sgpr:
559 ; SI-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
560 ; SI-NEXT: s_load_dword s8, s[0:1], 0xd
561 ; SI-NEXT: s_mov_b32 s3, 0xf000
562 ; SI-NEXT: s_mov_b32 s2, 0
563 ; SI-NEXT: v_lshlrev_b32_e32 v4, 4, v0
564 ; SI-NEXT: v_mov_b32_e32 v5, 0
565 ; SI-NEXT: s_waitcnt lgkmcnt(0)
566 ; SI-NEXT: s_mov_b64 s[0:1], s[6:7]
567 ; SI-NEXT: buffer_load_dwordx4 v[1:4], v[4:5], s[0:3], 0 addr64
568 ; SI-NEXT: v_lshlrev_b32_e32 v6, 1, v0
569 ; SI-NEXT: v_mov_b32_e32 v7, v5
570 ; SI-NEXT: s_mov_b64 s[6:7], s[2:3]
571 ; SI-NEXT: s_cmp_eq_u32 s8, 1
572 ; SI-NEXT: s_waitcnt vmcnt(0)
573 ; SI-NEXT: v_cvt_f32_f16_e32 v0, v1
574 ; SI-NEXT: v_lshrrev_b32_e32 v1, 16, v1
575 ; SI-NEXT: v_cvt_f32_f16_e32 v5, v2
576 ; SI-NEXT: v_lshrrev_b32_e32 v2, 16, v2
577 ; SI-NEXT: v_cvt_f32_f16_e32 v8, v3
578 ; SI-NEXT: v_lshrrev_b32_e32 v3, 16, v3
579 ; SI-NEXT: v_cvt_f32_f16_e32 v9, v4
580 ; SI-NEXT: v_lshrrev_b32_e32 v4, 16, v4
581 ; SI-NEXT: v_cvt_f32_f16_e32 v1, v1
582 ; SI-NEXT: s_cselect_b64 vcc, -1, 0
583 ; SI-NEXT: s_cmp_eq_u32 s8, 2
584 ; SI-NEXT: v_cvt_f32_f16_e32 v2, v2
585 ; SI-NEXT: v_cvt_f32_f16_e32 v3, v3
586 ; SI-NEXT: v_cvt_f32_f16_e32 v4, v4
587 ; SI-NEXT: v_cndmask_b32_e32 v0, v0, v1, vcc
588 ; SI-NEXT: s_cselect_b64 vcc, -1, 0
589 ; SI-NEXT: s_cmp_eq_u32 s8, 3
590 ; SI-NEXT: v_cndmask_b32_e32 v0, v0, v5, vcc
591 ; SI-NEXT: s_cselect_b64 vcc, -1, 0
592 ; SI-NEXT: s_cmp_eq_u32 s8, 4
593 ; SI-NEXT: v_cndmask_b32_e32 v0, v0, v2, vcc
594 ; SI-NEXT: s_cselect_b64 vcc, -1, 0
595 ; SI-NEXT: s_cmp_eq_u32 s8, 5
596 ; SI-NEXT: v_cndmask_b32_e32 v0, v0, v8, vcc
597 ; SI-NEXT: s_cselect_b64 vcc, -1, 0
598 ; SI-NEXT: s_cmp_eq_u32 s8, 6
599 ; SI-NEXT: v_cndmask_b32_e32 v0, v0, v3, vcc
600 ; SI-NEXT: s_cselect_b64 vcc, -1, 0
601 ; SI-NEXT: s_cmp_eq_u32 s8, 7
602 ; SI-NEXT: v_cndmask_b32_e32 v0, v0, v9, vcc
603 ; SI-NEXT: s_cselect_b64 vcc, -1, 0
604 ; SI-NEXT: v_cndmask_b32_e32 v0, v0, v4, vcc
605 ; SI-NEXT: v_cvt_f16_f32_e32 v0, v0
606 ; SI-NEXT: buffer_store_short v0, v[6:7], s[4:7], 0 addr64
609 ; VI-LABEL: v_extractelement_v8f16_dynamic_sgpr:
611 ; VI-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
612 ; VI-NEXT: s_load_dword s0, s[0:1], 0x34
613 ; VI-NEXT: v_lshlrev_b32_e32 v1, 4, v0
614 ; VI-NEXT: v_lshlrev_b32_e32 v0, 1, v0
615 ; VI-NEXT: s_waitcnt lgkmcnt(0)
616 ; VI-NEXT: v_mov_b32_e32 v2, s7
617 ; VI-NEXT: v_add_u32_e32 v1, vcc, s6, v1
618 ; VI-NEXT: v_addc_u32_e32 v2, vcc, 0, v2, vcc
619 ; VI-NEXT: flat_load_dwordx4 v[1:4], v[1:2]
620 ; VI-NEXT: v_mov_b32_e32 v6, s5
621 ; VI-NEXT: v_add_u32_e32 v5, vcc, s4, v0
622 ; VI-NEXT: s_cmp_eq_u32 s0, 1
623 ; VI-NEXT: v_addc_u32_e32 v6, vcc, 0, v6, vcc
624 ; VI-NEXT: s_cselect_b64 vcc, -1, 0
625 ; VI-NEXT: s_cmp_eq_u32 s0, 2
626 ; VI-NEXT: s_waitcnt vmcnt(0)
627 ; VI-NEXT: v_lshrrev_b32_e32 v0, 16, v1
628 ; VI-NEXT: v_cndmask_b32_e32 v0, v1, v0, vcc
629 ; VI-NEXT: s_cselect_b64 vcc, -1, 0
630 ; VI-NEXT: s_cmp_eq_u32 s0, 3
631 ; VI-NEXT: v_lshrrev_b32_e32 v7, 16, v2
632 ; VI-NEXT: v_cndmask_b32_e32 v0, v0, v2, vcc
633 ; VI-NEXT: s_cselect_b64 vcc, -1, 0
634 ; VI-NEXT: s_cmp_eq_u32 s0, 4
635 ; VI-NEXT: v_cndmask_b32_e32 v0, v0, v7, vcc
636 ; VI-NEXT: s_cselect_b64 vcc, -1, 0
637 ; VI-NEXT: s_cmp_eq_u32 s0, 5
638 ; VI-NEXT: v_lshrrev_b32_e32 v8, 16, v3
639 ; VI-NEXT: v_cndmask_b32_e32 v0, v0, v3, vcc
640 ; VI-NEXT: s_cselect_b64 vcc, -1, 0
641 ; VI-NEXT: s_cmp_eq_u32 s0, 6
642 ; VI-NEXT: v_cndmask_b32_e32 v0, v0, v8, vcc
643 ; VI-NEXT: s_cselect_b64 vcc, -1, 0
644 ; VI-NEXT: s_cmp_eq_u32 s0, 7
645 ; VI-NEXT: v_lshrrev_b32_e32 v9, 16, v4
646 ; VI-NEXT: v_cndmask_b32_e32 v0, v0, v4, vcc
647 ; VI-NEXT: s_cselect_b64 vcc, -1, 0
648 ; VI-NEXT: v_cndmask_b32_e32 v0, v0, v9, vcc
649 ; VI-NEXT: flat_store_short v[5:6], v0
652 ; GFX11-LABEL: v_extractelement_v8f16_dynamic_sgpr:
654 ; GFX11-NEXT: s_load_b128 s[4:7], s[0:1], 0x24
655 ; GFX11-NEXT: v_lshlrev_b32_e32 v1, 4, v0
656 ; GFX11-NEXT: s_load_b32 s0, s[0:1], 0x34
657 ; GFX11-NEXT: v_lshlrev_b32_e32 v0, 1, v0
658 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
659 ; GFX11-NEXT: global_load_b128 v[1:4], v1, s[6:7]
660 ; GFX11-NEXT: s_cmp_eq_u32 s0, 1
661 ; GFX11-NEXT: s_cselect_b32 vcc_lo, -1, 0
662 ; GFX11-NEXT: s_cmp_eq_u32 s0, 2
663 ; GFX11-NEXT: s_waitcnt vmcnt(0)
664 ; GFX11-NEXT: v_lshrrev_b32_e32 v5, 16, v1
665 ; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_2)
666 ; GFX11-NEXT: v_cndmask_b32_e32 v1, v1, v5, vcc_lo
667 ; GFX11-NEXT: s_cselect_b32 vcc_lo, -1, 0
668 ; GFX11-NEXT: v_lshrrev_b32_e32 v5, 16, v2
669 ; GFX11-NEXT: s_cmp_eq_u32 s0, 3
670 ; GFX11-NEXT: v_cndmask_b32_e32 v1, v1, v2, vcc_lo
671 ; GFX11-NEXT: s_cselect_b32 vcc_lo, -1, 0
672 ; GFX11-NEXT: s_cmp_eq_u32 s0, 4
673 ; GFX11-NEXT: v_lshrrev_b32_e32 v2, 16, v3
674 ; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1)
675 ; GFX11-NEXT: v_cndmask_b32_e32 v1, v1, v5, vcc_lo
676 ; GFX11-NEXT: s_cselect_b32 vcc_lo, -1, 0
677 ; GFX11-NEXT: s_cmp_eq_u32 s0, 5
678 ; GFX11-NEXT: v_cndmask_b32_e32 v1, v1, v3, vcc_lo
679 ; GFX11-NEXT: s_cselect_b32 vcc_lo, -1, 0
680 ; GFX11-NEXT: s_cmp_eq_u32 s0, 6
681 ; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_2)
682 ; GFX11-NEXT: v_cndmask_b32_e32 v1, v1, v2, vcc_lo
683 ; GFX11-NEXT: s_cselect_b32 vcc_lo, -1, 0
684 ; GFX11-NEXT: v_lshrrev_b32_e32 v2, 16, v4
685 ; GFX11-NEXT: s_cmp_eq_u32 s0, 7
686 ; GFX11-NEXT: v_cndmask_b32_e32 v1, v1, v4, vcc_lo
687 ; GFX11-NEXT: s_cselect_b32 vcc_lo, -1, 0
688 ; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1)
689 ; GFX11-NEXT: v_cndmask_b32_e32 v1, v1, v2, vcc_lo
690 ; GFX11-NEXT: global_store_b16 v0, v1, s[4:5]
691 ; GFX11-NEXT: s_nop 0
692 ; GFX11-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
693 ; GFX11-NEXT: s_endpgm
694 %tid = call i32 @llvm.amdgcn.workitem.id.x() #1
695 %tid.ext = sext i32 %tid to i64
696 %in.gep = getelementptr inbounds <8 x half>, ptr addrspace(1) %in, i64 %tid.ext
697 %out.gep = getelementptr inbounds half, ptr addrspace(1) %out, i64 %tid.ext
698 %vec = load <8 x half>, ptr addrspace(1) %in.gep
699 %vec.extract = extractelement <8 x half> %vec, i32 %n
700 store half %vec.extract, ptr addrspace(1) %out.gep
704 define amdgpu_kernel void @v_extractelement_v16f16_dynamic_sgpr(ptr addrspace(1) %out, ptr addrspace(1) %in, i32 %n) #0 {
705 ; SI-LABEL: v_extractelement_v16f16_dynamic_sgpr:
707 ; SI-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
708 ; SI-NEXT: s_load_dword s8, s[0:1], 0xd
709 ; SI-NEXT: s_mov_b32 s3, 0xf000
710 ; SI-NEXT: s_mov_b32 s2, 0
711 ; SI-NEXT: v_lshlrev_b32_e32 v5, 5, v0
712 ; SI-NEXT: v_mov_b32_e32 v6, 0
713 ; SI-NEXT: s_waitcnt lgkmcnt(0)
714 ; SI-NEXT: s_mov_b64 s[0:1], s[6:7]
715 ; SI-NEXT: buffer_load_dwordx4 v[1:4], v[5:6], s[0:3], 0 addr64
716 ; SI-NEXT: v_lshlrev_b32_e32 v9, 1, v0
717 ; SI-NEXT: v_mov_b32_e32 v10, v6
718 ; SI-NEXT: s_mov_b64 s[6:7], s[2:3]
719 ; SI-NEXT: buffer_load_dwordx4 v[5:8], v[5:6], s[0:3], 0 addr64 offset:16
720 ; SI-NEXT: s_cmp_eq_u32 s8, 1
721 ; SI-NEXT: s_waitcnt vmcnt(1)
722 ; SI-NEXT: v_cvt_f32_f16_e32 v0, v1
723 ; SI-NEXT: v_lshrrev_b32_e32 v1, 16, v1
724 ; SI-NEXT: v_cvt_f32_f16_e32 v11, v2
725 ; SI-NEXT: v_lshrrev_b32_e32 v2, 16, v2
726 ; SI-NEXT: v_cvt_f32_f16_e32 v12, v3
727 ; SI-NEXT: v_lshrrev_b32_e32 v3, 16, v3
728 ; SI-NEXT: v_cvt_f32_f16_e32 v13, v4
729 ; SI-NEXT: v_lshrrev_b32_e32 v4, 16, v4
730 ; SI-NEXT: s_waitcnt vmcnt(0)
731 ; SI-NEXT: v_cvt_f32_f16_e32 v14, v5
732 ; SI-NEXT: v_lshrrev_b32_e32 v5, 16, v5
733 ; SI-NEXT: v_cvt_f32_f16_e32 v15, v6
734 ; SI-NEXT: v_lshrrev_b32_e32 v6, 16, v6
735 ; SI-NEXT: v_cvt_f32_f16_e32 v16, v7
736 ; SI-NEXT: v_lshrrev_b32_e32 v7, 16, v7
737 ; SI-NEXT: v_cvt_f32_f16_e32 v17, v8
738 ; SI-NEXT: v_lshrrev_b32_e32 v8, 16, v8
739 ; SI-NEXT: v_cvt_f32_f16_e32 v1, v1
740 ; SI-NEXT: s_cselect_b64 vcc, -1, 0
741 ; SI-NEXT: s_cmp_eq_u32 s8, 2
742 ; SI-NEXT: v_cvt_f32_f16_e32 v2, v2
743 ; SI-NEXT: v_cvt_f32_f16_e32 v3, v3
744 ; SI-NEXT: v_cvt_f32_f16_e32 v4, v4
745 ; SI-NEXT: v_cvt_f32_f16_e32 v5, v5
746 ; SI-NEXT: v_cvt_f32_f16_e32 v6, v6
747 ; SI-NEXT: v_cvt_f32_f16_e32 v7, v7
748 ; SI-NEXT: v_cvt_f32_f16_e32 v8, v8
749 ; SI-NEXT: v_cndmask_b32_e32 v0, v0, v1, vcc
750 ; SI-NEXT: s_cselect_b64 vcc, -1, 0
751 ; SI-NEXT: s_cmp_eq_u32 s8, 3
752 ; SI-NEXT: v_cndmask_b32_e32 v0, v0, v11, vcc
753 ; SI-NEXT: s_cselect_b64 vcc, -1, 0
754 ; SI-NEXT: s_cmp_eq_u32 s8, 4
755 ; SI-NEXT: v_cndmask_b32_e32 v0, v0, v2, vcc
756 ; SI-NEXT: s_cselect_b64 vcc, -1, 0
757 ; SI-NEXT: s_cmp_eq_u32 s8, 5
758 ; SI-NEXT: v_cndmask_b32_e32 v0, v0, v12, vcc
759 ; SI-NEXT: s_cselect_b64 vcc, -1, 0
760 ; SI-NEXT: s_cmp_eq_u32 s8, 6
761 ; SI-NEXT: v_cndmask_b32_e32 v0, v0, v3, vcc
762 ; SI-NEXT: s_cselect_b64 vcc, -1, 0
763 ; SI-NEXT: s_cmp_eq_u32 s8, 7
764 ; SI-NEXT: v_cndmask_b32_e32 v0, v0, v13, vcc
765 ; SI-NEXT: s_cselect_b64 vcc, -1, 0
766 ; SI-NEXT: s_cmp_eq_u32 s8, 8
767 ; SI-NEXT: v_cndmask_b32_e32 v0, v0, v4, vcc
768 ; SI-NEXT: s_cselect_b64 vcc, -1, 0
769 ; SI-NEXT: s_cmp_eq_u32 s8, 9
770 ; SI-NEXT: v_cndmask_b32_e32 v0, v0, v14, vcc
771 ; SI-NEXT: s_cselect_b64 vcc, -1, 0
772 ; SI-NEXT: s_cmp_eq_u32 s8, 10
773 ; SI-NEXT: v_cndmask_b32_e32 v0, v0, v5, vcc
774 ; SI-NEXT: s_cselect_b64 vcc, -1, 0
775 ; SI-NEXT: s_cmp_eq_u32 s8, 11
776 ; SI-NEXT: v_cndmask_b32_e32 v0, v0, v15, vcc
777 ; SI-NEXT: s_cselect_b64 vcc, -1, 0
778 ; SI-NEXT: s_cmp_eq_u32 s8, 12
779 ; SI-NEXT: v_cndmask_b32_e32 v0, v0, v6, vcc
780 ; SI-NEXT: s_cselect_b64 vcc, -1, 0
781 ; SI-NEXT: s_cmp_eq_u32 s8, 13
782 ; SI-NEXT: v_cndmask_b32_e32 v0, v0, v16, vcc
783 ; SI-NEXT: s_cselect_b64 vcc, -1, 0
784 ; SI-NEXT: s_cmp_eq_u32 s8, 14
785 ; SI-NEXT: v_cndmask_b32_e32 v0, v0, v7, vcc
786 ; SI-NEXT: s_cselect_b64 vcc, -1, 0
787 ; SI-NEXT: s_cmp_eq_u32 s8, 15
788 ; SI-NEXT: v_cndmask_b32_e32 v0, v0, v17, vcc
789 ; SI-NEXT: s_cselect_b64 vcc, -1, 0
790 ; SI-NEXT: v_cndmask_b32_e32 v0, v0, v8, vcc
791 ; SI-NEXT: v_cvt_f16_f32_e32 v0, v0
792 ; SI-NEXT: buffer_store_short v0, v[9:10], s[4:7], 0 addr64
795 ; VI-LABEL: v_extractelement_v16f16_dynamic_sgpr:
797 ; VI-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
798 ; VI-NEXT: s_load_dword s0, s[0:1], 0x34
799 ; VI-NEXT: v_lshlrev_b32_e32 v1, 5, v0
800 ; VI-NEXT: v_lshlrev_b32_e32 v0, 1, v0
801 ; VI-NEXT: s_waitcnt lgkmcnt(0)
802 ; VI-NEXT: v_mov_b32_e32 v2, s7
803 ; VI-NEXT: v_add_u32_e32 v5, vcc, s6, v1
804 ; VI-NEXT: v_addc_u32_e32 v6, vcc, 0, v2, vcc
805 ; VI-NEXT: flat_load_dwordx4 v[1:4], v[5:6]
806 ; VI-NEXT: v_add_u32_e32 v5, vcc, 16, v5
807 ; VI-NEXT: v_addc_u32_e32 v6, vcc, 0, v6, vcc
808 ; VI-NEXT: flat_load_dwordx4 v[5:8], v[5:6]
809 ; VI-NEXT: v_mov_b32_e32 v10, s5
810 ; VI-NEXT: v_add_u32_e32 v9, vcc, s4, v0
811 ; VI-NEXT: s_cmp_eq_u32 s0, 1
812 ; VI-NEXT: v_addc_u32_e32 v10, vcc, 0, v10, vcc
813 ; VI-NEXT: s_cselect_b64 vcc, -1, 0
814 ; VI-NEXT: s_cmp_eq_u32 s0, 2
815 ; VI-NEXT: s_waitcnt vmcnt(1)
816 ; VI-NEXT: v_lshrrev_b32_e32 v0, 16, v1
817 ; VI-NEXT: v_cndmask_b32_e32 v0, v1, v0, vcc
818 ; VI-NEXT: s_cselect_b64 vcc, -1, 0
819 ; VI-NEXT: s_cmp_eq_u32 s0, 3
820 ; VI-NEXT: v_lshrrev_b32_e32 v11, 16, v2
821 ; VI-NEXT: v_cndmask_b32_e32 v0, v0, v2, vcc
822 ; VI-NEXT: s_cselect_b64 vcc, -1, 0
823 ; VI-NEXT: s_cmp_eq_u32 s0, 4
824 ; VI-NEXT: v_cndmask_b32_e32 v0, v0, v11, vcc
825 ; VI-NEXT: s_cselect_b64 vcc, -1, 0
826 ; VI-NEXT: s_cmp_eq_u32 s0, 5
827 ; VI-NEXT: v_lshrrev_b32_e32 v12, 16, v3
828 ; VI-NEXT: v_cndmask_b32_e32 v0, v0, v3, vcc
829 ; VI-NEXT: s_cselect_b64 vcc, -1, 0
830 ; VI-NEXT: s_cmp_eq_u32 s0, 6
831 ; VI-NEXT: v_cndmask_b32_e32 v0, v0, v12, vcc
832 ; VI-NEXT: s_cselect_b64 vcc, -1, 0
833 ; VI-NEXT: s_cmp_eq_u32 s0, 7
834 ; VI-NEXT: v_lshrrev_b32_e32 v13, 16, v4
835 ; VI-NEXT: v_cndmask_b32_e32 v0, v0, v4, vcc
836 ; VI-NEXT: s_cselect_b64 vcc, -1, 0
837 ; VI-NEXT: s_cmp_eq_u32 s0, 8
838 ; VI-NEXT: v_cndmask_b32_e32 v0, v0, v13, vcc
839 ; VI-NEXT: s_cselect_b64 vcc, -1, 0
840 ; VI-NEXT: s_cmp_eq_u32 s0, 9
841 ; VI-NEXT: s_waitcnt vmcnt(0)
842 ; VI-NEXT: v_lshrrev_b32_e32 v1, 16, v5
843 ; VI-NEXT: v_cndmask_b32_e32 v0, v0, v5, vcc
844 ; VI-NEXT: s_cselect_b64 vcc, -1, 0
845 ; VI-NEXT: s_cmp_eq_u32 s0, 10
846 ; VI-NEXT: v_cndmask_b32_e32 v0, v0, v1, vcc
847 ; VI-NEXT: s_cselect_b64 vcc, -1, 0
848 ; VI-NEXT: s_cmp_eq_u32 s0, 11
849 ; VI-NEXT: v_lshrrev_b32_e32 v14, 16, v6
850 ; VI-NEXT: v_cndmask_b32_e32 v0, v0, v6, vcc
851 ; VI-NEXT: s_cselect_b64 vcc, -1, 0
852 ; VI-NEXT: s_cmp_eq_u32 s0, 12
853 ; VI-NEXT: v_cndmask_b32_e32 v0, v0, v14, vcc
854 ; VI-NEXT: s_cselect_b64 vcc, -1, 0
855 ; VI-NEXT: s_cmp_eq_u32 s0, 13
856 ; VI-NEXT: v_lshrrev_b32_e32 v15, 16, v7
857 ; VI-NEXT: v_cndmask_b32_e32 v0, v0, v7, vcc
858 ; VI-NEXT: s_cselect_b64 vcc, -1, 0
859 ; VI-NEXT: s_cmp_eq_u32 s0, 14
860 ; VI-NEXT: v_cndmask_b32_e32 v0, v0, v15, vcc
861 ; VI-NEXT: s_cselect_b64 vcc, -1, 0
862 ; VI-NEXT: s_cmp_eq_u32 s0, 15
863 ; VI-NEXT: v_lshrrev_b32_e32 v16, 16, v8
864 ; VI-NEXT: v_cndmask_b32_e32 v0, v0, v8, vcc
865 ; VI-NEXT: s_cselect_b64 vcc, -1, 0
866 ; VI-NEXT: v_cndmask_b32_e32 v0, v0, v16, vcc
867 ; VI-NEXT: flat_store_short v[9:10], v0
870 ; GFX11-LABEL: v_extractelement_v16f16_dynamic_sgpr:
872 ; GFX11-NEXT: s_load_b128 s[4:7], s[0:1], 0x24
873 ; GFX11-NEXT: v_lshlrev_b32_e32 v5, 5, v0
874 ; GFX11-NEXT: s_load_b32 s0, s[0:1], 0x34
875 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
876 ; GFX11-NEXT: s_clause 0x1
877 ; GFX11-NEXT: global_load_b128 v[1:4], v5, s[6:7]
878 ; GFX11-NEXT: global_load_b128 v[5:8], v5, s[6:7] offset:16
879 ; GFX11-NEXT: v_lshlrev_b32_e32 v0, 1, v0
880 ; GFX11-NEXT: s_cmp_eq_u32 s0, 1
881 ; GFX11-NEXT: s_cselect_b32 vcc_lo, -1, 0
882 ; GFX11-NEXT: s_cmp_eq_u32 s0, 2
883 ; GFX11-NEXT: s_waitcnt vmcnt(1)
884 ; GFX11-NEXT: v_lshrrev_b32_e32 v9, 16, v1
885 ; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_2)
886 ; GFX11-NEXT: v_cndmask_b32_e32 v1, v1, v9, vcc_lo
887 ; GFX11-NEXT: s_cselect_b32 vcc_lo, -1, 0
888 ; GFX11-NEXT: v_lshrrev_b32_e32 v9, 16, v2
889 ; GFX11-NEXT: s_cmp_eq_u32 s0, 3
890 ; GFX11-NEXT: v_cndmask_b32_e32 v1, v1, v2, vcc_lo
891 ; GFX11-NEXT: s_cselect_b32 vcc_lo, -1, 0
892 ; GFX11-NEXT: s_cmp_eq_u32 s0, 4
893 ; GFX11-NEXT: v_lshrrev_b32_e32 v2, 16, v3
894 ; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1)
895 ; GFX11-NEXT: v_cndmask_b32_e32 v1, v1, v9, vcc_lo
896 ; GFX11-NEXT: s_cselect_b32 vcc_lo, -1, 0
897 ; GFX11-NEXT: s_cmp_eq_u32 s0, 5
898 ; GFX11-NEXT: v_cndmask_b32_e32 v1, v1, v3, vcc_lo
899 ; GFX11-NEXT: s_cselect_b32 vcc_lo, -1, 0
900 ; GFX11-NEXT: s_cmp_eq_u32 s0, 6
901 ; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_2)
902 ; GFX11-NEXT: v_cndmask_b32_e32 v1, v1, v2, vcc_lo
903 ; GFX11-NEXT: s_cselect_b32 vcc_lo, -1, 0
904 ; GFX11-NEXT: v_lshrrev_b32_e32 v2, 16, v4
905 ; GFX11-NEXT: s_cmp_eq_u32 s0, 7
906 ; GFX11-NEXT: v_cndmask_b32_e32 v1, v1, v4, vcc_lo
907 ; GFX11-NEXT: s_cselect_b32 vcc_lo, -1, 0
908 ; GFX11-NEXT: s_cmp_eq_u32 s0, 8
909 ; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1)
910 ; GFX11-NEXT: v_cndmask_b32_e32 v1, v1, v2, vcc_lo
911 ; GFX11-NEXT: s_cselect_b32 vcc_lo, -1, 0
912 ; GFX11-NEXT: s_waitcnt vmcnt(0)
913 ; GFX11-NEXT: v_lshrrev_b32_e32 v2, 16, v5
914 ; GFX11-NEXT: s_cmp_eq_u32 s0, 9
915 ; GFX11-NEXT: v_cndmask_b32_e32 v1, v1, v5, vcc_lo
916 ; GFX11-NEXT: s_cselect_b32 vcc_lo, -1, 0
917 ; GFX11-NEXT: s_cmp_eq_u32 s0, 10
918 ; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_2)
919 ; GFX11-NEXT: v_cndmask_b32_e32 v1, v1, v2, vcc_lo
920 ; GFX11-NEXT: s_cselect_b32 vcc_lo, -1, 0
921 ; GFX11-NEXT: v_lshrrev_b32_e32 v2, 16, v6
922 ; GFX11-NEXT: s_cmp_eq_u32 s0, 11
923 ; GFX11-NEXT: v_cndmask_b32_e32 v1, v1, v6, vcc_lo
924 ; GFX11-NEXT: s_cselect_b32 vcc_lo, -1, 0
925 ; GFX11-NEXT: s_cmp_eq_u32 s0, 12
926 ; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_2)
927 ; GFX11-NEXT: v_cndmask_b32_e32 v1, v1, v2, vcc_lo
928 ; GFX11-NEXT: s_cselect_b32 vcc_lo, -1, 0
929 ; GFX11-NEXT: v_lshrrev_b32_e32 v2, 16, v7
930 ; GFX11-NEXT: s_cmp_eq_u32 s0, 13
931 ; GFX11-NEXT: v_cndmask_b32_e32 v1, v1, v7, vcc_lo
932 ; GFX11-NEXT: s_cselect_b32 vcc_lo, -1, 0
933 ; GFX11-NEXT: s_cmp_eq_u32 s0, 14
934 ; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_2)
935 ; GFX11-NEXT: v_cndmask_b32_e32 v1, v1, v2, vcc_lo
936 ; GFX11-NEXT: s_cselect_b32 vcc_lo, -1, 0
937 ; GFX11-NEXT: v_lshrrev_b32_e32 v2, 16, v8
938 ; GFX11-NEXT: s_cmp_eq_u32 s0, 15
939 ; GFX11-NEXT: v_cndmask_b32_e32 v1, v1, v8, vcc_lo
940 ; GFX11-NEXT: s_cselect_b32 vcc_lo, -1, 0
941 ; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1)
942 ; GFX11-NEXT: v_cndmask_b32_e32 v1, v1, v2, vcc_lo
943 ; GFX11-NEXT: global_store_b16 v0, v1, s[4:5]
944 ; GFX11-NEXT: s_nop 0
945 ; GFX11-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
946 ; GFX11-NEXT: s_endpgm
947 %tid = call i32 @llvm.amdgcn.workitem.id.x() #1
948 %tid.ext = sext i32 %tid to i64
949 %in.gep = getelementptr inbounds <16 x half>, ptr addrspace(1) %in, i64 %tid.ext
950 %out.gep = getelementptr inbounds half, ptr addrspace(1) %out, i64 %tid.ext
951 %vec = load <16 x half>, ptr addrspace(1) %in.gep
952 %vec.extract = extractelement <16 x half> %vec, i32 %n
953 store half %vec.extract, ptr addrspace(1) %out.gep
957 declare i32 @llvm.amdgcn.workitem.id.x() #1
959 attributes #0 = { nounwind }
960 attributes #1 = { nounwind readnone }