1 # RUN: llc -O0 -mtriple=aarch64-apple-ios -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=IOS
2 # RUN: llc -O0 -mtriple=aarch64-linux-gnu -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=LINUX-DEFAULT
3 # RUN: llc -O0 -mtriple=aarch64-linux-gnu -relocation-model=pic -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=LINUX-PIC
6 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
8 define void @frame_index() {
13 define i8* @gep(i8* %in) { ret i8* undef }
14 define i8* @gep_no_constant(i8* %in) { ret i8* undef }
15 define i8* @gep_bad_imm(i8* %in) { ret i8* undef }
17 define i8* @ptr_mask(i8* %in) { ret i8* undef }
19 @var_local = global i8 0
20 define i8* @global_local() { ret i8* undef }
22 @var_got = external global i8
23 define i8* @global_got() { ret i8* undef }
25 define void @icmp() { ret void }
26 define void @fcmp() { ret void }
28 define void @phi() { ret void }
30 define void @select() { ret void }
34 # CHECK-LABEL: name: frame_index
40 # CHECK-NEXT: - { id: 0, class: gpr64sp, preferred-register: '' }
42 - { id: 0, class: gpr }
45 - { id: 0, name: ptr0, offset: 0, size: 8, alignment: 8 }
48 # CHECK: %0:gpr64sp = ADDXri %stack.0.ptr0, 0, 0
51 %0(p0) = G_FRAME_INDEX %stack.0.ptr0
56 # CHECK-LABEL: name: gep
61 - { id: 0, class: gpr }
62 - { id: 1, class: gpr }
63 - { id: 2, class: gpr }
66 # CHECK: %2:gpr64sp = ADDXri %0, 42, 0
71 %1(s64) = G_CONSTANT i64 42
72 %2(p0) = G_GEP %0, %1(s64)
77 # CHECK-LABEL: name: gep_no_constant
82 - { id: 0, class: gpr }
83 - { id: 1, class: gpr }
84 - { id: 2, class: gpr }
87 # CHECK: %0:gpr64 = COPY $x0
88 # CHECK: %1:gpr64 = COPY $x1
89 # CHECK: %2:gpr64 = ADDXrr %0, %1
95 %2(p0) = G_GEP %0, %1(s64)
100 # CHECK-LABEL: name: gep_bad_imm
103 regBankSelected: true
105 - { id: 0, class: gpr }
106 - { id: 1, class: gpr }
107 - { id: 2, class: gpr }
110 # CHECK: %0:gpr64 = COPY $x0
111 # CHECK: %3:gpr32 = MOVi32imm 10000
112 # CHECK: %1:gpr64 = SUBREG_TO_REG 0, %3, %subreg.sub_32
113 # CHECK: %2:gpr64 = ADDXrr %0, %1
118 %1(s64) = G_CONSTANT i64 10000
119 %2(p0) = G_GEP %0, %1(s64)
124 # CHECK-LABEL: name: ptr_mask
127 regBankSelected: true
130 # CHECK: %1:gpr64sp = ANDXri %0, 8060
134 %0:gpr(p0) = COPY $x0
135 %1:gpr(p0) = G_PTR_MASK %0, 3
140 # Global defined in the same linkage unit so no GOT is needed
141 # CHECK-LABEL: name: global_local
144 regBankSelected: true
146 - { id: 0, class: gpr }
149 # IOS: %0:gpr64 = MOVaddr target-flags(aarch64-page) @var_local, target-flags(aarch64-pageoff, aarch64-nc) @var_local
150 # LINUX-DEFAULT: %0:gpr64 = MOVaddr target-flags(aarch64-page) @var_local, target-flags(aarch64-pageoff, aarch64-nc) @var_local
151 # LINUX-PIC: %0:gpr64 = LOADgot target-flags(aarch64-got) @var_local
154 %0(p0) = G_GLOBAL_VALUE @var_local
159 # CHECK-LABEL: name: global_got
162 regBankSelected: true
164 - { id: 0, class: gpr }
167 # IOS: %0:gpr64 = LOADgot target-flags(aarch64-got) @var_got
168 # LINUX-DEFAULT: %0:gpr64 = MOVaddr target-flags(aarch64-page) @var_got, target-flags(aarch64-pageoff, aarch64-nc) @var_got
169 # LINUX-PIC: %0:gpr64 = LOADgot target-flags(aarch64-got) @var_got
172 %0(p0) = G_GLOBAL_VALUE @var_got
177 # CHECK-LABEL: name: icmp
180 regBankSelected: true
183 # CHECK-NEXT: - { id: 0, class: gpr32, preferred-register: '' }
184 # CHECK-NEXT: - { id: 1, class: gpr32, preferred-register: '' }
185 # CHECK-NEXT: - { id: 2, class: gpr64, preferred-register: '' }
186 # CHECK-NEXT: - { id: 3, class: gpr32, preferred-register: '' }
187 # CHECK-NEXT: - { id: 4, class: gpr64, preferred-register: '' }
188 # CHECK-NEXT: - { id: 5, class: gpr32, preferred-register: '' }
190 - { id: 0, class: gpr }
191 - { id: 1, class: gpr }
192 - { id: 2, class: gpr }
193 - { id: 3, class: gpr }
194 - { id: 4, class: gpr }
195 - { id: 5, class: gpr }
196 - { id: 6, class: gpr }
197 - { id: 7, class: gpr }
198 - { id: 8, class: gpr }
199 - { id: 9, class: gpr }
200 - { id: 10, class: gpr }
201 - { id: 11, class: gpr }
204 # CHECK: $wzr = SUBSWrr %0, %0, implicit-def $nzcv
205 # CHECK: %1:gpr32 = CSINCWr $wzr, $wzr, 1, implicit $nzcv
207 # CHECK: $xzr = SUBSXrr %2, %2, implicit-def $nzcv
208 # CHECK: %3:gpr32 = CSINCWr $wzr, $wzr, 3, implicit $nzcv
210 # CHECK: $xzr = SUBSXrr %4, %4, implicit-def $nzcv
211 # CHECK: %5:gpr32 = CSINCWr $wzr, $wzr, 0, implicit $nzcv
218 %1(s32) = G_ICMP intpred(eq), %0, %0
219 %6(s1) = G_TRUNC %1(s32)
220 %9(s32) = G_ANYEXT %6
224 %3(s32) = G_ICMP intpred(uge), %2, %2
225 %7(s1) = G_TRUNC %3(s32)
226 %10(s32) = G_ANYEXT %7
230 %5(s32) = G_ICMP intpred(ne), %4, %4
231 %8(s1) = G_TRUNC %5(s32)
232 %11(s32) = G_ANYEXT %8
237 # CHECK-LABEL: name: fcmp
240 regBankSelected: true
243 # CHECK-NEXT: - { id: 0, class: fpr32, preferred-register: '' }
244 # CHECK-NEXT: - { id: 1, class: gpr32, preferred-register: '' }
245 # CHECK-NEXT: - { id: 2, class: fpr64, preferred-register: '' }
246 # CHECK-NEXT: - { id: 3, class: gpr32, preferred-register: '' }
247 # CHECK-NEXT: - { id: 4, class: gpr32, preferred-register: '' }
248 # CHECK-NEXT: - { id: 5, class: gpr32, preferred-register: '' }
250 - { id: 0, class: fpr }
251 - { id: 1, class: gpr }
252 - { id: 2, class: fpr }
253 - { id: 3, class: gpr }
254 - { id: 4, class: gpr }
255 - { id: 5, class: gpr }
256 - { id: 6, class: gpr }
257 - { id: 7, class: gpr }
260 # CHECK: FCMPSrr %0, %0, implicit-def $nzcv
261 # CHECK: [[TST_MI:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 5, implicit $nzcv
262 # CHECK: [[TST_GT:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 13, implicit $nzcv
263 # CHECK: %1:gpr32 = ORRWrr [[TST_MI]], [[TST_GT]]
265 # CHECK: FCMPDrr %2, %2, implicit-def $nzcv
266 # CHECK: %3:gpr32 = CSINCWr $wzr, $wzr, 4, implicit $nzcv
273 %1(s32) = G_FCMP floatpred(one), %0, %0
274 %4(s1) = G_TRUNC %1(s32)
275 %6(s32) = G_ANYEXT %4
279 %3(s32) = G_FCMP floatpred(uge), %2, %2
280 %5(s1) = G_TRUNC %3(s32)
281 %7(s32) = G_ANYEXT %5
287 # CHECK-LABEL: name: phi
290 regBankSelected: true
291 tracksRegLiveness: true
294 # CHECK-NEXT: - { id: 0, class: fpr32, preferred-register: '' }
295 # CHECK-NEXT: - { id: 1, class: gpr32, preferred-register: '' }
296 # CHECK-NEXT: - { id: 2, class: fpr32, preferred-register: '' }
298 - { id: 0, class: fpr }
299 - { id: 1, class: gpr }
300 - { id: 2, class: fpr }
304 # CHECK: %2:fpr32 = PHI %0, %bb.0, %2, %bb.1
311 %3:gpr(s32) = COPY $w0
315 successors: %bb.1, %bb.2
316 %2(s32) = PHI %0, %bb.0, %2, %bb.1
321 RET_ReallyLR implicit $s0
325 # CHECK-LABEL: name: select
328 regBankSelected: true
329 tracksRegLiveness: true
332 # CHECK-NEXT: - { id: 0, class: gpr32, preferred-register: '' }
333 # CHECK-NEXT: - { id: 1, class: gpr32, preferred-register: '' }
334 # CHECK-NEXT: - { id: 2, class: gpr32, preferred-register: '' }
335 # CHECK-NEXT: - { id: 3, class: gpr32, preferred-register: '' }
336 # CHECK-NEXT: - { id: 4, class: gpr64, preferred-register: '' }
337 # CHECK-NEXT: - { id: 5, class: gpr64, preferred-register: '' }
338 # CHECK-NEXT: - { id: 6, class: gpr64, preferred-register: '' }
339 # CHECK-NEXT: - { id: 7, class: gpr64, preferred-register: '' }
340 # CHECK-NEXT: - { id: 8, class: gpr64, preferred-register: '' }
341 # CHECK-NEXT: - { id: 9, class: gpr64, preferred-register: '' }
343 - { id: 0, class: gpr }
344 - { id: 1, class: gpr }
345 - { id: 2, class: gpr }
346 - { id: 3, class: gpr }
347 - { id: 4, class: gpr }
348 - { id: 5, class: gpr }
349 - { id: 6, class: gpr }
350 - { id: 7, class: gpr }
351 - { id: 8, class: gpr }
352 - { id: 9, class: gpr }
355 # CHECK: $wzr = ANDSWri %10, 0, implicit-def $nzcv
356 # CHECK: %3:gpr32 = CSELWr %1, %2, 1, implicit $nzcv
357 # CHECK: $wzr = ANDSWri %10, 0, implicit-def $nzcv
358 # CHECK: %6:gpr64 = CSELXr %4, %5, 1, implicit $nzcv
359 # CHECK: $wzr = ANDSWri %10, 0, implicit-def $nzcv
360 # CHECK: %9:gpr64 = CSELXr %7, %8, 1, implicit $nzcv
363 liveins: $w0, $w1, $w2
364 %10:gpr(s32) = COPY $w0
369 %3(s32) = G_SELECT %0, %1, %2
374 %6(s64) = G_SELECT %0, %4, %5
379 %9(p0) = G_SELECT %0, %7, %8