1 ; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN,GCN-NOHSA,GCN-NOHSA-SI,FUNC %s
2 ; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=kaveri -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN -check-prefix=GCN-HSA -check-prefix=FUNC %s
3 ; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN,GCN-NOHSA,GCN-NOHSA-VI,FUNC %s
4 ; RUN: llc -march=r600 -mcpu=redwood -verify-machineinstrs < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
6 ; FUNC-LABEL: {{^}}constant_load_i16:
7 ; GCN-NOHSA: buffer_load_ushort v{{[0-9]+}}
8 ; GCN-HSA: flat_load_ushort
10 ; EG: VTX_READ_16 T{{[0-9]+}}.X, T{{[0-9]+}}.X, 0, #1
11 define amdgpu_kernel void @constant_load_i16(i16 addrspace(1)* %out, i16 addrspace(4)* %in) {
13 %ld = load i16, i16 addrspace(4)* %in
14 store i16 %ld, i16 addrspace(1)* %out
18 ; FUNC-LABEL: {{^}}constant_load_v2i16:
21 ; EG: VTX_READ_32 T{{[0-9]+}}.X, T{{[0-9]+}}.X, 0, #1
22 define amdgpu_kernel void @constant_load_v2i16(<2 x i16> addrspace(1)* %out, <2 x i16> addrspace(4)* %in) {
24 %ld = load <2 x i16>, <2 x i16> addrspace(4)* %in
25 store <2 x i16> %ld, <2 x i16> addrspace(1)* %out
29 ; FUNC-LABEL: {{^}}constant_load_v3i16:
30 ; GCN: s_load_dwordx2 s
32 ; EG-DAG: VTX_READ_16 T{{[0-9]+}}.X, T{{[0-9]+}}.X, 0, #1
33 ; EG-DAG: VTX_READ_16 T{{[0-9]+}}.X, T{{[0-9]+}}.X, 2, #1
34 ; EG-DAG: VTX_READ_16 T{{[0-9]+}}.X, T{{[0-9]+}}.X, 4, #1
35 define amdgpu_kernel void @constant_load_v3i16(<3 x i16> addrspace(1)* %out, <3 x i16> addrspace(4)* %in) {
37 %ld = load <3 x i16>, <3 x i16> addrspace(4)* %in
38 store <3 x i16> %ld, <3 x i16> addrspace(1)* %out
42 ; FUNC-LABEL: {{^}}constant_load_v4i16:
45 ; EG: VTX_READ_64 T{{[0-9]+}}.XY, T{{[0-9]+}}.X, 0, #1
46 define amdgpu_kernel void @constant_load_v4i16(<4 x i16> addrspace(1)* %out, <4 x i16> addrspace(4)* %in) {
48 %ld = load <4 x i16>, <4 x i16> addrspace(4)* %in
49 store <4 x i16> %ld, <4 x i16> addrspace(1)* %out
53 ; FUNC-LABEL: {{^}}constant_load_v8i16:
56 ; EG: VTX_READ_128 T{{[0-9]+}}.XYZW, T{{[0-9]+}}.X, 0, #1
57 define amdgpu_kernel void @constant_load_v8i16(<8 x i16> addrspace(1)* %out, <8 x i16> addrspace(4)* %in) {
59 %ld = load <8 x i16>, <8 x i16> addrspace(4)* %in
60 store <8 x i16> %ld, <8 x i16> addrspace(1)* %out
64 ; FUNC-LABEL: {{^}}constant_load_v16i16:
67 ; EG-DAG: VTX_READ_128 T{{[0-9]+}}.XYZW, T{{[0-9]+}}.X, 0, #1
68 ; EG-DAG: VTX_READ_128 T{{[0-9]+}}.XYZW, T{{[0-9]+}}.X, 16, #1
69 define amdgpu_kernel void @constant_load_v16i16(<16 x i16> addrspace(1)* %out, <16 x i16> addrspace(4)* %in) {
71 %ld = load <16 x i16>, <16 x i16> addrspace(4)* %in
72 store <16 x i16> %ld, <16 x i16> addrspace(1)* %out
76 ; FUNC-LABEL: {{^}}constant_load_v16i16_align2:
77 ; GCN-HSA: flat_load_dwordx4
78 ; GCN-HSA: flat_load_dwordx4
79 ; GCN-HSA: flat_store_dwordx4
80 ; GCN-HSA: flat_store_dwordx4
81 define amdgpu_kernel void @constant_load_v16i16_align2(<16 x i16> addrspace(4)* %ptr0) #0 {
83 %ld = load <16 x i16>, <16 x i16> addrspace(4)* %ptr0, align 2
84 store <16 x i16> %ld, <16 x i16> addrspace(1)* undef, align 32
88 ; FUNC-LABEL: {{^}}constant_zextload_i16_to_i32:
89 ; GCN-NOHSA: buffer_load_ushort
90 ; GCN-NOHSA: buffer_store_dword
92 ; GCN-HSA: flat_load_ushort
93 ; GCN-HSA: flat_store_dword
95 ; EG: VTX_READ_16 T{{[0-9]+\.X, T[0-9]+\.X}}, 0, #1
96 define amdgpu_kernel void @constant_zextload_i16_to_i32(i32 addrspace(1)* %out, i16 addrspace(4)* %in) #0 {
97 %a = load i16, i16 addrspace(4)* %in
98 %ext = zext i16 %a to i32
99 store i32 %ext, i32 addrspace(1)* %out
103 ; FUNC-LABEL: {{^}}constant_sextload_i16_to_i32:
104 ; GCN-NOHSA: buffer_load_sshort
105 ; GCN-NOHSA: buffer_store_dword
107 ; GCN-HSA: flat_load_sshort
108 ; GCN-HSA: flat_store_dword
110 ; EG: VTX_READ_16 [[DST:T[0-9]\.[XYZW]]], [[DST]], 0, #1
111 ; EG: BFE_INT {{[* ]*}}T{{[0-9].[XYZW]}}, [[DST]], 0.0, literal
113 define amdgpu_kernel void @constant_sextload_i16_to_i32(i32 addrspace(1)* %out, i16 addrspace(4)* %in) #0 {
114 %a = load i16, i16 addrspace(4)* %in
115 %ext = sext i16 %a to i32
116 store i32 %ext, i32 addrspace(1)* %out
120 ; FUNC-LABEL: {{^}}constant_zextload_v1i16_to_v1i32:
121 ; GCN-NOHSA: buffer_load_ushort
122 ; GCN-HSA: flat_load_ushort
124 ; EG: VTX_READ_16 T{{[0-9]+\.X, T[0-9]+\.X}}, 0, #1
125 define amdgpu_kernel void @constant_zextload_v1i16_to_v1i32(<1 x i32> addrspace(1)* %out, <1 x i16> addrspace(4)* %in) #0 {
126 %load = load <1 x i16>, <1 x i16> addrspace(4)* %in
127 %ext = zext <1 x i16> %load to <1 x i32>
128 store <1 x i32> %ext, <1 x i32> addrspace(1)* %out
132 ; FUNC-LABEL: {{^}}constant_sextload_v1i16_to_v1i32:
133 ; GCN-NOHSA: buffer_load_sshort
134 ; GCN-HSA: flat_load_sshort
136 ; EG: VTX_READ_16 [[DST:T[0-9]\.[XYZW]]], [[DST]], 0, #1
137 ; EG: BFE_INT {{[* ]*}}T{{[0-9].[XYZW]}}, [[DST]], 0.0, literal
139 define amdgpu_kernel void @constant_sextload_v1i16_to_v1i32(<1 x i32> addrspace(1)* %out, <1 x i16> addrspace(4)* %in) #0 {
140 %load = load <1 x i16>, <1 x i16> addrspace(4)* %in
141 %ext = sext <1 x i16> %load to <1 x i32>
142 store <1 x i32> %ext, <1 x i32> addrspace(1)* %out
146 ; FUNC-LABEL: {{^}}constant_zextload_v2i16_to_v2i32:
147 ; GCN: s_load_dword s
148 ; GCN-DAG: s_and_b32 s{{[0-9]+}}, s{{[0-9]+}}, 0xffff{{$}}
149 ; GCN-DAG: s_lshr_b32 s{{[0-9]+}}, s{{[0-9]+}}, 16
151 ; v2i16 is naturally 4 byte aligned
152 ; EG: VTX_READ_32 [[DST:T[0-9]\.[XYZW]]], [[DST]], 0, #1
153 ; EG: BFE_UINT {{[* ]*}}T{{[0-9].[XYZW]}}, [[DST]], literal
156 define amdgpu_kernel void @constant_zextload_v2i16_to_v2i32(<2 x i32> addrspace(1)* %out, <2 x i16> addrspace(4)* %in) #0 {
157 %load = load <2 x i16>, <2 x i16> addrspace(4)* %in
158 %ext = zext <2 x i16> %load to <2 x i32>
159 store <2 x i32> %ext, <2 x i32> addrspace(1)* %out
163 ; FUNC-LABEL: {{^}}constant_sextload_v2i16_to_v2i32:
164 ; GCN: s_load_dword s
165 ; GCN-DAG: s_ashr_i32
166 ; GCN-DAG: s_sext_i32_i16
168 ; v2i16 is naturally 4 byte aligned
169 ; EG: MEM_RAT_CACHELESS STORE_RAW [[ST:T[0-9]]].XY, {{T[0-9].[XYZW]}},
170 ; EG: VTX_READ_32 [[DST:T[0-9]\.[XYZW]]], [[DST]], 0, #1
171 ; EG-DAG: BFE_INT {{[* ]*}}[[ST]].X, [[DST]], 0.0, literal
172 ; TODO: We should use ASHR instead of LSHR + BFE
173 ; EG-DAG: BFE_INT {{[* ]*}}[[ST]].Y, {{PV\.[XYZW]}}, 0.0, literal
176 define amdgpu_kernel void @constant_sextload_v2i16_to_v2i32(<2 x i32> addrspace(1)* %out, <2 x i16> addrspace(4)* %in) #0 {
177 %load = load <2 x i16>, <2 x i16> addrspace(4)* %in
178 %ext = sext <2 x i16> %load to <2 x i32>
179 store <2 x i32> %ext, <2 x i32> addrspace(1)* %out
183 ; FUNC-LABEL: {{^}}constant_zextload_v3i16_to_v3i32:
184 ; GCN: s_load_dwordx2
186 ; v3i16 is naturally 8 byte aligned
187 ; EG-DAG: MEM_RAT_CACHELESS STORE_RAW [[ST_LO:T[0-9]]].XY, {{T[0-9].[XYZW]}},
188 ; EG-DAG: MEM_RAT_CACHELESS STORE_RAW [[ST_HI:T[0-9]]].X, {{T[0-9].[XYZW]}},
190 ; EG-DAG: VTX_READ_16 [[ST_LO]].X, [[SRC:T[0-9]\.[XYZW]]], 0, #1
191 ; EG-DAG: VTX_READ_16 {{T[0-9]\.[XYZW]}}, [[SRC]], 2, #1
192 ; EG-DAG: VTX_READ_16 [[ST_HI]].X, [[SRC]], 4, #1
193 ; EG-DAG: LSHR {{[* ]*}}{{T[0-9]\.[XYZW]}}, {{T[0-9]\.[XYZW]}}, literal
195 define amdgpu_kernel void @constant_zextload_v3i16_to_v3i32(<3 x i32> addrspace(1)* %out, <3 x i16> addrspace(4)* %in) {
197 %ld = load <3 x i16>, <3 x i16> addrspace(4)* %in
198 %ext = zext <3 x i16> %ld to <3 x i32>
199 store <3 x i32> %ext, <3 x i32> addrspace(1)* %out
203 ; FUNC-LABEL: {{^}}constant_sextload_v3i16_to_v3i32:
204 ; GCN: s_load_dwordx2
206 ; EG-DAG: MEM_RAT_CACHELESS STORE_RAW [[ST_LO:T[0-9]]].XY, {{T[0-9].[XYZW]}},
207 ; EG-DAG: MEM_RAT_CACHELESS STORE_RAW [[ST_HI:T[0-9]]].X, {{T[0-9].[XYZW]}},
208 ; v3i16 is naturally 8 byte aligned
209 ; EG-DAG: VTX_READ_16 [[ST_LO]].X, [[SRC:T[0-9]\.[XYZW]]], 0, #1
210 ; EG-DAG: VTX_READ_16 [[DST_MID:T[0-9]\.[XYZW]]], [[SRC]], 2, #1
211 ; EG-DAG: VTX_READ_16 [[ST_HI]].X, [[SRC]], 4, #1
212 ; EG-DAG: BFE_INT {{[* ]*}}[[ST_LO]].X, [[ST_LO]].X, 0.0, literal
213 ; EG-DAG: BFE_INT {{[* ]*}}[[ST_LO]].Y, [[DST_MID]], 0.0, literal
214 ; EG-DAG: BFE_INT {{[* ]*}}[[ST_HI]].X, [[ST_HI]].X, 0.0, literal
217 define amdgpu_kernel void @constant_sextload_v3i16_to_v3i32(<3 x i32> addrspace(1)* %out, <3 x i16> addrspace(4)* %in) {
219 %ld = load <3 x i16>, <3 x i16> addrspace(4)* %in
220 %ext = sext <3 x i16> %ld to <3 x i32>
221 store <3 x i32> %ext, <3 x i32> addrspace(1)* %out
225 ; FUNC-LABEL: {{^}}constant_zextload_v4i16_to_v4i32:
226 ; GCN: s_load_dwordx2
228 ; GCN-DAG: s_lshr_b32
230 ; v4i16 is naturally 8 byte aligned
231 ; EG: MEM_RAT_CACHELESS STORE_RAW [[ST:T[0-9]]].XYZW, {{T[0-9].[XYZW]}}
232 ; EG: VTX_READ_64 [[LD:T[0-9]]].XY, {{T[0-9].[XYZW]}}, 0, #1
233 ; TODO: This should use LD, but for some there are redundant MOVs
234 ; EG-DAG: BFE_UINT {{[* ]*}}[[ST]].Y, {{.*\.[XYZW]}}, literal
235 ; EG-DAG: BFE_UINT {{[* ]*}}[[ST]].W, {{.*\.[XYZW]}}, literal
238 ; EG-DAG: AND_INT {{[* ]*}}[[ST]].X, {{T[0-9]\.[XYZW]}}, literal
239 ; EG-DAG: AND_INT {{[* ]*}}[[ST]].Z, {{T[0-9]\.[XYZW]}}, literal
242 define amdgpu_kernel void @constant_zextload_v4i16_to_v4i32(<4 x i32> addrspace(1)* %out, <4 x i16> addrspace(4)* %in) #0 {
243 %load = load <4 x i16>, <4 x i16> addrspace(4)* %in
244 %ext = zext <4 x i16> %load to <4 x i32>
245 store <4 x i32> %ext, <4 x i32> addrspace(1)* %out
249 ; FUNC-LABEL: {{^}}constant_sextload_v4i16_to_v4i32:
250 ; GCN: s_load_dwordx2
251 ; GCN-DAG: s_ashr_i32
252 ; GCN-DAG: s_sext_i32_i16
254 ; v4i16 is naturally 8 byte aligned
255 ; EG: MEM_RAT_CACHELESS STORE_RAW [[ST:T[0-9]]].XYZW, {{T[0-9]\.[XYZW]}},
256 ; EG: VTX_READ_64 [[DST:T[0-9]]].XY, {{T[0-9].[XYZW]}}, 0, #1
257 ; TODO: This should use LD, but for some there are redundant MOVs
258 ; EG-DAG: BFE_INT {{[* ]*}}[[ST]].X, {{.*}}, 0.0, literal
259 ; EG-DAG: BFE_INT {{[* ]*}}[[ST]].Z, {{.*}}, 0.0, literal
260 ; TODO: We should use ASHR instead of LSHR + BFE
261 ; EG-DAG: BFE_INT {{[* ]*}}[[ST]].Y, {{.*}}, 0.0, literal
262 ; EG-DAG: BFE_INT {{[* ]*}}[[ST]].W, {{.*}}, 0.0, literal
267 define amdgpu_kernel void @constant_sextload_v4i16_to_v4i32(<4 x i32> addrspace(1)* %out, <4 x i16> addrspace(4)* %in) #0 {
268 %load = load <4 x i16>, <4 x i16> addrspace(4)* %in
269 %ext = sext <4 x i16> %load to <4 x i32>
270 store <4 x i32> %ext, <4 x i32> addrspace(1)* %out
274 ; FUNC-LABEL: {{^}}constant_zextload_v8i16_to_v8i32:
275 ; GCN: s_load_dwordx4
277 ; GCN-DAG: s_lshr_b32
279 ; v8i16 is naturally 16 byte aligned
280 ; EG: MEM_RAT_CACHELESS STORE_RAW [[ST_HI:T[0-9]]].XYZW, {{T[0-9]+.[XYZW]}},
281 ; EG: MEM_RAT_CACHELESS STORE_RAW [[ST_LO:T[0-9]]].XYZW, {{T[0-9]+.[XYZW]}},
282 ; EG: VTX_READ_128 [[DST:T[0-9]]].XYZW, {{T[0-9].[XYZW]}}, 0, #1
283 ; TODO: These should use LSHR instead of BFE_UINT
284 ; TODO: This should use DST, but for some there are redundant MOVs
285 ; EG-DAG: BFE_UINT {{[* ]*}}[[ST_LO]].Y, {{.*}}, literal
286 ; EG-DAG: BFE_UINT {{[* ]*}}[[ST_LO]].W, {{.*}}, literal
287 ; EG-DAG: BFE_UINT {{[* ]*}}[[ST_HI]].Y, {{.*}}, literal
288 ; EG-DAG: BFE_UINT {{[* ]*}}[[ST_HI]].W, {{.*}}, literal
289 ; EG-DAG: AND_INT {{[* ]*}}[[ST_LO]].X, {{.*}}, literal
290 ; EG-DAG: AND_INT {{[* ]*}}[[ST_LO]].Z, {{.*}}, literal
291 ; EG-DAG: AND_INT {{[* ]*}}[[ST_HI]].X, {{.*}}, literal
292 ; EG-DAG: AND_INT {{[* ]*}}[[ST_HI]].Z, {{.*}}, literal
301 define amdgpu_kernel void @constant_zextload_v8i16_to_v8i32(<8 x i32> addrspace(1)* %out, <8 x i16> addrspace(4)* %in) #0 {
302 %load = load <8 x i16>, <8 x i16> addrspace(4)* %in
303 %ext = zext <8 x i16> %load to <8 x i32>
304 store <8 x i32> %ext, <8 x i32> addrspace(1)* %out
308 ; FUNC-LABEL: {{^}}constant_sextload_v8i16_to_v8i32:
309 ; GCN: s_load_dwordx4
310 ; GCN-DAG: s_ashr_i32
311 ; GCN-DAG: s_sext_i32_i16
313 ; v8i16 is naturally 16 byte aligned
314 ; EG: MEM_RAT_CACHELESS STORE_RAW [[ST_HI:T[0-9]]].XYZW, {{T[0-9]+.[XYZW]}},
315 ; EG: MEM_RAT_CACHELESS STORE_RAW [[ST_LO:T[0-9]]].XYZW, {{T[0-9]+.[XYZW]}},
316 ; EG: VTX_READ_128 [[DST:T[0-9]]].XYZW, {{T[0-9].[XYZW]}}, 0, #1
317 ; TODO: 4 of these should use ASHR instead of LSHR + BFE_INT
318 ; TODO: This should use DST, but for some there are redundant MOVs
319 ; EG-DAG: BFE_INT {{[* ]*}}[[ST_LO]].Y, {{.*}}, 0.0, literal
320 ; EG-DAG: BFE_INT {{[* ]*}}[[ST_LO]].W, {{.*}}, 0.0, literal
321 ; EG-DAG: BFE_INT {{[* ]*}}[[ST_HI]].Y, {{.*}}, 0.0, literal
322 ; EG-DAG: BFE_INT {{[* ]*}}[[ST_HI]].W, {{.*}}, 0.0, literal
323 ; EG-DAG: BFE_INT {{[* ]*}}[[ST_LO]].X, {{.*}}, 0.0, literal
324 ; EG-DAG: BFE_INT {{[* ]*}}[[ST_LO]].Z, {{.*}}, 0.0, literal
325 ; EG-DAG: BFE_INT {{[* ]*}}[[ST_HI]].X, {{.*}}, 0.0, literal
326 ; EG-DAG: BFE_INT {{[* ]*}}[[ST_HI]].Z, {{.*}}, 0.0, literal
335 define amdgpu_kernel void @constant_sextload_v8i16_to_v8i32(<8 x i32> addrspace(1)* %out, <8 x i16> addrspace(4)* %in) #0 {
336 %load = load <8 x i16>, <8 x i16> addrspace(4)* %in
337 %ext = sext <8 x i16> %load to <8 x i32>
338 store <8 x i32> %ext, <8 x i32> addrspace(1)* %out
342 ; FUNC-LABEL: {{^}}constant_zextload_v16i16_to_v16i32:
343 ; GCN: s_load_dwordx8
345 ; GCN-DAG: s_lshr_b32
347 ; v16i16 is naturally 32 byte aligned
348 ; EG-DAG: VTX_READ_128 [[DST_HI:T[0-9]+\.XYZW]], {{T[0-9]+.[XYZW]}}, 0, #1
349 ; EG-DAG: VTX_READ_128 [[DST_LO:T[0-9]+\.XYZW]], {{T[0-9]+.[XYZW]}}, 16, #1
350 define amdgpu_kernel void @constant_zextload_v16i16_to_v16i32(<16 x i32> addrspace(1)* %out, <16 x i16> addrspace(4)* %in) #0 {
351 %load = load <16 x i16>, <16 x i16> addrspace(4)* %in
352 %ext = zext <16 x i16> %load to <16 x i32>
353 store <16 x i32> %ext, <16 x i32> addrspace(1)* %out
357 ; FUNC-LABEL: {{^}}constant_sextload_v16i16_to_v16i32:
358 ; GCN: s_load_dwordx8
359 ; GCN-DAG: s_ashr_i32
360 ; GCN-DAG: s_sext_i32_i16
362 ; v16i16 is naturally 32 byte aligned
363 ; EG-DAG: VTX_READ_128 [[DST_HI:T[0-9]+\.XYZW]], {{T[0-9]+\.[XYZW]}}, 0, #1
364 ; EG-DAG: VTX_READ_128 [[DST_LO:T[0-9]+\.XYZW]], {{T[0-9]+\.[XYZW]}}, 16, #1
365 define amdgpu_kernel void @constant_sextload_v16i16_to_v16i32(<16 x i32> addrspace(1)* %out, <16 x i16> addrspace(4)* %in) #0 {
366 %load = load <16 x i16>, <16 x i16> addrspace(4)* %in
367 %ext = sext <16 x i16> %load to <16 x i32>
368 store <16 x i32> %ext, <16 x i32> addrspace(1)* %out
372 ; FUNC-LABEL: {{^}}constant_zextload_v32i16_to_v32i32:
373 ; GCN-DAG: s_load_dwordx16
374 ; GCN-DAG: s_mov_b32 [[K:s[0-9]+]], 0xffff{{$}}
375 ; GCN-DAG: s_lshr_b32 s{{[0-9]+}}, s{{[0-9]+}}, 16
376 ; GCN-DAG: s_and_b32 s{{[0-9]+}}, s{{[0-9]+}}, [[K]]
378 ; EG-DAG: VTX_READ_128 {{T[0-9]+\.XYZW}}, {{T[0-9]+\.[XYZW]}}, 0, #1
379 ; EG-DAG: VTX_READ_128 {{T[0-9]+\.XYZW}}, {{T[0-9]+\.[XYZW]}}, 16, #1
380 ; EG-DAG: VTX_READ_128 {{T[0-9]+\.XYZW}}, {{T[0-9]+\.[XYZW]}}, 32, #1
381 ; EG-DAG: VTX_READ_128 {{T[0-9]+\.XYZW}}, {{T[0-9]+\.[XYZW]}}, 48, #1
382 define amdgpu_kernel void @constant_zextload_v32i16_to_v32i32(<32 x i32> addrspace(1)* %out, <32 x i16> addrspace(4)* %in) #0 {
383 %load = load <32 x i16>, <32 x i16> addrspace(4)* %in
384 %ext = zext <32 x i16> %load to <32 x i32>
385 store <32 x i32> %ext, <32 x i32> addrspace(1)* %out
389 ; FUNC-LABEL: {{^}}constant_sextload_v32i16_to_v32i32:
390 ; GCN: s_load_dwordx16
391 ; GCN-DAG: s_ashr_i32
392 ; GCN-DAG: s_sext_i32_i16
394 ; EG-DAG: VTX_READ_128 {{T[0-9]+\.XYZW}}, {{T[0-9]+\.[XYZW]}}, 0, #1
395 ; EG-DAG: VTX_READ_128 {{T[0-9]+\.XYZW}}, {{T[0-9]+\.[XYZW]}}, 16, #1
396 ; EG-DAG: VTX_READ_128 {{T[0-9]+\.XYZW}}, {{T[0-9]+\.[XYZW]}}, 32, #1
397 ; EG-DAG: VTX_READ_128 {{T[0-9]+\.XYZW}}, {{T[0-9]+\.[XYZW]}}, 48, #1
398 define amdgpu_kernel void @constant_sextload_v32i16_to_v32i32(<32 x i32> addrspace(1)* %out, <32 x i16> addrspace(4)* %in) #0 {
399 %load = load <32 x i16>, <32 x i16> addrspace(4)* %in
400 %ext = sext <32 x i16> %load to <32 x i32>
401 store <32 x i32> %ext, <32 x i32> addrspace(1)* %out
405 ; FUNC-LABEL: {{^}}constant_zextload_v64i16_to_v64i32:
406 ; GCN: s_load_dwordx16
407 ; GCN: s_load_dwordx16
409 ; EG-DAG: VTX_READ_128 {{T[0-9]+\.XYZW}}, {{T[0-9]+\.[XYZW]}}, 0, #1
410 ; EG-DAG: VTX_READ_128 {{T[0-9]+\.XYZW}}, {{T[0-9]+\.[XYZW]}}, 16, #1
411 ; EG-DAG: VTX_READ_128 {{T[0-9]+\.XYZW}}, {{T[0-9]+\.[XYZW]}}, 32, #1
412 ; EG-DAG: VTX_READ_128 {{T[0-9]+\.XYZW}}, {{T[0-9]+\.[XYZW]}}, 48, #1
413 ; EG-DAG: VTX_READ_128 {{T[0-9]+\.XYZW}}, {{T[0-9]+\.[XYZW]}}, 64, #1
414 ; EG-DAG: VTX_READ_128 {{T[0-9]+\.XYZW}}, {{T[0-9]+\.[XYZW]}}, 80, #1
415 ; EG-DAG: VTX_READ_128 {{T[0-9]+\.XYZW}}, {{T[0-9]+\.[XYZW]}}, 96, #1
416 ; EG-DAG: VTX_READ_128 {{T[0-9]+\.XYZW}}, {{T[0-9]+\.[XYZW]}}, 112, #1
417 define amdgpu_kernel void @constant_zextload_v64i16_to_v64i32(<64 x i32> addrspace(1)* %out, <64 x i16> addrspace(4)* %in) #0 {
418 %load = load <64 x i16>, <64 x i16> addrspace(4)* %in
419 %ext = zext <64 x i16> %load to <64 x i32>
420 store <64 x i32> %ext, <64 x i32> addrspace(1)* %out
424 ; FUNC-LABEL: {{^}}constant_sextload_v64i16_to_v64i32:
426 ; EG-DAG: VTX_READ_128 {{T[0-9]+\.XYZW}}, {{T[0-9]+\.[XYZW]}}, 0, #1
427 ; EG-DAG: VTX_READ_128 {{T[0-9]+\.XYZW}}, {{T[0-9]+\.[XYZW]}}, 16, #1
428 ; EG-DAG: VTX_READ_128 {{T[0-9]+\.XYZW}}, {{T[0-9]+\.[XYZW]}}, 32, #1
429 ; EG-DAG: VTX_READ_128 {{T[0-9]+\.XYZW}}, {{T[0-9]+\.[XYZW]}}, 48, #1
430 ; EG-DAG: VTX_READ_128 {{T[0-9]+\.XYZW}}, {{T[0-9]+\.[XYZW]}}, 64, #1
431 ; EG-DAG: VTX_READ_128 {{T[0-9]+\.XYZW}}, {{T[0-9]+\.[XYZW]}}, 80, #1
432 ; EG-DAG: VTX_READ_128 {{T[0-9]+\.XYZW}}, {{T[0-9]+\.[XYZW]}}, 96, #1
433 ; EG-DAG: VTX_READ_128 {{T[0-9]+\.XYZW}}, {{T[0-9]+\.[XYZW]}}, 112, #1
434 define amdgpu_kernel void @constant_sextload_v64i16_to_v64i32(<64 x i32> addrspace(1)* %out, <64 x i16> addrspace(4)* %in) #0 {
435 %load = load <64 x i16>, <64 x i16> addrspace(4)* %in
436 %ext = sext <64 x i16> %load to <64 x i32>
437 store <64 x i32> %ext, <64 x i32> addrspace(1)* %out
441 ; FUNC-LABEL: {{^}}constant_zextload_i16_to_i64:
442 ; GCN-NOHSA-DAG: buffer_load_ushort v[[LO:[0-9]+]],
443 ; GCN-HSA-DAG: flat_load_ushort v[[LO:[0-9]+]],
444 ; GCN-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], 0{{$}}
446 ; GCN-NOHSA: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]]
447 ; GCN-HSA: flat_store_dwordx2 v{{\[[0-9]+:[0-9]+\]}}, v{{\[}}[[LO]]:[[HI]]{{\]}}
449 ; EG: VTX_READ_16 T{{[0-9]+}}.X, T{{[0-9]+}}.X, 0, #1
450 ; EG: MOV {{.*}}, 0.0
451 define amdgpu_kernel void @constant_zextload_i16_to_i64(i64 addrspace(1)* %out, i16 addrspace(4)* %in) #0 {
452 %a = load i16, i16 addrspace(4)* %in
453 %ext = zext i16 %a to i64
454 store i64 %ext, i64 addrspace(1)* %out
458 ; FUNC-LABEL: {{^}}constant_sextload_i16_to_i64:
459 ; FIXME: Need to optimize this sequence to avoid extra bfe:
460 ; t28: i32,ch = load<LD2[%in(addrspace=1)], anyext from i16> t12, t27, undef:i64
461 ; t31: i64 = any_extend t28
462 ; t33: i64 = sign_extend_inreg t31, ValueType:ch:i16
464 ; GCN-NOHSA-SI-DAG: buffer_load_sshort v[[LO:[0-9]+]],
465 ; GCN-HSA-DAG: flat_load_sshort v[[LO:[0-9]+]],
466 ; GCN-NOHSA-VI-DAG: buffer_load_ushort v[[ULO:[0-9]+]],
467 ; GCN-NOHSA-VI-DAG: v_bfe_i32 v[[LO:[0-9]+]], v[[ULO]], 0, 16
468 ; GCN-DAG: v_ashrrev_i32_e32 v[[HI:[0-9]+]], 31, v[[LO]]
470 ; GCN-NOHSA: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]]
471 ; GCN-HSA: flat_store_dwordx2 v{{\[[0-9]+:[0-9]+\]}}, v{{\[}}[[LO]]:[[HI]]{{\]}}
473 ; EG: VTX_READ_16 T{{[0-9]+}}.X, T{{[0-9]+}}.X, 0, #1
474 ; EG: ASHR {{\**}} {{T[0-9]\.[XYZW]}}, {{.*}}, literal
475 ; TODO: These could be expanded earlier using ASHR 15
477 define amdgpu_kernel void @constant_sextload_i16_to_i64(i64 addrspace(1)* %out, i16 addrspace(4)* %in) #0 {
478 %a = load i16, i16 addrspace(4)* %in
479 %ext = sext i16 %a to i64
480 store i64 %ext, i64 addrspace(1)* %out
484 ; FUNC-LABEL: {{^}}constant_zextload_v1i16_to_v1i64:
486 ; EG: VTX_READ_16 T{{[0-9]+}}.X, T{{[0-9]+}}.X, 0, #1
487 ; EG: MOV {{.*}}, 0.0
488 define amdgpu_kernel void @constant_zextload_v1i16_to_v1i64(<1 x i64> addrspace(1)* %out, <1 x i16> addrspace(4)* %in) #0 {
489 %load = load <1 x i16>, <1 x i16> addrspace(4)* %in
490 %ext = zext <1 x i16> %load to <1 x i64>
491 store <1 x i64> %ext, <1 x i64> addrspace(1)* %out
495 ; FUNC-LABEL: {{^}}constant_sextload_v1i16_to_v1i64:
497 ; EG: VTX_READ_16 T{{[0-9]+}}.X, T{{[0-9]+}}.X, 0, #1
498 ; EG: ASHR {{\**}} {{T[0-9]\.[XYZW]}}, {{.*}}, literal
499 ; TODO: These could be expanded earlier using ASHR 15
501 define amdgpu_kernel void @constant_sextload_v1i16_to_v1i64(<1 x i64> addrspace(1)* %out, <1 x i16> addrspace(4)* %in) #0 {
502 %load = load <1 x i16>, <1 x i16> addrspace(4)* %in
503 %ext = sext <1 x i16> %load to <1 x i64>
504 store <1 x i64> %ext, <1 x i64> addrspace(1)* %out
508 ; FUNC-LABEL: {{^}}constant_zextload_v2i16_to_v2i64:
510 ; EG: VTX_READ_32 T{{[0-9]+}}.X, T{{[0-9]+}}.X, 0, #1
511 define amdgpu_kernel void @constant_zextload_v2i16_to_v2i64(<2 x i64> addrspace(1)* %out, <2 x i16> addrspace(4)* %in) #0 {
512 %load = load <2 x i16>, <2 x i16> addrspace(4)* %in
513 %ext = zext <2 x i16> %load to <2 x i64>
514 store <2 x i64> %ext, <2 x i64> addrspace(1)* %out
518 ; FUNC-LABEL: {{^}}constant_sextload_v2i16_to_v2i64:
520 ; EG: VTX_READ_32 T{{[0-9]+}}.X, T{{[0-9]+}}.X, 0, #1
521 define amdgpu_kernel void @constant_sextload_v2i16_to_v2i64(<2 x i64> addrspace(1)* %out, <2 x i16> addrspace(4)* %in) #0 {
522 %load = load <2 x i16>, <2 x i16> addrspace(4)* %in
523 %ext = sext <2 x i16> %load to <2 x i64>
524 store <2 x i64> %ext, <2 x i64> addrspace(1)* %out
528 ; FUNC-LABEL: {{^}}constant_zextload_v4i16_to_v4i64:
530 ; EG: VTX_READ_64 T{{[0-9]+}}.XY, T{{[0-9]+}}.X, 0, #1
531 define amdgpu_kernel void @constant_zextload_v4i16_to_v4i64(<4 x i64> addrspace(1)* %out, <4 x i16> addrspace(4)* %in) #0 {
532 %load = load <4 x i16>, <4 x i16> addrspace(4)* %in
533 %ext = zext <4 x i16> %load to <4 x i64>
534 store <4 x i64> %ext, <4 x i64> addrspace(1)* %out
538 ; FUNC-LABEL: {{^}}constant_sextload_v4i16_to_v4i64:
540 ; EG: VTX_READ_64 T{{[0-9]+}}.XY, T{{[0-9]+}}.X, 0, #1
541 define amdgpu_kernel void @constant_sextload_v4i16_to_v4i64(<4 x i64> addrspace(1)* %out, <4 x i16> addrspace(4)* %in) #0 {
542 %load = load <4 x i16>, <4 x i16> addrspace(4)* %in
543 %ext = sext <4 x i16> %load to <4 x i64>
544 store <4 x i64> %ext, <4 x i64> addrspace(1)* %out
548 ; FUNC-LABEL: {{^}}constant_zextload_v8i16_to_v8i64:
550 ; EG: VTX_READ_128 T{{[0-9]+}}.XYZW, T{{[0-9]+}}.X, 0, #1
551 define amdgpu_kernel void @constant_zextload_v8i16_to_v8i64(<8 x i64> addrspace(1)* %out, <8 x i16> addrspace(4)* %in) #0 {
552 %load = load <8 x i16>, <8 x i16> addrspace(4)* %in
553 %ext = zext <8 x i16> %load to <8 x i64>
554 store <8 x i64> %ext, <8 x i64> addrspace(1)* %out
558 ; FUNC-LABEL: {{^}}constant_sextload_v8i16_to_v8i64:
560 ; EG: VTX_READ_128 T{{[0-9]+}}.XYZW, T{{[0-9]+}}.X, 0, #1
561 define amdgpu_kernel void @constant_sextload_v8i16_to_v8i64(<8 x i64> addrspace(1)* %out, <8 x i16> addrspace(4)* %in) #0 {
562 %load = load <8 x i16>, <8 x i16> addrspace(4)* %in
563 %ext = sext <8 x i16> %load to <8 x i64>
564 store <8 x i64> %ext, <8 x i64> addrspace(1)* %out
568 ; FUNC-LABEL: {{^}}constant_zextload_v16i16_to_v16i64:
570 ; EG-DAG: VTX_READ_128 T{{[0-9]+}}.XYZW, T{{[0-9]+}}.X, 0, #1
571 ; EG-DAG: VTX_READ_128 T{{[0-9]+}}.XYZW, T{{[0-9]+}}.X, 16, #1
572 define amdgpu_kernel void @constant_zextload_v16i16_to_v16i64(<16 x i64> addrspace(1)* %out, <16 x i16> addrspace(4)* %in) #0 {
573 %load = load <16 x i16>, <16 x i16> addrspace(4)* %in
574 %ext = zext <16 x i16> %load to <16 x i64>
575 store <16 x i64> %ext, <16 x i64> addrspace(1)* %out
579 ; FUNC-LABEL: {{^}}constant_sextload_v16i16_to_v16i64:
581 ; EG-DAG: VTX_READ_128 T{{[0-9]+}}.XYZW, T{{[0-9]+}}.X, 0, #1
582 ; EG-DAG: VTX_READ_128 T{{[0-9]+}}.XYZW, T{{[0-9]+}}.X, 16, #1
583 define amdgpu_kernel void @constant_sextload_v16i16_to_v16i64(<16 x i64> addrspace(1)* %out, <16 x i16> addrspace(4)* %in) #0 {
584 %load = load <16 x i16>, <16 x i16> addrspace(4)* %in
585 %ext = sext <16 x i16> %load to <16 x i64>
586 store <16 x i64> %ext, <16 x i64> addrspace(1)* %out
590 ; FUNC-LABEL: {{^}}constant_zextload_v32i16_to_v32i64:
592 ; EG-DAG: VTX_READ_128 T{{[0-9]+}}.XYZW, T{{[0-9]+}}.X, 0, #1
593 ; EG-DAG: VTX_READ_128 T{{[0-9]+}}.XYZW, T{{[0-9]+}}.X, 16, #1
594 ; EG-DAG: VTX_READ_128 T{{[0-9]+}}.XYZW, T{{[0-9]+}}.X, 32, #1
595 ; EG-DAG: VTX_READ_128 T{{[0-9]+}}.XYZW, T{{[0-9]+}}.X, 48, #1
596 define amdgpu_kernel void @constant_zextload_v32i16_to_v32i64(<32 x i64> addrspace(1)* %out, <32 x i16> addrspace(4)* %in) #0 {
597 %load = load <32 x i16>, <32 x i16> addrspace(4)* %in
598 %ext = zext <32 x i16> %load to <32 x i64>
599 store <32 x i64> %ext, <32 x i64> addrspace(1)* %out
603 ; FUNC-LABEL: {{^}}constant_sextload_v32i16_to_v32i64:
605 ; EG-DAG: VTX_READ_128 T{{[0-9]+}}.XYZW, T{{[0-9]+}}.X, 0, #1
606 ; EG-DAG: VTX_READ_128 T{{[0-9]+}}.XYZW, T{{[0-9]+}}.X, 16, #1
607 ; EG-DAG: VTX_READ_128 T{{[0-9]+}}.XYZW, T{{[0-9]+}}.X, 32, #1
608 ; EG-DAG: VTX_READ_128 T{{[0-9]+}}.XYZW, T{{[0-9]+}}.X, 48, #1
609 define amdgpu_kernel void @constant_sextload_v32i16_to_v32i64(<32 x i64> addrspace(1)* %out, <32 x i16> addrspace(4)* %in) #0 {
610 %load = load <32 x i16>, <32 x i16> addrspace(4)* %in
611 %ext = sext <32 x i16> %load to <32 x i64>
612 store <32 x i64> %ext, <32 x i64> addrspace(1)* %out
616 ; These trigger undefined register machine verifier errors
618 ; ; XFUNC-LABEL: {{^}}constant_zextload_v64i16_to_v64i64:
619 ; define amdgpu_kernel void @constant_zextload_v64i16_to_v64i64(<64 x i64> addrspace(1)* %out, <64 x i16> addrspace(4)* %in) #0 {
620 ; %load = load <64 x i16>, <64 x i16> addrspace(4)* %in
621 ; %ext = zext <64 x i16> %load to <64 x i64>
622 ; store <64 x i64> %ext, <64 x i64> addrspace(1)* %out
626 ; ; XFUNC-LABEL: {{^}}constant_sextload_v64i16_to_v64i64:
627 ; define amdgpu_kernel void @constant_sextload_v64i16_to_v64i64(<64 x i64> addrspace(1)* %out, <64 x i16> addrspace(4)* %in) #0 {
628 ; %load = load <64 x i16>, <64 x i16> addrspace(4)* %in
629 ; %ext = sext <64 x i16> %load to <64 x i64>
630 ; store <64 x i64> %ext, <64 x i64> addrspace(1)* %out
634 attributes #0 = { nounwind }