1 ; RUN: llc -mtriple=aarch64-none-linux-gnu < %s | FileCheck %s
3 ; This test checks that LLVM can do basic stripping and reapplying of branches
6 declare void @test_true()
7 declare void @test_false()
9 ; !0 corresponds to a branch being taken, !1 to not being takne.
10 !0 = !{!"branch_weights", i32 64, i32 4}
11 !1 = !{!"branch_weights", i32 4, i32 64}
13 define void @test_Bcc_fallthrough_taken(i32 %in) nounwind {
14 ; CHECK-LABEL: test_Bcc_fallthrough_taken:
15 %tst = icmp eq i32 %in, 42
16 br i1 %tst, label %true, label %false, !prof !0
18 ; CHECK: cmp {{w[0-9]+}}, #42
20 ; CHECK: b.ne [[FALSE:.LBB[0-9]+_[0-9]+]]
22 ; CHECK-NEXT: bl test_true
25 ; CHECK: bl test_false
28 call void @test_true()
32 call void @test_false()
36 define void @test_Bcc_fallthrough_nottaken(i32 %in) nounwind {
37 ; CHECK-LABEL: test_Bcc_fallthrough_nottaken:
38 %tst = icmp eq i32 %in, 42
39 br i1 %tst, label %true, label %false, !prof !1
41 ; CHECK: cmp {{w[0-9]+}}, #42
43 ; CHECK: b.eq [[TRUE:.LBB[0-9]+_[0-9]+]]
45 ; CHECK-NEXT: bl test_false
51 call void @test_true()
55 call void @test_false()
59 define void @test_CBZ_fallthrough_taken(i32 %in) nounwind {
60 ; CHECK-LABEL: test_CBZ_fallthrough_taken:
61 %tst = icmp eq i32 %in, 0
62 br i1 %tst, label %true, label %false, !prof !0
64 ; CHECK: cbnz {{w[0-9]+}}, [[FALSE:.LBB[0-9]+_[0-9]+]]
66 ; CHECK-NEXT: bl test_true
69 ; CHECK: bl test_false
72 call void @test_true()
76 call void @test_false()
80 define void @test_CBZ_fallthrough_nottaken(i64 %in) nounwind {
81 ; CHECK-LABEL: test_CBZ_fallthrough_nottaken:
82 %tst = icmp eq i64 %in, 0
83 br i1 %tst, label %true, label %false, !prof !1
85 ; CHECK: cbz {{x[0-9]+}}, [[TRUE:.LBB[0-9]+_[0-9]+]]
87 ; CHECK-NEXT: bl test_false
93 call void @test_true()
97 call void @test_false()
101 define void @test_CBNZ_fallthrough_taken(i32 %in) nounwind {
102 ; CHECK-LABEL: test_CBNZ_fallthrough_taken:
103 %tst = icmp ne i32 %in, 0
104 br i1 %tst, label %true, label %false, !prof !0
106 ; CHECK: cbz {{w[0-9]+}}, [[FALSE:.LBB[0-9]+_[0-9]+]]
107 ; CHECK-NEXT: // %bb.
108 ; CHECK-NEXT: bl test_true
111 ; CHECK: bl test_false
114 call void @test_true()
118 call void @test_false()
122 define void @test_CBNZ_fallthrough_nottaken(i64 %in) nounwind {
123 ; CHECK-LABEL: test_CBNZ_fallthrough_nottaken:
124 %tst = icmp ne i64 %in, 0
125 br i1 %tst, label %true, label %false, !prof !1
127 ; CHECK: cbnz {{x[0-9]+}}, [[TRUE:.LBB[0-9]+_[0-9]+]]
128 ; CHECK-NEXT: // %bb.
129 ; CHECK-NEXT: bl test_false
132 ; CHECK: bl test_true
135 call void @test_true()
139 call void @test_false()
143 define void @test_TBZ_fallthrough_taken(i32 %in) nounwind {
144 ; CHECK-LABEL: test_TBZ_fallthrough_taken:
145 %bit = and i32 %in, 32768
146 %tst = icmp eq i32 %bit, 0
147 br i1 %tst, label %true, label %false, !prof !0
149 ; CHECK: tbnz {{w[0-9]+}}, #15, [[FALSE:.LBB[0-9]+_[0-9]+]]
150 ; CHECK-NEXT: // %bb.
151 ; CHECK-NEXT: bl test_true
154 ; CHECK: bl test_false
157 call void @test_true()
161 call void @test_false()
165 define void @test_TBZ_fallthrough_nottaken(i64 %in) nounwind {
166 ; CHECK-LABEL: test_TBZ_fallthrough_nottaken:
167 %bit = and i64 %in, 32768
168 %tst = icmp eq i64 %bit, 0
169 br i1 %tst, label %true, label %false, !prof !1
171 ; CHECK: tbz {{[wx][0-9]+}}, #15, [[TRUE:.LBB[0-9]+_[0-9]+]]
172 ; CHECK-NEXT: // %bb.
173 ; CHECK-NEXT: bl test_false
176 ; CHECK: bl test_true
179 call void @test_true()
183 call void @test_false()
188 define void @test_TBNZ_fallthrough_taken(i32 %in) nounwind {
189 ; CHECK-LABEL: test_TBNZ_fallthrough_taken:
190 %bit = and i32 %in, 32768
191 %tst = icmp ne i32 %bit, 0
192 br i1 %tst, label %true, label %false, !prof !0
194 ; CHECK: tbz {{w[0-9]+}}, #15, [[FALSE:.LBB[0-9]+_[0-9]+]]
195 ; CHECK-NEXT: // %bb.
196 ; CHECK-NEXT: bl test_true
199 ; CHECK: bl test_false
202 call void @test_true()
206 call void @test_false()
210 define void @test_TBNZ_fallthrough_nottaken(i64 %in) nounwind {
211 ; CHECK-LABEL: test_TBNZ_fallthrough_nottaken:
212 %bit = and i64 %in, 32768
213 %tst = icmp ne i64 %bit, 0
214 br i1 %tst, label %true, label %false, !prof !1
216 ; CHECK: tbnz {{[wx][0-9]+}}, #15, [[TRUE:.LBB[0-9]+_[0-9]+]]
217 ; CHECK-NEXT: // %bb.
218 ; CHECK-NEXT: bl test_false
221 ; CHECK: bl test_true
224 call void @test_true()
228 call void @test_false()