1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 4
2 # RUN: llc -O0 -mtriple=aarch64-apple-ios -run-pass=instruction-select -global-isel-abort=1 -verify-machineinstrs %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=IOS
3 # RUN: llc -O0 -mtriple=aarch64-linux-gnu -relocation-model=pic -run-pass=instruction-select -global-isel-abort=1 -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 ptr @ptr_mask(ptr %in) { ret ptr undef }
15 @var_local = global i8 0
16 define ptr @global_local() { ret ptr undef }
18 @var_got = external global i8
19 define ptr @global_got() { ret ptr undef }
21 define void @icmp() { ret void }
22 define void @fcmp() { ret void }
24 define void @phi() { ret void }
26 define void @select() { ret void }
34 - { id: 0, name: ptr0, offset: 0, size: 8, alignment: 8 }
37 ; CHECK-LABEL: name: frame_index
38 ; CHECK: [[ADDXri:%[0-9]+]]:gpr64sp = ADDXri %stack.0.ptr0, 0, 0
39 ; CHECK-NEXT: $x0 = COPY [[ADDXri]]
40 %0:gpr(p0) = G_FRAME_INDEX %stack.0.ptr0
53 ; CHECK-LABEL: name: ptr_mask
56 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0
57 ; CHECK-NEXT: [[ANDXri:%[0-9]+]]:gpr64sp = ANDXri [[COPY]], 8060
58 ; CHECK-NEXT: $x0 = COPY [[ANDXri]]
60 %const:gpr(s64) = G_CONSTANT i64 -8
61 %1:gpr(p0) = G_PTRMASK %0, %const
66 # Global defined in the same linkage unit so no GOT is needed
72 ; IOS-LABEL: name: global_local
73 ; IOS: [[MOVaddr:%[0-9]+]]:gpr64common = MOVaddr target-flags(aarch64-page) @var_local, target-flags(aarch64-pageoff, aarch64-nc) @var_local
74 ; IOS-NEXT: $x0 = COPY [[MOVaddr]]
76 ; LINUX-PIC-LABEL: name: global_local
77 ; LINUX-PIC: [[LOADgot:%[0-9]+]]:gpr64common = LOADgot target-flags(aarch64-got) @var_local
78 ; LINUX-PIC-NEXT: $x0 = COPY [[LOADgot]]
79 %0:gpr(p0) = G_GLOBAL_VALUE @var_local
89 ; CHECK-LABEL: name: global_got
90 ; CHECK: [[LOADgot:%[0-9]+]]:gpr64common = LOADgot target-flags(aarch64-got) @var_got
91 ; CHECK-NEXT: $x0 = COPY [[LOADgot]]
92 %0:gpr(p0) = G_GLOBAL_VALUE @var_got
104 ; CHECK-LABEL: name: icmp
105 ; CHECK: liveins: $w0, $x0
107 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr32 = COPY $w0
108 ; CHECK-NEXT: [[SUBSWrr:%[0-9]+]]:gpr32 = SUBSWrr [[COPY]], [[COPY]], implicit-def $nzcv
109 ; CHECK-NEXT: [[CSINCWr:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 1, implicit $nzcv
110 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr32all = COPY [[CSINCWr]]
111 ; CHECK-NEXT: $w0 = COPY [[COPY1]]
112 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:gpr64 = COPY $x0
113 ; CHECK-NEXT: [[SUBSXrr:%[0-9]+]]:gpr64 = SUBSXrr [[COPY2]], [[COPY2]], implicit-def $nzcv
114 ; CHECK-NEXT: [[CSINCWr1:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 3, implicit $nzcv
115 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:gpr32all = COPY [[CSINCWr1]]
116 ; CHECK-NEXT: $w0 = COPY [[COPY3]]
117 ; CHECK-NEXT: [[COPY4:%[0-9]+]]:gpr64 = COPY $x0
118 ; CHECK-NEXT: [[SUBSXrr1:%[0-9]+]]:gpr64 = SUBSXrr [[COPY4]], [[COPY4]], implicit-def $nzcv
119 ; CHECK-NEXT: [[CSINCWr2:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 0, implicit $nzcv
120 ; CHECK-NEXT: [[COPY5:%[0-9]+]]:gpr32all = COPY [[CSINCWr2]]
121 ; CHECK-NEXT: $w0 = COPY [[COPY5]]
122 %0:gpr(s32) = COPY $w0
123 %1:gpr(s32) = G_ICMP intpred(eq), %0, %0
124 %6:gpr(s8) = G_TRUNC %1(s32)
125 %9:gpr(s32) = G_ANYEXT %6
128 %2:gpr(s64) = COPY $x0
129 %3:gpr(s32) = G_ICMP intpred(uge), %2, %2
130 %7:gpr(s8) = G_TRUNC %3(s32)
131 %10:gpr(s32) = G_ANYEXT %7
134 %4:gpr(p0) = COPY $x0
135 %5:gpr(s32) = G_ICMP intpred(ne), %4, %4
136 %8:gpr(s8) = G_TRUNC %5(s32)
137 %11:gpr(s32) = G_ANYEXT %8
144 regBankSelected: true
149 ; CHECK-LABEL: name: fcmp
150 ; CHECK: liveins: $w0, $x0
152 ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr32 = COPY $s0
153 ; CHECK-NEXT: nofpexcept FCMPSrr [[COPY]], [[COPY]], implicit-def $nzcv, implicit $fpcr
154 ; CHECK-NEXT: [[CSINCWr:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 5, implicit $nzcv
155 ; CHECK-NEXT: [[CSINCWr1:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 13, implicit $nzcv
156 ; CHECK-NEXT: [[ORRWrr:%[0-9]+]]:gpr32 = ORRWrr [[CSINCWr]], [[CSINCWr1]]
157 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr32all = COPY [[ORRWrr]]
158 ; CHECK-NEXT: $w0 = COPY [[COPY1]]
159 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:fpr64 = COPY $d0
160 ; CHECK-NEXT: nofpexcept FCMPDrr [[COPY2]], [[COPY2]], implicit-def $nzcv, implicit $fpcr
161 ; CHECK-NEXT: [[CSINCWr2:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 4, implicit $nzcv
162 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:gpr32all = COPY [[CSINCWr2]]
163 ; CHECK-NEXT: $w0 = COPY [[COPY3]]
164 ; CHECK-NEXT: [[COPY4:%[0-9]+]]:fpr32 = COPY $s0
165 ; CHECK-NEXT: nofpexcept FCMPSrr [[COPY4]], [[COPY4]], implicit-def $nzcv, implicit $fpcr
166 ; CHECK-NEXT: [[CSINCWr3:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 15, implicit $nzcv
167 ; CHECK-NEXT: [[COPY5:%[0-9]+]]:gpr32all = COPY [[CSINCWr3]]
168 ; CHECK-NEXT: $w0 = COPY [[COPY5]]
169 ; CHECK-NEXT: [[COPY6:%[0-9]+]]:fpr64 = COPY $d0
170 ; CHECK-NEXT: nofpexcept FCMPDrr [[COPY6]], [[COPY6]], implicit-def $nzcv, implicit $fpcr
171 ; CHECK-NEXT: [[CSINCWr4:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 14, implicit $nzcv
172 ; CHECK-NEXT: [[COPY7:%[0-9]+]]:gpr32all = COPY [[CSINCWr4]]
173 ; CHECK-NEXT: $w0 = COPY [[COPY7]]
174 %0:fpr(s32) = COPY $s0
175 %1:gpr(s32) = G_FCMP floatpred(one), %0, %0
176 %2:gpr(s8) = G_TRUNC %1(s32)
177 %3:gpr(s32) = G_ANYEXT %2
180 %4:fpr(s64) = COPY $d0
181 %5:gpr(s32) = G_FCMP floatpred(uge), %4, %4
182 %6:gpr(s8) = G_TRUNC %5(s32)
183 %7:gpr(s32) = G_ANYEXT %6
186 %8:fpr(s32) = COPY $s0
187 %9:gpr(s32) = G_FCMP floatpred(true), %8, %8
188 %10:gpr(s8) = G_TRUNC %9(s32)
189 %11:gpr(s32) = G_ANYEXT %10
192 %12:fpr(s64) = COPY $d0
193 %13:gpr(s32) = G_FCMP floatpred(false), %12, %12
194 %14:gpr(s8) = G_TRUNC %13(s32)
195 %15:gpr(s32) = G_ANYEXT %14
203 regBankSelected: true
204 tracksRegLiveness: true
206 ; CHECK-LABEL: name: phi
208 ; CHECK-NEXT: successors: %bb.1(0x80000000)
209 ; CHECK-NEXT: liveins: $s0, $w0
211 ; CHECK-NEXT: [[COPY:%[0-9]+]]:fpr32 = COPY $s0
212 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr32 = COPY $w0
215 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
217 ; CHECK-NEXT: [[PHI:%[0-9]+]]:fpr32 = PHI [[COPY]], %bb.0, [[PHI]], %bb.1
218 ; CHECK-NEXT: TBNZW [[COPY1]], 0, %bb.1
221 ; CHECK-NEXT: $s0 = COPY [[PHI]]
222 ; CHECK-NEXT: RET_ReallyLR implicit $s0
226 %0:fpr(s32) = COPY $s0
227 %3:gpr(s32) = COPY $w0
230 successors: %bb.1, %bb.2
231 %2:fpr(s32) = PHI %0, %bb.0, %2, %bb.1
236 RET_ReallyLR implicit $s0
242 regBankSelected: true
243 tracksRegLiveness: true
246 liveins: $w0, $w1, $w2
247 ; CHECK-LABEL: name: select
248 ; CHECK: liveins: $w0, $w1, $w2
250 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr32 = COPY $w0
251 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr32 = COPY $w1
252 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:gpr32 = COPY $w2
253 ; CHECK-NEXT: [[ANDSWri:%[0-9]+]]:gpr32 = ANDSWri [[COPY]], 0, implicit-def $nzcv
254 ; CHECK-NEXT: [[CSELWr:%[0-9]+]]:gpr32 = CSELWr [[COPY1]], [[COPY2]], 1, implicit $nzcv
255 ; CHECK-NEXT: $w0 = COPY [[CSELWr]]
256 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:gpr64 = COPY $x0
257 ; CHECK-NEXT: [[COPY4:%[0-9]+]]:gpr64 = COPY $x1
258 ; CHECK-NEXT: [[ANDSWri1:%[0-9]+]]:gpr32 = ANDSWri [[COPY]], 0, implicit-def $nzcv
259 ; CHECK-NEXT: [[CSELXr:%[0-9]+]]:gpr64 = CSELXr [[COPY3]], [[COPY4]], 1, implicit $nzcv
260 ; CHECK-NEXT: $x0 = COPY [[CSELXr]]
261 ; CHECK-NEXT: [[COPY5:%[0-9]+]]:gpr64 = COPY $x0
262 ; CHECK-NEXT: [[COPY6:%[0-9]+]]:gpr64 = COPY $x1
263 ; CHECK-NEXT: [[ANDSWri2:%[0-9]+]]:gpr32 = ANDSWri [[COPY]], 0, implicit-def $nzcv
264 ; CHECK-NEXT: [[CSELXr1:%[0-9]+]]:gpr64 = CSELXr [[COPY5]], [[COPY6]], 1, implicit $nzcv
265 ; CHECK-NEXT: $x0 = COPY [[CSELXr1]]
266 %10:gpr(s32) = COPY $w0
268 %1:gpr(s32) = COPY $w1
269 %2:gpr(s32) = COPY $w2
270 %3:gpr(s32) = G_SELECT %10, %1, %2
273 %4:gpr(s64) = COPY $x0
274 %5:gpr(s64) = COPY $x1
275 %6:gpr(s64) = G_SELECT %10, %4, %5
278 %7:gpr(p0) = COPY $x0
279 %8:gpr(p0) = COPY $x1
280 %9:gpr(p0) = G_SELECT %10, %7, %8