1 ; RUN: llc -mtriple=amdgcn -mattr=+promote-alloca,+max-private-element-size-4 -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
2 ; RUN: llc -mtriple=amdgcn -mattr=-promote-alloca,+max-private-element-size-4 -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
4 ; Pointer value is stored in a candidate for LDS usage.
6 ; GCN-LABEL: {{^}}stored_lds_pointer_value:
7 ; GCN: buffer_store_dword v
8 define amdgpu_kernel void @stored_lds_pointer_value(ptr addrspace(1) %ptr) #0 {
9 %tmp = alloca float, addrspace(5)
10 store float 0.0, ptr addrspace(5) %tmp
11 store ptr addrspace(5) %tmp, ptr addrspace(1) %ptr
15 ; GCN-LABEL: {{^}}stored_lds_pointer_value_offset:
16 ; GCN: buffer_store_dword v
17 define amdgpu_kernel void @stored_lds_pointer_value_offset(ptr addrspace(1) %ptr) #0 {
18 %tmp0 = alloca float, addrspace(5)
19 %tmp1 = alloca float, addrspace(5)
20 store float 0.0, ptr addrspace(5) %tmp0
21 store float 0.0, ptr addrspace(5) %tmp1
22 store volatile ptr addrspace(5) %tmp0, ptr addrspace(1) %ptr
23 store volatile ptr addrspace(5) %tmp1, ptr addrspace(1) %ptr
27 ; GCN-LABEL: {{^}}stored_lds_pointer_value_gep:
28 ; GCN-DAG: s_mov_b32 s{{[0-9]+}}, SCRATCH_RSRC_DWORD0
29 ; GCN-DAG: s_mov_b32 s{{[0-9]+}}, SCRATCH_RSRC_DWORD1
30 ; GCN: buffer_store_dword v
31 ; GCN: buffer_store_dword v
32 define amdgpu_kernel void @stored_lds_pointer_value_gep(ptr addrspace(1) %ptr, i32 %idx) #0 {
34 %tmp = alloca float, i32 16, addrspace(5)
35 store float 0.0, ptr addrspace(5) %tmp
36 %tmp2 = getelementptr inbounds float, ptr addrspace(5) %tmp, i32 %idx
37 store ptr addrspace(5) %tmp2, ptr addrspace(1) %ptr
41 ; Pointer value is stored in a candidate for vector usage
42 ; GCN-LABEL: {{^}}stored_vector_pointer_value:
43 ; GCN-DAG: s_mov_b32 s{{[0-9]+}}, SCRATCH_RSRC_DWORD0
44 ; GCN-DAG: s_mov_b32 s{{[0-9]+}}, SCRATCH_RSRC_DWORD1
45 ; GCN: buffer_store_dword
46 ; GCN: buffer_store_dword
47 ; GCN: buffer_store_dword
48 ; GCN: buffer_store_dword
49 define amdgpu_kernel void @stored_vector_pointer_value(ptr addrspace(1) %out, i32 %index) {
51 %tmp0 = alloca [4 x i32], addrspace(5)
52 %y = getelementptr inbounds [4 x i32], ptr addrspace(5) %tmp0, i32 0, i32 1
53 %z = getelementptr inbounds [4 x i32], ptr addrspace(5) %tmp0, i32 0, i32 2
54 %w = getelementptr inbounds [4 x i32], ptr addrspace(5) %tmp0, i32 0, i32 3
55 store i32 0, ptr addrspace(5) %tmp0
56 store i32 1, ptr addrspace(5) %y
57 store i32 2, ptr addrspace(5) %z
58 store i32 3, ptr addrspace(5) %w
59 %tmp1 = getelementptr inbounds [4 x i32], ptr addrspace(5) %tmp0, i32 0, i32 %index
60 store ptr addrspace(5) %tmp1, ptr addrspace(1) %out
64 ; GCN-LABEL: {{^}}stored_fi_to_self:
66 define amdgpu_kernel void @stored_fi_to_self() #0 {
67 %tmp = alloca ptr addrspace(5), addrspace(5)
68 store volatile ptr addrspace(5) inttoptr (i32 1234 to ptr addrspace(5)), ptr addrspace(5) %tmp
69 store volatile ptr addrspace(5) %tmp, ptr addrspace(5) %tmp
73 attributes #0 = { nounwind }