150
|
1 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=kaveri -mattr=-promote-alloca -amdgpu-sroa=0 -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,CI %s
|
|
2 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -mattr=-promote-alloca -amdgpu-sroa=0 -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GFX9 %s
|
|
3
|
|
4 ; Test that non-entry function frame indices are expanded properly to
|
|
5 ; give an index relative to the scratch wave offset register
|
|
6
|
|
7 ; Materialize into a mov. Make sure there isn't an unnecessary copy.
|
|
8 ; GCN-LABEL: {{^}}func_mov_fi_i32:
|
|
9 ; GCN: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
|
|
10
|
173
|
11 ; CI-NEXT: v_lshr_b32_e64 v0, s32, 6
|
|
12 ; GFX9-NEXT: v_lshrrev_b32_e64 v0, 6, s32
|
150
|
13
|
|
14 ; GCN-NOT: v_mov
|
|
15 ; GCN: ds_write_b32 v0, v0
|
|
16 define void @func_mov_fi_i32() #0 {
|
|
17 %alloca = alloca i32, addrspace(5)
|
|
18 store volatile i32 addrspace(5)* %alloca, i32 addrspace(5)* addrspace(3)* undef
|
|
19 ret void
|
|
20 }
|
|
21
|
|
22 ; Offset due to different objects
|
|
23 ; GCN-LABEL: {{^}}func_mov_fi_i32_offset:
|
|
24 ; GCN: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
|
|
25
|
173
|
26 ; CI-DAG: v_lshr_b32_e64 v0, s32, 6
|
150
|
27 ; CI-NOT: v_mov
|
|
28 ; CI: ds_write_b32 v0, v0
|
173
|
29 ; CI-NEXT: v_lshr_b32_e64 [[SCALED:v[0-9]+]], s32, 6
|
|
30 ; CI-NEXT: v_add_i32_e{{32|64}} v0, {{s\[[0-9]+:[0-9]+\]|vcc}}, 4, [[SCALED]]
|
150
|
31 ; CI-NEXT: ds_write_b32 v0, v0
|
|
32
|
173
|
33 ; GFX9: v_lshrrev_b32_e64 v0, 6, s32
|
|
34 ; GFX9-NEXT: ds_write_b32 v0, v0
|
|
35 ; GFX9-NEXT: v_lshrrev_b32_e64 [[SCALED:v[0-9]+]], 6, s32
|
150
|
36 ; GFX9-NEXT: v_add_u32_e32 v0, 4, [[SCALED]]
|
|
37 ; GFX9-NEXT: ds_write_b32 v0, v0
|
|
38 define void @func_mov_fi_i32_offset() #0 {
|
|
39 %alloca0 = alloca i32, addrspace(5)
|
|
40 %alloca1 = alloca i32, addrspace(5)
|
|
41 store volatile i32 addrspace(5)* %alloca0, i32 addrspace(5)* addrspace(3)* undef
|
|
42 store volatile i32 addrspace(5)* %alloca1, i32 addrspace(5)* addrspace(3)* undef
|
|
43 ret void
|
|
44 }
|
|
45
|
|
46 ; Materialize into an add of a constant offset from the FI.
|
|
47 ; FIXME: Should be able to merge adds
|
|
48
|
|
49 ; GCN-LABEL: {{^}}func_add_constant_to_fi_i32:
|
|
50 ; GCN: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
|
|
51
|
173
|
52 ; CI: v_lshr_b32_e64 [[SCALED:v[0-9]+]], s32, 6
|
150
|
53 ; CI-NEXT: v_add_i32_e32 v0, vcc, 4, [[SCALED]]
|
|
54
|
173
|
55 ; GFX9: v_lshrrev_b32_e64 [[SCALED:v[0-9]+]], 6, s32
|
150
|
56 ; GFX9-NEXT: v_add_u32_e32 v0, 4, [[SCALED]]
|
|
57
|
|
58 ; GCN-NOT: v_mov
|
|
59 ; GCN: ds_write_b32 v0, v0
|
|
60 define void @func_add_constant_to_fi_i32() #0 {
|
|
61 %alloca = alloca [2 x i32], align 4, addrspace(5)
|
|
62 %gep0 = getelementptr inbounds [2 x i32], [2 x i32] addrspace(5)* %alloca, i32 0, i32 1
|
|
63 store volatile i32 addrspace(5)* %gep0, i32 addrspace(5)* addrspace(3)* undef
|
|
64 ret void
|
|
65 }
|
|
66
|
|
67 ; A user the materialized frame index can't be meaningfully folded
|
|
68 ; into.
|
|
69
|
|
70 ; GCN-LABEL: {{^}}func_other_fi_user_i32:
|
|
71
|
173
|
72 ; CI: v_lshr_b32_e64 v0, s32, 6
|
150
|
73
|
173
|
74 ; GFX9: v_lshrrev_b32_e64 v0, 6, s32
|
150
|
75
|
|
76 ; GCN-NEXT: v_mul_u32_u24_e32 v0, 9, v0
|
|
77 ; GCN-NOT: v_mov
|
|
78 ; GCN: ds_write_b32 v0, v0
|
|
79 define void @func_other_fi_user_i32() #0 {
|
|
80 %alloca = alloca [2 x i32], align 4, addrspace(5)
|
|
81 %ptrtoint = ptrtoint [2 x i32] addrspace(5)* %alloca to i32
|
|
82 %mul = mul i32 %ptrtoint, 9
|
|
83 store volatile i32 %mul, i32 addrspace(3)* undef
|
|
84 ret void
|
|
85 }
|
|
86
|
|
87 ; GCN-LABEL: {{^}}func_store_private_arg_i32_ptr:
|
|
88 ; GCN: v_mov_b32_e32 v1, 15{{$}}
|
173
|
89 ; GCN: buffer_store_dword v1, v0, s[0:3], 0 offen{{$}}
|
150
|
90 define void @func_store_private_arg_i32_ptr(i32 addrspace(5)* %ptr) #0 {
|
|
91 store volatile i32 15, i32 addrspace(5)* %ptr
|
|
92 ret void
|
|
93 }
|
|
94
|
|
95 ; GCN-LABEL: {{^}}func_load_private_arg_i32_ptr:
|
|
96 ; GCN: s_waitcnt
|
173
|
97 ; GCN-NEXT: buffer_load_dword v0, v0, s[0:3], 0 offen{{$}}
|
150
|
98 define void @func_load_private_arg_i32_ptr(i32 addrspace(5)* %ptr) #0 {
|
|
99 %val = load volatile i32, i32 addrspace(5)* %ptr
|
|
100 ret void
|
|
101 }
|
|
102
|
|
103 ; GCN-LABEL: {{^}}void_func_byval_struct_i8_i32_ptr:
|
|
104 ; GCN: s_waitcnt
|
|
105
|
173
|
106 ; CI: v_lshr_b32_e64 [[SHIFT:v[0-9]+]], s32, 6
|
150
|
107 ; CI-NEXT: v_or_b32_e32 v0, 4, [[SHIFT]]
|
|
108
|
173
|
109 ; GFX9: v_lshrrev_b32_e64 [[SHIFT:v[0-9]+]], 6, s32
|
150
|
110 ; GFX9-NEXT: v_or_b32_e32 v0, 4, [[SHIFT]]
|
|
111
|
|
112 ; GCN-NOT: v_mov
|
|
113 ; GCN: ds_write_b32 v0, v0
|
|
114 define void @void_func_byval_struct_i8_i32_ptr({ i8, i32 } addrspace(5)* byval %arg0) #0 {
|
|
115 %gep0 = getelementptr inbounds { i8, i32 }, { i8, i32 } addrspace(5)* %arg0, i32 0, i32 0
|
|
116 %gep1 = getelementptr inbounds { i8, i32 }, { i8, i32 } addrspace(5)* %arg0, i32 0, i32 1
|
|
117 %load1 = load i32, i32 addrspace(5)* %gep1
|
|
118 store volatile i32 addrspace(5)* %gep1, i32 addrspace(5)* addrspace(3)* undef
|
|
119 ret void
|
|
120 }
|
|
121
|
|
122 ; GCN-LABEL: {{^}}void_func_byval_struct_i8_i32_ptr_value:
|
|
123 ; GCN: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
|
|
124 ; GCN-NEXT: buffer_load_ubyte v0, off, s[0:3], s32
|
|
125 ; GCN_NEXT: buffer_load_dword v1, off, s[0:3], s32 offset:4
|
|
126 define void @void_func_byval_struct_i8_i32_ptr_value({ i8, i32 } addrspace(5)* byval %arg0) #0 {
|
|
127 %gep0 = getelementptr inbounds { i8, i32 }, { i8, i32 } addrspace(5)* %arg0, i32 0, i32 0
|
|
128 %gep1 = getelementptr inbounds { i8, i32 }, { i8, i32 } addrspace(5)* %arg0, i32 0, i32 1
|
|
129 %load0 = load i8, i8 addrspace(5)* %gep0
|
|
130 %load1 = load i32, i32 addrspace(5)* %gep1
|
|
131 store volatile i8 %load0, i8 addrspace(3)* undef
|
|
132 store volatile i32 %load1, i32 addrspace(3)* undef
|
|
133 ret void
|
|
134 }
|
|
135
|
|
136 ; GCN-LABEL: {{^}}void_func_byval_struct_i8_i32_ptr_nonentry_block:
|
|
137
|
173
|
138 ; CI: v_lshr_b32_e64 [[SHIFT:v[0-9]+]], s32, 6
|
150
|
139
|
173
|
140 ; GFX9: v_lshrrev_b32_e64 [[SHIFT:v[0-9]+]], 6, s32
|
150
|
141
|
|
142 ; GCN: s_and_saveexec_b64
|
|
143
|
|
144 ; CI: v_add_i32_e32 [[GEP:v[0-9]+]], vcc, 4, [[SHIFT]]
|
|
145 ; CI: buffer_load_dword v{{[0-9]+}}, off, s[0:3], s32 offset:4{{$}}
|
|
146
|
|
147 ; GFX9: v_add_u32_e32 [[GEP:v[0-9]+]], 4, [[SHIFT]]
|
|
148 ; GFX9: buffer_load_dword v{{[0-9]+}}, off, s[0:3], s32 offset:4{{$}}
|
|
149
|
|
150 ; GCN: ds_write_b32 v{{[0-9]+}}, [[GEP]]
|
|
151 define void @void_func_byval_struct_i8_i32_ptr_nonentry_block({ i8, i32 } addrspace(5)* byval %arg0, i32 %arg2) #0 {
|
|
152 %cmp = icmp eq i32 %arg2, 0
|
|
153 br i1 %cmp, label %bb, label %ret
|
|
154
|
|
155 bb:
|
|
156 %gep0 = getelementptr inbounds { i8, i32 }, { i8, i32 } addrspace(5)* %arg0, i32 0, i32 0
|
|
157 %gep1 = getelementptr inbounds { i8, i32 }, { i8, i32 } addrspace(5)* %arg0, i32 0, i32 1
|
|
158 %load1 = load volatile i32, i32 addrspace(5)* %gep1
|
|
159 store volatile i32 addrspace(5)* %gep1, i32 addrspace(5)* addrspace(3)* undef
|
|
160 br label %ret
|
|
161
|
|
162 ret:
|
|
163 ret void
|
|
164 }
|
|
165
|
|
166 ; Added offset can't be used with VOP3 add
|
|
167 ; GCN-LABEL: {{^}}func_other_fi_user_non_inline_imm_offset_i32:
|
173
|
168
|
150
|
169 ; CI-DAG: s_movk_i32 [[K:s[0-9]+|vcc_lo|vcc_hi]], 0x200
|
173
|
170 ; CI-DAG: v_lshr_b32_e64 [[SCALED:v[0-9]+]], s32, 6
|
150
|
171 ; CI: v_add_i32_e32 [[VZ:v[0-9]+]], vcc, [[K]], [[SCALED]]
|
|
172
|
173
|
173 ; GFX9-DAG: v_lshrrev_b32_e64 [[SCALED:v[0-9]+]], 6, s32
|
150
|
174 ; GFX9: v_add_u32_e32 [[VZ:v[0-9]+]], 0x200, [[SCALED]]
|
|
175
|
|
176 ; GCN: v_mul_u32_u24_e32 [[VZ]], 9, [[VZ]]
|
|
177 ; GCN: ds_write_b32 v0, [[VZ]]
|
|
178 define void @func_other_fi_user_non_inline_imm_offset_i32() #0 {
|
|
179 %alloca0 = alloca [128 x i32], align 4, addrspace(5)
|
|
180 %alloca1 = alloca [8 x i32], align 4, addrspace(5)
|
|
181 %gep0 = getelementptr inbounds [128 x i32], [128 x i32] addrspace(5)* %alloca0, i32 0, i32 65
|
|
182 %gep1 = getelementptr inbounds [8 x i32], [8 x i32] addrspace(5)* %alloca1, i32 0, i32 0
|
|
183 store volatile i32 7, i32 addrspace(5)* %gep0
|
|
184 %ptrtoint = ptrtoint i32 addrspace(5)* %gep1 to i32
|
|
185 %mul = mul i32 %ptrtoint, 9
|
|
186 store volatile i32 %mul, i32 addrspace(3)* undef
|
|
187 ret void
|
|
188 }
|
|
189
|
|
190 ; GCN-LABEL: {{^}}func_other_fi_user_non_inline_imm_offset_i32_vcc_live:
|
173
|
191
|
150
|
192 ; CI-DAG: s_movk_i32 [[OFFSET:s[0-9]+]], 0x200
|
173
|
193 ; CI-DAG: v_lshr_b32_e64 [[SCALED:v[0-9]+]], s32, 6
|
150
|
194 ; CI: v_add_i32_e64 [[VZ:v[0-9]+]], s{{\[[0-9]+:[0-9]+\]}}, [[OFFSET]], [[SCALED]]
|
|
195
|
173
|
196 ; GFX9-DAG: v_lshrrev_b32_e64 [[SCALED:v[0-9]+]], 6, s32
|
150
|
197 ; GFX9: v_add_u32_e32 [[VZ:v[0-9]+]], 0x200, [[SCALED]]
|
|
198
|
|
199 ; GCN: v_mul_u32_u24_e32 [[VZ]], 9, [[VZ]]
|
|
200 ; GCN: ds_write_b32 v0, [[VZ]]
|
|
201 define void @func_other_fi_user_non_inline_imm_offset_i32_vcc_live() #0 {
|
|
202 %alloca0 = alloca [128 x i32], align 4, addrspace(5)
|
|
203 %alloca1 = alloca [8 x i32], align 4, addrspace(5)
|
|
204 %vcc = call i64 asm sideeffect "; def $0", "={vcc}"()
|
|
205 %gep0 = getelementptr inbounds [128 x i32], [128 x i32] addrspace(5)* %alloca0, i32 0, i32 65
|
|
206 %gep1 = getelementptr inbounds [8 x i32], [8 x i32] addrspace(5)* %alloca1, i32 0, i32 0
|
|
207 store volatile i32 7, i32 addrspace(5)* %gep0
|
|
208 call void asm sideeffect "; use $0", "{vcc}"(i64 %vcc)
|
|
209 %ptrtoint = ptrtoint i32 addrspace(5)* %gep1 to i32
|
|
210 %mul = mul i32 %ptrtoint, 9
|
|
211 store volatile i32 %mul, i32 addrspace(3)* undef
|
|
212 ret void
|
|
213 }
|
|
214
|
|
215 declare void @func(<4 x float> addrspace(5)* nocapture) #0
|
|
216
|
|
217 ; undef flag not preserved in eliminateFrameIndex when handling the
|
|
218 ; stores in the middle block.
|
|
219
|
|
220 ; GCN-LABEL: {{^}}undefined_stack_store_reg:
|
|
221 ; GCN: s_and_saveexec_b64
|
173
|
222 ; GCN: buffer_store_dword v0, off, s[0:3], s33 offset:
|
|
223 ; GCN: buffer_store_dword v0, off, s[0:3], s33 offset:
|
|
224 ; GCN: buffer_store_dword v0, off, s[0:3], s33 offset:
|
|
225 ; GCN: buffer_store_dword v{{[0-9]+}}, off, s[0:3], s33 offset:
|
150
|
226 define void @undefined_stack_store_reg(float %arg, i32 %arg1) #0 {
|
|
227 bb:
|
|
228 %tmp = alloca <4 x float>, align 16, addrspace(5)
|
|
229 %tmp2 = insertelement <4 x float> undef, float %arg, i32 0
|
|
230 store <4 x float> %tmp2, <4 x float> addrspace(5)* undef
|
|
231 %tmp3 = icmp eq i32 %arg1, 0
|
|
232 br i1 %tmp3, label %bb4, label %bb5
|
|
233
|
|
234 bb4:
|
|
235 call void @func(<4 x float> addrspace(5)* nonnull undef)
|
|
236 store <4 x float> %tmp2, <4 x float> addrspace(5)* %tmp, align 16
|
|
237 call void @func(<4 x float> addrspace(5)* nonnull %tmp)
|
|
238 br label %bb5
|
|
239
|
|
240 bb5:
|
|
241 ret void
|
|
242 }
|
|
243
|
|
244 ; GCN-LABEL: {{^}}alloca_ptr_nonentry_block:
|
|
245 ; GCN: s_and_saveexec_b64
|
|
246 ; GCN: buffer_load_dword v{{[0-9]+}}, off, s[0:3], s32 offset:4
|
|
247
|
173
|
248 ; CI: v_lshr_b32_e64 [[SHIFT:v[0-9]+]], s32, 6
|
150
|
249 ; CI-NEXT: v_or_b32_e32 [[PTR:v[0-9]+]], 4, [[SHIFT]]
|
|
250
|
173
|
251 ; GFX9: v_lshrrev_b32_e64 [[SHIFT:v[0-9]+]], 6, s32
|
150
|
252 ; GFX9-NEXT: v_or_b32_e32 [[PTR:v[0-9]+]], 4, [[SHIFT]]
|
|
253
|
|
254 ; GCN: ds_write_b32 v{{[0-9]+}}, [[PTR]]
|
|
255 define void @alloca_ptr_nonentry_block(i32 %arg0) #0 {
|
|
256 %alloca0 = alloca { i8, i32 }, align 4, addrspace(5)
|
|
257 %cmp = icmp eq i32 %arg0, 0
|
|
258 br i1 %cmp, label %bb, label %ret
|
|
259
|
|
260 bb:
|
|
261 %gep0 = getelementptr inbounds { i8, i32 }, { i8, i32 } addrspace(5)* %alloca0, i32 0, i32 0
|
|
262 %gep1 = getelementptr inbounds { i8, i32 }, { i8, i32 } addrspace(5)* %alloca0, i32 0, i32 1
|
|
263 %load1 = load volatile i32, i32 addrspace(5)* %gep1
|
|
264 store volatile i32 addrspace(5)* %gep1, i32 addrspace(5)* addrspace(3)* undef
|
|
265 br label %ret
|
|
266
|
|
267 ret:
|
|
268 ret void
|
|
269 }
|
|
270
|
|
271 attributes #0 = { nounwind }
|