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: mov w8, w0
8 ; CHECK-NEXT: mov x0, xzr
9 ; CHECK-NEXT: cbnz w8, LBB0_2
10 ; CHECK-NEXT: LBB0_1: ; %common.ret
12 ; CHECK-NEXT: LBB0_2: ; %bb1.cond.split
13 ; CHECK-NEXT: mov x0, xzr
14 ; CHECK-NEXT: cbz w1, LBB0_1
15 ; CHECK-NEXT: ; %bb.3: ; %bb4
16 ; CHECK-NEXT: stp x29, x30, [sp, #-16]! ; 16-byte Folded Spill
17 ; CHECK-NEXT: .cfi_def_cfa_offset 16
18 ; CHECK-NEXT: .cfi_offset w30, -8
19 ; CHECK-NEXT: .cfi_offset w29, -16
21 ; CHECK-NEXT: ldp x29, x30, [sp], #16 ; 16-byte Folded Reload
24 %0 = icmp eq i32 %a, 0
25 %1 = icmp eq i32 %b, 0
26 %or.cond = or i1 %0, %1
27 br i1 %or.cond, label %bb3, label %bb4, !prof !0
37 define i64 @test_or_select(i32 %a, i32 %b) {
38 ; CHECK-LABEL: test_or_select:
39 ; CHECK: ; %bb.0: ; %bb1
40 ; CHECK-NEXT: mov w8, w0
41 ; CHECK-NEXT: mov x0, xzr
42 ; CHECK-NEXT: cbnz w8, LBB1_2
43 ; CHECK-NEXT: LBB1_1: ; %common.ret
45 ; CHECK-NEXT: LBB1_2: ; %bb1.cond.split
46 ; CHECK-NEXT: mov x0, xzr
47 ; CHECK-NEXT: cbz w1, LBB1_1
48 ; CHECK-NEXT: ; %bb.3: ; %bb4
49 ; CHECK-NEXT: stp x29, x30, [sp, #-16]! ; 16-byte Folded Spill
50 ; CHECK-NEXT: .cfi_def_cfa_offset 16
51 ; CHECK-NEXT: .cfi_offset w30, -8
52 ; CHECK-NEXT: .cfi_offset w29, -16
54 ; CHECK-NEXT: ldp x29, x30, [sp], #16 ; 16-byte Folded Reload
57 %0 = icmp eq i32 %a, 0
58 %1 = icmp eq i32 %b, 0
59 %or.cond = select i1 %0, i1 true, i1 %1
60 br i1 %or.cond, label %bb3, label %bb4, !prof !0
70 define i64 @test_and(i32 %a, i32 %b) {
71 ; CHECK-LABEL: test_and:
72 ; CHECK: ; %bb.0: ; %bb1
73 ; CHECK-NEXT: mov w8, w0
74 ; CHECK-NEXT: mov x0, xzr
75 ; CHECK-NEXT: cbnz w8, LBB2_2
76 ; CHECK-NEXT: LBB2_1: ; %common.ret
78 ; CHECK-NEXT: LBB2_2: ; %bb1.cond.split
79 ; CHECK-NEXT: mov x0, xzr
80 ; CHECK-NEXT: cbz w1, LBB2_1
81 ; CHECK-NEXT: ; %bb.3: ; %bb4
82 ; CHECK-NEXT: stp x29, x30, [sp, #-16]! ; 16-byte Folded Spill
83 ; CHECK-NEXT: .cfi_def_cfa_offset 16
84 ; CHECK-NEXT: .cfi_offset w30, -8
85 ; CHECK-NEXT: .cfi_offset w29, -16
87 ; CHECK-NEXT: ldp x29, x30, [sp], #16 ; 16-byte Folded Reload
90 %0 = icmp ne i32 %a, 0
91 %1 = icmp ne i32 %b, 0
92 %or.cond = and i1 %0, %1
93 br i1 %or.cond, label %bb4, label %bb3, !prof !1
103 define i64 @test_and_select(i32 %a, i32 %b) {
104 ; CHECK-LABEL: test_and_select:
105 ; CHECK: ; %bb.0: ; %bb1
106 ; CHECK-NEXT: mov w8, w0
107 ; CHECK-NEXT: mov x0, xzr
108 ; CHECK-NEXT: cbnz w8, LBB3_2
109 ; CHECK-NEXT: LBB3_1: ; %common.ret
111 ; CHECK-NEXT: LBB3_2: ; %bb1.cond.split
112 ; CHECK-NEXT: mov x0, xzr
113 ; CHECK-NEXT: cbz w1, LBB3_1
114 ; CHECK-NEXT: ; %bb.3: ; %bb4
115 ; CHECK-NEXT: stp x29, x30, [sp, #-16]! ; 16-byte Folded Spill
116 ; CHECK-NEXT: .cfi_def_cfa_offset 16
117 ; CHECK-NEXT: .cfi_offset w30, -8
118 ; CHECK-NEXT: .cfi_offset w29, -16
119 ; CHECK-NEXT: bl _bar
120 ; CHECK-NEXT: ldp x29, x30, [sp], #16 ; 16-byte Folded Reload
123 %0 = icmp ne i32 %a, 0
124 %1 = icmp ne i32 %b, 0
125 %or.cond = select i1 %0, i1 %1, i1 false
126 br i1 %or.cond, label %bb4, label %bb3, !prof !1
136 ; If the branch is unpredictable, don't add another branch.
138 define i64 @test_or_unpredictable(i32 %a, i32 %b) {
139 ; CHECK-LABEL: test_or_unpredictable:
140 ; CHECK: ; %bb.0: ; %bb1
141 ; CHECK-NEXT: cmp w0, #0
142 ; CHECK-NEXT: mov x0, xzr
143 ; CHECK-NEXT: cset w8, eq
144 ; CHECK-NEXT: cmp w1, #0
145 ; CHECK-NEXT: cset w9, eq
146 ; CHECK-NEXT: orr w8, w8, w9
147 ; CHECK-NEXT: tbnz w8, #0, LBB4_2
148 ; CHECK-NEXT: ; %bb.1: ; %bb4
149 ; CHECK-NEXT: stp x29, x30, [sp, #-16]! ; 16-byte Folded Spill
150 ; CHECK-NEXT: .cfi_def_cfa_offset 16
151 ; CHECK-NEXT: .cfi_offset w30, -8
152 ; CHECK-NEXT: .cfi_offset w29, -16
153 ; CHECK-NEXT: bl _bar
154 ; CHECK-NEXT: ldp x29, x30, [sp], #16 ; 16-byte Folded Reload
155 ; CHECK-NEXT: LBB4_2: ; %common.ret
158 %0 = icmp eq i32 %a, 0
159 %1 = icmp eq i32 %b, 0
160 %or.cond = or i1 %0, %1
161 br i1 %or.cond, label %bb3, label %bb4, !unpredictable !2
171 define i64 @test_and_unpredictable(i32 %a, i32 %b) {
172 ; CHECK-LABEL: test_and_unpredictable:
173 ; CHECK: ; %bb.0: ; %bb1
174 ; CHECK-NEXT: cmp w0, #0
175 ; CHECK-NEXT: mov x0, xzr
176 ; CHECK-NEXT: cset w8, ne
177 ; CHECK-NEXT: cmp w1, #0
178 ; CHECK-NEXT: cset w9, ne
179 ; CHECK-NEXT: and w8, w8, w9
180 ; CHECK-NEXT: tbz w8, #0, LBB5_2
181 ; CHECK-NEXT: ; %bb.1: ; %bb4
182 ; CHECK-NEXT: stp x29, x30, [sp, #-16]! ; 16-byte Folded Spill
183 ; CHECK-NEXT: .cfi_def_cfa_offset 16
184 ; CHECK-NEXT: .cfi_offset w30, -8
185 ; CHECK-NEXT: .cfi_offset w29, -16
186 ; CHECK-NEXT: bl _bar
187 ; CHECK-NEXT: ldp x29, x30, [sp], #16 ; 16-byte Folded Reload
188 ; CHECK-NEXT: LBB5_2: ; %common.ret
191 %0 = icmp ne i32 %a, 0
192 %1 = icmp ne i32 %b, 0
193 %or.cond = and i1 %0, %1
194 br i1 %or.cond, label %bb4, label %bb3, !unpredictable !2
206 !0 = !{!"branch_weights", i32 5128, i32 32}
207 !1 = !{!"branch_weights", i32 1024, i32 4136}