1 ; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -allow-deprecated-dag-overlap -check-prefix=GCN -check-prefix=GCN-NOHSA -check-prefix=FUNC %s
2 ; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=kaveri -verify-machineinstrs < %s | FileCheck -allow-deprecated-dag-overlap -check-prefix=GCN -check-prefix=GCN-HSA -check-prefix=FUNC %s
3 ; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -allow-deprecated-dag-overlap -check-prefix=GCN -check-prefix=GCN-NOHSA -check-prefix=FUNC %s
4 ; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -allow-deprecated-dag-overlap -check-prefix=EG -check-prefix=FUNC %s
6 ; FUNC-LABEL: {{^}}constant_load_i32:
7 ; GCN: s_load_dword s{{[0-9]+}}
9 ; EG: VTX_READ_32 T{{[0-9]+}}.X, T{{[0-9]+}}.X, 0
10 define amdgpu_kernel void @constant_load_i32(i32 addrspace(1)* %out, i32 addrspace(4)* %in) #0 {
12 %ld = load i32, i32 addrspace(4)* %in
13 store i32 %ld, i32 addrspace(1)* %out
17 ; FUNC-LABEL: {{^}}constant_load_v2i32:
21 define amdgpu_kernel void @constant_load_v2i32(<2 x i32> addrspace(1)* %out, <2 x i32> addrspace(4)* %in) #0 {
23 %ld = load <2 x i32>, <2 x i32> addrspace(4)* %in
24 store <2 x i32> %ld, <2 x i32> addrspace(1)* %out
28 ; FUNC-LABEL: {{^}}constant_load_v3i32:
32 define amdgpu_kernel void @constant_load_v3i32(<3 x i32> addrspace(1)* %out, <3 x i32> addrspace(4)* %in) #0 {
34 %ld = load <3 x i32>, <3 x i32> addrspace(4)* %in
35 store <3 x i32> %ld, <3 x i32> addrspace(1)* %out
39 ; FUNC-LABEL: {{^}}constant_load_v4i32:
43 define amdgpu_kernel void @constant_load_v4i32(<4 x i32> addrspace(1)* %out, <4 x i32> addrspace(4)* %in) #0 {
45 %ld = load <4 x i32>, <4 x i32> addrspace(4)* %in
46 store <4 x i32> %ld, <4 x i32> addrspace(1)* %out
50 ; FUNC-LABEL: {{^}}constant_load_v8i32:
55 define amdgpu_kernel void @constant_load_v8i32(<8 x i32> addrspace(1)* %out, <8 x i32> addrspace(4)* %in) #0 {
57 %ld = load <8 x i32>, <8 x i32> addrspace(4)* %in
58 store <8 x i32> %ld, <8 x i32> addrspace(1)* %out
62 ; FUNC-LABEL: {{^}}constant_load_v16i32:
63 ; GCN: s_load_dwordx16
69 define amdgpu_kernel void @constant_load_v16i32(<16 x i32> addrspace(1)* %out, <16 x i32> addrspace(4)* %in) #0 {
71 %ld = load <16 x i32>, <16 x i32> addrspace(4)* %in
72 store <16 x i32> %ld, <16 x i32> addrspace(1)* %out
76 ; FUNC-LABEL: {{^}}constant_zextload_i32_to_i64:
77 ; GCN-DAG: s_load_dword s[[SLO:[0-9]+]],
78 ; GCN-DAG: v_mov_b32_e32 v[[SHI:[0-9]+]], 0{{$}}
81 ; EG: MEM_RAT_CACHELESS STORE_RAW T{{[0-9]+}}.XY
84 define amdgpu_kernel void @constant_zextload_i32_to_i64(i64 addrspace(1)* %out, i32 addrspace(4)* %in) #0 {
85 %ld = load i32, i32 addrspace(4)* %in
86 %ext = zext i32 %ld to i64
87 store i64 %ext, i64 addrspace(1)* %out
91 ; FUNC-LABEL: {{^}}constant_sextload_i32_to_i64:
92 ; GCN: s_load_dword s[[SLO:[0-9]+]]
93 ; GCN: s_ashr_i32 s[[HI:[0-9]+]], s[[SLO]], 31
96 ; EG: MEM_RAT_CACHELESS STORE_RAW T{{[0-9]+}}.XY
99 ; EG: ASHR {{[* ]*}}T{{[0-9]\.[XYZW]}}, T{{[0-9]\.[XYZW]}}, literal.
101 define amdgpu_kernel void @constant_sextload_i32_to_i64(i64 addrspace(1)* %out, i32 addrspace(4)* %in) #0 {
102 %ld = load i32, i32 addrspace(4)* %in
103 %ext = sext i32 %ld to i64
104 store i64 %ext, i64 addrspace(1)* %out
108 ; FUNC-LABEL: {{^}}constant_zextload_v1i32_to_v1i64:
111 define amdgpu_kernel void @constant_zextload_v1i32_to_v1i64(<1 x i64> addrspace(1)* %out, <1 x i32> addrspace(4)* %in) #0 {
112 %ld = load <1 x i32>, <1 x i32> addrspace(4)* %in
113 %ext = zext <1 x i32> %ld to <1 x i64>
114 store <1 x i64> %ext, <1 x i64> addrspace(1)* %out
118 ; FUNC-LABEL: {{^}}constant_sextload_v1i32_to_v1i64:
119 ; GCN: s_load_dword s[[LO:[0-9]+]]
120 ; GCN: s_ashr_i32 s[[HI:[0-9]+]], s[[LO]], 31
122 define amdgpu_kernel void @constant_sextload_v1i32_to_v1i64(<1 x i64> addrspace(1)* %out, <1 x i32> addrspace(4)* %in) #0 {
123 %ld = load <1 x i32>, <1 x i32> addrspace(4)* %in
124 %ext = sext <1 x i32> %ld to <1 x i64>
125 store <1 x i64> %ext, <1 x i64> addrspace(1)* %out
129 ; FUNC-LABEL: {{^}}constant_zextload_v2i32_to_v2i64:
130 ; GCN: s_load_dwordx2 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0x0{{$}}
132 define amdgpu_kernel void @constant_zextload_v2i32_to_v2i64(<2 x i64> addrspace(1)* %out, <2 x i32> addrspace(4)* %in) #0 {
133 %ld = load <2 x i32>, <2 x i32> addrspace(4)* %in
134 %ext = zext <2 x i32> %ld to <2 x i64>
135 store <2 x i64> %ext, <2 x i64> addrspace(1)* %out
139 ; FUNC-LABEL: {{^}}constant_sextload_v2i32_to_v2i64:
140 ; GCN: s_load_dwordx2 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0x0{{$}}
142 ; GCN-DAG: s_ashr_i32
143 ; GCN-DAG: s_ashr_i32
146 define amdgpu_kernel void @constant_sextload_v2i32_to_v2i64(<2 x i64> addrspace(1)* %out, <2 x i32> addrspace(4)* %in) #0 {
147 %ld = load <2 x i32>, <2 x i32> addrspace(4)* %in
148 %ext = sext <2 x i32> %ld to <2 x i64>
149 store <2 x i64> %ext, <2 x i64> addrspace(1)* %out
153 ; FUNC-LABEL: {{^}}constant_zextload_v4i32_to_v4i64:
154 ; GCN: s_load_dwordx4
158 define amdgpu_kernel void @constant_zextload_v4i32_to_v4i64(<4 x i64> addrspace(1)* %out, <4 x i32> addrspace(4)* %in) #0 {
159 %ld = load <4 x i32>, <4 x i32> addrspace(4)* %in
160 %ext = zext <4 x i32> %ld to <4 x i64>
161 store <4 x i64> %ext, <4 x i64> addrspace(1)* %out
165 ; FUNC-LABEL: {{^}}constant_sextload_v4i32_to_v4i64:
166 ; GCN: s_load_dwordx4
175 define amdgpu_kernel void @constant_sextload_v4i32_to_v4i64(<4 x i64> addrspace(1)* %out, <4 x i32> addrspace(4)* %in) #0 {
176 %ld = load <4 x i32>, <4 x i32> addrspace(4)* %in
177 %ext = sext <4 x i32> %ld to <4 x i64>
178 store <4 x i64> %ext, <4 x i64> addrspace(1)* %out
182 ; FUNC-LABEL: {{^}}constant_zextload_v8i32_to_v8i64:
183 ; GCN: s_load_dwordx8
185 ; GCN-NOHSA-DAG: buffer_store_dwordx4
186 ; GCN-NOHSA-DAG: buffer_store_dwordx4
187 ; GCN-NOHSA-DAG: buffer_store_dwordx4
188 ; GCN-NOHSA-DAG: buffer_store_dwordx4
190 ; GCN-HSA-DAG: flat_store_dwordx4
191 ; GCN-HSA-DAG: flat_store_dwordx4
192 ; GCN-SA-DAG: flat_store_dwordx4
193 ; GCN-HSA-DAG: flat_store_dwordx4
194 define amdgpu_kernel void @constant_zextload_v8i32_to_v8i64(<8 x i64> addrspace(1)* %out, <8 x i32> addrspace(4)* %in) #0 {
195 %ld = load <8 x i32>, <8 x i32> addrspace(4)* %in
196 %ext = zext <8 x i32> %ld to <8 x i64>
197 store <8 x i64> %ext, <8 x i64> addrspace(1)* %out
201 ; FUNC-LABEL: {{^}}constant_sextload_v8i32_to_v8i64:
202 ; GCN: s_load_dwordx8
213 ; GCN-NOHSA-DAG: buffer_store_dwordx4
214 ; GCN-NOHSA-DAG: buffer_store_dwordx4
215 ; GCN-NOHSA-DAG: buffer_store_dwordx4
216 ; GCN-NOHSA-DAG: buffer_store_dwordx4
218 ; GCN-HSA-DAG: flat_store_dwordx4
219 ; GCN-HSA-DAG: flat_store_dwordx4
220 ; GCN-HSA-DAG: flat_store_dwordx4
221 ; GCN-HSA-DAG: flat_store_dwordx4
222 define amdgpu_kernel void @constant_sextload_v8i32_to_v8i64(<8 x i64> addrspace(1)* %out, <8 x i32> addrspace(4)* %in) #0 {
223 %ld = load <8 x i32>, <8 x i32> addrspace(4)* %in
224 %ext = sext <8 x i32> %ld to <8 x i64>
225 store <8 x i64> %ext, <8 x i64> addrspace(1)* %out
229 ; FUNC-LABEL: {{^}}constant_sextload_v16i32_to_v16i64:
230 ; GCN: s_load_dwordx16
233 ; GCN-DAG: s_ashr_i32
243 define amdgpu_kernel void @constant_sextload_v16i32_to_v16i64(<16 x i64> addrspace(1)* %out, <16 x i32> addrspace(4)* %in) #0 {
244 %ld = load <16 x i32>, <16 x i32> addrspace(4)* %in
245 %ext = sext <16 x i32> %ld to <16 x i64>
246 store <16 x i64> %ext, <16 x i64> addrspace(1)* %out
250 ; FUNC-LABEL: {{^}}constant_zextload_v16i32_to_v16i64
251 ; GCN: s_load_dwordx16
253 ; GCN-NOHSA: buffer_store_dwordx4
254 ; GCN-NOHSA: buffer_store_dwordx4
255 ; GCN-NOHSA: buffer_store_dwordx4
256 ; GCN-NOHSA: buffer_store_dwordx4
257 ; GCN-NOHSA: buffer_store_dwordx4
258 ; GCN-NOHSA: buffer_store_dwordx4
259 ; GCN-NOHSA: buffer_store_dwordx4
260 ; GCN-NOHSA: buffer_store_dwordx4
262 ; GCN-HSA: flat_store_dwordx4
263 ; GCN-HSA: flat_store_dwordx4
264 ; GCN-HSA: flat_store_dwordx4
265 ; GCN-HSA: flat_store_dwordx4
266 ; GCN-HSA: flat_store_dwordx4
267 ; GCN-HSA: flat_store_dwordx4
268 ; GCN-HSA: flat_store_dwordx4
269 ; GCN-HSA: flat_store_dwordx4
270 define amdgpu_kernel void @constant_zextload_v16i32_to_v16i64(<16 x i64> addrspace(1)* %out, <16 x i32> addrspace(4)* %in) #0 {
271 %ld = load <16 x i32>, <16 x i32> addrspace(4)* %in
272 %ext = zext <16 x i32> %ld to <16 x i64>
273 store <16 x i64> %ext, <16 x i64> addrspace(1)* %out
277 ; FUNC-LABEL: {{^}}constant_sextload_v32i32_to_v32i64:
279 ; GCN: s_load_dwordx16
280 ; GCN-DAG: s_load_dwordx16
282 ; GCN-NOHSA-DAG: buffer_store_dwordx4
283 ; GCN-NOHSA-DAG: buffer_store_dwordx4
284 ; GCN-NOHSA-DAG: buffer_store_dwordx4
285 ; GCN-NOHSA-DAG: buffer_store_dwordx4
287 ; GCN-NOHSA-DAG: buffer_store_dwordx4
288 ; GCN-NOHSA-DAG: buffer_store_dwordx4
289 ; GCN-NOHSA-DAG: buffer_store_dwordx4
290 ; GCN-NOHSA-DAG: buffer_store_dwordx4
292 ; GCN-NOHSA-DAG: buffer_store_dwordx4
293 ; GCN-NOHSA-DAG: buffer_store_dwordx4
294 ; GCN-NOHSA-DAG: buffer_store_dwordx4
295 ; GCN-NOHSA-DAG: buffer_store_dwordx4
297 ; GCN-NOHSA-DAG: buffer_store_dwordx4
298 ; GCN-NOHSA-DAG: buffer_store_dwordx4
299 ; GCN-NOHSA-DAG: buffer_store_dwordx4
300 ; GCN-NOHSA-DAG: buffer_store_dwordx4
302 ; GCN-HSA-DAG: flat_store_dwordx4
303 ; GCN-HSA-DAG: flat_store_dwordx4
304 ; GCN-HSA-DAG: flat_store_dwordx4
305 ; GCN-HSA-DAG: flat_store_dwordx4
307 ; GCN-HSA-DAG: flat_store_dwordx4
308 ; GCN-HSA-DAG: flat_store_dwordx4
309 ; GCN-HSA-DAG: flat_store_dwordx4
310 ; GCN-HSA-DAG: flat_store_dwordx4
312 ; GCN-HSA-DAG: flat_store_dwordx4
313 ; GCN-HSA-DAG: flat_store_dwordx4
314 ; GCN-HSA-DAG: flat_store_dwordx4
315 ; GCN-HSA-DAG: flat_store_dwordx4
317 ; GCN-HSA-DAG: flat_store_dwordx4
318 ; GCN-HSA-DAG: flat_store_dwordx4
319 ; GCN-HSA-DAG: flat_store_dwordx4
320 ; GCN-HSA-DAG: flat_store_dwordx4
322 define amdgpu_kernel void @constant_sextload_v32i32_to_v32i64(<32 x i64> addrspace(1)* %out, <32 x i32> addrspace(4)* %in) #0 {
323 %ld = load <32 x i32>, <32 x i32> addrspace(4)* %in
324 %ext = sext <32 x i32> %ld to <32 x i64>
325 store <32 x i64> %ext, <32 x i64> addrspace(1)* %out
329 ; FUNC-LABEL: {{^}}constant_zextload_v32i32_to_v32i64:
330 ; GCN: s_load_dwordx16
331 ; GCN: s_load_dwordx16
333 ; GCN-NOHSA-DAG: buffer_store_dwordx4
334 ; GCN-NOHSA-DAG: buffer_store_dwordx4
335 ; GCN-NOHSA-DAG: buffer_store_dwordx4
336 ; GCN-NOHSA-DAG: buffer_store_dwordx4
338 ; GCN-NOHSA-DAG: buffer_store_dwordx4
339 ; GCN-NOHSA-DAG: buffer_store_dwordx4
340 ; GCN-NOHSA-DAG: buffer_store_dwordx4
341 ; GCN-NOHSA-DAG: buffer_store_dwordx4
343 ; GCN-NOHSA-DAG: buffer_store_dwordx4
344 ; GCN-NOHSA-DAG: buffer_store_dwordx4
345 ; GCN-NOHSA-DAG: buffer_store_dwordx4
346 ; GCN-NOHSA-DAG: buffer_store_dwordx4
348 ; GCN-NOHSA-DAG: buffer_store_dwordx4
349 ; GCN-NOHSA-DAG: buffer_store_dwordx4
350 ; GCN-NOHSA-DAG: buffer_store_dwordx4
351 ; GCN-NOHSA-DAG: buffer_store_dwordx4
354 ; GCN-HSA-DAG: flat_store_dwordx4
355 ; GCN-HSA-DAG: flat_store_dwordx4
356 ; GCN-HSA-DAG: flat_store_dwordx4
357 ; GCN-HSA-DAG: flat_store_dwordx4
359 ; GCN-HSA-DAG: flat_store_dwordx4
360 ; GCN-HSA-DAG: flat_store_dwordx4
361 ; GCN-HSA-DAG: flat_store_dwordx4
362 ; GCN-HSA-DAG: flat_store_dwordx4
364 ; GCN-HSA-DAG: flat_store_dwordx4
365 ; GCN-HSA-DAG: flat_store_dwordx4
366 ; GCN-HSA-DAG: flat_store_dwordx4
367 ; GCN-HSA-DAG: flat_store_dwordx4
369 ; GCN-HSA-DAG: flat_store_dwordx4
370 ; GCN-HSA-DAG: flat_store_dwordx4
371 ; GCN-HSA-DAG: flat_store_dwordx4
372 ; GCN-HSA-DAG: flat_store_dwordx4
373 define amdgpu_kernel void @constant_zextload_v32i32_to_v32i64(<32 x i64> addrspace(1)* %out, <32 x i32> addrspace(4)* %in) #0 {
374 %ld = load <32 x i32>, <32 x i32> addrspace(4)* %in
375 %ext = zext <32 x i32> %ld to <32 x i64>
376 store <32 x i64> %ext, <32 x i64> addrspace(1)* %out
380 attributes #0 = { nounwind }