1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=arm64-unknown-unknown -global-isel -global-isel-abort=1 -O0 -run-pass=legalizer %s -o - | FileCheck %s
4 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
5 target triple = "aarch64"
7 define ptr @test_simple_alloca(i32 %numelts) {
8 %addr = alloca i8, i32 %numelts
12 define ptr @test_aligned_alloca(i32 %numelts) {
13 %addr = alloca i8, i32 %numelts, align 32
17 define ptr @test_natural_alloca(i32 %numelts) {
18 %addr = alloca i128, i32 %numelts
22 define ptr @test_simple_alloca_stack_probing(i32 %numelts) "probe-stack"="inline-asm" {
23 %addr = alloca i8, i32 %numelts
27 define ptr @test_aligned_alloca_stack_probing(i32 %numelts) "probe-stack"="inline-asm" {
28 %addr = alloca i8, i32 %numelts, align 32
32 define ptr @test_natural_alloca_stack_probing(i32 %numelts) "probe-stack"="inline-asm" {
33 %addr = alloca i128, i32 %numelts
39 name: test_simple_alloca
41 tracksRegLiveness: true
47 - { id: 0, name: addr, type: variable-sized, alignment: 1 }
48 machineFunctionInfo: {}
53 ; CHECK-LABEL: name: test_simple_alloca
56 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
57 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
58 ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY]](s32)
59 ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[ZEXT]], [[C]]
60 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 15
61 ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s64) = nuw G_ADD [[MUL]], [[C1]]
62 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 -16
63 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[ADD]], [[C2]]
64 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $sp
65 ; CHECK-NEXT: [[PTRTOINT:%[0-9]+]]:_(s64) = G_PTRTOINT [[COPY1]](p0)
66 ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[PTRTOINT]], [[AND]]
67 ; CHECK-NEXT: [[INTTOPTR:%[0-9]+]]:_(p0) = G_INTTOPTR [[SUB]](s64)
68 ; CHECK-NEXT: $sp = COPY [[INTTOPTR]](p0)
69 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(p0) = COPY [[INTTOPTR]](p0)
70 ; CHECK-NEXT: $x0 = COPY [[COPY2]](p0)
71 ; CHECK-NEXT: RET_ReallyLR implicit $x0
73 %3:_(s64) = G_CONSTANT i64 1
74 %1:_(s64) = G_ZEXT %0(s32)
75 %2:_(s64) = G_MUL %1, %3
76 %4:_(s64) = G_CONSTANT i64 15
77 %5:_(s64) = nuw G_ADD %2, %4
78 %6:_(s64) = G_CONSTANT i64 -16
79 %7:_(s64) = G_AND %5, %6
80 %8:_(p0) = G_DYN_STACKALLOC %7(s64), 0
82 RET_ReallyLR implicit $x0
86 name: test_aligned_alloca
88 tracksRegLiveness: true
94 - { id: 0, name: addr, type: variable-sized, alignment: 32 }
95 machineFunctionInfo: {}
100 ; CHECK-LABEL: name: test_aligned_alloca
101 ; CHECK: liveins: $w0
103 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
104 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
105 ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY]](s32)
106 ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[ZEXT]], [[C]]
107 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 15
108 ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s64) = nuw G_ADD [[MUL]], [[C1]]
109 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 -16
110 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[ADD]], [[C2]]
111 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $sp
112 ; CHECK-NEXT: [[PTRTOINT:%[0-9]+]]:_(s64) = G_PTRTOINT [[COPY1]](p0)
113 ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[PTRTOINT]], [[AND]]
114 ; CHECK-NEXT: [[C3:%[0-9]+]]:_(s64) = G_CONSTANT i64 -32
115 ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s64) = G_AND [[SUB]], [[C3]]
116 ; CHECK-NEXT: [[INTTOPTR:%[0-9]+]]:_(p0) = G_INTTOPTR [[AND1]](s64)
117 ; CHECK-NEXT: $sp = COPY [[INTTOPTR]](p0)
118 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(p0) = COPY [[INTTOPTR]](p0)
119 ; CHECK-NEXT: $x0 = COPY [[COPY2]](p0)
120 ; CHECK-NEXT: RET_ReallyLR implicit $x0
122 %3:_(s64) = G_CONSTANT i64 1
123 %1:_(s64) = G_ZEXT %0(s32)
124 %2:_(s64) = G_MUL %1, %3
125 %4:_(s64) = G_CONSTANT i64 15
126 %5:_(s64) = nuw G_ADD %2, %4
127 %6:_(s64) = G_CONSTANT i64 -16
128 %7:_(s64) = G_AND %5, %6
129 %8:_(p0) = G_DYN_STACKALLOC %7(s64), 32
131 RET_ReallyLR implicit $x0
135 name: test_natural_alloca
137 tracksRegLiveness: true
143 - { id: 0, name: addr, type: variable-sized, alignment: 1 }
144 machineFunctionInfo: {}
149 ; CHECK-LABEL: name: test_natural_alloca
150 ; CHECK: liveins: $w0
152 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
153 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 16
154 ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY]](s32)
155 ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[ZEXT]], [[C]]
156 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 15
157 ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s64) = nuw G_ADD [[MUL]], [[C1]]
158 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 -16
159 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[ADD]], [[C2]]
160 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $sp
161 ; CHECK-NEXT: [[PTRTOINT:%[0-9]+]]:_(s64) = G_PTRTOINT [[COPY1]](p0)
162 ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[PTRTOINT]], [[AND]]
163 ; CHECK-NEXT: [[INTTOPTR:%[0-9]+]]:_(p0) = G_INTTOPTR [[SUB]](s64)
164 ; CHECK-NEXT: $sp = COPY [[INTTOPTR]](p0)
165 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(p0) = COPY [[INTTOPTR]](p0)
166 ; CHECK-NEXT: $x0 = COPY [[COPY2]](p0)
167 ; CHECK-NEXT: RET_ReallyLR implicit $x0
169 %3:_(s64) = G_CONSTANT i64 16
170 %1:_(s64) = G_ZEXT %0(s32)
171 %2:_(s64) = G_MUL %1, %3
172 %4:_(s64) = G_CONSTANT i64 15
173 %5:_(s64) = nuw G_ADD %2, %4
174 %6:_(s64) = G_CONSTANT i64 -16
175 %7:_(s64) = G_AND %5, %6
176 %8:_(p0) = G_DYN_STACKALLOC %7(s64), 0
178 RET_ReallyLR implicit $x0
182 name: test_simple_alloca_stack_probing
184 tracksRegLiveness: true
190 - { id: 0, name: addr, type: variable-sized, alignment: 1 }
191 machineFunctionInfo: {}
196 ; CHECK-LABEL: name: test_simple_alloca_stack_probing
197 ; CHECK: liveins: $w0
199 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
200 ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY]](s32)
201 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
202 ; CHECK-NEXT: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[ZEXT]], [[C]](s64)
203 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 15
204 ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s64) = nuw G_ADD [[SHL]], [[C1]]
205 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 -16
206 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[ADD]], [[C2]]
207 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $sp
208 ; CHECK-NEXT: [[PTRTOINT:%[0-9]+]]:_(s64) = G_PTRTOINT [[COPY1]](p0)
209 ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[PTRTOINT]], [[AND]]
210 ; CHECK-NEXT: [[INTTOPTR:%[0-9]+]]:gpr64common(p0) = G_INTTOPTR [[SUB]](s64)
211 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(p0) = COPY [[INTTOPTR]](p0)
212 ; CHECK-NEXT: PROBED_STACKALLOC_DYN [[INTTOPTR]](p0), implicit-def $sp, implicit-def $nzcv, implicit $sp
213 ; CHECK-NEXT: $x0 = COPY [[COPY2]](p0)
214 ; CHECK-NEXT: RET_ReallyLR implicit $x0
216 %1:_(s64) = G_ZEXT %0(s32)
217 %9:_(s64) = G_CONSTANT i64 0
218 %2:_(s64) = G_SHL %1, %9(s64)
219 %4:_(s64) = G_CONSTANT i64 15
220 %5:_(s64) = nuw G_ADD %2, %4
221 %6:_(s64) = G_CONSTANT i64 -16
222 %7:_(s64) = G_AND %5, %6
223 %8:_(p0) = G_DYN_STACKALLOC %7(s64), 1
225 RET_ReallyLR implicit $x0
229 name: test_aligned_alloca_stack_probing
231 tracksRegLiveness: true
237 - { id: 0, name: addr, type: variable-sized, alignment: 32 }
238 machineFunctionInfo: {}
243 ; CHECK-LABEL: name: test_aligned_alloca_stack_probing
244 ; CHECK: liveins: $w0
246 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
247 ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY]](s32)
248 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
249 ; CHECK-NEXT: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[ZEXT]], [[C]](s64)
250 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 15
251 ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s64) = nuw G_ADD [[SHL]], [[C1]]
252 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 -16
253 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[ADD]], [[C2]]
254 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $sp
255 ; CHECK-NEXT: [[PTRTOINT:%[0-9]+]]:_(s64) = G_PTRTOINT [[COPY1]](p0)
256 ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[PTRTOINT]], [[AND]]
257 ; CHECK-NEXT: [[C3:%[0-9]+]]:_(s64) = G_CONSTANT i64 -32
258 ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s64) = G_AND [[SUB]], [[C3]]
259 ; CHECK-NEXT: [[INTTOPTR:%[0-9]+]]:gpr64common(p0) = G_INTTOPTR [[AND1]](s64)
260 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(p0) = COPY [[INTTOPTR]](p0)
261 ; CHECK-NEXT: PROBED_STACKALLOC_DYN [[INTTOPTR]](p0), implicit-def $sp, implicit-def $nzcv, implicit $sp
262 ; CHECK-NEXT: $x0 = COPY [[COPY2]](p0)
263 ; CHECK-NEXT: RET_ReallyLR implicit $x0
265 %1:_(s64) = G_ZEXT %0(s32)
266 %9:_(s64) = G_CONSTANT i64 0
267 %2:_(s64) = G_SHL %1, %9(s64)
268 %4:_(s64) = G_CONSTANT i64 15
269 %5:_(s64) = nuw G_ADD %2, %4
270 %6:_(s64) = G_CONSTANT i64 -16
271 %7:_(s64) = G_AND %5, %6
272 %8:_(p0) = G_DYN_STACKALLOC %7(s64), 32
274 RET_ReallyLR implicit $x0
278 name: test_natural_alloca_stack_probing
280 tracksRegLiveness: true
286 - { id: 0, name: addr, type: variable-sized, alignment: 1 }
287 machineFunctionInfo: {}
292 ; CHECK-LABEL: name: test_natural_alloca_stack_probing
293 ; CHECK: liveins: $w0
295 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
296 ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY]](s32)
297 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 4
298 ; CHECK-NEXT: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[ZEXT]], [[C]](s64)
299 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 15
300 ; CHECK-NEXT: [[ADD:%[0-9]+]]:_(s64) = nuw G_ADD [[SHL]], [[C1]]
301 ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 -16
302 ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[ADD]], [[C2]]
303 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $sp
304 ; CHECK-NEXT: [[PTRTOINT:%[0-9]+]]:_(s64) = G_PTRTOINT [[COPY1]](p0)
305 ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[PTRTOINT]], [[AND]]
306 ; CHECK-NEXT: [[INTTOPTR:%[0-9]+]]:gpr64common(p0) = G_INTTOPTR [[SUB]](s64)
307 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(p0) = COPY [[INTTOPTR]](p0)
308 ; CHECK-NEXT: PROBED_STACKALLOC_DYN [[INTTOPTR]](p0), implicit-def $sp, implicit-def $nzcv, implicit $sp
309 ; CHECK-NEXT: $x0 = COPY [[COPY2]](p0)
310 ; CHECK-NEXT: RET_ReallyLR implicit $x0
312 %1:_(s64) = G_ZEXT %0(s32)
313 %9:_(s64) = G_CONSTANT i64 4
314 %2:_(s64) = G_SHL %1, %9(s64)
315 %4:_(s64) = G_CONSTANT i64 15
316 %5:_(s64) = nuw G_ADD %2, %4
317 %6:_(s64) = G_CONSTANT i64 -16
318 %7:_(s64) = G_AND %5, %6
319 %8:_(p0) = G_DYN_STACKALLOC %7(s64), 1
321 RET_ReallyLR implicit $x0