1 # RUN: llc -O0 -mtriple=aarch64 -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s --check-prefixes=CHECK,LINUX-DEFAULT
4 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
6 define dso_local void @frame_index() {
11 define dso_local i8* @ptr_mask(i8* %in) { ret i8* undef }
13 @var_local = dso_local global i8 0
14 define dso_local i8* @global_local() { ret i8* undef }
16 @var_got = external dso_local global i8
17 define dso_local i8* @global_got() { ret i8* undef }
19 define dso_local void @icmp() { ret void }
20 define dso_local void @fcmp() { ret void }
22 define dso_local void @phi() { ret void }
24 define dso_local void @select() { ret void }
28 # CHECK-LABEL: name: frame_index
34 # CHECK-NEXT: - { id: 0, class: gpr64sp, preferred-register: '' }
36 - { id: 0, class: gpr }
39 - { id: 0, name: ptr0, offset: 0, size: 8, alignment: 8 }
42 # CHECK: %0:gpr64sp = ADDXri %stack.0.ptr0, 0, 0
45 %0(p0) = G_FRAME_INDEX %stack.0.ptr0
52 # CHECK-LABEL: name: ptr_mask
58 # CHECK: %2:gpr64sp = ANDXri %0, 8060
63 %const:gpr(s64) = G_CONSTANT i64 -8
64 %1:gpr(p0) = G_PTRMASK %0, %const
69 # Global defined in the same linkage unit so no GOT is needed
70 # CHECK-LABEL: name: global_local
75 - { id: 0, class: gpr }
78 # LINUX-DEFAULT: %0:gpr64 = MOVaddr target-flags(aarch64-page) @var_local, target-flags(aarch64-pageoff, aarch64-nc) @var_local
81 %0(p0) = G_GLOBAL_VALUE @var_local
86 # CHECK-LABEL: name: global_got
91 - { id: 0, class: gpr }
94 # LINUX-DEFAULT: %0:gpr64 = MOVaddr target-flags(aarch64-page) @var_got, target-flags(aarch64-pageoff, aarch64-nc) @var_got
97 %0(p0) = G_GLOBAL_VALUE @var_got
102 # CHECK-LABEL: name: icmp
105 regBankSelected: true
108 # CHECK-NEXT: - { id: 0, class: gpr32, preferred-register: '' }
109 # CHECK-NEXT: - { id: 1, class: gpr32, preferred-register: '' }
110 # CHECK-NEXT: - { id: 2, class: gpr64, preferred-register: '' }
111 # CHECK-NEXT: - { id: 3, class: gpr32, preferred-register: '' }
112 # CHECK-NEXT: - { id: 4, class: gpr64, preferred-register: '' }
113 # CHECK-NEXT: - { id: 5, class: gpr32, preferred-register: '' }
115 - { id: 0, class: gpr }
116 - { id: 1, class: gpr }
117 - { id: 2, class: gpr }
118 - { id: 3, class: gpr }
119 - { id: 4, class: gpr }
120 - { id: 5, class: gpr }
121 - { id: 6, class: gpr }
122 - { id: 7, class: gpr }
123 - { id: 8, class: gpr }
124 - { id: 9, class: gpr }
125 - { id: 10, class: gpr }
126 - { id: 11, class: gpr }
129 # CHECK: SUBSWrr %0, %0, implicit-def $nzcv
130 # CHECK: %1:gpr32 = CSINCWr $wzr, $wzr, 1, implicit $nzcv
132 # CHECK: SUBSXrr %2, %2, implicit-def $nzcv
133 # CHECK: %3:gpr32 = CSINCWr $wzr, $wzr, 3, implicit $nzcv
135 # CHECK: SUBSXrr %4, %4, implicit-def $nzcv
136 # CHECK: %5:gpr32 = CSINCWr $wzr, $wzr, 0, implicit $nzcv
143 %1(s32) = G_ICMP intpred(eq), %0, %0
144 %6(s1) = G_TRUNC %1(s32)
145 %9(s32) = G_ANYEXT %6
149 %3(s32) = G_ICMP intpred(uge), %2, %2
150 %7(s1) = G_TRUNC %3(s32)
151 %10(s32) = G_ANYEXT %7
155 %5(s32) = G_ICMP intpred(ne), %4, %4
156 %8(s1) = G_TRUNC %5(s32)
157 %11(s32) = G_ANYEXT %8
162 # CHECK-LABEL: name: fcmp
165 regBankSelected: true
168 # CHECK-NEXT: - { id: 0, class: fpr32, preferred-register: '' }
169 # CHECK-NEXT: - { id: 1, class: gpr32, preferred-register: '' }
170 # CHECK-NEXT: - { id: 2, class: fpr64, preferred-register: '' }
171 # CHECK-NEXT: - { id: 3, class: gpr32, preferred-register: '' }
172 # CHECK-NEXT: - { id: 4, class: gpr32, preferred-register: '' }
173 # CHECK-NEXT: - { id: 5, class: gpr32, preferred-register: '' }
175 - { id: 0, class: fpr }
176 - { id: 1, class: gpr }
177 - { id: 2, class: fpr }
178 - { id: 3, class: gpr }
179 - { id: 4, class: gpr }
180 - { id: 5, class: gpr }
181 - { id: 6, class: gpr }
182 - { id: 7, class: gpr }
185 # CHECK: FCMPSrr %0, %0, implicit-def $nzcv
186 # CHECK: [[TST_MI:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 5, implicit $nzcv
187 # CHECK: [[TST_GT:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 13, implicit $nzcv
188 # CHECK: %1:gpr32 = ORRWrr [[TST_MI]], [[TST_GT]]
190 # CHECK: FCMPDrr %2, %2, implicit-def $nzcv
191 # CHECK: %3:gpr32 = CSINCWr $wzr, $wzr, 4, implicit $nzcv
198 %1(s32) = G_FCMP floatpred(one), %0, %0
199 %4(s1) = G_TRUNC %1(s32)
200 %6(s32) = G_ANYEXT %4
204 %3(s32) = G_FCMP floatpred(uge), %2, %2
205 %5(s1) = G_TRUNC %3(s32)
206 %7(s32) = G_ANYEXT %5
212 # CHECK-LABEL: name: phi
215 regBankSelected: true
216 tracksRegLiveness: true
219 # CHECK-NEXT: - { id: 0, class: fpr32, preferred-register: '' }
220 # CHECK-NEXT: - { id: 1, class: gpr, preferred-register: '' }
221 # CHECK-NEXT: - { id: 2, class: fpr32, preferred-register: '' }
222 # CHECK-NEXT: - { id: 3, class: gpr32, preferred-register: '' }
224 - { id: 0, class: fpr }
225 - { id: 1, class: gpr }
226 - { id: 2, class: fpr }
230 # CHECK: %2:fpr32 = PHI %0, %bb.0, %2, %bb.1
237 %3:gpr(s32) = COPY $w0
241 successors: %bb.1, %bb.2
242 %2(s32) = PHI %0, %bb.0, %2, %bb.1
247 RET_ReallyLR implicit $s0
251 # CHECK-LABEL: name: select
254 regBankSelected: true
255 tracksRegLiveness: true
258 # CHECK-NEXT: - { id: 0, class: gpr32, preferred-register: '' }
259 # CHECK-NEXT: - { id: 1, class: gpr32, preferred-register: '' }
260 # CHECK-NEXT: - { id: 2, class: gpr32, preferred-register: '' }
261 # CHECK-NEXT: - { id: 3, class: gpr32, preferred-register: '' }
262 # CHECK-NEXT: - { id: 4, class: gpr64, preferred-register: '' }
263 # CHECK-NEXT: - { id: 5, class: gpr64, preferred-register: '' }
264 # CHECK-NEXT: - { id: 6, class: gpr64, preferred-register: '' }
265 # CHECK-NEXT: - { id: 7, class: gpr64, preferred-register: '' }
266 # CHECK-NEXT: - { id: 8, class: gpr64, preferred-register: '' }
267 # CHECK-NEXT: - { id: 9, class: gpr64, preferred-register: '' }
269 - { id: 0, class: gpr }
270 - { id: 1, class: gpr }
271 - { id: 2, class: gpr }
272 - { id: 3, class: gpr }
273 - { id: 4, class: gpr }
274 - { id: 5, class: gpr }
275 - { id: 6, class: gpr }
276 - { id: 7, class: gpr }
277 - { id: 8, class: gpr }
278 - { id: 9, class: gpr }
281 # CHECK: ANDSWri %10, 0, implicit-def $nzcv
282 # CHECK: %3:gpr32 = CSELWr %1, %2, 1, implicit $nzcv
283 # CHECK: ANDSWri %10, 0, implicit-def $nzcv
284 # CHECK: %6:gpr64 = CSELXr %4, %5, 1, implicit $nzcv
285 # CHECK: ANDSWri %10, 0, implicit-def $nzcv
286 # CHECK: %9:gpr64 = CSELXr %7, %8, 1, implicit $nzcv
289 liveins: $w0, $w1, $w2
290 %10:gpr(s32) = COPY $w0
295 %3(s32) = G_SELECT %0, %1, %2
300 %6(s64) = G_SELECT %0, %4, %5
305 %9(p0) = G_SELECT %0, %7, %8