ARM64: enable more regression tests from AArch64
[oota-llvm.git] / test / CodeGen / AArch64 / analyze-branch.ll
1 ; RUN: llc -mtriple=aarch64-none-linux-gnu < %s | FileCheck %s
2 ; RUN: llc -mtriple=arm64-none-linux-gnu < %s | FileCheck %s
3
4 ; This test checks that LLVM can do basic stripping and reapplying of branches
5 ; to basic blocks.
6
7 declare void @test_true()
8 declare void @test_false()
9
10 ; !0 corresponds to a branch being taken, !1 to not being takne.
11 !0 = metadata !{metadata !"branch_weights", i32 64, i32 4}
12 !1 = metadata !{metadata !"branch_weights", i32 4, i32 64}
13
14 define void @test_Bcc_fallthrough_taken(i32 %in) nounwind {
15 ; CHECK-LABEL: test_Bcc_fallthrough_taken:
16   %tst = icmp eq i32 %in, 42
17   br i1 %tst, label %true, label %false, !prof !0
18
19 ; CHECK: cmp {{w[0-9]+}}, #42
20
21 ; CHECK: b.ne [[FALSE:.LBB[0-9]+_[0-9]+]]
22 ; CHECK-NEXT: // BB#
23 ; CHECK-NEXT: bl test_true
24
25 ; CHECK: [[FALSE]]:
26 ; CHECK: bl test_false
27
28 true:
29   call void @test_true()
30   ret void
31
32 false:
33   call void @test_false()
34   ret void
35 }
36
37 define void @test_Bcc_fallthrough_nottaken(i32 %in) nounwind {
38 ; CHECK-LABEL: test_Bcc_fallthrough_nottaken:
39   %tst = icmp eq i32 %in, 42
40   br i1 %tst, label %true, label %false, !prof !1
41
42 ; CHECK: cmp {{w[0-9]+}}, #42
43
44 ; CHECK: b.eq [[TRUE:.LBB[0-9]+_[0-9]+]]
45 ; CHECK-NEXT: // BB#
46 ; CHECK-NEXT: bl test_false
47
48 ; CHECK: [[TRUE]]:
49 ; CHECK: bl test_true
50
51 true:
52   call void @test_true()
53   ret void
54
55 false:
56   call void @test_false()
57   ret void
58 }
59
60 define void @test_CBZ_fallthrough_taken(i32 %in) nounwind {
61 ; CHECK-LABEL: test_CBZ_fallthrough_taken:
62   %tst = icmp eq i32 %in, 0
63   br i1 %tst, label %true, label %false, !prof !0
64
65 ; CHECK: cbnz {{w[0-9]+}}, [[FALSE:.LBB[0-9]+_[0-9]+]]
66 ; CHECK-NEXT: // BB#
67 ; CHECK-NEXT: bl test_true
68
69 ; CHECK: [[FALSE]]:
70 ; CHECK: bl test_false
71
72 true:
73   call void @test_true()
74   ret void
75
76 false:
77   call void @test_false()
78   ret void
79 }
80
81 define void @test_CBZ_fallthrough_nottaken(i64 %in) nounwind {
82 ; CHECK-LABEL: test_CBZ_fallthrough_nottaken:
83   %tst = icmp eq i64 %in, 0
84   br i1 %tst, label %true, label %false, !prof !1
85
86 ; CHECK: cbz {{x[0-9]+}}, [[TRUE:.LBB[0-9]+_[0-9]+]]
87 ; CHECK-NEXT: // BB#
88 ; CHECK-NEXT: bl test_false
89
90 ; CHECK: [[TRUE]]:
91 ; CHECK: bl test_true
92
93 true:
94   call void @test_true()
95   ret void
96
97 false:
98   call void @test_false()
99   ret void
100 }
101
102 define void @test_CBNZ_fallthrough_taken(i32 %in) nounwind {
103 ; CHECK-LABEL: test_CBNZ_fallthrough_taken:
104   %tst = icmp ne i32 %in, 0
105   br i1 %tst, label %true, label %false, !prof !0
106
107 ; CHECK: cbz {{w[0-9]+}}, [[FALSE:.LBB[0-9]+_[0-9]+]]
108 ; CHECK-NEXT: // BB#
109 ; CHECK-NEXT: bl test_true
110
111 ; CHECK: [[FALSE]]:
112 ; CHECK: bl test_false
113
114 true:
115   call void @test_true()
116   ret void
117
118 false:
119   call void @test_false()
120   ret void
121 }
122
123 define void @test_CBNZ_fallthrough_nottaken(i64 %in) nounwind {
124 ; CHECK-LABEL: test_CBNZ_fallthrough_nottaken:
125   %tst = icmp ne i64 %in, 0
126   br i1 %tst, label %true, label %false, !prof !1
127
128 ; CHECK: cbnz {{x[0-9]+}}, [[TRUE:.LBB[0-9]+_[0-9]+]]
129 ; CHECK-NEXT: // BB#
130 ; CHECK-NEXT: bl test_false
131
132 ; CHECK: [[TRUE]]:
133 ; CHECK: bl test_true
134
135 true:
136   call void @test_true()
137   ret void
138
139 false:
140   call void @test_false()
141   ret void
142 }
143
144 define void @test_TBZ_fallthrough_taken(i32 %in) nounwind {
145 ; CHECK-LABEL: test_TBZ_fallthrough_taken:
146   %bit = and i32 %in, 32768
147   %tst = icmp eq i32 %bit, 0
148   br i1 %tst, label %true, label %false, !prof !0
149
150 ; CHECK: tbnz {{w[0-9]+}}, #15, [[FALSE:.LBB[0-9]+_[0-9]+]]
151 ; CHECK-NEXT: // BB#
152 ; CHECK-NEXT: bl test_true
153
154 ; CHECK: [[FALSE]]:
155 ; CHECK: bl test_false
156
157 true:
158   call void @test_true()
159   ret void
160
161 false:
162   call void @test_false()
163   ret void
164 }
165
166 define void @test_TBZ_fallthrough_nottaken(i64 %in) nounwind {
167 ; CHECK-LABEL: test_TBZ_fallthrough_nottaken:
168   %bit = and i64 %in, 32768
169   %tst = icmp eq i64 %bit, 0
170   br i1 %tst, label %true, label %false, !prof !1
171
172 ; CHECK: tbz {{[wx][0-9]+}}, #15, [[TRUE:.LBB[0-9]+_[0-9]+]]
173 ; CHECK-NEXT: // BB#
174 ; CHECK-NEXT: bl test_false
175
176 ; CHECK: [[TRUE]]:
177 ; CHECK: bl test_true
178
179 true:
180   call void @test_true()
181   ret void
182
183 false:
184   call void @test_false()
185   ret void
186 }
187
188
189 define void @test_TBNZ_fallthrough_taken(i32 %in) nounwind {
190 ; CHECK-LABEL: test_TBNZ_fallthrough_taken:
191   %bit = and i32 %in, 32768
192   %tst = icmp ne i32 %bit, 0
193   br i1 %tst, label %true, label %false, !prof !0
194
195 ; CHECK: tbz {{w[0-9]+}}, #15, [[FALSE:.LBB[0-9]+_[0-9]+]]
196 ; CHECK-NEXT: // BB#
197 ; CHECK-NEXT: bl test_true
198
199 ; CHECK: [[FALSE]]:
200 ; CHECK: bl test_false
201
202 true:
203   call void @test_true()
204   ret void
205
206 false:
207   call void @test_false()
208   ret void
209 }
210
211 define void @test_TBNZ_fallthrough_nottaken(i64 %in) nounwind {
212 ; CHECK-LABEL: test_TBNZ_fallthrough_nottaken:
213   %bit = and i64 %in, 32768
214   %tst = icmp ne i64 %bit, 0
215   br i1 %tst, label %true, label %false, !prof !1
216
217 ; CHECK: tbnz {{[wx][0-9]+}}, #15, [[TRUE:.LBB[0-9]+_[0-9]+]]
218 ; CHECK-NEXT: // BB#
219 ; CHECK-NEXT: bl test_false
220
221 ; CHECK: [[TRUE]]:
222 ; CHECK: bl test_true
223
224 true:
225   call void @test_true()
226   ret void
227
228 false:
229   call void @test_false()
230   ret void
231 }
232