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: successors: %bb.1(0x40000000), %bb.2(0x40000000)
13 ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY $x0
14 ; CHECK: [[LDRBBui:%[0-9]+]]:gpr32 = LDRBBui [[COPY]], 0 :: (load (s8))
15 ; CHECK: TBZW [[LDRBBui]], 0, %bb.2
21 successors: %bb.2, %bb.3
25 %8:gpr(s8) = G_LOAD %0(p0) :: (load (s8))
26 %4:gpr(s32) = G_ANYEXT %8(s8)
27 %5:gpr(s32) = G_CONSTANT i32 1
28 %6:gpr(s32) = G_XOR %4, %5
29 %3:gpr(s1) = G_TRUNC %6(s32)
30 G_BRCOND %3(s1), %bb.3
40 name: condbr_of_not_64
46 ; CHECK-LABEL: name: condbr_of_not_64
48 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
49 ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY $x0
50 ; CHECK: [[LDRBBui:%[0-9]+]]:gpr32 = LDRBBui [[COPY]], 0 :: (load (s8))
51 ; CHECK: TBZW [[LDRBBui]], 0, %bb.2
56 ; TB(N)ZX has no encoding if the bit being tested is < 32, so we should get
60 successors: %bb.2, %bb.3
64 %8:gpr(s8) = G_LOAD %0(p0) :: (load (s8))
65 %4:gpr(s64) = G_ANYEXT %8(s8)
66 %5:gpr(s64) = G_CONSTANT i64 1
67 %6:gpr(s64) = G_XOR %4, %5
68 %3:gpr(s1) = G_TRUNC %6(s64)
69 G_BRCOND %3(s1), %bb.3
83 ; CHECK-LABEL: name: condbr_of_and
85 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
86 ; CHECK: %lhs:gpr32 = COPY $w0
87 ; CHECK: TBNZW %lhs, 0, %bb.2
93 successors: %bb.2, %bb.3
95 %lhs:gpr(s32) = COPY $w0
96 %rhs:gpr(s32) = G_CONSTANT i32 1
97 %op:gpr(s32) = G_AND %lhs, %rhs
98 %trunc:gpr(s1) = G_TRUNC %op(s32)
99 G_BRCOND %trunc(s1), %bb.3
109 name: condbr_of_and_no_cst
111 regBankSelected: true
113 ; CHECK-LABEL: name: condbr_of_and_no_cst
115 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
116 ; CHECK: %lhs:gpr32 = COPY $w0
117 ; CHECK: %rhs:gpr32 = COPY $w1
118 ; CHECK: %op:gpr32 = ANDWrr %lhs, %rhs
119 ; CHECK: TBNZW %op, 0, %bb.2
121 ; CHECK: RET_ReallyLR
123 ; CHECK: RET_ReallyLR
125 successors: %bb.2, %bb.3
127 %lhs:gpr(s32) = COPY $w0
128 %rhs:gpr(s32) = COPY $w1
129 %op:gpr(s32) = G_AND %lhs, %rhs
130 %trunc:gpr(s1) = G_TRUNC %op(s32)
131 G_BRCOND %trunc(s1), %bb.3
143 regBankSelected: true
145 ; CHECK-LABEL: name: condbr_of_shl
147 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
148 ; CHECK: %lhs:gpr32 = COPY $w0
149 ; CHECK: %op:gpr32 = UBFMWri %lhs, 31, 30
150 ; CHECK: TBNZW %op, 0, %bb.2
152 ; CHECK: RET_ReallyLR
154 ; CHECK: RET_ReallyLR
155 ; We won't ever fold this, because
157 ; bit - constant < 0, which isn't valid for tbz/tbnz.
160 successors: %bb.2, %bb.3
162 %lhs:gpr(s32) = COPY $w0
163 %rhs:gpr(s32) = G_CONSTANT i32 1
164 %op:gpr(s32) = G_SHL %lhs, %rhs
165 %trunc:gpr(s1) = G_TRUNC %op(s32)
166 G_BRCOND %trunc(s1), %bb.3
178 regBankSelected: true
180 ; CHECK-LABEL: name: condbr_of_ashr
182 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
183 ; CHECK: %lhs:gpr32 = COPY $w0
184 ; CHECK: TBNZW %lhs, 1, %bb.2
186 ; CHECK: RET_ReallyLR
188 ; CHECK: RET_ReallyLR
189 ; We can fold ashr, because we can have
191 ; (tbz (ashr x, c), 0) where 0 + c > # bits in x.
194 successors: %bb.2, %bb.3
196 %lhs:gpr(s32) = COPY $w0
197 %rhs:gpr(s32) = G_CONSTANT i32 1
198 %op:gpr(s32) = G_ASHR %lhs, %rhs
199 %trunc:gpr(s1) = G_TRUNC %op(s32)
200 G_BRCOND %trunc(s1), %bb.3
212 regBankSelected: true
214 ; CHECK-LABEL: name: tbnzx
216 ; CHECK: successors: %bb.1(0x40000000), %bb.2(0x40000000)
217 ; CHECK: %lhs:gpr64 = COPY $x0
218 ; CHECK: TBNZX %lhs, 63, %bb.2
220 ; CHECK: RET_ReallyLR
222 ; CHECK: RET_ReallyLR
224 successors: %bb.2, %bb.3
226 %lhs:gpr(s64) = COPY $x0
227 %rhs:gpr(s64) = G_CONSTANT i64 8589934592
228 %op:gpr(s64) = G_ASHR %lhs, %rhs
229 %trunc:gpr(s1) = G_TRUNC %op(s64)
230 G_BRCOND %trunc(s1), %bb.3