1 ; RUN: llc < %s -O1 -mtriple=aarch64 -aarch64-enable-cond-br-tune=false | FileCheck %s
5 define void @test1(i32 %a) {
8 %sub = add nsw i32 %a, -12
9 %cmp = icmp slt i32 %sub, 0
10 br i1 %cmp, label %if.then, label %if.end
12 ; CHECK: sub [[CMP:w[0-9]+]], w0, #12
13 ; CHECK: tbnz [[CMP]], #31
23 define void @test2(i64 %a) {
26 %sub = add nsw i64 %a, -12
27 %cmp = icmp slt i64 %sub, 0
28 br i1 %cmp, label %if.then, label %if.end
30 ; CHECK: sub [[CMP:x[0-9]+]], x0, #12
31 ; CHECK: tbnz [[CMP]], #63
41 define void @test3(i32 %a) {
44 %sub = add nsw i32 %a, -12
45 %cmp = icmp sgt i32 %sub, -1
46 br i1 %cmp, label %if.then, label %if.end
48 ; CHECK: sub [[CMP:w[0-9]+]], w0, #12
49 ; CHECK: tbnz [[CMP]], #31
59 define void @test4(i64 %a) {
62 %sub = add nsw i64 %a, -12
63 %cmp = icmp sgt i64 %sub, -1
64 br i1 %cmp, label %if.then, label %if.end
66 ; CHECK: sub [[CMP:x[0-9]+]], x0, #12
67 ; CHECK: tbnz [[CMP]], #63
77 define void @test5(i32 %a) {
80 %sub = add nsw i32 %a, -12
81 %cmp = icmp sge i32 %sub, 0
82 br i1 %cmp, label %if.then, label %if.end
84 ; CHECK: sub [[CMP:w[0-9]+]], w0, #12
85 ; CHECK: tbnz [[CMP]], #31
95 define void @test6(i64 %a) {
98 %sub = add nsw i64 %a, -12
99 %cmp = icmp sge i64 %sub, 0
100 br i1 %cmp, label %if.then, label %if.end
102 ; CHECK: sub [[CMP:x[0-9]+]], x0, #12
103 ; CHECK: tbnz [[CMP]], #63
113 define void @test7(i32 %a) {
114 ; CHECK-LABEL: @test7
116 %sub = sub nsw i32 %a, 12
117 %cmp = icmp slt i32 %sub, 0
118 br i1 %cmp, label %if.then, label %if.end
120 ; CHECK: sub [[CMP:w[0-9]+]], w0, #12
121 ; CHECK: tbnz [[CMP]], #31
131 define void @test8(i64 %val1, i64 %val2, i64 %val3) {
132 ; CHECK-LABEL: @test8
133 %and1 = and i64 %val1, %val2
134 %tst1 = icmp slt i64 %and1, 0
135 br i1 %tst1, label %if.then1, label %if.end
141 %and2 = and i64 %val2, %val3
142 %tst2 = icmp sge i64 %and2, 0
143 br i1 %tst2, label %if.then2, label %if.end
145 ; CHECK: and [[CMP:x[0-9]+]], x1, x2
147 ; CHECK: tbnz [[CMP]], #63
150 %shifted_op1 = shl i64 %val2, 63
151 %shifted_and1 = and i64 %val1, %shifted_op1
152 %tst3 = icmp slt i64 %shifted_and1, 0
153 br i1 %tst3, label %if.then3, label %if.end
155 ; CHECK: tst x0, x1, lsl #63
159 %shifted_op2 = shl i64 %val2, 62
160 %shifted_and2 = and i64 %val1, %shifted_op2
161 %tst4 = icmp sge i64 %shifted_and2, 0
162 br i1 %tst4, label %if.then4, label %if.end
164 ; CHECK: tst x0, x1, lsl #62
175 define void @test9(i64 %val1) {
176 ; CHECK-LABEL: @test9
177 %tst = icmp slt i64 %val1, 0
178 br i1 %tst, label %if.then, label %if.end
181 ; CHECK: tbnz x0, #63
191 define void @test10(i64 %val1) {
192 ; CHECK-LABEL: @test10
193 %tst = icmp slt i64 %val1, 0
194 br i1 %tst, label %if.then, label %if.end
197 ; CHECK: tbnz x0, #63
207 define void @test11(i64 %val1, ptr %ptr) {
208 ; CHECK-LABEL: @test11
210 ; CHECK: ldr [[CMP:x[0-9]+]], [x1]
212 ; CHECK: tbnz [[CMP]], #63
214 %val = load i64, ptr %ptr
215 %tst = icmp slt i64 %val, 0
216 br i1 %tst, label %if.then, label %if.end
226 define void @test12(i64 %val1) {
227 ; CHECK-LABEL: @test12
228 %tst = icmp slt i64 %val1, 0
229 br i1 %tst, label %if.then, label %if.end
232 ; CHECK: tbnz x0, #63
242 define void @test13(i64 %val1, i64 %val2) {
243 ; CHECK-LABEL: @test13
244 %or = or i64 %val1, %val2
245 %tst = icmp slt i64 %or, 0
246 br i1 %tst, label %if.then, label %if.end
248 ; CHECK: orr [[CMP:x[0-9]+]], x0, x1
250 ; CHECK: tbnz [[CMP]], #63
260 define void @test14(i1 %cond) {
261 ; CHECK-LABEL: @test14
262 br i1 %cond, label %if.end, label %if.then
275 define void @test15(i1 %cond) {
276 ; CHECK-LABEL: @test15
277 %cond1 = xor i1 %cond, -1
278 br i1 %cond1, label %if.then, label %if.end
291 define void @test16(i64 %in) {
292 ; CHECK-LABEL: @test16
293 %shl = shl i64 %in, 3
294 %and = and i64 %shl, 32
295 %cond = icmp eq i64 %and, 0
296 br i1 %cond, label %then, label %end
309 define void @test17(i64 %in) {
310 ; CHECK-LABEL: @test17
311 %shr = ashr i64 %in, 3
312 %and = and i64 %shr, 1
313 %cond = icmp eq i64 %and, 0
314 br i1 %cond, label %then, label %end
327 define void @test18(i32 %in) {
328 ; CHECK-LABEL: @test18
329 %shr = ashr i32 %in, 2
330 %cond = icmp sge i32 %shr, 0
331 br i1 %cond, label %then, label %end
334 ; CHECK: tbnz w0, #31
344 define void @test19(i64 %in) {
345 ; CHECK-LABEL: @test19
346 %shl = lshr i64 %in, 3
347 %trunc = trunc i64 %shl to i32
348 %and = and i32 %trunc, 1
349 %cond = icmp eq i32 %and, 0
350 br i1 %cond, label %then, label %end
363 define void @test20(i32 %in) nounwind {
364 ; CHECK-LABEL: test20:
366 ; CHECK-NEXT: tbnz w0, #2, .LBB19_2
367 ; CHECK-NEXT: // %bb.1: // %then
368 ; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
370 ; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
371 ; CHECK-NEXT: .LBB19_2: // %end
373 %shl = shl i32 %in, 3
374 %zext = zext i32 %shl to i64
375 %and = and i64 %zext, 32
376 %cond = icmp eq i64 %and, 0
377 br i1 %cond, label %then, label %end