1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=amdgcn-- -mcpu=tahiti -verify-machineinstrs < %s | FileCheck %s -allow-deprecated-dag-overlap -check-prefixes=GCN,SI
3 ; RUN: llc -mtriple=amdgcn-- -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck %s -allow-deprecated-dag-overlap -check-prefixes=GCN,VI
5 declare i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
6 declare i32 @llvm.amdgcn.workitem.id.y() nounwind readnone
8 define amdgpu_kernel void @load_i8_to_f32(float addrspace(1)* noalias %out, i8 addrspace(1)* noalias %in) nounwind {
9 ; SI-LABEL: load_i8_to_f32:
11 ; SI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
12 ; SI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
13 ; SI-NEXT: s_mov_b32 s7, 0xf000
14 ; SI-NEXT: v_mov_b32_e32 v1, 0
15 ; SI-NEXT: s_mov_b32 s2, 0
16 ; SI-NEXT: s_mov_b32 s3, s7
17 ; SI-NEXT: s_waitcnt lgkmcnt(0)
18 ; SI-NEXT: buffer_load_ubyte v0, v[0:1], s[0:3], 0 addr64
19 ; SI-NEXT: s_mov_b32 s6, -1
20 ; SI-NEXT: s_waitcnt vmcnt(0)
21 ; SI-NEXT: v_cvt_f32_ubyte0_e32 v0, v0
22 ; SI-NEXT: buffer_store_dword v0, off, s[4:7], 0
25 ; VI-LABEL: load_i8_to_f32:
27 ; VI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
28 ; VI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2c
29 ; VI-NEXT: s_mov_b32 s7, 0xf000
30 ; VI-NEXT: s_mov_b32 s6, -1
31 ; VI-NEXT: s_waitcnt lgkmcnt(0)
32 ; VI-NEXT: v_mov_b32_e32 v1, s1
33 ; VI-NEXT: v_add_u32_e32 v0, vcc, s0, v0
34 ; VI-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
35 ; VI-NEXT: flat_load_ubyte v0, v[0:1]
36 ; VI-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
37 ; VI-NEXT: v_cvt_f32_ubyte0_e32 v0, v0
38 ; VI-NEXT: buffer_store_dword v0, off, s[4:7], 0
40 %tid = call i32 @llvm.amdgcn.workitem.id.x()
41 %gep = getelementptr i8, i8 addrspace(1)* %in, i32 %tid
42 %load = load i8, i8 addrspace(1)* %gep, align 1
43 %cvt = uitofp i8 %load to float
44 store float %cvt, float addrspace(1)* %out, align 4
48 define amdgpu_kernel void @load_v2i8_to_v2f32(<2 x float> addrspace(1)* noalias %out, <2 x i8> addrspace(1)* noalias %in) nounwind {
49 ; SI-LABEL: load_v2i8_to_v2f32:
51 ; SI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
52 ; SI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
53 ; SI-NEXT: s_mov_b32 s7, 0xf000
54 ; SI-NEXT: s_mov_b32 s2, 0
55 ; SI-NEXT: s_mov_b32 s3, s7
56 ; SI-NEXT: v_lshlrev_b32_e32 v0, 1, v0
57 ; SI-NEXT: v_mov_b32_e32 v1, 0
58 ; SI-NEXT: s_waitcnt lgkmcnt(0)
59 ; SI-NEXT: buffer_load_ushort v0, v[0:1], s[0:3], 0 addr64
60 ; SI-NEXT: s_mov_b32 s6, -1
61 ; SI-NEXT: s_waitcnt vmcnt(0)
62 ; SI-NEXT: v_cvt_f32_ubyte1_e32 v1, v0
63 ; SI-NEXT: v_cvt_f32_ubyte0_e32 v0, v0
64 ; SI-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
67 ; VI-LABEL: load_v2i8_to_v2f32:
69 ; VI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
70 ; VI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2c
71 ; VI-NEXT: v_lshlrev_b32_e32 v0, 1, v0
72 ; VI-NEXT: s_mov_b32 s7, 0xf000
73 ; VI-NEXT: s_mov_b32 s6, -1
74 ; VI-NEXT: s_waitcnt lgkmcnt(0)
75 ; VI-NEXT: v_mov_b32_e32 v1, s1
76 ; VI-NEXT: v_add_u32_e32 v0, vcc, s0, v0
77 ; VI-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
78 ; VI-NEXT: flat_load_ushort v0, v[0:1]
79 ; VI-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
80 ; VI-NEXT: v_cvt_f32_ubyte1_e32 v1, v0
81 ; VI-NEXT: v_cvt_f32_ubyte0_e32 v0, v0
82 ; VI-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
84 %tid = call i32 @llvm.amdgcn.workitem.id.x()
85 %gep = getelementptr <2 x i8>, <2 x i8> addrspace(1)* %in, i32 %tid
86 %load = load <2 x i8>, <2 x i8> addrspace(1)* %gep, align 2
87 %cvt = uitofp <2 x i8> %load to <2 x float>
88 store <2 x float> %cvt, <2 x float> addrspace(1)* %out, align 16
92 define amdgpu_kernel void @load_v3i8_to_v3f32(<3 x float> addrspace(1)* noalias %out, <3 x i8> addrspace(1)* noalias %in) nounwind {
93 ; SI-LABEL: load_v3i8_to_v3f32:
95 ; SI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
96 ; SI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
97 ; SI-NEXT: s_mov_b32 s7, 0xf000
98 ; SI-NEXT: s_mov_b32 s2, 0
99 ; SI-NEXT: s_mov_b32 s3, s7
100 ; SI-NEXT: v_lshlrev_b32_e32 v0, 2, v0
101 ; SI-NEXT: v_mov_b32_e32 v1, 0
102 ; SI-NEXT: s_waitcnt lgkmcnt(0)
103 ; SI-NEXT: buffer_load_dword v2, v[0:1], s[0:3], 0 addr64
104 ; SI-NEXT: s_mov_b32 s6, -1
105 ; SI-NEXT: s_waitcnt vmcnt(0)
106 ; SI-NEXT: v_cvt_f32_ubyte1_e32 v1, v2
107 ; SI-NEXT: v_cvt_f32_ubyte0_e32 v0, v2
108 ; SI-NEXT: v_cvt_f32_ubyte2_e32 v2, v2
109 ; SI-NEXT: buffer_store_dword v2, off, s[4:7], 0 offset:8
110 ; SI-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
113 ; VI-LABEL: load_v3i8_to_v3f32:
115 ; VI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
116 ; VI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2c
117 ; VI-NEXT: v_lshlrev_b32_e32 v0, 2, v0
118 ; VI-NEXT: s_mov_b32 s7, 0xf000
119 ; VI-NEXT: s_mov_b32 s6, -1
120 ; VI-NEXT: s_waitcnt lgkmcnt(0)
121 ; VI-NEXT: v_mov_b32_e32 v1, s1
122 ; VI-NEXT: v_add_u32_e32 v0, vcc, s0, v0
123 ; VI-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
124 ; VI-NEXT: flat_load_dword v0, v[0:1]
125 ; VI-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
126 ; VI-NEXT: v_cvt_f32_ubyte2_e32 v2, v0
127 ; VI-NEXT: v_cvt_f32_ubyte1_e32 v1, v0
128 ; VI-NEXT: v_cvt_f32_ubyte0_e32 v0, v0
129 ; VI-NEXT: buffer_store_dwordx3 v[0:2], off, s[4:7], 0
131 %tid = call i32 @llvm.amdgcn.workitem.id.x()
132 %gep = getelementptr <3 x i8>, <3 x i8> addrspace(1)* %in, i32 %tid
133 %load = load <3 x i8>, <3 x i8> addrspace(1)* %gep, align 4
134 %cvt = uitofp <3 x i8> %load to <3 x float>
135 store <3 x float> %cvt, <3 x float> addrspace(1)* %out, align 16
139 define amdgpu_kernel void @load_v4i8_to_v4f32(<4 x float> addrspace(1)* noalias %out, <4 x i8> addrspace(1)* noalias %in) nounwind {
140 ; SI-LABEL: load_v4i8_to_v4f32:
142 ; SI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
143 ; SI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
144 ; SI-NEXT: s_mov_b32 s7, 0xf000
145 ; SI-NEXT: s_mov_b32 s2, 0
146 ; SI-NEXT: s_mov_b32 s3, s7
147 ; SI-NEXT: v_lshlrev_b32_e32 v0, 2, v0
148 ; SI-NEXT: v_mov_b32_e32 v1, 0
149 ; SI-NEXT: s_waitcnt lgkmcnt(0)
150 ; SI-NEXT: buffer_load_dword v0, v[0:1], s[0:3], 0 addr64
151 ; SI-NEXT: s_mov_b32 s6, -1
152 ; SI-NEXT: s_waitcnt vmcnt(0)
153 ; SI-NEXT: v_cvt_f32_ubyte3_e32 v3, v0
154 ; SI-NEXT: v_cvt_f32_ubyte2_e32 v2, v0
155 ; SI-NEXT: v_cvt_f32_ubyte1_e32 v1, v0
156 ; SI-NEXT: v_cvt_f32_ubyte0_e32 v0, v0
157 ; SI-NEXT: buffer_store_dwordx4 v[0:3], off, s[4:7], 0
160 ; VI-LABEL: load_v4i8_to_v4f32:
162 ; VI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
163 ; VI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2c
164 ; VI-NEXT: v_lshlrev_b32_e32 v0, 2, v0
165 ; VI-NEXT: s_mov_b32 s7, 0xf000
166 ; VI-NEXT: s_mov_b32 s6, -1
167 ; VI-NEXT: s_waitcnt lgkmcnt(0)
168 ; VI-NEXT: v_mov_b32_e32 v1, s1
169 ; VI-NEXT: v_add_u32_e32 v0, vcc, s0, v0
170 ; VI-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
171 ; VI-NEXT: flat_load_dword v0, v[0:1]
172 ; VI-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
173 ; VI-NEXT: v_cvt_f32_ubyte3_e32 v3, v0
174 ; VI-NEXT: v_cvt_f32_ubyte2_e32 v2, v0
175 ; VI-NEXT: v_cvt_f32_ubyte1_e32 v1, v0
176 ; VI-NEXT: v_cvt_f32_ubyte0_e32 v0, v0
177 ; VI-NEXT: buffer_store_dwordx4 v[0:3], off, s[4:7], 0
179 %tid = call i32 @llvm.amdgcn.workitem.id.x()
180 %gep = getelementptr <4 x i8>, <4 x i8> addrspace(1)* %in, i32 %tid
181 %load = load <4 x i8>, <4 x i8> addrspace(1)* %gep, align 4
182 %cvt = uitofp <4 x i8> %load to <4 x float>
183 store <4 x float> %cvt, <4 x float> addrspace(1)* %out, align 16
187 ; This should not be adding instructions to shift into the correct
188 ; position in the word for the component.
190 ; FIXME: Packing bytes
191 define amdgpu_kernel void @load_v4i8_to_v4f32_unaligned(<4 x float> addrspace(1)* noalias %out, <4 x i8> addrspace(1)* noalias %in) nounwind {
192 ; SI-LABEL: load_v4i8_to_v4f32_unaligned:
194 ; SI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
195 ; SI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
196 ; SI-NEXT: s_mov_b32 s7, 0xf000
197 ; SI-NEXT: s_mov_b32 s2, 0
198 ; SI-NEXT: s_mov_b32 s3, s7
199 ; SI-NEXT: v_lshlrev_b32_e32 v0, 2, v0
200 ; SI-NEXT: v_mov_b32_e32 v1, 0
201 ; SI-NEXT: s_waitcnt lgkmcnt(0)
202 ; SI-NEXT: buffer_load_ubyte v2, v[0:1], s[0:3], 0 addr64
203 ; SI-NEXT: buffer_load_ubyte v3, v[0:1], s[0:3], 0 addr64 offset:1
204 ; SI-NEXT: buffer_load_ubyte v4, v[0:1], s[0:3], 0 addr64 offset:2
205 ; SI-NEXT: buffer_load_ubyte v0, v[0:1], s[0:3], 0 addr64 offset:3
206 ; SI-NEXT: s_mov_b32 s6, -1
207 ; SI-NEXT: s_waitcnt vmcnt(2)
208 ; SI-NEXT: v_lshlrev_b32_e32 v1, 8, v3
209 ; SI-NEXT: v_or_b32_e32 v1, v1, v2
210 ; SI-NEXT: s_waitcnt vmcnt(0)
211 ; SI-NEXT: v_lshlrev_b32_e32 v0, 8, v0
212 ; SI-NEXT: v_or_b32_e32 v0, v0, v4
213 ; SI-NEXT: v_lshlrev_b32_e32 v0, 16, v0
214 ; SI-NEXT: v_or_b32_e32 v0, v0, v1
215 ; SI-NEXT: v_cvt_f32_ubyte3_e32 v3, v0
216 ; SI-NEXT: v_cvt_f32_ubyte2_e32 v2, v0
217 ; SI-NEXT: v_cvt_f32_ubyte1_e32 v1, v0
218 ; SI-NEXT: v_cvt_f32_ubyte0_e32 v0, v0
219 ; SI-NEXT: buffer_store_dwordx4 v[0:3], off, s[4:7], 0
222 ; VI-LABEL: load_v4i8_to_v4f32_unaligned:
224 ; VI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
225 ; VI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2c
226 ; VI-NEXT: v_lshlrev_b32_e32 v0, 2, v0
227 ; VI-NEXT: s_mov_b32 s7, 0xf000
228 ; VI-NEXT: s_mov_b32 s6, -1
229 ; VI-NEXT: s_waitcnt lgkmcnt(0)
230 ; VI-NEXT: v_mov_b32_e32 v1, s1
231 ; VI-NEXT: v_add_u32_e32 v0, vcc, s0, v0
232 ; VI-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
233 ; VI-NEXT: v_add_u32_e32 v2, vcc, 3, v0
234 ; VI-NEXT: v_addc_u32_e32 v3, vcc, 0, v1, vcc
235 ; VI-NEXT: v_add_u32_e32 v4, vcc, 2, v0
236 ; VI-NEXT: v_addc_u32_e32 v5, vcc, 0, v1, vcc
237 ; VI-NEXT: v_add_u32_e32 v6, vcc, 1, v0
238 ; VI-NEXT: v_addc_u32_e32 v7, vcc, 0, v1, vcc
239 ; VI-NEXT: flat_load_ubyte v0, v[0:1]
240 ; VI-NEXT: flat_load_ubyte v1, v[6:7]
241 ; VI-NEXT: flat_load_ubyte v4, v[4:5]
242 ; VI-NEXT: flat_load_ubyte v2, v[2:3]
243 ; VI-NEXT: s_waitcnt vmcnt(2) lgkmcnt(2)
244 ; VI-NEXT: v_lshlrev_b32_e32 v1, 8, v1
245 ; VI-NEXT: v_or_b32_e32 v0, v1, v0
246 ; VI-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
247 ; VI-NEXT: v_lshlrev_b32_e32 v2, 8, v2
248 ; VI-NEXT: v_or_b32_e32 v2, v2, v4
249 ; VI-NEXT: v_lshlrev_b32_e32 v3, 16, v2
250 ; VI-NEXT: v_cvt_f32_ubyte1_e32 v1, v0
251 ; VI-NEXT: v_cvt_f32_ubyte0_e32 v2, v2
252 ; VI-NEXT: v_cvt_f32_ubyte0_e32 v0, v0
253 ; VI-NEXT: v_cvt_f32_ubyte3_e32 v3, v3
254 ; VI-NEXT: buffer_store_dwordx4 v[0:3], off, s[4:7], 0
256 %tid = call i32 @llvm.amdgcn.workitem.id.x()
257 %gep = getelementptr <4 x i8>, <4 x i8> addrspace(1)* %in, i32 %tid
258 %load = load <4 x i8>, <4 x i8> addrspace(1)* %gep, align 1
259 %cvt = uitofp <4 x i8> %load to <4 x float>
260 store <4 x float> %cvt, <4 x float> addrspace(1)* %out, align 16
264 ; FIXME: Need to handle non-uniform case for function below (load without gep).
265 ; Instructions still emitted to repack bytes for add use.
266 define amdgpu_kernel void @load_v4i8_to_v4f32_2_uses(<4 x float> addrspace(1)* noalias %out, <4 x i8> addrspace(1)* noalias %out2, <4 x i8> addrspace(1)* noalias %in) nounwind {
267 ; SI-LABEL: load_v4i8_to_v4f32_2_uses:
269 ; SI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0xd
270 ; SI-NEXT: s_mov_b32 s3, 0xf000
271 ; SI-NEXT: s_mov_b32 s6, 0
272 ; SI-NEXT: s_mov_b32 s7, s3
273 ; SI-NEXT: v_lshlrev_b32_e32 v0, 2, v0
274 ; SI-NEXT: v_mov_b32_e32 v1, 0
275 ; SI-NEXT: s_waitcnt lgkmcnt(0)
276 ; SI-NEXT: buffer_load_dword v1, v[0:1], s[4:7], 0 addr64
277 ; SI-NEXT: s_load_dwordx2 s[8:9], s[0:1], 0x9
278 ; SI-NEXT: s_mov_b32 s2, -1
279 ; SI-NEXT: s_movk_i32 s12, 0xff
280 ; SI-NEXT: s_mov_b32 s10, s2
281 ; SI-NEXT: s_mov_b32 s11, s3
282 ; SI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
283 ; SI-NEXT: s_movk_i32 s13, 0x900
284 ; SI-NEXT: s_waitcnt vmcnt(0)
285 ; SI-NEXT: v_lshrrev_b32_e32 v4, 16, v1
286 ; SI-NEXT: v_add_i32_e32 v7, vcc, 9, v1
287 ; SI-NEXT: v_and_b32_e32 v6, 0xff00, v1
288 ; SI-NEXT: v_lshrrev_b32_e32 v5, 24, v1
289 ; SI-NEXT: v_cvt_f32_ubyte3_e32 v3, v1
290 ; SI-NEXT: v_cvt_f32_ubyte2_e32 v2, v1
291 ; SI-NEXT: v_cvt_f32_ubyte0_e32 v0, v1
292 ; SI-NEXT: v_cvt_f32_ubyte1_e32 v1, v6
293 ; SI-NEXT: v_and_b32_e32 v7, s12, v7
294 ; SI-NEXT: v_add_i32_e32 v4, vcc, 9, v4
295 ; SI-NEXT: s_waitcnt lgkmcnt(0)
296 ; SI-NEXT: buffer_store_dwordx4 v[0:3], off, s[8:11], 0
297 ; SI-NEXT: s_waitcnt expcnt(0)
298 ; SI-NEXT: v_or_b32_e32 v0, v6, v7
299 ; SI-NEXT: v_lshlrev_b32_e32 v5, 8, v5
300 ; SI-NEXT: v_and_b32_e32 v1, s12, v4
301 ; SI-NEXT: v_add_i32_e32 v0, vcc, s13, v0
302 ; SI-NEXT: v_or_b32_e32 v1, v5, v1
303 ; SI-NEXT: v_and_b32_e32 v0, 0xffff, v0
304 ; SI-NEXT: v_lshlrev_b32_e32 v1, 16, v1
305 ; SI-NEXT: v_or_b32_e32 v0, v1, v0
306 ; SI-NEXT: v_add_i32_e32 v0, vcc, 0x9000000, v0
307 ; SI-NEXT: buffer_store_dword v0, off, s[0:3], 0
310 ; VI-LABEL: load_v4i8_to_v4f32_2_uses:
312 ; VI-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
313 ; VI-NEXT: v_lshlrev_b32_e32 v0, 2, v0
314 ; VI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
315 ; VI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2c
316 ; VI-NEXT: v_mov_b32_e32 v4, 9
317 ; VI-NEXT: s_waitcnt lgkmcnt(0)
318 ; VI-NEXT: v_mov_b32_e32 v1, s3
319 ; VI-NEXT: v_add_u32_e32 v0, vcc, s2, v0
320 ; VI-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
321 ; VI-NEXT: flat_load_dword v5, v[0:1]
322 ; VI-NEXT: s_mov_b32 s3, 0xf000
323 ; VI-NEXT: s_mov_b32 s2, -1
324 ; VI-NEXT: s_mov_b32 s6, s2
325 ; VI-NEXT: s_mov_b32 s7, s3
326 ; VI-NEXT: s_movk_i32 s8, 0x900
327 ; VI-NEXT: v_mov_b32_e32 v6, s8
328 ; VI-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
329 ; VI-NEXT: v_lshrrev_b32_e32 v7, 24, v5
330 ; VI-NEXT: v_cvt_f32_ubyte3_e32 v3, v5
331 ; VI-NEXT: v_cvt_f32_ubyte2_e32 v2, v5
332 ; VI-NEXT: v_cvt_f32_ubyte1_e32 v1, v5
333 ; VI-NEXT: v_cvt_f32_ubyte0_e32 v0, v5
334 ; VI-NEXT: buffer_store_dwordx4 v[0:3], off, s[4:7], 0
335 ; VI-NEXT: v_and_b32_e32 v8, 0xffffff00, v5
336 ; VI-NEXT: v_add_u16_e32 v9, 9, v5
337 ; VI-NEXT: v_add_u16_sdwa v4, v5, v4 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:DWORD
338 ; VI-NEXT: v_lshlrev_b16_e32 v1, 8, v7
339 ; VI-NEXT: v_or_b32_sdwa v0, v8, v9 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:BYTE_0
340 ; VI-NEXT: v_or_b32_sdwa v1, v1, v4 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:BYTE_0
341 ; VI-NEXT: v_add_u16_e32 v0, s8, v0
342 ; VI-NEXT: v_add_u16_sdwa v1, v1, v6 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
343 ; VI-NEXT: v_or_b32_e32 v0, v0, v1
344 ; VI-NEXT: buffer_store_dword v0, off, s[0:3], 0
346 %tid.x = call i32 @llvm.amdgcn.workitem.id.x()
347 %in.ptr = getelementptr <4 x i8>, <4 x i8> addrspace(1)* %in, i32 %tid.x
348 %load = load <4 x i8>, <4 x i8> addrspace(1)* %in.ptr, align 4
349 %cvt = uitofp <4 x i8> %load to <4 x float>
350 store <4 x float> %cvt, <4 x float> addrspace(1)* %out, align 16
351 %add = add <4 x i8> %load, <i8 9, i8 9, i8 9, i8 9> ; Second use of %load
352 store <4 x i8> %add, <4 x i8> addrspace(1)* %out2, align 4
356 ; Make sure this doesn't crash.
357 define amdgpu_kernel void @load_v7i8_to_v7f32(<7 x float> addrspace(1)* noalias %out, <7 x i8> addrspace(1)* noalias %in) nounwind {
358 ; SI-LABEL: load_v7i8_to_v7f32:
360 ; SI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
361 ; SI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
362 ; SI-NEXT: s_mov_b32 s7, 0xf000
363 ; SI-NEXT: s_mov_b32 s2, 0
364 ; SI-NEXT: s_mov_b32 s3, s7
365 ; SI-NEXT: v_lshlrev_b32_e32 v0, 3, v0
366 ; SI-NEXT: v_mov_b32_e32 v1, 0
367 ; SI-NEXT: s_waitcnt lgkmcnt(0)
368 ; SI-NEXT: buffer_load_ubyte v2, v[0:1], s[0:3], 0 addr64
369 ; SI-NEXT: buffer_load_ubyte v3, v[0:1], s[0:3], 0 addr64 offset:1
370 ; SI-NEXT: buffer_load_ubyte v4, v[0:1], s[0:3], 0 addr64 offset:2
371 ; SI-NEXT: buffer_load_ubyte v5, v[0:1], s[0:3], 0 addr64 offset:3
372 ; SI-NEXT: buffer_load_ubyte v6, v[0:1], s[0:3], 0 addr64 offset:4
373 ; SI-NEXT: buffer_load_ubyte v7, v[0:1], s[0:3], 0 addr64 offset:5
374 ; SI-NEXT: buffer_load_ubyte v0, v[0:1], s[0:3], 0 addr64 offset:6
375 ; SI-NEXT: s_mov_b32 s6, -1
376 ; SI-NEXT: s_waitcnt vmcnt(5)
377 ; SI-NEXT: v_lshlrev_b32_e32 v1, 8, v3
378 ; SI-NEXT: v_or_b32_e32 v1, v1, v2
379 ; SI-NEXT: s_waitcnt vmcnt(3)
380 ; SI-NEXT: v_lshlrev_b32_e32 v2, 8, v5
381 ; SI-NEXT: v_or_b32_e32 v2, v2, v4
382 ; SI-NEXT: s_waitcnt vmcnt(1)
383 ; SI-NEXT: v_lshlrev_b32_e32 v3, 8, v7
384 ; SI-NEXT: s_waitcnt vmcnt(0)
385 ; SI-NEXT: v_cvt_f32_ubyte0_e32 v0, v0
386 ; SI-NEXT: buffer_store_dword v0, off, s[4:7], 0 offset:24
387 ; SI-NEXT: s_waitcnt expcnt(0)
388 ; SI-NEXT: v_lshlrev_b32_e32 v0, 16, v2
389 ; SI-NEXT: v_or_b32_e32 v0, v0, v1
390 ; SI-NEXT: v_or_b32_e32 v4, v3, v6
391 ; SI-NEXT: v_and_b32_e32 v5, 0xffff0000, v0
392 ; SI-NEXT: v_or_b32_e32 v4, v4, v5
393 ; SI-NEXT: v_cvt_f32_ubyte1_e32 v5, v4
394 ; SI-NEXT: v_cvt_f32_ubyte3_e32 v3, v0
395 ; SI-NEXT: v_cvt_f32_ubyte2_e32 v2, v0
396 ; SI-NEXT: v_cvt_f32_ubyte1_e32 v1, v0
397 ; SI-NEXT: v_cvt_f32_ubyte0_e32 v0, v0
398 ; SI-NEXT: v_cvt_f32_ubyte0_e32 v4, v4
399 ; SI-NEXT: buffer_store_dwordx4 v[0:3], off, s[4:7], 0
400 ; SI-NEXT: buffer_store_dwordx2 v[4:5], off, s[4:7], 0 offset:16
403 ; VI-LABEL: load_v7i8_to_v7f32:
405 ; VI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
406 ; VI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2c
407 ; VI-NEXT: v_lshlrev_b32_e32 v0, 3, v0
408 ; VI-NEXT: s_mov_b32 s7, 0xf000
409 ; VI-NEXT: s_mov_b32 s6, -1
410 ; VI-NEXT: s_waitcnt lgkmcnt(0)
411 ; VI-NEXT: v_mov_b32_e32 v1, s1
412 ; VI-NEXT: v_add_u32_e32 v0, vcc, s0, v0
413 ; VI-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
414 ; VI-NEXT: v_add_u32_e32 v2, vcc, 1, v0
415 ; VI-NEXT: v_addc_u32_e32 v3, vcc, 0, v1, vcc
416 ; VI-NEXT: v_add_u32_e32 v4, vcc, 3, v0
417 ; VI-NEXT: v_addc_u32_e32 v5, vcc, 0, v1, vcc
418 ; VI-NEXT: flat_load_ubyte v10, v[4:5]
419 ; VI-NEXT: flat_load_ubyte v11, v[2:3]
420 ; VI-NEXT: v_add_u32_e32 v2, vcc, 2, v0
421 ; VI-NEXT: v_addc_u32_e32 v3, vcc, 0, v1, vcc
422 ; VI-NEXT: v_add_u32_e32 v4, vcc, 5, v0
423 ; VI-NEXT: v_addc_u32_e32 v5, vcc, 0, v1, vcc
424 ; VI-NEXT: v_add_u32_e32 v6, vcc, 4, v0
425 ; VI-NEXT: v_addc_u32_e32 v7, vcc, 0, v1, vcc
426 ; VI-NEXT: v_add_u32_e32 v8, vcc, 6, v0
427 ; VI-NEXT: v_addc_u32_e32 v9, vcc, 0, v1, vcc
428 ; VI-NEXT: flat_load_ubyte v0, v[0:1]
429 ; VI-NEXT: flat_load_ubyte v1, v[8:9]
430 ; VI-NEXT: flat_load_ubyte v7, v[6:7]
431 ; VI-NEXT: flat_load_ubyte v4, v[4:5]
432 ; VI-NEXT: flat_load_ubyte v2, v[2:3]
433 ; VI-NEXT: s_waitcnt vmcnt(6) lgkmcnt(6)
434 ; VI-NEXT: v_lshlrev_b32_e32 v5, 8, v10
435 ; VI-NEXT: s_waitcnt vmcnt(5) lgkmcnt(5)
436 ; VI-NEXT: v_lshlrev_b32_e32 v3, 8, v11
437 ; VI-NEXT: s_waitcnt vmcnt(4) lgkmcnt(4)
438 ; VI-NEXT: v_or_b32_e32 v0, v3, v0
439 ; VI-NEXT: s_waitcnt vmcnt(3) lgkmcnt(3)
440 ; VI-NEXT: v_cvt_f32_ubyte0_e32 v6, v1
441 ; VI-NEXT: s_waitcnt vmcnt(1) lgkmcnt(1)
442 ; VI-NEXT: v_lshlrev_b32_e32 v4, 8, v4
443 ; VI-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
444 ; VI-NEXT: v_or_b32_sdwa v1, v5, v2 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
445 ; VI-NEXT: v_or_b32_e32 v0, v1, v0
446 ; VI-NEXT: v_or_b32_e32 v4, v4, v7
447 ; VI-NEXT: v_and_b32_e32 v5, 0xffff0000, v0
448 ; VI-NEXT: v_or_b32_e32 v4, v4, v5
449 ; VI-NEXT: v_cvt_f32_ubyte1_e32 v5, v4
450 ; VI-NEXT: v_cvt_f32_ubyte3_e32 v3, v0
451 ; VI-NEXT: v_cvt_f32_ubyte2_e32 v2, v0
452 ; VI-NEXT: v_cvt_f32_ubyte1_e32 v1, v0
453 ; VI-NEXT: v_cvt_f32_ubyte0_e32 v0, v0
454 ; VI-NEXT: v_cvt_f32_ubyte0_e32 v4, v4
455 ; VI-NEXT: buffer_store_dwordx4 v[0:3], off, s[4:7], 0
456 ; VI-NEXT: buffer_store_dwordx3 v[4:6], off, s[4:7], 0 offset:16
458 %tid = call i32 @llvm.amdgcn.workitem.id.x()
459 %gep = getelementptr <7 x i8>, <7 x i8> addrspace(1)* %in, i32 %tid
460 %load = load <7 x i8>, <7 x i8> addrspace(1)* %gep, align 1
461 %cvt = uitofp <7 x i8> %load to <7 x float>
462 store <7 x float> %cvt, <7 x float> addrspace(1)* %out, align 16
466 define amdgpu_kernel void @load_v8i8_to_v8f32(<8 x float> addrspace(1)* noalias %out, <8 x i8> addrspace(1)* noalias %in) nounwind {
467 ; SI-LABEL: load_v8i8_to_v8f32:
469 ; SI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
470 ; SI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
471 ; SI-NEXT: s_mov_b32 s7, 0xf000
472 ; SI-NEXT: s_mov_b32 s2, 0
473 ; SI-NEXT: s_mov_b32 s3, s7
474 ; SI-NEXT: v_lshlrev_b32_e32 v0, 3, v0
475 ; SI-NEXT: v_mov_b32_e32 v1, 0
476 ; SI-NEXT: s_waitcnt lgkmcnt(0)
477 ; SI-NEXT: buffer_load_dwordx2 v[7:8], v[0:1], s[0:3], 0 addr64
478 ; SI-NEXT: s_mov_b32 s6, -1
479 ; SI-NEXT: s_waitcnt vmcnt(0)
480 ; SI-NEXT: v_cvt_f32_ubyte3_e32 v3, v7
481 ; SI-NEXT: v_cvt_f32_ubyte2_e32 v2, v7
482 ; SI-NEXT: v_cvt_f32_ubyte1_e32 v1, v7
483 ; SI-NEXT: v_cvt_f32_ubyte0_e32 v0, v7
484 ; SI-NEXT: v_cvt_f32_ubyte3_e32 v7, v8
485 ; SI-NEXT: v_cvt_f32_ubyte2_e32 v6, v8
486 ; SI-NEXT: v_cvt_f32_ubyte1_e32 v5, v8
487 ; SI-NEXT: v_cvt_f32_ubyte0_e32 v4, v8
488 ; SI-NEXT: buffer_store_dwordx4 v[4:7], off, s[4:7], 0 offset:16
489 ; SI-NEXT: buffer_store_dwordx4 v[0:3], off, s[4:7], 0
492 ; VI-LABEL: load_v8i8_to_v8f32:
494 ; VI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
495 ; VI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2c
496 ; VI-NEXT: v_lshlrev_b32_e32 v0, 3, v0
497 ; VI-NEXT: s_mov_b32 s7, 0xf000
498 ; VI-NEXT: s_mov_b32 s6, -1
499 ; VI-NEXT: s_waitcnt lgkmcnt(0)
500 ; VI-NEXT: v_mov_b32_e32 v1, s1
501 ; VI-NEXT: v_add_u32_e32 v0, vcc, s0, v0
502 ; VI-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
503 ; VI-NEXT: flat_load_dwordx2 v[7:8], v[0:1]
504 ; VI-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
505 ; VI-NEXT: v_cvt_f32_ubyte3_e32 v3, v7
506 ; VI-NEXT: v_cvt_f32_ubyte2_e32 v2, v7
507 ; VI-NEXT: v_cvt_f32_ubyte1_e32 v1, v7
508 ; VI-NEXT: v_cvt_f32_ubyte0_e32 v0, v7
509 ; VI-NEXT: v_cvt_f32_ubyte3_e32 v7, v8
510 ; VI-NEXT: v_cvt_f32_ubyte2_e32 v6, v8
511 ; VI-NEXT: v_cvt_f32_ubyte1_e32 v5, v8
512 ; VI-NEXT: v_cvt_f32_ubyte0_e32 v4, v8
513 ; VI-NEXT: buffer_store_dwordx4 v[4:7], off, s[4:7], 0 offset:16
514 ; VI-NEXT: buffer_store_dwordx4 v[0:3], off, s[4:7], 0
516 %tid = call i32 @llvm.amdgcn.workitem.id.x()
517 %gep = getelementptr <8 x i8>, <8 x i8> addrspace(1)* %in, i32 %tid
518 %load = load <8 x i8>, <8 x i8> addrspace(1)* %gep, align 8
519 %cvt = uitofp <8 x i8> %load to <8 x float>
520 store <8 x float> %cvt, <8 x float> addrspace(1)* %out, align 16
524 define amdgpu_kernel void @i8_zext_inreg_i32_to_f32(float addrspace(1)* noalias %out, i32 addrspace(1)* noalias %in) nounwind {
525 ; SI-LABEL: i8_zext_inreg_i32_to_f32:
527 ; SI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
528 ; SI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
529 ; SI-NEXT: s_mov_b32 s7, 0xf000
530 ; SI-NEXT: s_mov_b32 s2, 0
531 ; SI-NEXT: s_mov_b32 s3, s7
532 ; SI-NEXT: v_lshlrev_b32_e32 v0, 2, v0
533 ; SI-NEXT: v_mov_b32_e32 v1, 0
534 ; SI-NEXT: s_waitcnt lgkmcnt(0)
535 ; SI-NEXT: buffer_load_dword v0, v[0:1], s[0:3], 0 addr64
536 ; SI-NEXT: s_mov_b32 s6, -1
537 ; SI-NEXT: s_waitcnt vmcnt(0)
538 ; SI-NEXT: v_add_i32_e32 v0, vcc, 2, v0
539 ; SI-NEXT: v_cvt_f32_ubyte0_e32 v0, v0
540 ; SI-NEXT: buffer_store_dword v0, off, s[4:7], 0
543 ; VI-LABEL: i8_zext_inreg_i32_to_f32:
545 ; VI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
546 ; VI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2c
547 ; VI-NEXT: v_lshlrev_b32_e32 v0, 2, v0
548 ; VI-NEXT: s_mov_b32 s7, 0xf000
549 ; VI-NEXT: s_mov_b32 s6, -1
550 ; VI-NEXT: s_waitcnt lgkmcnt(0)
551 ; VI-NEXT: v_mov_b32_e32 v1, s1
552 ; VI-NEXT: v_add_u32_e32 v0, vcc, s0, v0
553 ; VI-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
554 ; VI-NEXT: flat_load_dword v0, v[0:1]
555 ; VI-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
556 ; VI-NEXT: v_add_u32_e32 v0, vcc, 2, v0
557 ; VI-NEXT: v_cvt_f32_ubyte0_e32 v0, v0
558 ; VI-NEXT: buffer_store_dword v0, off, s[4:7], 0
560 %tid = call i32 @llvm.amdgcn.workitem.id.x()
561 %gep = getelementptr i32, i32 addrspace(1)* %in, i32 %tid
562 %load = load i32, i32 addrspace(1)* %gep, align 4
563 %add = add i32 %load, 2
564 %inreg = and i32 %add, 255
565 %cvt = uitofp i32 %inreg to float
566 store float %cvt, float addrspace(1)* %out, align 4
570 define amdgpu_kernel void @i8_zext_inreg_hi1_to_f32(float addrspace(1)* noalias %out, i32 addrspace(1)* noalias %in) nounwind {
571 ; SI-LABEL: i8_zext_inreg_hi1_to_f32:
573 ; SI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
574 ; SI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
575 ; SI-NEXT: s_mov_b32 s7, 0xf000
576 ; SI-NEXT: s_mov_b32 s2, 0
577 ; SI-NEXT: s_mov_b32 s3, s7
578 ; SI-NEXT: v_lshlrev_b32_e32 v0, 2, v0
579 ; SI-NEXT: v_mov_b32_e32 v1, 0
580 ; SI-NEXT: s_waitcnt lgkmcnt(0)
581 ; SI-NEXT: buffer_load_dword v0, v[0:1], s[0:3], 0 addr64
582 ; SI-NEXT: s_mov_b32 s6, -1
583 ; SI-NEXT: s_waitcnt vmcnt(0)
584 ; SI-NEXT: v_cvt_f32_ubyte1_e32 v0, v0
585 ; SI-NEXT: buffer_store_dword v0, off, s[4:7], 0
588 ; VI-LABEL: i8_zext_inreg_hi1_to_f32:
590 ; VI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
591 ; VI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2c
592 ; VI-NEXT: v_lshlrev_b32_e32 v0, 2, v0
593 ; VI-NEXT: s_mov_b32 s7, 0xf000
594 ; VI-NEXT: s_mov_b32 s6, -1
595 ; VI-NEXT: s_waitcnt lgkmcnt(0)
596 ; VI-NEXT: v_mov_b32_e32 v1, s1
597 ; VI-NEXT: v_add_u32_e32 v0, vcc, s0, v0
598 ; VI-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
599 ; VI-NEXT: flat_load_dword v0, v[0:1]
600 ; VI-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
601 ; VI-NEXT: v_cvt_f32_ubyte1_e32 v0, v0
602 ; VI-NEXT: buffer_store_dword v0, off, s[4:7], 0
604 %tid = call i32 @llvm.amdgcn.workitem.id.x()
605 %gep = getelementptr i32, i32 addrspace(1)* %in, i32 %tid
606 %load = load i32, i32 addrspace(1)* %gep, align 4
607 %inreg = and i32 %load, 65280
608 %shr = lshr i32 %inreg, 8
609 %cvt = uitofp i32 %shr to float
610 store float %cvt, float addrspace(1)* %out, align 4
614 ; We don't get these ones because of the zext, but instcombine removes
615 ; them so it shouldn't really matter.
616 define amdgpu_kernel void @i8_zext_i32_to_f32(float addrspace(1)* noalias %out, i8 addrspace(1)* noalias %in) nounwind {
617 ; SI-LABEL: i8_zext_i32_to_f32:
619 ; SI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
620 ; SI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
621 ; SI-NEXT: s_mov_b32 s7, 0xf000
622 ; SI-NEXT: v_mov_b32_e32 v1, 0
623 ; SI-NEXT: s_mov_b32 s2, 0
624 ; SI-NEXT: s_mov_b32 s3, s7
625 ; SI-NEXT: s_waitcnt lgkmcnt(0)
626 ; SI-NEXT: buffer_load_ubyte v0, v[0:1], s[0:3], 0 addr64
627 ; SI-NEXT: s_mov_b32 s6, -1
628 ; SI-NEXT: s_waitcnt vmcnt(0)
629 ; SI-NEXT: v_cvt_f32_ubyte0_e32 v0, v0
630 ; SI-NEXT: buffer_store_dword v0, off, s[4:7], 0
633 ; VI-LABEL: i8_zext_i32_to_f32:
635 ; VI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
636 ; VI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2c
637 ; VI-NEXT: s_mov_b32 s7, 0xf000
638 ; VI-NEXT: s_mov_b32 s6, -1
639 ; VI-NEXT: s_waitcnt lgkmcnt(0)
640 ; VI-NEXT: v_mov_b32_e32 v1, s1
641 ; VI-NEXT: v_add_u32_e32 v0, vcc, s0, v0
642 ; VI-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
643 ; VI-NEXT: flat_load_ubyte v0, v[0:1]
644 ; VI-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
645 ; VI-NEXT: v_cvt_f32_ubyte0_e32 v0, v0
646 ; VI-NEXT: buffer_store_dword v0, off, s[4:7], 0
648 %tid = call i32 @llvm.amdgcn.workitem.id.x()
649 %gep = getelementptr i8, i8 addrspace(1)* %in, i32 %tid
650 %load = load i8, i8 addrspace(1)* %gep, align 1
651 %ext = zext i8 %load to i32
652 %cvt = uitofp i32 %ext to float
653 store float %cvt, float addrspace(1)* %out, align 4
657 define amdgpu_kernel void @v4i8_zext_v4i32_to_v4f32(<4 x float> addrspace(1)* noalias %out, <4 x i8> addrspace(1)* noalias %in) nounwind {
658 ; SI-LABEL: v4i8_zext_v4i32_to_v4f32:
660 ; SI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
661 ; SI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
662 ; SI-NEXT: s_mov_b32 s7, 0xf000
663 ; SI-NEXT: s_mov_b32 s2, 0
664 ; SI-NEXT: s_mov_b32 s3, s7
665 ; SI-NEXT: v_lshlrev_b32_e32 v0, 2, v0
666 ; SI-NEXT: v_mov_b32_e32 v1, 0
667 ; SI-NEXT: s_waitcnt lgkmcnt(0)
668 ; SI-NEXT: buffer_load_ubyte v2, v[0:1], s[0:3], 0 addr64
669 ; SI-NEXT: buffer_load_ubyte v3, v[0:1], s[0:3], 0 addr64 offset:1
670 ; SI-NEXT: buffer_load_ubyte v4, v[0:1], s[0:3], 0 addr64 offset:2
671 ; SI-NEXT: buffer_load_ubyte v0, v[0:1], s[0:3], 0 addr64 offset:3
672 ; SI-NEXT: s_mov_b32 s6, -1
673 ; SI-NEXT: s_waitcnt vmcnt(2)
674 ; SI-NEXT: v_lshlrev_b32_e32 v1, 8, v3
675 ; SI-NEXT: v_or_b32_e32 v1, v1, v2
676 ; SI-NEXT: s_waitcnt vmcnt(0)
677 ; SI-NEXT: v_lshlrev_b32_e32 v0, 8, v0
678 ; SI-NEXT: v_or_b32_e32 v0, v0, v4
679 ; SI-NEXT: v_lshlrev_b32_e32 v0, 16, v0
680 ; SI-NEXT: v_or_b32_e32 v0, v0, v1
681 ; SI-NEXT: v_cvt_f32_ubyte3_e32 v3, v0
682 ; SI-NEXT: v_cvt_f32_ubyte2_e32 v2, v0
683 ; SI-NEXT: v_cvt_f32_ubyte1_e32 v1, v0
684 ; SI-NEXT: v_cvt_f32_ubyte0_e32 v0, v0
685 ; SI-NEXT: buffer_store_dwordx4 v[0:3], off, s[4:7], 0
688 ; VI-LABEL: v4i8_zext_v4i32_to_v4f32:
690 ; VI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
691 ; VI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2c
692 ; VI-NEXT: v_lshlrev_b32_e32 v0, 2, v0
693 ; VI-NEXT: s_mov_b32 s7, 0xf000
694 ; VI-NEXT: s_mov_b32 s6, -1
695 ; VI-NEXT: s_waitcnt lgkmcnt(0)
696 ; VI-NEXT: v_mov_b32_e32 v1, s1
697 ; VI-NEXT: v_add_u32_e32 v0, vcc, s0, v0
698 ; VI-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
699 ; VI-NEXT: v_add_u32_e32 v2, vcc, 1, v0
700 ; VI-NEXT: v_addc_u32_e32 v3, vcc, 0, v1, vcc
701 ; VI-NEXT: v_add_u32_e32 v4, vcc, 3, v0
702 ; VI-NEXT: v_addc_u32_e32 v5, vcc, 0, v1, vcc
703 ; VI-NEXT: v_add_u32_e32 v6, vcc, 2, v0
704 ; VI-NEXT: v_addc_u32_e32 v7, vcc, 0, v1, vcc
705 ; VI-NEXT: flat_load_ubyte v0, v[0:1]
706 ; VI-NEXT: flat_load_ubyte v1, v[6:7]
707 ; VI-NEXT: flat_load_ubyte v4, v[4:5]
708 ; VI-NEXT: flat_load_ubyte v2, v[2:3]
709 ; VI-NEXT: s_waitcnt vmcnt(1) lgkmcnt(1)
710 ; VI-NEXT: v_lshlrev_b32_e32 v3, 8, v4
711 ; VI-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
712 ; VI-NEXT: v_lshlrev_b32_e32 v2, 8, v2
713 ; VI-NEXT: v_or_b32_e32 v4, v2, v0
714 ; VI-NEXT: v_or_b32_sdwa v0, v3, v1 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
715 ; VI-NEXT: v_or_b32_e32 v0, v0, v4
716 ; VI-NEXT: v_cvt_f32_ubyte3_e32 v3, v0
717 ; VI-NEXT: v_cvt_f32_ubyte2_e32 v2, v0
718 ; VI-NEXT: v_cvt_f32_ubyte0_e32 v0, v0
719 ; VI-NEXT: v_cvt_f32_ubyte1_e32 v1, v4
720 ; VI-NEXT: buffer_store_dwordx4 v[0:3], off, s[4:7], 0
722 %tid = call i32 @llvm.amdgcn.workitem.id.x()
723 %gep = getelementptr <4 x i8>, <4 x i8> addrspace(1)* %in, i32 %tid
724 %load = load <4 x i8>, <4 x i8> addrspace(1)* %gep, align 1
725 %ext = zext <4 x i8> %load to <4 x i32>
726 %cvt = uitofp <4 x i32> %ext to <4 x float>
727 store <4 x float> %cvt, <4 x float> addrspace(1)* %out, align 16
731 define amdgpu_kernel void @extract_byte0_to_f32(float addrspace(1)* noalias %out, i32 addrspace(1)* noalias %in) nounwind {
732 ; SI-LABEL: extract_byte0_to_f32:
734 ; SI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
735 ; SI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
736 ; SI-NEXT: s_mov_b32 s7, 0xf000
737 ; SI-NEXT: s_mov_b32 s2, 0
738 ; SI-NEXT: s_mov_b32 s3, s7
739 ; SI-NEXT: v_lshlrev_b32_e32 v0, 2, v0
740 ; SI-NEXT: v_mov_b32_e32 v1, 0
741 ; SI-NEXT: s_waitcnt lgkmcnt(0)
742 ; SI-NEXT: buffer_load_dword v0, v[0:1], s[0:3], 0 addr64
743 ; SI-NEXT: s_mov_b32 s6, -1
744 ; SI-NEXT: s_waitcnt vmcnt(0)
745 ; SI-NEXT: v_cvt_f32_ubyte0_e32 v0, v0
746 ; SI-NEXT: buffer_store_dword v0, off, s[4:7], 0
749 ; VI-LABEL: extract_byte0_to_f32:
751 ; VI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
752 ; VI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2c
753 ; VI-NEXT: v_lshlrev_b32_e32 v0, 2, v0
754 ; VI-NEXT: s_mov_b32 s7, 0xf000
755 ; VI-NEXT: s_mov_b32 s6, -1
756 ; VI-NEXT: s_waitcnt lgkmcnt(0)
757 ; VI-NEXT: v_mov_b32_e32 v1, s1
758 ; VI-NEXT: v_add_u32_e32 v0, vcc, s0, v0
759 ; VI-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
760 ; VI-NEXT: flat_load_dword v0, v[0:1]
761 ; VI-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
762 ; VI-NEXT: v_cvt_f32_ubyte0_e32 v0, v0
763 ; VI-NEXT: buffer_store_dword v0, off, s[4:7], 0
765 %tid = call i32 @llvm.amdgcn.workitem.id.x()
766 %gep = getelementptr i32, i32 addrspace(1)* %in, i32 %tid
767 %val = load i32, i32 addrspace(1)* %gep
768 %and = and i32 %val, 255
769 %cvt = uitofp i32 %and to float
770 store float %cvt, float addrspace(1)* %out
774 define amdgpu_kernel void @extract_byte1_to_f32(float addrspace(1)* noalias %out, i32 addrspace(1)* noalias %in) nounwind {
775 ; SI-LABEL: extract_byte1_to_f32:
777 ; SI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
778 ; SI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
779 ; SI-NEXT: s_mov_b32 s7, 0xf000
780 ; SI-NEXT: s_mov_b32 s2, 0
781 ; SI-NEXT: s_mov_b32 s3, s7
782 ; SI-NEXT: v_lshlrev_b32_e32 v0, 2, v0
783 ; SI-NEXT: v_mov_b32_e32 v1, 0
784 ; SI-NEXT: s_waitcnt lgkmcnt(0)
785 ; SI-NEXT: buffer_load_dword v0, v[0:1], s[0:3], 0 addr64
786 ; SI-NEXT: s_mov_b32 s6, -1
787 ; SI-NEXT: s_waitcnt vmcnt(0)
788 ; SI-NEXT: v_cvt_f32_ubyte1_e32 v0, v0
789 ; SI-NEXT: buffer_store_dword v0, off, s[4:7], 0
792 ; VI-LABEL: extract_byte1_to_f32:
794 ; VI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
795 ; VI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2c
796 ; VI-NEXT: v_lshlrev_b32_e32 v0, 2, v0
797 ; VI-NEXT: s_mov_b32 s7, 0xf000
798 ; VI-NEXT: s_mov_b32 s6, -1
799 ; VI-NEXT: s_waitcnt lgkmcnt(0)
800 ; VI-NEXT: v_mov_b32_e32 v1, s1
801 ; VI-NEXT: v_add_u32_e32 v0, vcc, s0, v0
802 ; VI-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
803 ; VI-NEXT: flat_load_dword v0, v[0:1]
804 ; VI-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
805 ; VI-NEXT: v_cvt_f32_ubyte1_e32 v0, v0
806 ; VI-NEXT: buffer_store_dword v0, off, s[4:7], 0
808 %tid = call i32 @llvm.amdgcn.workitem.id.x()
809 %gep = getelementptr i32, i32 addrspace(1)* %in, i32 %tid
810 %val = load i32, i32 addrspace(1)* %gep
811 %srl = lshr i32 %val, 8
812 %and = and i32 %srl, 255
813 %cvt = uitofp i32 %and to float
814 store float %cvt, float addrspace(1)* %out
818 define amdgpu_kernel void @extract_byte2_to_f32(float addrspace(1)* noalias %out, i32 addrspace(1)* noalias %in) nounwind {
819 ; SI-LABEL: extract_byte2_to_f32:
821 ; SI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
822 ; SI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
823 ; SI-NEXT: s_mov_b32 s7, 0xf000
824 ; SI-NEXT: s_mov_b32 s2, 0
825 ; SI-NEXT: s_mov_b32 s3, s7
826 ; SI-NEXT: v_lshlrev_b32_e32 v0, 2, v0
827 ; SI-NEXT: v_mov_b32_e32 v1, 0
828 ; SI-NEXT: s_waitcnt lgkmcnt(0)
829 ; SI-NEXT: buffer_load_dword v0, v[0:1], s[0:3], 0 addr64
830 ; SI-NEXT: s_mov_b32 s6, -1
831 ; SI-NEXT: s_waitcnt vmcnt(0)
832 ; SI-NEXT: v_cvt_f32_ubyte2_e32 v0, v0
833 ; SI-NEXT: buffer_store_dword v0, off, s[4:7], 0
836 ; VI-LABEL: extract_byte2_to_f32:
838 ; VI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
839 ; VI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2c
840 ; VI-NEXT: v_lshlrev_b32_e32 v0, 2, v0
841 ; VI-NEXT: s_mov_b32 s7, 0xf000
842 ; VI-NEXT: s_mov_b32 s6, -1
843 ; VI-NEXT: s_waitcnt lgkmcnt(0)
844 ; VI-NEXT: v_mov_b32_e32 v1, s1
845 ; VI-NEXT: v_add_u32_e32 v0, vcc, s0, v0
846 ; VI-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
847 ; VI-NEXT: flat_load_dword v0, v[0:1]
848 ; VI-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
849 ; VI-NEXT: v_cvt_f32_ubyte2_e32 v0, v0
850 ; VI-NEXT: buffer_store_dword v0, off, s[4:7], 0
852 %tid = call i32 @llvm.amdgcn.workitem.id.x()
853 %gep = getelementptr i32, i32 addrspace(1)* %in, i32 %tid
854 %val = load i32, i32 addrspace(1)* %gep
855 %srl = lshr i32 %val, 16
856 %and = and i32 %srl, 255
857 %cvt = uitofp i32 %and to float
858 store float %cvt, float addrspace(1)* %out
862 define amdgpu_kernel void @extract_byte3_to_f32(float addrspace(1)* noalias %out, i32 addrspace(1)* noalias %in) nounwind {
863 ; SI-LABEL: extract_byte3_to_f32:
865 ; SI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x9
866 ; SI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xb
867 ; SI-NEXT: s_mov_b32 s7, 0xf000
868 ; SI-NEXT: s_mov_b32 s2, 0
869 ; SI-NEXT: s_mov_b32 s3, s7
870 ; SI-NEXT: v_lshlrev_b32_e32 v0, 2, v0
871 ; SI-NEXT: v_mov_b32_e32 v1, 0
872 ; SI-NEXT: s_waitcnt lgkmcnt(0)
873 ; SI-NEXT: buffer_load_dword v0, v[0:1], s[0:3], 0 addr64
874 ; SI-NEXT: s_mov_b32 s6, -1
875 ; SI-NEXT: s_waitcnt vmcnt(0)
876 ; SI-NEXT: v_cvt_f32_ubyte3_e32 v0, v0
877 ; SI-NEXT: buffer_store_dword v0, off, s[4:7], 0
880 ; VI-LABEL: extract_byte3_to_f32:
882 ; VI-NEXT: s_load_dwordx2 s[4:5], s[0:1], 0x24
883 ; VI-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x2c
884 ; VI-NEXT: v_lshlrev_b32_e32 v0, 2, v0
885 ; VI-NEXT: s_mov_b32 s7, 0xf000
886 ; VI-NEXT: s_mov_b32 s6, -1
887 ; VI-NEXT: s_waitcnt lgkmcnt(0)
888 ; VI-NEXT: v_mov_b32_e32 v1, s1
889 ; VI-NEXT: v_add_u32_e32 v0, vcc, s0, v0
890 ; VI-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
891 ; VI-NEXT: flat_load_dword v0, v[0:1]
892 ; VI-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
893 ; VI-NEXT: v_cvt_f32_ubyte3_e32 v0, v0
894 ; VI-NEXT: buffer_store_dword v0, off, s[4:7], 0
896 %tid = call i32 @llvm.amdgcn.workitem.id.x()
897 %gep = getelementptr i32, i32 addrspace(1)* %in, i32 %tid
898 %val = load i32, i32 addrspace(1)* %gep
899 %srl = lshr i32 %val, 24
900 %and = and i32 %srl, 255
901 %cvt = uitofp i32 %and to float
902 store float %cvt, float addrspace(1)* %out
906 define amdgpu_kernel void @cvt_ubyte0_or_multiuse(i32 addrspace(1)* %in, float addrspace(1)* %out) {
907 ; SI-LABEL: cvt_ubyte0_or_multiuse:
909 ; SI-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
910 ; SI-NEXT: s_mov_b32 s7, 0xf000
911 ; SI-NEXT: v_lshlrev_b32_e32 v0, 2, v0
912 ; SI-NEXT: v_mov_b32_e32 v1, 0
913 ; SI-NEXT: s_mov_b32 s6, -1
914 ; SI-NEXT: s_waitcnt lgkmcnt(0)
915 ; SI-NEXT: s_mov_b32 s4, s2
916 ; SI-NEXT: s_mov_b32 s5, s3
917 ; SI-NEXT: s_mov_b32 s2, 0
918 ; SI-NEXT: s_mov_b32 s3, s7
919 ; SI-NEXT: buffer_load_dword v0, v[0:1], s[0:3], 0 addr64
920 ; SI-NEXT: s_waitcnt vmcnt(0)
921 ; SI-NEXT: v_or_b32_e32 v0, 0x80000001, v0
922 ; SI-NEXT: v_cvt_f32_ubyte0_e32 v1, v0
923 ; SI-NEXT: v_add_f32_e32 v0, v0, v1
924 ; SI-NEXT: buffer_store_dword v0, off, s[4:7], 0
927 ; VI-LABEL: cvt_ubyte0_or_multiuse:
929 ; VI-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
930 ; VI-NEXT: v_lshlrev_b32_e32 v0, 2, v0
931 ; VI-NEXT: s_mov_b32 s7, 0xf000
932 ; VI-NEXT: s_mov_b32 s6, -1
933 ; VI-NEXT: s_waitcnt lgkmcnt(0)
934 ; VI-NEXT: v_mov_b32_e32 v1, s1
935 ; VI-NEXT: v_add_u32_e32 v0, vcc, s0, v0
936 ; VI-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
937 ; VI-NEXT: flat_load_dword v0, v[0:1]
938 ; VI-NEXT: s_mov_b32 s4, s2
939 ; VI-NEXT: s_mov_b32 s5, s3
940 ; VI-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
941 ; VI-NEXT: v_or_b32_e32 v0, 0x80000001, v0
942 ; VI-NEXT: v_cvt_f32_ubyte0_e32 v1, v0
943 ; VI-NEXT: v_add_f32_e32 v0, v0, v1
944 ; VI-NEXT: buffer_store_dword v0, off, s[4:7], 0
947 %lid = tail call i32 @llvm.amdgcn.workitem.id.x()
948 %gep = getelementptr inbounds i32, i32 addrspace(1)* %in, i32 %lid
949 %load = load i32, i32 addrspace(1)* %gep
950 %or = or i32 %load, -2147483647
951 %and = and i32 %or, 255
952 %uitofp = uitofp i32 %and to float
953 %cast = bitcast i32 %or to float
954 %add = fadd float %cast, %uitofp
955 store float %add, float addrspace(1)* %out