1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=aarch64-- -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s
10 ; CHECK-LABEL: name: condbr_of_not
12 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
13 ; CHECK-NEXT: liveins: $x0
15 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64sp = COPY $x0
16 ; CHECK-NEXT: [[LDRBBui:%[0-9]+]]:gpr32 = LDRBBui [[COPY]], 0 :: (load (s8))
17 ; CHECK-NEXT: TBZW [[LDRBBui]], 0, %bb.2
20 ; CHECK-NEXT: RET_ReallyLR
23 ; CHECK-NEXT: RET_ReallyLR
25 successors: %bb.2, %bb.3
29 %8:gpr(s8) = G_LOAD %0(p0) :: (load (s8))
30 %4:gpr(s32) = G_ANYEXT %8(s8)
31 %5:gpr(s32) = G_CONSTANT i32 1
32 %6:gpr(s32) = G_XOR %4, %5
43 name: condbr_of_not_64
49 ; CHECK-LABEL: name: condbr_of_not_64
51 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
52 ; CHECK-NEXT: liveins: $x0
54 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64sp = COPY $x0
55 ; CHECK-NEXT: [[LDRBBui:%[0-9]+]]:gpr32 = LDRBBui [[COPY]], 0 :: (load (s8))
56 ; CHECK-NEXT: TBZW [[LDRBBui]], 0, %bb.2
59 ; CHECK-NEXT: RET_ReallyLR
62 ; CHECK-NEXT: RET_ReallyLR
63 ; TB(N)ZX has no encoding if the bit being tested is < 32, so we should get
67 successors: %bb.2, %bb.3
71 %8:gpr(s8) = G_LOAD %0(p0) :: (load (s8))
72 %4:gpr(s64) = G_ANYEXT %8(s8)
73 %5:gpr(s64) = G_CONSTANT i64 1
74 %6:gpr(s64) = G_XOR %4, %5
75 %3:gpr(s32) = G_TRUNC %6(s64)
76 G_BRCOND %3(s32), %bb.3
90 ; CHECK-LABEL: name: condbr_of_and
92 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
93 ; CHECK-NEXT: liveins: $w0
95 ; CHECK-NEXT: %lhs:gpr32 = COPY $w0
96 ; CHECK-NEXT: TBNZW %lhs, 0, %bb.2
99 ; CHECK-NEXT: RET_ReallyLR
102 ; CHECK-NEXT: RET_ReallyLR
104 successors: %bb.2, %bb.3
106 %lhs:gpr(s32) = COPY $w0
107 %rhs:gpr(s32) = G_CONSTANT i32 1
108 %op:gpr(s32) = G_AND %lhs, %rhs
119 name: condbr_of_and_no_cst
121 regBankSelected: true
123 ; CHECK-LABEL: name: condbr_of_and_no_cst
125 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
126 ; CHECK-NEXT: liveins: $w0, $w1
128 ; CHECK-NEXT: %lhs:gpr32 = COPY $w0
129 ; CHECK-NEXT: %rhs:gpr32 = COPY $w1
130 ; CHECK-NEXT: %op:gpr32 = ANDWrr %lhs, %rhs
131 ; CHECK-NEXT: TBNZW %op, 0, %bb.2
134 ; CHECK-NEXT: RET_ReallyLR
137 ; CHECK-NEXT: RET_ReallyLR
139 successors: %bb.2, %bb.3
141 %lhs:gpr(s32) = COPY $w0
142 %rhs:gpr(s32) = COPY $w1
143 %op:gpr(s32) = G_AND %lhs, %rhs
156 regBankSelected: true
158 ; CHECK-LABEL: name: condbr_of_shl
160 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
161 ; CHECK-NEXT: liveins: $w0
163 ; CHECK-NEXT: %lhs:gpr32 = COPY $w0
164 ; CHECK-NEXT: %op:gpr32 = UBFMWri %lhs, 31, 30
165 ; CHECK-NEXT: TBNZW %op, 0, %bb.2
168 ; CHECK-NEXT: RET_ReallyLR
171 ; CHECK-NEXT: RET_ReallyLR
172 ; We won't ever fold this, because
174 ; bit - constant < 0, which isn't valid for tbz/tbnz.
177 successors: %bb.2, %bb.3
179 %lhs:gpr(s32) = COPY $w0
180 %rhs:gpr(s32) = G_CONSTANT i32 1
181 %op:gpr(s32) = G_SHL %lhs, %rhs
194 regBankSelected: true
196 ; CHECK-LABEL: name: condbr_of_ashr
198 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
199 ; CHECK-NEXT: liveins: $w0
201 ; CHECK-NEXT: %lhs:gpr32 = COPY $w0
202 ; CHECK-NEXT: TBNZW %lhs, 1, %bb.2
205 ; CHECK-NEXT: RET_ReallyLR
208 ; CHECK-NEXT: RET_ReallyLR
209 ; We can fold ashr, because we can have
211 ; (tbz (ashr x, c), 0) where 0 + c > # bits in x.
214 successors: %bb.2, %bb.3
216 %lhs:gpr(s32) = COPY $w0
217 %rhs:gpr(s32) = G_CONSTANT i32 1
218 %op:gpr(s32) = G_ASHR %lhs, %rhs
231 regBankSelected: true
233 ; CHECK-LABEL: name: tbnzx
235 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
236 ; CHECK-NEXT: liveins: $x0
238 ; CHECK-NEXT: %lhs:gpr64 = COPY $x0
239 ; CHECK-NEXT: TBNZX %lhs, 63, %bb.2
242 ; CHECK-NEXT: RET_ReallyLR
245 ; CHECK-NEXT: RET_ReallyLR
247 successors: %bb.2, %bb.3
249 %lhs:gpr(s64) = COPY $x0
250 %rhs:gpr(s64) = G_CONSTANT i64 8589934592
251 %op:gpr(s64) = G_ASHR %lhs, %rhs
252 %trunc:gpr(s32) = G_TRUNC %op(s64)
253 G_BRCOND %trunc, %bb.3