1 ; RUN: llc -mtriple=amdgcn-- -mcpu=tahiti -mattr=-promote-alloca -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
3 ; GCN-LABEL: {{^}}store_fi_lifetime:
4 ; GCN: v_mov_b32_e32 [[FI:v[0-9]+]], 4{{$}}
5 ; GCN: buffer_store_dword [[FI]]
6 define amdgpu_kernel void @store_fi_lifetime(ptr addrspace(1) %out, i32 %in) #0 {
8 %b = alloca i8, addrspace(5)
9 call void @llvm.lifetime.start.p5(i64 1, ptr addrspace(5) %b)
10 store volatile ptr addrspace(5) %b, ptr addrspace(1) undef
11 call void @llvm.lifetime.end.p5(i64 1, ptr addrspace(5) %b)
15 ; GCN-LABEL: {{^}}stored_fi_to_lds:
16 ; GCN: s_load_dword [[LDSPTR:s[0-9]+]]
17 ; GCN: v_mov_b32_e32 [[ZERO0:v[0-9]+]], 4{{$}}
18 ; GCN: buffer_store_dword v{{[0-9]+}}, off,
19 ; GCN: v_mov_b32_e32 [[VLDSPTR:v[0-9]+]], [[LDSPTR]]
20 ; GCN: ds_write_b32 [[VLDSPTR]], [[ZERO0]]
21 define amdgpu_kernel void @stored_fi_to_lds(ptr addrspace(3) %ptr) #0 {
22 %tmp = alloca float, addrspace(5)
23 store float 4.0, ptr addrspace(5) %tmp
24 store ptr addrspace(5) %tmp, ptr addrspace(3) %ptr
29 ; GCN-LABEL: {{^}}stored_fi_to_lds_2_small_objects:
30 ; GCN-DAG: v_mov_b32_e32 [[ZERO:v[0-9]+]], 4{{$}}
31 ; GCN-DAG: buffer_store_dword v{{[0-9]+}}, off, s{{\[[0-9]+:[0-9]+\]}}, 0 offset:4{{$}}
32 ; GCN-DAG: buffer_store_dword v{{[0-9]+}}, off, s{{\[[0-9]+:[0-9]+\]}}, 0 offset:8{{$}}
34 ; GCN-DAG: s_load_dword [[LDSPTR:s[0-9]+]]
36 ; GCN-DAG: v_mov_b32_e32 [[VLDSPTR:v[0-9]+]], [[LDSPTR]]
37 ; GCN: ds_write_b32 [[VLDSPTR]], [[ZERO]]
39 ; GCN-DAG: v_mov_b32_e32 [[FI1:v[0-9]+]], 8{{$}}
40 ; GCN: ds_write_b32 [[VLDSPTR]], [[FI1]]
41 define amdgpu_kernel void @stored_fi_to_lds_2_small_objects(ptr addrspace(3) %ptr) #0 {
42 %tmp0 = alloca float, addrspace(5)
43 %tmp1 = alloca float, addrspace(5)
44 store float 4.0, ptr addrspace(5) %tmp0
45 store float 4.0, ptr addrspace(5) %tmp1
46 store volatile ptr addrspace(5) %tmp0, ptr addrspace(3) %ptr
47 store volatile ptr addrspace(5) %tmp1, ptr addrspace(3) %ptr
51 ; Same frame index is used multiple times in the store
52 ; GCN-LABEL: {{^}}stored_fi_to_self:
53 ; GCN-DAG: v_mov_b32_e32 [[K:v[0-9]+]], 0x4d2{{$}}
54 ; GCN: buffer_store_dword [[K]], off, s{{\[[0-9]+:[0-9]+\]}}, 0 offset:4{{$}}
55 ; GCN-DAG: v_mov_b32_e32 [[ZERO:v[0-9]+]], 4{{$}}
56 ; GCN: buffer_store_dword [[ZERO]], off, s{{\[[0-9]+:[0-9]+\]}}, 0 offset:4{{$}}
57 define amdgpu_kernel void @stored_fi_to_self() #0 {
58 %tmp = alloca ptr addrspace(5), addrspace(5)
60 ; Avoid optimizing everything out
61 store volatile ptr addrspace(5) inttoptr (i32 1234 to ptr addrspace(5)), ptr addrspace(5) %tmp
62 store volatile ptr addrspace(5) %tmp, ptr addrspace(5) %tmp
66 ; GCN-LABEL: {{^}}stored_fi_to_self_offset:
67 ; GCN-DAG: v_mov_b32_e32 [[K0:v[0-9]+]], 32{{$}}
68 ; GCN: buffer_store_dword [[K0]], off, s{{\[[0-9]+:[0-9]+\]}}, 0 offset:4{{$}}
70 ; GCN-DAG: v_mov_b32_e32 [[K1:v[0-9]+]], 0x4d2{{$}}
71 ; GCN: buffer_store_dword [[K1]], off, s{{\[[0-9]+:[0-9]+\]}}, 0 offset:2052{{$}}
73 ; GCN: v_mov_b32_e32 [[OFFSETK:v[0-9]+]], 0x804{{$}}
74 ; GCN: buffer_store_dword [[OFFSETK]], off, s{{\[[0-9]+:[0-9]+\]}}, 0 offset:2052{{$}}
75 define amdgpu_kernel void @stored_fi_to_self_offset() #0 {
76 %tmp0 = alloca [512 x i32], addrspace(5)
77 %tmp1 = alloca ptr addrspace(5), addrspace(5)
79 ; Avoid optimizing everything out
80 store volatile i32 32, ptr addrspace(5) %tmp0
82 store volatile ptr addrspace(5) inttoptr (i32 1234 to ptr addrspace(5)), ptr addrspace(5) %tmp1
84 store volatile ptr addrspace(5) %tmp1, ptr addrspace(5) %tmp1
88 ; GCN-LABEL: {{^}}stored_fi_to_fi:
89 ; GCN: buffer_store_dword v{{[0-9]+}}, off, s{{\[[0-9]+:[0-9]+\]}}, 0 offset:4{{$}}
90 ; GCN: buffer_store_dword v{{[0-9]+}}, off, s{{\[[0-9]+:[0-9]+\]}}, 0 offset:8{{$}}
91 ; GCN: buffer_store_dword v{{[0-9]+}}, off, s{{\[[0-9]+:[0-9]+\]}}, 0 offset:12{{$}}
93 ; GCN: v_mov_b32_e32 [[FI1:v[0-9]+]], 8{{$}}
94 ; GCN: buffer_store_dword [[FI1]], off, s{{\[[0-9]+:[0-9]+\]}}, 0 offset:12{{$}}
96 ; GCN: v_mov_b32_e32 [[FI2:v[0-9]+]], 12{{$}}
97 ; GCN: buffer_store_dword [[FI2]], off, s{{\[[0-9]+:[0-9]+\]}}, 0 offset:8{{$}}
98 define amdgpu_kernel void @stored_fi_to_fi() #0 {
99 %tmp0 = alloca ptr addrspace(5), addrspace(5)
100 %tmp1 = alloca ptr addrspace(5), addrspace(5)
101 %tmp2 = alloca ptr addrspace(5), addrspace(5)
102 store volatile ptr addrspace(5) inttoptr (i32 1234 to ptr addrspace(5)), ptr addrspace(5) %tmp0
103 store volatile ptr addrspace(5) inttoptr (i32 5678 to ptr addrspace(5)), ptr addrspace(5) %tmp1
104 store volatile ptr addrspace(5) inttoptr (i32 9999 to ptr addrspace(5)), ptr addrspace(5) %tmp2
107 store volatile ptr addrspace(5) %tmp1, ptr addrspace(5) %tmp2 ; store offset 4 at offset 8
108 store volatile ptr addrspace(5) %tmp2, ptr addrspace(5) %tmp1 ; store offset 8 at offset 4
112 ; GCN-LABEL: {{^}}stored_fi_to_global:
113 ; GCN: buffer_store_dword v{{[0-9]+}}, off, s{{\[[0-9]+:[0-9]+\]}}, 0 offset:4{{$}}
114 ; GCN: v_mov_b32_e32 [[FI:v[0-9]+]], 4{{$}}
115 ; GCN: buffer_store_dword [[FI]]
116 define amdgpu_kernel void @stored_fi_to_global(ptr addrspace(1) %ptr) #0 {
117 %tmp = alloca float, addrspace(5)
118 store float 0.0, ptr addrspace(5) %tmp
119 store ptr addrspace(5) %tmp, ptr addrspace(1) %ptr
124 ; GCN-LABEL: {{^}}stored_fi_to_global_2_small_objects:
125 ; GCN: buffer_store_dword v{{[0-9]+}}, off, s{{\[[0-9]+:[0-9]+\]}}, 0 offset:4{{$}}
126 ; GCN: buffer_store_dword v{{[0-9]+}}, off, s{{\[[0-9]+:[0-9]+\]}}, 0 offset:8{{$}}
127 ; GCN: buffer_store_dword v{{[0-9]+}}, off, s{{\[[0-9]+:[0-9]+\]}}, 0 offset:12{{$}}
129 ; GCN: v_mov_b32_e32 [[FI1:v[0-9]+]], 8{{$}}
130 ; GCN: buffer_store_dword [[FI1]], off, s{{\[[0-9]+:[0-9]+\]}}, 0{{$}}
132 ; GCN-DAG: v_mov_b32_e32 [[FI2:v[0-9]+]], 12{{$}}
133 ; GCN: buffer_store_dword [[FI2]], off, s{{\[[0-9]+:[0-9]+\]}}, 0{{$}}
134 define amdgpu_kernel void @stored_fi_to_global_2_small_objects(ptr addrspace(1) %ptr) #0 {
135 %tmp0 = alloca float, addrspace(5)
136 %tmp1 = alloca float, addrspace(5)
137 %tmp2 = alloca float, addrspace(5)
138 store volatile float 0.0, ptr addrspace(5) %tmp0
139 store volatile float 0.0, ptr addrspace(5) %tmp1
140 store volatile float 0.0, ptr addrspace(5) %tmp2
141 store volatile ptr addrspace(5) %tmp1, ptr addrspace(1) %ptr
142 store volatile ptr addrspace(5) %tmp2, ptr addrspace(1) %ptr
146 ; GCN-LABEL: {{^}}stored_fi_to_global_huge_frame_offset:
147 ; GCN: v_mov_b32_e32 [[BASE_0:v[0-9]+]], 0{{$}}
148 ; GCN: buffer_store_dword [[BASE_0]], off, s{{\[[0-9]+:[0-9]+\]}}, 0 offset:4{{$}}
150 ; FIXME: Re-initialize
151 ; GCN: v_mov_b32_e32 [[BASE_0_1:v[0-9]+]], 4{{$}}
153 ; GCN-DAG: v_mov_b32_e32 [[K:v[0-9]+]], 0x3e7{{$}}
154 ; GCN-DAG: v_add_i32_e32 [[BASE_1_OFF_1:v[0-9]+]], vcc, 0x3ffc, [[BASE_0_1]]
157 ; GCN: v_add_i32_e32 [[BASE_1_OFF_2:v[0-9]+]], vcc, 56, [[BASE_0_1]]
158 ; GCN: buffer_store_dword [[K]], [[BASE_1_OFF_1]], s{{\[[0-9]+:[0-9]+\]}}, 0 offen{{$}}
160 ; GCN: buffer_store_dword [[BASE_1_OFF_2]], off, s{{\[[0-9]+:[0-9]+\]}}, 0{{$}}
161 define amdgpu_kernel void @stored_fi_to_global_huge_frame_offset(ptr addrspace(1) %ptr) #0 {
162 %tmp0 = alloca [4096 x i32], addrspace(5)
163 %tmp1 = alloca [4096 x i32], addrspace(5)
164 store volatile i32 0, ptr addrspace(5) %tmp0
165 %gep1.tmp0 = getelementptr [4096 x i32], ptr addrspace(5) %tmp0, i32 0, i32 4095
166 store volatile i32 999, ptr addrspace(5) %gep1.tmp0
167 %gep0.tmp1 = getelementptr [4096 x i32], ptr addrspace(5) %tmp0, i32 0, i32 14
168 store ptr addrspace(5) %gep0.tmp1, ptr addrspace(1) %ptr
172 @g1 = external addrspace(1) global ptr addrspace(5)
174 ; This was leaving a dead node around resulting in failing to select
175 ; on the leftover AssertZext's ValueType operand.
177 ; GCN-LABEL: {{^}}cannot_select_assertzext_valuetype:
178 ; GCN: s_getpc_b64 s[[[PC_LO:[0-9]+]]:[[PC_HI:[0-9]+]]]
179 ; GCN: s_add_u32 s{{[0-9]+}}, s[[PC_LO]], g1@gotpcrel32@lo+4
180 ; GCN: s_addc_u32 s{{[0-9]+}}, s[[PC_HI]], g1@gotpcrel32@hi+12
181 ; GCN: v_mov_b32_e32 [[FI:v[0-9]+]], 4{{$}}
182 ; GCN: buffer_store_dword [[FI]]
183 define amdgpu_kernel void @cannot_select_assertzext_valuetype(ptr addrspace(1) %out, i32 %idx) #0 {
185 %b = alloca i32, align 4, addrspace(5)
186 %tmp1 = load volatile ptr addrspace(5), ptr addrspace(1) @g1, align 4
187 %arrayidx = getelementptr inbounds i32, ptr addrspace(5) %tmp1, i32 %idx
188 %tmp2 = load i32, ptr addrspace(5) %arrayidx, align 4
189 store volatile ptr addrspace(5) %b, ptr addrspace(1) undef
193 declare void @llvm.lifetime.start.p5(i64, ptr addrspace(5) nocapture) #1
194 declare void @llvm.lifetime.end.p5(i64, ptr addrspace(5) nocapture) #1
196 attributes #0 = { nounwind }
197 attributes #1 = { argmemonly nounwind }