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 }
15 define i8* @ptr_mask(i8* %in) { ret i8* undef }
17 @var_local = global i8 0
18 define i8* @global_local() { ret i8* undef }
20 @var_got = external global i8
21 define i8* @global_got() { ret i8* undef }
23 define void @icmp() { ret void }
24 define void @fcmp() { ret void }
26 define void @phi() { ret void }
28 define void @select() { ret void }
32 # CHECK-LABEL: name: frame_index
38 # CHECK-NEXT: - { id: 0, class: gpr64sp, preferred-register: '' }
40 - { id: 0, class: gpr }
43 - { id: 0, name: ptr0, offset: 0, size: 8, alignment: 8 }
46 # CHECK: %0:gpr64sp = ADDXri %stack.0.ptr0, 0, 0
49 %0(p0) = G_FRAME_INDEX %stack.0.ptr0
54 # CHECK-LABEL: name: gep
59 - { id: 0, class: gpr }
60 - { id: 1, class: gpr }
61 - { id: 2, class: gpr }
64 # CHECK: %1:gpr64 = MOVi64imm 42
65 # CHECK: %2:gpr64 = ADDXrr %0, %1
70 %1(s64) = G_CONSTANT i64 42
71 %2(p0) = G_GEP %0, %1(s64)
76 # CHECK-LABEL: name: ptr_mask
82 # CHECK: %1:gpr64sp = ANDXri %0, 8060
87 %1:gpr(p0) = G_PTR_MASK %0, 3
92 # Global defined in the same linkage unit so no GOT is needed
93 # CHECK-LABEL: name: global_local
98 - { id: 0, class: gpr }
101 # IOS: %0:gpr64 = MOVaddr target-flags(aarch64-page) @var_local, target-flags(aarch64-pageoff, aarch64-nc) @var_local
102 # LINUX-DEFAULT: %0:gpr64 = MOVaddr target-flags(aarch64-page) @var_local, target-flags(aarch64-pageoff, aarch64-nc) @var_local
103 # LINUX-PIC: %0:gpr64 = LOADgot target-flags(aarch64-got) @var_local
106 %0(p0) = G_GLOBAL_VALUE @var_local
111 # CHECK-LABEL: name: global_got
114 regBankSelected: true
116 - { id: 0, class: gpr }
119 # IOS: %0:gpr64 = LOADgot target-flags(aarch64-got) @var_got
120 # LINUX-DEFAULT: %0:gpr64 = MOVaddr target-flags(aarch64-page) @var_got, target-flags(aarch64-pageoff, aarch64-nc) @var_got
121 # LINUX-PIC: %0:gpr64 = LOADgot target-flags(aarch64-got) @var_got
124 %0(p0) = G_GLOBAL_VALUE @var_got
129 # CHECK-LABEL: name: icmp
132 regBankSelected: true
135 # CHECK-NEXT: - { id: 0, class: gpr32, preferred-register: '' }
136 # CHECK-NEXT: - { id: 1, class: gpr32, preferred-register: '' }
137 # CHECK-NEXT: - { id: 2, class: gpr64, preferred-register: '' }
138 # CHECK-NEXT: - { id: 3, class: gpr32, preferred-register: '' }
139 # CHECK-NEXT: - { id: 4, class: gpr64, preferred-register: '' }
140 # CHECK-NEXT: - { id: 5, class: gpr32, preferred-register: '' }
142 - { id: 0, class: gpr }
143 - { id: 1, class: gpr }
144 - { id: 2, class: gpr }
145 - { id: 3, class: gpr }
146 - { id: 4, class: gpr }
147 - { id: 5, class: gpr }
148 - { id: 6, class: gpr }
149 - { id: 7, class: gpr }
150 - { id: 8, class: gpr }
151 - { id: 9, class: gpr }
152 - { id: 10, class: gpr }
153 - { id: 11, class: gpr }
156 # CHECK: $wzr = SUBSWrr %0, %0, implicit-def $nzcv
157 # CHECK: %1:gpr32 = CSINCWr $wzr, $wzr, 1, implicit $nzcv
159 # CHECK: $xzr = SUBSXrr %2, %2, implicit-def $nzcv
160 # CHECK: %3:gpr32 = CSINCWr $wzr, $wzr, 3, implicit $nzcv
162 # CHECK: $xzr = SUBSXrr %4, %4, implicit-def $nzcv
163 # CHECK: %5:gpr32 = CSINCWr $wzr, $wzr, 0, implicit $nzcv
170 %1(s32) = G_ICMP intpred(eq), %0, %0
171 %6(s1) = G_TRUNC %1(s32)
172 %9(s32) = G_ANYEXT %6
176 %3(s32) = G_ICMP intpred(uge), %2, %2
177 %7(s1) = G_TRUNC %3(s32)
178 %10(s32) = G_ANYEXT %7
182 %5(s32) = G_ICMP intpred(ne), %4, %4
183 %8(s1) = G_TRUNC %5(s32)
184 %11(s32) = G_ANYEXT %8
189 # CHECK-LABEL: name: fcmp
192 regBankSelected: true
195 # CHECK-NEXT: - { id: 0, class: fpr32, preferred-register: '' }
196 # CHECK-NEXT: - { id: 1, class: gpr32, preferred-register: '' }
197 # CHECK-NEXT: - { id: 2, class: fpr64, preferred-register: '' }
198 # CHECK-NEXT: - { id: 3, class: gpr32, preferred-register: '' }
199 # CHECK-NEXT: - { id: 4, class: gpr32, preferred-register: '' }
200 # CHECK-NEXT: - { id: 5, class: gpr32, preferred-register: '' }
202 - { id: 0, class: fpr }
203 - { id: 1, class: gpr }
204 - { id: 2, class: fpr }
205 - { id: 3, class: gpr }
206 - { id: 4, class: gpr }
207 - { id: 5, class: gpr }
208 - { id: 6, class: gpr }
209 - { id: 7, class: gpr }
212 # CHECK: FCMPSrr %0, %0, implicit-def $nzcv
213 # CHECK: [[TST_MI:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 5, implicit $nzcv
214 # CHECK: [[TST_GT:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 13, implicit $nzcv
215 # CHECK: %1:gpr32 = ORRWrr [[TST_MI]], [[TST_GT]]
217 # CHECK: FCMPDrr %2, %2, implicit-def $nzcv
218 # CHECK: %3:gpr32 = CSINCWr $wzr, $wzr, 4, implicit $nzcv
225 %1(s32) = G_FCMP floatpred(one), %0, %0
226 %4(s1) = G_TRUNC %1(s32)
227 %6(s32) = G_ANYEXT %4
231 %3(s32) = G_FCMP floatpred(uge), %2, %2
232 %5(s1) = G_TRUNC %3(s32)
233 %7(s32) = G_ANYEXT %5
239 # CHECK-LABEL: name: phi
242 regBankSelected: true
243 tracksRegLiveness: true
246 # CHECK-NEXT: - { id: 0, class: fpr32, preferred-register: '' }
247 # CHECK-NEXT: - { id: 1, class: gpr32, preferred-register: '' }
248 # CHECK-NEXT: - { id: 2, class: fpr32, preferred-register: '' }
250 - { id: 0, class: fpr }
251 - { id: 1, class: gpr }
252 - { id: 2, class: fpr }
256 # CHECK: %2:fpr32 = PHI %0, %bb.0, %2, %bb.1
263 %3:gpr(s32) = COPY $w0
267 successors: %bb.1, %bb.2
268 %2(s32) = PHI %0, %bb.0, %2, %bb.1
273 RET_ReallyLR implicit $s0
277 # CHECK-LABEL: name: select
280 regBankSelected: true
281 tracksRegLiveness: true
284 # CHECK-NEXT: - { id: 0, class: gpr32, preferred-register: '' }
285 # CHECK-NEXT: - { id: 1, class: gpr32, preferred-register: '' }
286 # CHECK-NEXT: - { id: 2, class: gpr32, preferred-register: '' }
287 # CHECK-NEXT: - { id: 3, class: gpr32, preferred-register: '' }
288 # CHECK-NEXT: - { id: 4, class: gpr64, preferred-register: '' }
289 # CHECK-NEXT: - { id: 5, class: gpr64, preferred-register: '' }
290 # CHECK-NEXT: - { id: 6, class: gpr64, preferred-register: '' }
291 # CHECK-NEXT: - { id: 7, class: gpr64, preferred-register: '' }
292 # CHECK-NEXT: - { id: 8, class: gpr64, preferred-register: '' }
293 # CHECK-NEXT: - { id: 9, class: gpr64, preferred-register: '' }
295 - { id: 0, class: gpr }
296 - { id: 1, class: gpr }
297 - { id: 2, class: gpr }
298 - { id: 3, class: gpr }
299 - { id: 4, class: gpr }
300 - { id: 5, class: gpr }
301 - { id: 6, class: gpr }
302 - { id: 7, class: gpr }
303 - { id: 8, class: gpr }
304 - { id: 9, class: gpr }
307 # CHECK: $wzr = ANDSWri %10, 0, implicit-def $nzcv
308 # CHECK: %3:gpr32 = CSELWr %1, %2, 1, implicit $nzcv
309 # CHECK: $wzr = ANDSWri %10, 0, implicit-def $nzcv
310 # CHECK: %6:gpr64 = CSELXr %4, %5, 1, implicit $nzcv
311 # CHECK: $wzr = ANDSWri %10, 0, implicit-def $nzcv
312 # CHECK: %9:gpr64 = CSELXr %7, %8, 1, implicit $nzcv
315 liveins: $w0, $w1, $w2
316 %10:gpr(s32) = COPY $w0
321 %3(s32) = G_SELECT %0, %1, %2
326 %6(s64) = G_SELECT %0, %4, %5
331 %9(p0) = G_SELECT %0, %7, %8