1 ; RUN: llc -fast-isel-sink-local-values -O0 -fast-isel -fast-isel-abort=2 -code-model=small -verify-machineinstrs -frame-pointer=all -mtriple=arm64-apple-darwin < %s | FileCheck %s
2 ; RUN: llc -fast-isel-sink-local-values -O0 -fast-isel -fast-isel-abort=2 -code-model=large -verify-machineinstrs -frame-pointer=all -mtriple=arm64-apple-darwin < %s | FileCheck %s --check-prefix=LARGE
3 ; RUN: llc -fast-isel-sink-local-values -O0 -fast-isel -fast-isel-abort=2 -code-model=small -verify-machineinstrs -frame-pointer=all -mtriple=aarch64_be-linux-gnu < %s | FileCheck %s --check-prefix=CHECK-BE
5 define void @call0() nounwind {
10 define void @foo0() nounwind {
15 ; LARGE: adrp [[REG0:x[0-9]+]], _call0@GOTPAGE
16 ; LARGE: ldr [[REG1:x[0-9]+]], {{\[}}[[REG0]], _call0@GOTPAGEOFF{{\]}}
17 ; LARGE-NEXT: blr [[REG1]]
22 define i32 @call1(i32 %a) nounwind {
24 %a.addr = alloca i32, align 4
25 store i32 %a, i32* %a.addr, align 4
26 %tmp = load i32, i32* %a.addr, align 4
30 define i32 @foo1(i32 %a) nounwind {
33 ; CHECK: stur w0, [x29, #-4]
34 ; CHECK-NEXT: ldur w0, [x29, #-4]
35 ; CHECK-NEXT: bl _call1
36 %a.addr = alloca i32, align 4
37 store i32 %a, i32* %a.addr, align 4
38 %tmp = load i32, i32* %a.addr, align 4
39 %call = call i32 @call1(i32 %tmp)
43 define i32 @sext_(i8 %a, i16 %b) nounwind {
48 ; CHECK: bl _foo_sext_
49 call void @foo_sext_(i8 signext %a, i16 signext %b)
53 declare void @foo_sext_(i8 %a, i16 %b)
55 define i32 @zext_(i8 %a, i16 %b) nounwind {
60 call void @foo_zext_(i8 zeroext %a, i16 zeroext %b)
64 declare void @foo_zext_(i8 %a, i16 %b)
66 define i32 @t1(i32 %argc, i8** nocapture %argv) {
69 ; The last parameter will be passed on stack via i8.
70 ; CHECK: strb w{{[0-9]+}}, [sp]
72 %call = call i32 @bar(i8 zeroext 0, i8 zeroext -8, i8 zeroext -69, i8 zeroext 28, i8 zeroext 40, i8 zeroext -70, i8 zeroext 28, i8 zeroext 39, i8 zeroext -41)
76 declare i32 @bar(i8 zeroext, i8 zeroext, i8 zeroext, i8 zeroext, i8 zeroext, i8 zeroext, i8 zeroext, i8 zeroext, i8 zeroext)
78 ; Test materialization of integers. Target-independent selector handles this.
82 ; CHECK: mov [[REG1:x[0-9]+]], xzr
83 ; CHECK: mov x0, [[REG1]]
85 ; CHECK: mov [[REG2:w[0-9]+]], #1023
86 ; CHECK: uxth w2, [[REG2]]
87 ; CHECK: mov [[REG3:w[0-9]+]], #2
88 ; CHECK: sxtb w3, [[REG3]]
89 ; CHECK: mov [[REG4:w[0-9]+]], wzr
90 ; CHECK: and w4, [[REG4]], #0x1
91 ; CHECK: mov [[REG5:w[0-9]+]], #1
92 ; CHECK: and w5, [[REG5]], #0x1
94 %call = call i32 @func2(i64 zeroext 0, i32 signext -8, i16 zeroext 1023, i8 signext -254, i1 zeroext 0, i1 zeroext 1)
98 declare i32 @func2(i64 zeroext, i32 signext, i16 zeroext, i8 signext, i1 zeroext, i1 zeroext)
100 declare void @callee_b0f(i8 %bp10, i8 %bp11, i8 %bp12, i8 %bp13, i8 %bp14, i8 %bp15, i8 %bp17, i8 %bp18, i8 %bp19)
101 define void @caller_b1f() {
103 ; CHECK-BE-LABEL: caller_b1f
104 ; CHECK-BE: strb w{{.*}}, [sp, #7]
105 call void @callee_b0f(i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 42)
109 define zeroext i1 @call_arguments1(i1 %a1, i1 %a2, i1 %a3, i1 %a4, i1 %a5, i1 %a6, i1 %a7, i1 %a8) {
110 ; CHECK-LABEL: call_arguments1
111 ; CHECK: and {{w[0-9]+}}, w0, w1
112 ; CHECK-NEXT: and {{w[0-9]+}}, w2, w3
113 ; CHECK-NEXT: and {{w[0-9]+}}, w4, w5
114 ; CHECK-NEXT: and {{w[0-9]+}}, w6, w7
125 define i32 @call_arguments2(i8 zeroext %a1, i8 zeroext %a2, i8 zeroext %a3, i8 zeroext %a4, i8 signext %a5, i8 signext %a6, i8 signext %a7, i8 signext %a8) {
126 ; CHECK-LABEL: call_arguments2
127 ; CHECK: add {{w[0-9]+}}, w0, w1
128 ; CHECK-NEXT: add {{w[0-9]+}}, w2, w3
129 ; CHECK-NEXT: add {{w[0-9]+}}, w4, w5
130 ; CHECK-NEXT: add {{w[0-9]+}}, w6, w7
131 %a1z = zext i8 %a1 to i32
132 %a2z = zext i8 %a2 to i32
133 %a3z = zext i8 %a3 to i32
134 %a4z = zext i8 %a4 to i32
135 %a5s = sext i8 %a5 to i32
136 %a6s = sext i8 %a6 to i32
137 %a7s = sext i8 %a7 to i32
138 %a8s = sext i8 %a8 to i32
139 %1 = add i32 %a1z, %a2z
140 %2 = add i32 %a3z, %a4z
141 %3 = add i32 %a5s, %a6s
142 %4 = add i32 %a7s, %a8s
149 define i32 @call_arguments3(i16 zeroext %a1, i16 zeroext %a2, i16 zeroext %a3, i16 zeroext %a4, i16 signext %a5, i16 signext %a6, i16 signext %a7, i16 signext %a8) {
150 ; CHECK-LABEL: call_arguments3
151 ; CHECK: add {{w[0-9]+}}, w0, w1
152 ; CHECK-NEXT: add {{w[0-9]+}}, w2, w3
153 ; CHECK-NEXT: add {{w[0-9]+}}, w4, w5
154 ; CHECK-NEXT: add {{w[0-9]+}}, w6, w7
155 %a1z = zext i16 %a1 to i32
156 %a2z = zext i16 %a2 to i32
157 %a3z = zext i16 %a3 to i32
158 %a4z = zext i16 %a4 to i32
159 %a5s = sext i16 %a5 to i32
160 %a6s = sext i16 %a6 to i32
161 %a7s = sext i16 %a7 to i32
162 %a8s = sext i16 %a8 to i32
163 %1 = add i32 %a1z, %a2z
164 %2 = add i32 %a3z, %a4z
165 %3 = add i32 %a5s, %a6s
166 %4 = add i32 %a7s, %a8s
173 define i32 @call_arguments4(i32 %a1, i32 %a2, i32 %a3, i32 %a4, i32 %a5, i32 %a6, i32 %a7, i32 %a8) {
174 ; CHECK-LABEL: call_arguments4
175 ; CHECK: add {{w[0-9]+}}, w0, w1
176 ; CHECK-NEXT: add {{w[0-9]+}}, w2, w3
177 ; CHECK-NEXT: add {{w[0-9]+}}, w4, w5
178 ; CHECK-NEXT: add {{w[0-9]+}}, w6, w7
179 %1 = add i32 %a1, %a2
180 %2 = add i32 %a3, %a4
181 %3 = add i32 %a5, %a6
182 %4 = add i32 %a7, %a8
189 define i64 @call_arguments5(i64 %a1, i64 %a2, i64 %a3, i64 %a4, i64 %a5, i64 %a6, i64 %a7, i64 %a8) {
190 ; CHECK-LABEL: call_arguments5
191 ; CHECK: add {{x[0-9]+}}, x0, x1
192 ; CHECK-NEXT: add {{x[0-9]+}}, x2, x3
193 ; CHECK-NEXT: add {{x[0-9]+}}, x4, x5
194 ; CHECK-NEXT: add {{x[0-9]+}}, x6, x7
195 %1 = add i64 %a1, %a2
196 %2 = add i64 %a3, %a4
197 %3 = add i64 %a5, %a6
198 %4 = add i64 %a7, %a8
205 define float @call_arguments6(float %a1, float %a2, float %a3, float %a4, float %a5, float %a6, float %a7, float %a8) {
206 ; CHECK-LABEL: call_arguments6
207 ; CHECK: fadd {{s[0-9]+}}, s0, s1
208 ; CHECK-NEXT: fadd {{s[0-9]+}}, s2, s3
209 ; CHECK-NEXT: fadd {{s[0-9]+}}, s4, s5
210 ; CHECK-NEXT: fadd {{s[0-9]+}}, s6, s7
211 %1 = fadd float %a1, %a2
212 %2 = fadd float %a3, %a4
213 %3 = fadd float %a5, %a6
214 %4 = fadd float %a7, %a8
215 %5 = fadd float %1, %2
216 %6 = fadd float %3, %4
217 %7 = fadd float %5, %6
221 define double @call_arguments7(double %a1, double %a2, double %a3, double %a4, double %a5, double %a6, double %a7, double %a8) {
222 ; CHECK-LABEL: call_arguments7
223 ; CHECK: fadd {{d[0-9]+}}, d0, d1
224 ; CHECK-NEXT: fadd {{d[0-9]+}}, d2, d3
225 ; CHECK-NEXT: fadd {{d[0-9]+}}, d4, d5
226 ; CHECK-NEXT: fadd {{d[0-9]+}}, d6, d7
227 %1 = fadd double %a1, %a2
228 %2 = fadd double %a3, %a4
229 %3 = fadd double %a5, %a6
230 %4 = fadd double %a7, %a8
231 %5 = fadd double %1, %2
232 %6 = fadd double %3, %4
233 %7 = fadd double %5, %6
237 define i64 @call_arguments8(i32 %a1, i64 %a2, i32 %a3, i64 %a4) {
238 ; CHECK-LABEL: call_arguments8
239 ; CHECK: ubfx [[REG1:x[0-9]+]], {{x[0-9]+}}, #0, #32
240 ; CHECK: ubfx [[REG2:x[0-9]+]], {{x[0-9]+}}, #0, #32
241 ; CHECK: add {{x[0-9]+}}, [[REG1]], x1
242 ; CHECK-NEXT: add {{x[0-9]+}}, [[REG2]], x3
243 %aa1 = zext i32 %a1 to i64
244 %aa3 = zext i32 %a3 to i64
245 %1 = add i64 %aa1, %a2
246 %2 = add i64 %aa3, %a4
251 define void @call_arguments9(i8 %a1, i16 %a2, i32 %a3, i64 %a4, float %a5, double %a6, i64 %a7, double %a8) {
252 ; CHECK-LABEL: call_arguments9
256 ; Test that we use the correct register class for the branch.
257 define void @call_blr(i64 %Fn, i1 %c) {
258 ; CHECK-LABEL: call_blr
260 br i1 %c, label %bb1, label %bb2
262 %1 = inttoptr i64 %Fn to void (i64)*
265 %2 = phi void (i64)* [ %1, %bb1 ], [ undef, %0 ]