[FastISel][AArch64] Optimize compare-and-branch for i1 to use 'tbz'.
[oota-llvm.git] / test / CodeGen / AArch64 / arm64-bcc.ll
1 ; RUN: llc < %s -mtriple=arm64-apple-darwin  | FileCheck %s
2 ; Checks for conditional branch b.vs
3
4 ; Function Attrs: nounwind
5 define i32 @add(i32, i32) {
6 entry:
7   %2 = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %0, i32 %1)
8   %3 = extractvalue { i32, i1 } %2, 1
9   br i1 %3, label %6, label %4
10
11 ; <label>:4                                       ; preds = %entry
12   %5 = extractvalue { i32, i1 } %2, 0
13   ret i32 %5
14
15 ; <label>:6                                       ; preds = %entry
16   tail call void @llvm.trap()
17   unreachable
18 ; CHECK: b.vs
19 }
20
21 %S64 = type <{ i64 }>
22 %S32 = type <{ i32 }>
23 %Sstruct = type <{ %S64, %S32 }>
24
25 ; Checks for compfail when optimizing csincr-cbz sequence
26
27 define { i64, i1 } @foo(i64* , %Sstruct* , i1, i64) {
28 entry:
29   %.sroa.0 = alloca i72, align 16
30   %.count.value = getelementptr inbounds %Sstruct* %1, i64 0, i32 0, i32 0
31   %4 = load i64* %.count.value, align 8
32   %.repeatedValue.value = getelementptr inbounds %Sstruct* %1, i64 0, i32 1, i32 0
33   %5 = load i32* %.repeatedValue.value, align 8
34   %6 = icmp eq i64 %4, 0
35   br label %7
36
37 ; <label>:7                                      ; preds = %entry
38   %.mask58 = and i32 %5, -2048
39   %8 = icmp eq i32 %.mask58, 55296
40   %.not134 = xor i1 %8, true
41   %9 = icmp eq i32 %5, 1114112
42   %or.cond135 = and i1 %9, %.not134
43   br i1 %or.cond135, label %10, label %.loopexit
44
45 ; <label>:10                                      ; preds = %7
46   %11 = and i32 %5, -2048
47   %12 = icmp eq i32 %11, 55296
48   br i1 %12, label %.loopexit, label %10
49
50
51 .loopexit:                                        ; preds = %.entry,%7,%10
52   tail call void @llvm.trap()
53   unreachable
54 }
55
56 ; Function Attrs: nounwind readnone
57 declare { i32, i1 } @llvm.sadd.with.overflow.i32(i32, i32)
58
59 ; Function Attrs: noreturn nounwind
60 declare void @llvm.trap()