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
5 ; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -allow-deprecated-dag-overlap -check-prefix=GCN -check-prefix=GCN-HSA -check-prefix=FUNC %s
6 ; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=gfx908 -verify-machineinstrs < %s | FileCheck -allow-deprecated-dag-overlap -check-prefix=GCN -check-prefix=GCN-HSA -check-prefix=FUNC %s
8 ; FUNC-LABEL: {{^}}constant_load_i32:
9 ; GCN: s_load_dword s{{[0-9]+}}
11 ; EG: VTX_READ_32 T{{[0-9]+}}.X, T{{[0-9]+}}.X, 0
12 define amdgpu_kernel void @constant_load_i32(i32 addrspace(1)* %out, i32 addrspace(4)* %in) #0 {
14 %ld = load i32, i32 addrspace(4)* %in
15 store i32 %ld, i32 addrspace(1)* %out
19 ; FUNC-LABEL: {{^}}constant_load_v2i32:
23 define amdgpu_kernel void @constant_load_v2i32(<2 x i32> addrspace(1)* %out, <2 x i32> addrspace(4)* %in) #0 {
25 %ld = load <2 x i32>, <2 x i32> addrspace(4)* %in
26 store <2 x i32> %ld, <2 x i32> addrspace(1)* %out
30 ; FUNC-LABEL: {{^}}constant_load_v3i32:
34 define amdgpu_kernel void @constant_load_v3i32(<3 x i32> addrspace(1)* %out, <3 x i32> addrspace(4)* %in) #0 {
36 %ld = load <3 x i32>, <3 x i32> addrspace(4)* %in
37 store <3 x i32> %ld, <3 x i32> addrspace(1)* %out
41 ; FUNC-LABEL: {{^}}constant_load_v4i32:
45 define amdgpu_kernel void @constant_load_v4i32(<4 x i32> addrspace(1)* %out, <4 x i32> addrspace(4)* %in) #0 {
47 %ld = load <4 x i32>, <4 x i32> addrspace(4)* %in
48 store <4 x i32> %ld, <4 x i32> addrspace(1)* %out
52 ; FUNC-LABEL: {{^}}constant_load_v8i32:
57 define amdgpu_kernel void @constant_load_v8i32(<8 x i32> addrspace(1)* %out, <8 x i32> addrspace(4)* %in) #0 {
59 %ld = load <8 x i32>, <8 x i32> addrspace(4)* %in
60 store <8 x i32> %ld, <8 x i32> addrspace(1)* %out
64 ; FUNC-LABEL: {{^}}constant_load_v16i32:
65 ; GCN: s_load_dwordx16
71 define amdgpu_kernel void @constant_load_v16i32(<16 x i32> addrspace(1)* %out, <16 x i32> addrspace(4)* %in) #0 {
73 %ld = load <16 x i32>, <16 x i32> addrspace(4)* %in
74 store <16 x i32> %ld, <16 x i32> addrspace(1)* %out
78 ; FUNC-LABEL: {{^}}constant_zextload_i32_to_i64:
79 ; GCN-DAG: s_load_dword s[[SLO:[0-9]+]],
80 ; GCN-DAG: v_mov_b32_e32 v[[SHI:[0-9]+]], 0{{$}}
83 ; EG: MEM_RAT_CACHELESS STORE_RAW T{{[0-9]+}}.XY
86 define amdgpu_kernel void @constant_zextload_i32_to_i64(i64 addrspace(1)* %out, i32 addrspace(4)* %in) #0 {
87 %ld = load i32, i32 addrspace(4)* %in
88 %ext = zext i32 %ld to i64
89 store i64 %ext, i64 addrspace(1)* %out
93 ; FUNC-LABEL: {{^}}constant_sextload_i32_to_i64:
94 ; GCN: s_load_dword s[[SLO:[0-9]+]]
95 ; GCN: s_ashr_i32 s[[HI:[0-9]+]], s[[SLO]], 31
98 ; EG: MEM_RAT_CACHELESS STORE_RAW T{{[0-9]+}}.XY
101 ; EG: ASHR {{[* ]*}}T{{[0-9]\.[XYZW]}}, T{{[0-9]\.[XYZW]}}, literal.
103 define amdgpu_kernel void @constant_sextload_i32_to_i64(i64 addrspace(1)* %out, i32 addrspace(4)* %in) #0 {
104 %ld = load i32, i32 addrspace(4)* %in
105 %ext = sext i32 %ld to i64
106 store i64 %ext, i64 addrspace(1)* %out
110 ; FUNC-LABEL: {{^}}constant_zextload_v1i32_to_v1i64:
113 define amdgpu_kernel void @constant_zextload_v1i32_to_v1i64(<1 x i64> addrspace(1)* %out, <1 x i32> addrspace(4)* %in) #0 {
114 %ld = load <1 x i32>, <1 x i32> addrspace(4)* %in
115 %ext = zext <1 x i32> %ld to <1 x i64>
116 store <1 x i64> %ext, <1 x i64> addrspace(1)* %out
120 ; FUNC-LABEL: {{^}}constant_sextload_v1i32_to_v1i64:
121 ; GCN: s_load_dword s[[LO:[0-9]+]]
122 ; GCN: s_ashr_i32 s[[HI:[0-9]+]], s[[LO]], 31
124 define amdgpu_kernel void @constant_sextload_v1i32_to_v1i64(<1 x i64> addrspace(1)* %out, <1 x i32> addrspace(4)* %in) #0 {
125 %ld = load <1 x i32>, <1 x i32> addrspace(4)* %in
126 %ext = sext <1 x i32> %ld to <1 x i64>
127 store <1 x i64> %ext, <1 x i64> addrspace(1)* %out
131 ; FUNC-LABEL: {{^}}constant_zextload_v2i32_to_v2i64:
132 ; GCN: s_load_dwordx2 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0x0{{$}}
134 define amdgpu_kernel void @constant_zextload_v2i32_to_v2i64(<2 x i64> addrspace(1)* %out, <2 x i32> addrspace(4)* %in) #0 {
135 %ld = load <2 x i32>, <2 x i32> addrspace(4)* %in
136 %ext = zext <2 x i32> %ld to <2 x i64>
137 store <2 x i64> %ext, <2 x i64> addrspace(1)* %out
141 ; FUNC-LABEL: {{^}}constant_sextload_v2i32_to_v2i64:
142 ; GCN: s_load_dwordx2 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0x0{{$}}
144 ; GCN-DAG: s_ashr_i32
145 ; GCN-DAG: s_ashr_i32
148 define amdgpu_kernel void @constant_sextload_v2i32_to_v2i64(<2 x i64> addrspace(1)* %out, <2 x i32> addrspace(4)* %in) #0 {
149 %ld = load <2 x i32>, <2 x i32> addrspace(4)* %in
150 %ext = sext <2 x i32> %ld to <2 x i64>
151 store <2 x i64> %ext, <2 x i64> addrspace(1)* %out
155 ; FUNC-LABEL: {{^}}constant_zextload_v4i32_to_v4i64:
156 ; GCN: s_load_dwordx4
160 define amdgpu_kernel void @constant_zextload_v4i32_to_v4i64(<4 x i64> addrspace(1)* %out, <4 x i32> addrspace(4)* %in) #0 {
161 %ld = load <4 x i32>, <4 x i32> addrspace(4)* %in
162 %ext = zext <4 x i32> %ld to <4 x i64>
163 store <4 x i64> %ext, <4 x i64> addrspace(1)* %out
167 ; FUNC-LABEL: {{^}}constant_sextload_v4i32_to_v4i64:
168 ; GCN: s_load_dwordx4
177 define amdgpu_kernel void @constant_sextload_v4i32_to_v4i64(<4 x i64> addrspace(1)* %out, <4 x i32> addrspace(4)* %in) #0 {
178 %ld = load <4 x i32>, <4 x i32> addrspace(4)* %in
179 %ext = sext <4 x i32> %ld to <4 x i64>
180 store <4 x i64> %ext, <4 x i64> addrspace(1)* %out
184 ; FUNC-LABEL: {{^}}constant_zextload_v8i32_to_v8i64:
185 ; GCN: s_load_dwordx8
187 ; GCN-NOHSA-DAG: buffer_store_dwordx4
188 ; GCN-NOHSA-DAG: buffer_store_dwordx4
189 ; GCN-NOHSA-DAG: buffer_store_dwordx4
190 ; GCN-NOHSA-DAG: buffer_store_dwordx4
192 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
193 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
194 ; GCN-SA-DAG: {{flat|global}}_store_dwordx4
195 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
196 define amdgpu_kernel void @constant_zextload_v8i32_to_v8i64(<8 x i64> addrspace(1)* %out, <8 x i32> addrspace(4)* %in) #0 {
197 %ld = load <8 x i32>, <8 x i32> addrspace(4)* %in
198 %ext = zext <8 x i32> %ld to <8 x i64>
199 store <8 x i64> %ext, <8 x i64> addrspace(1)* %out
203 ; FUNC-LABEL: {{^}}constant_sextload_v8i32_to_v8i64:
204 ; GCN: s_load_dwordx8
215 ; GCN-NOHSA-DAG: buffer_store_dwordx4
216 ; GCN-NOHSA-DAG: buffer_store_dwordx4
217 ; GCN-NOHSA-DAG: buffer_store_dwordx4
218 ; GCN-NOHSA-DAG: buffer_store_dwordx4
220 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
221 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
222 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
223 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
224 define amdgpu_kernel void @constant_sextload_v8i32_to_v8i64(<8 x i64> addrspace(1)* %out, <8 x i32> addrspace(4)* %in) #0 {
225 %ld = load <8 x i32>, <8 x i32> addrspace(4)* %in
226 %ext = sext <8 x i32> %ld to <8 x i64>
227 store <8 x i64> %ext, <8 x i64> addrspace(1)* %out
231 ; FUNC-LABEL: {{^}}constant_sextload_v16i32_to_v16i64:
232 ; GCN: s_load_dwordx16
235 ; GCN-DAG: s_ashr_i32
245 define amdgpu_kernel void @constant_sextload_v16i32_to_v16i64(<16 x i64> addrspace(1)* %out, <16 x i32> addrspace(4)* %in) #0 {
246 %ld = load <16 x i32>, <16 x i32> addrspace(4)* %in
247 %ext = sext <16 x i32> %ld to <16 x i64>
248 store <16 x i64> %ext, <16 x i64> addrspace(1)* %out
252 ; FUNC-LABEL: {{^}}constant_zextload_v16i32_to_v16i64
253 ; GCN: s_load_dwordx16
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
261 ; GCN-NOHSA: buffer_store_dwordx4
262 ; GCN-NOHSA: buffer_store_dwordx4
264 ; GCN-HSA: {{flat|global}}_store_dwordx4
265 ; GCN-HSA: {{flat|global}}_store_dwordx4
266 ; GCN-HSA: {{flat|global}}_store_dwordx4
267 ; GCN-HSA: {{flat|global}}_store_dwordx4
268 ; GCN-HSA: {{flat|global}}_store_dwordx4
269 ; GCN-HSA: {{flat|global}}_store_dwordx4
270 ; GCN-HSA: {{flat|global}}_store_dwordx4
271 ; GCN-HSA: {{flat|global}}_store_dwordx4
272 define amdgpu_kernel void @constant_zextload_v16i32_to_v16i64(<16 x i64> addrspace(1)* %out, <16 x i32> addrspace(4)* %in) #0 {
273 %ld = load <16 x i32>, <16 x i32> addrspace(4)* %in
274 %ext = zext <16 x i32> %ld to <16 x i64>
275 store <16 x i64> %ext, <16 x i64> addrspace(1)* %out
279 ; FUNC-LABEL: {{^}}constant_sextload_v32i32_to_v32i64:
281 ; GCN: s_load_dwordx16
282 ; GCN-DAG: s_load_dwordx16
284 ; GCN-NOHSA-DAG: buffer_store_dwordx4
285 ; GCN-NOHSA-DAG: buffer_store_dwordx4
286 ; GCN-NOHSA-DAG: buffer_store_dwordx4
287 ; GCN-NOHSA-DAG: buffer_store_dwordx4
289 ; GCN-NOHSA-DAG: buffer_store_dwordx4
290 ; GCN-NOHSA-DAG: buffer_store_dwordx4
291 ; GCN-NOHSA-DAG: buffer_store_dwordx4
292 ; GCN-NOHSA-DAG: buffer_store_dwordx4
294 ; GCN-NOHSA-DAG: buffer_store_dwordx4
295 ; GCN-NOHSA-DAG: buffer_store_dwordx4
296 ; GCN-NOHSA-DAG: buffer_store_dwordx4
297 ; GCN-NOHSA-DAG: buffer_store_dwordx4
299 ; GCN-NOHSA-DAG: buffer_store_dwordx4
300 ; GCN-NOHSA-DAG: buffer_store_dwordx4
301 ; GCN-NOHSA-DAG: buffer_store_dwordx4
302 ; GCN-NOHSA-DAG: buffer_store_dwordx4
304 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
305 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
306 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
307 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
309 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
310 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
311 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
312 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
314 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
315 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
316 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
317 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
319 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
320 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
321 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
322 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
324 define amdgpu_kernel void @constant_sextload_v32i32_to_v32i64(<32 x i64> addrspace(1)* %out, <32 x i32> addrspace(4)* %in) #0 {
325 %ld = load <32 x i32>, <32 x i32> addrspace(4)* %in
326 %ext = sext <32 x i32> %ld to <32 x i64>
327 store <32 x i64> %ext, <32 x i64> addrspace(1)* %out
331 ; FUNC-LABEL: {{^}}constant_zextload_v32i32_to_v32i64:
332 ; GCN: s_load_dwordx16
333 ; GCN: s_load_dwordx16
335 ; GCN-NOHSA-DAG: buffer_store_dwordx4
336 ; GCN-NOHSA-DAG: buffer_store_dwordx4
337 ; GCN-NOHSA-DAG: buffer_store_dwordx4
338 ; GCN-NOHSA-DAG: buffer_store_dwordx4
340 ; GCN-NOHSA-DAG: buffer_store_dwordx4
341 ; GCN-NOHSA-DAG: buffer_store_dwordx4
342 ; GCN-NOHSA-DAG: buffer_store_dwordx4
343 ; GCN-NOHSA-DAG: buffer_store_dwordx4
345 ; GCN-NOHSA-DAG: buffer_store_dwordx4
346 ; GCN-NOHSA-DAG: buffer_store_dwordx4
347 ; GCN-NOHSA-DAG: buffer_store_dwordx4
348 ; GCN-NOHSA-DAG: buffer_store_dwordx4
350 ; GCN-NOHSA-DAG: buffer_store_dwordx4
351 ; GCN-NOHSA-DAG: buffer_store_dwordx4
352 ; GCN-NOHSA-DAG: buffer_store_dwordx4
353 ; GCN-NOHSA-DAG: buffer_store_dwordx4
356 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
357 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
358 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
359 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
361 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
362 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
363 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
364 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
366 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
367 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
368 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
369 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
371 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
372 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
373 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
374 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
375 define amdgpu_kernel void @constant_zextload_v32i32_to_v32i64(<32 x i64> addrspace(1)* %out, <32 x i32> addrspace(4)* %in) #0 {
376 %ld = load <32 x i32>, <32 x i32> addrspace(4)* %in
377 %ext = zext <32 x i32> %ld to <32 x i64>
378 store <32 x i64> %ext, <32 x i64> addrspace(1)* %out
382 ; FUNC-LABEL: {{^}}constant_load_v32i32:
383 ; GCN: s_load_dwordx16
384 ; GCN: s_load_dwordx16
386 ; GCN-NOHSA-DAG: buffer_store_dwordx4
387 ; GCN-NOHSA-DAG: buffer_store_dwordx4
388 ; GCN-NOHSA-DAG: buffer_store_dwordx4
389 ; GCN-NOHSA-DAG: buffer_store_dwordx4
391 ; GCN-NOHSA-DAG: buffer_store_dwordx4
392 ; GCN-NOHSA-DAG: buffer_store_dwordx4
393 ; GCN-NOHSA-DAG: buffer_store_dwordx4
394 ; GCN-NOHSA-DAG: buffer_store_dwordx4
396 ; GCN-NOHSA-DAG: buffer_store_dwordx4
397 ; GCN-NOHSA-DAG: buffer_store_dwordx4
398 ; GCN-NOHSA-DAG: buffer_store_dwordx4
399 ; GCN-NOHSA-DAG: buffer_store_dwordx4
401 ; GCN-NOHSA-DAG: buffer_store_dwordx4
402 ; GCN-NOHSA-DAG: buffer_store_dwordx4
403 ; GCN-NOHSA-DAG: buffer_store_dwordx4
404 ; GCN-NOHSA-DAG: buffer_store_dwordx4
408 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
409 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
410 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
411 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
413 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
414 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
415 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
416 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
418 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
419 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
420 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
421 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
423 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
424 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
425 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
426 ; GCN-HSA-DAG: {{flat|global}}_store_dwordx4
427 define amdgpu_kernel void @constant_load_v32i32(<32 x i32> addrspace(1)* %out, <32 x i32> addrspace(4)* %in) #0 {
428 %ld = load <32 x i32>, <32 x i32> addrspace(4)* %in
429 store <32 x i32> %ld, <32 x i32> addrspace(1)* %out
433 attributes #0 = { nounwind }