1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64-apple-darwin -fast-isel -fast-isel-abort=1 -verify-machineinstrs < %s | FileCheck %s
4 define i64 @test_or(i32 %a, i32 %b) {
5 ; CHECK-LABEL: test_or:
6 ; CHECK: ; %bb.0: ; %bb1
7 ; CHECK-NEXT: cbnz w0, LBB0_2
9 ; CHECK-NEXT: mov x0, xzr
11 ; CHECK-NEXT: LBB0_2: ; %bb1.cond.split
12 ; CHECK-NEXT: cbz w1, LBB0_1
13 ; CHECK-NEXT: ; %bb.3: ; %bb4
14 ; CHECK-NEXT: stp x29, x30, [sp, #-16]! ; 16-byte Folded Spill
15 ; CHECK-NEXT: .cfi_def_cfa_offset 16
16 ; CHECK-NEXT: .cfi_offset w30, -8
17 ; CHECK-NEXT: .cfi_offset w29, -16
19 ; CHECK-NEXT: ldp x29, x30, [sp], #16 ; 16-byte Folded Reload
22 %0 = icmp eq i32 %a, 0
23 %1 = icmp eq i32 %b, 0
24 %or.cond = or i1 %0, %1
25 br i1 %or.cond, label %bb3, label %bb4, !prof !0
35 define i64 @test_or_select(i32 %a, i32 %b) {
36 ; CHECK-LABEL: test_or_select:
37 ; CHECK: ; %bb.0: ; %bb1
38 ; CHECK-NEXT: cbnz w0, LBB1_2
40 ; CHECK-NEXT: mov x0, xzr
42 ; CHECK-NEXT: LBB1_2: ; %bb1.cond.split
43 ; CHECK-NEXT: cbz w1, LBB1_1
44 ; CHECK-NEXT: ; %bb.3: ; %bb4
45 ; CHECK-NEXT: stp x29, x30, [sp, #-16]! ; 16-byte Folded Spill
46 ; CHECK-NEXT: .cfi_def_cfa_offset 16
47 ; CHECK-NEXT: .cfi_offset w30, -8
48 ; CHECK-NEXT: .cfi_offset w29, -16
50 ; CHECK-NEXT: ldp x29, x30, [sp], #16 ; 16-byte Folded Reload
53 %0 = icmp eq i32 %a, 0
54 %1 = icmp eq i32 %b, 0
55 %or.cond = select i1 %0, i1 true, i1 %1
56 br i1 %or.cond, label %bb3, label %bb4, !prof !0
66 define i64 @test_and(i32 %a, i32 %b) {
67 ; CHECK-LABEL: test_and:
68 ; CHECK: ; %bb.0: ; %bb1
69 ; CHECK-NEXT: cbnz w0, LBB2_2
71 ; CHECK-NEXT: mov x0, xzr
73 ; CHECK-NEXT: LBB2_2: ; %bb1.cond.split
74 ; CHECK-NEXT: cbz w1, LBB2_1
75 ; CHECK-NEXT: ; %bb.3: ; %bb4
76 ; CHECK-NEXT: stp x29, x30, [sp, #-16]! ; 16-byte Folded Spill
77 ; CHECK-NEXT: .cfi_def_cfa_offset 16
78 ; CHECK-NEXT: .cfi_offset w30, -8
79 ; CHECK-NEXT: .cfi_offset w29, -16
81 ; CHECK-NEXT: ldp x29, x30, [sp], #16 ; 16-byte Folded Reload
84 %0 = icmp ne i32 %a, 0
85 %1 = icmp ne i32 %b, 0
86 %or.cond = and i1 %0, %1
87 br i1 %or.cond, label %bb4, label %bb3, !prof !1
97 define i64 @test_and_select(i32 %a, i32 %b) {
98 ; CHECK-LABEL: test_and_select:
99 ; CHECK: ; %bb.0: ; %bb1
100 ; CHECK-NEXT: cbnz w0, LBB3_2
101 ; CHECK-NEXT: LBB3_1:
102 ; CHECK-NEXT: mov x0, xzr
104 ; CHECK-NEXT: LBB3_2: ; %bb1.cond.split
105 ; CHECK-NEXT: cbz w1, LBB3_1
106 ; CHECK-NEXT: ; %bb.3: ; %bb4
107 ; CHECK-NEXT: stp x29, x30, [sp, #-16]! ; 16-byte Folded Spill
108 ; CHECK-NEXT: .cfi_def_cfa_offset 16
109 ; CHECK-NEXT: .cfi_offset w30, -8
110 ; CHECK-NEXT: .cfi_offset w29, -16
111 ; CHECK-NEXT: bl _bar
112 ; CHECK-NEXT: ldp x29, x30, [sp], #16 ; 16-byte Folded Reload
115 %0 = icmp ne i32 %a, 0
116 %1 = icmp ne i32 %b, 0
117 %or.cond = select i1 %0, i1 %1, i1 false
118 br i1 %or.cond, label %bb4, label %bb3, !prof !1
128 ; If the branch is unpredictable, don't add another branch.
130 define i64 @test_or_unpredictable(i32 %a, i32 %b) {
131 ; CHECK-LABEL: test_or_unpredictable:
132 ; CHECK: ; %bb.0: ; %bb1
133 ; CHECK-NEXT: cmp w0, #0
134 ; CHECK-NEXT: mov x0, xzr
135 ; CHECK-NEXT: cset w8, eq
136 ; CHECK-NEXT: cmp w1, #0
137 ; CHECK-NEXT: cset w9, eq
138 ; CHECK-NEXT: orr w8, w8, w9
139 ; CHECK-NEXT: tbnz w8, #0, LBB4_2
140 ; CHECK-NEXT: ; %bb.1: ; %bb4
141 ; CHECK-NEXT: stp x29, x30, [sp, #-16]! ; 16-byte Folded Spill
142 ; CHECK-NEXT: .cfi_def_cfa_offset 16
143 ; CHECK-NEXT: .cfi_offset w30, -8
144 ; CHECK-NEXT: .cfi_offset w29, -16
145 ; CHECK-NEXT: bl _bar
146 ; CHECK-NEXT: ldp x29, x30, [sp], #16 ; 16-byte Folded Reload
147 ; CHECK-NEXT: LBB4_2: ; %common.ret
150 %0 = icmp eq i32 %a, 0
151 %1 = icmp eq i32 %b, 0
152 %or.cond = or i1 %0, %1
153 br i1 %or.cond, label %bb3, label %bb4, !unpredictable !2
163 define i64 @test_and_unpredictable(i32 %a, i32 %b) {
164 ; CHECK-LABEL: test_and_unpredictable:
165 ; CHECK: ; %bb.0: ; %bb1
166 ; CHECK-NEXT: cmp w0, #0
167 ; CHECK-NEXT: mov x0, xzr
168 ; CHECK-NEXT: cset w8, ne
169 ; CHECK-NEXT: cmp w1, #0
170 ; CHECK-NEXT: cset w9, ne
171 ; CHECK-NEXT: and w8, w8, w9
172 ; CHECK-NEXT: tbz w8, #0, LBB5_2
173 ; CHECK-NEXT: ; %bb.1: ; %bb4
174 ; CHECK-NEXT: stp x29, x30, [sp, #-16]! ; 16-byte Folded Spill
175 ; CHECK-NEXT: .cfi_def_cfa_offset 16
176 ; CHECK-NEXT: .cfi_offset w30, -8
177 ; CHECK-NEXT: .cfi_offset w29, -16
178 ; CHECK-NEXT: bl _bar
179 ; CHECK-NEXT: ldp x29, x30, [sp], #16 ; 16-byte Folded Reload
180 ; CHECK-NEXT: LBB5_2: ; %common.ret
183 %0 = icmp ne i32 %a, 0
184 %1 = icmp ne i32 %b, 0
185 %or.cond = and i1 %0, %1
186 br i1 %or.cond, label %bb4, label %bb3, !unpredictable !2
198 !0 = !{!"branch_weights", i32 5128, i32 32}
199 !1 = !{!"branch_weights", i32 1024, i32 4136}