1 ; RUN: llc -disable-peephole -aarch64-enable-atomic-cfg-tidy=0 -verify-machineinstrs -mtriple=aarch64-apple-darwin < %s | FileCheck %s
2 ; RUN: llc -disable-peephole -fast-isel -fast-isel-abort=1 -aarch64-enable-atomic-cfg-tidy=0 -verify-machineinstrs -mtriple=aarch64-apple-darwin < %s | FileCheck --check-prefix=CHECK --check-prefix=FAST %s
4 define i32 @icmp_eq_i8(i8 zeroext %a) {
5 ; CHECK-LABEL: icmp_eq_i8
6 ; CHECK: tbz {{w[0-9]+}}, #0, {{LBB.+_2}}
9 br i1 %2, label %bb1, label %bb2, !prof !0
16 define i32 @icmp_eq_i16(i16 zeroext %a) {
17 ; CHECK-LABEL: icmp_eq_i16
18 ; CHECK: tbz w0, #1, {{LBB.+_2}}
20 %2 = icmp eq i16 %1, 0
21 br i1 %2, label %bb1, label %bb2, !prof !0
28 define i32 @icmp_eq_i32(i32 %a) {
29 ; CHECK-LABEL: icmp_eq_i32
30 ; CHECK: tbz w0, #2, {{LBB.+_2}}
32 %2 = icmp eq i32 %1, 0
33 br i1 %2, label %bb1, label %bb2, !prof !0
40 define i32 @icmp_eq_i64_1(i64 %a) {
41 ; CHECK-LABEL: icmp_eq_i64_1
42 ; CHECK: tbz w0, #3, {{LBB.+_2}}
44 %2 = icmp eq i64 %1, 0
45 br i1 %2, label %bb1, label %bb2, !prof !0
52 define i32 @icmp_eq_i64_2(i64 %a) {
53 ; CHECK-LABEL: icmp_eq_i64_2
54 ; CHECK: tbz x0, #32, {{LBB.+_2}}
55 %1 = and i64 %a, 4294967296
56 %2 = icmp eq i64 %1, 0
57 br i1 %2, label %bb1, label %bb2, !prof !0
64 define i32 @icmp_ne_i8(i8 zeroext %a) {
65 ; CHECK-LABEL: icmp_ne_i8
66 ; CHECK: tbnz w0, #0, {{LBB.+_2}}
69 br i1 %2, label %bb1, label %bb2, !prof !0
76 define i32 @icmp_ne_i16(i16 zeroext %a) {
77 ; CHECK-LABEL: icmp_ne_i16
78 ; CHECK: tbnz w0, #1, {{LBB.+_2}}
80 %2 = icmp ne i16 %1, 0
81 br i1 %2, label %bb1, label %bb2, !prof !0
88 define i32 @icmp_ne_i32(i32 %a) {
89 ; CHECK-LABEL: icmp_ne_i32
90 ; CHECK: tbnz w0, #2, {{LBB.+_2}}
92 %2 = icmp ne i32 %1, 0
93 br i1 %2, label %bb1, label %bb2, !prof !0
100 define i32 @icmp_ne_i64_1(i64 %a) {
101 ; CHECK-LABEL: icmp_ne_i64_1
102 ; CHECK: tbnz w0, #3, {{LBB.+_2}}
104 %2 = icmp ne i64 %1, 0
105 br i1 %2, label %bb1, label %bb2, !prof !0
112 define i32 @icmp_ne_i64_2(i64 %a) {
113 ; CHECK-LABEL: icmp_ne_i64_2
114 ; CHECK: tbnz x0, #32, {{LBB.+_2}}
115 %1 = and i64 %a, 4294967296
116 %2 = icmp ne i64 %1, 0
117 br i1 %2, label %bb1, label %bb2, !prof !0
124 define i32 @icmp_slt_i8(i8 zeroext %a) {
125 ; FAST-LABEL: icmp_slt_i8
126 ; FAST: tbnz w0, #7, {{LBB.+_2}}
127 %1 = icmp slt i8 %a, 0
128 br i1 %1, label %bb1, label %bb2, !prof !0
135 define i32 @icmp_slt_i16(i16 zeroext %a) {
136 ; FAST-LABEL: icmp_slt_i16
137 ; FAST: tbnz w0, #15, {{LBB.+_2}}
138 %1 = icmp slt i16 %a, 0
139 br i1 %1, label %bb1, label %bb2, !prof !0
146 define i32 @icmp_slt_i32(i32 %a) {
147 ; CHECK-LABEL: icmp_slt_i32
148 ; CHECK: tbnz w0, #31, {{LBB.+_2}}
149 %1 = icmp slt i32 %a, 0
150 br i1 %1, label %bb1, label %bb2, !prof !0
157 define i32 @icmp_slt_i64(i64 %a) {
158 ; CHECK-LABEL: icmp_slt_i64
159 ; CHECK: tbnz x0, #63, {{LBB.+_2}}
160 %1 = icmp slt i64 %a, 0
161 br i1 %1, label %bb1, label %bb2, !prof !0
168 define i32 @icmp_sge_i8(i8 zeroext %a) {
169 ; FAST-LABEL: icmp_sge_i8
170 ; FAST: tbz w0, #7, {{LBB.+_2}}
171 %1 = icmp sge i8 %a, 0
172 br i1 %1, label %bb1, label %bb2, !prof !0
179 define i32 @icmp_sge_i16(i16 zeroext %a) {
180 ; FAST-LABEL: icmp_sge_i16
181 ; FAST: tbz w0, #15, {{LBB.+_2}}
182 %1 = icmp sge i16 %a, 0
183 br i1 %1, label %bb1, label %bb2, !prof !0
190 define i32 @icmp_sle_i8(i8 zeroext %a) {
191 ; FAST-LABEL: icmp_sle_i8
192 ; FAST: tbnz w0, #7, {{LBB.+_2}}
193 %1 = icmp sle i8 %a, -1
194 br i1 %1, label %bb1, label %bb2, !prof !0
201 define i32 @icmp_sle_i16(i16 zeroext %a) {
202 ; FAST-LABEL: icmp_sle_i16
203 ; FAST: tbnz w0, #15, {{LBB.+_2}}
204 %1 = icmp sle i16 %a, -1
205 br i1 %1, label %bb1, label %bb2, !prof !0
212 define i32 @icmp_sle_i32(i32 %a) {
213 ; CHECK-LABEL: icmp_sle_i32
214 ; CHECK: tbnz w0, #31, {{LBB.+_2}}
215 %1 = icmp sle i32 %a, -1
216 br i1 %1, label %bb1, label %bb2, !prof !0
223 define i32 @icmp_sle_i64(i64 %a) {
224 ; CHECK-LABEL: icmp_sle_i64
225 ; CHECK: tbnz x0, #63, {{LBB.+_2}}
226 %1 = icmp sle i64 %a, -1
227 br i1 %1, label %bb1, label %bb2, !prof !0
234 define i32 @icmp_sgt_i8(i8 zeroext %a) {
235 ; FAST-LABEL: icmp_sgt_i8
236 ; FAST: tbz w0, #7, {{LBB.+_2}}
237 %1 = icmp sgt i8 %a, -1
238 br i1 %1, label %bb1, label %bb2, !prof !0
245 define i32 @icmp_sgt_i16(i16 zeroext %a) {
246 ; FAST-LABEL: icmp_sgt_i16
247 ; FAST: tbz w0, #15, {{LBB.+_2}}
248 %1 = icmp sgt i16 %a, -1
249 br i1 %1, label %bb1, label %bb2, !prof !0
256 define i32 @icmp_sgt_i32(i32 %a) {
257 ; CHECK-LABEL: icmp_sgt_i32
258 ; CHECK: tbz w0, #31, {{LBB.+_2}}
259 %1 = icmp sgt i32 %a, -1
260 br i1 %1, label %bb1, label %bb2, !prof !0
267 define i32 @icmp_sgt_i64(i64 %a) {
268 ; FAST-LABEL: icmp_sgt_i64
269 ; FAST: tbz x0, #63, {{LBB.+_2}}
270 %1 = icmp sgt i64 %a, -1
271 br i1 %1, label %bb1, label %bb2, !prof !0
278 ; Test that we don't fold the 'and' instruction into the compare.
279 define i32 @icmp_eq_and_i32(i32 %a, i1 %c) {
280 ; CHECK-LABEL: icmp_eq_and_i32
281 ; CHECK: and [[REG:w[0-9]+]], w0, #0x3
282 ; CHECK-NEXT: cbz [[REG]], {{LBB.+_3}}
284 br i1 %c, label %bb0, label %bb2
286 %2 = icmp eq i32 %1, 0
287 br i1 %2, label %bb1, label %bb2, !prof !0
294 ; Test that we do fold the 'and' instruction into the compare and
295 ; generate a tbz instruction for the conditional branch.
296 define i32 @icmp_eq_and1bit_i32(i32 %a, i1 %c) {
297 ; CHECK-LABEL: icmp_eq_and1bit_i32
298 ; CHECK: tbz {{w[0-9]+}}, #2, {{LBB.+_3}}
300 br i1 %c, label %bb0, label %bb2
302 %2 = icmp eq i32 %1, 0
303 br i1 %2, label %bb1, label %bb2, !prof !0
310 !0 = !{!"branch_weights", i32 0, i32 2147483647}
311 !1 = !{!"branch_weights", i32 2147483647, i32 0}