1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=aarch64-- | FileCheck %s --check-prefixes=CHECK,SDISEL
3 ; RUN: llc < %s -mtriple=aarch64-- -global-isel | FileCheck %s --check-prefixes=CHECK,GISEL
5 ; Ensure chains of comparisons produce chains of `ccmp`
7 ; (x0 < x1) && (x2 > x3)
8 define i32 @cmp_and2(i32 %0, i32 %1, i32 %2, i32 %3) {
9 ; SDISEL-LABEL: cmp_and2:
11 ; SDISEL-NEXT: cmp w0, w1
12 ; SDISEL-NEXT: ccmp w2, w3, #0, lo
13 ; SDISEL-NEXT: cset w0, hi
16 ; GISEL-LABEL: cmp_and2:
18 ; GISEL-NEXT: cmp w0, w1
19 ; GISEL-NEXT: cset w8, lo
20 ; GISEL-NEXT: cmp w2, w3
21 ; GISEL-NEXT: cset w9, hi
22 ; GISEL-NEXT: and w0, w8, w9
24 %5 = icmp ult i32 %0, %1
25 %6 = icmp ugt i32 %2, %3
26 %7 = select i1 %5, i1 %6, i1 false
27 %8 = zext i1 %7 to i32
31 ; (x0 < x1) && (x2 > x3) && (x4 != x5)
32 define i32 @cmp_and3(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
33 ; SDISEL-LABEL: cmp_and3:
35 ; SDISEL-NEXT: cmp w0, w1
36 ; SDISEL-NEXT: ccmp w2, w3, #0, lo
37 ; SDISEL-NEXT: ccmp w4, w5, #4, hi
38 ; SDISEL-NEXT: cset w0, ne
41 ; GISEL-LABEL: cmp_and3:
43 ; GISEL-NEXT: cmp w0, w1
44 ; GISEL-NEXT: cset w8, lo
45 ; GISEL-NEXT: cmp w2, w3
46 ; GISEL-NEXT: cset w9, hi
47 ; GISEL-NEXT: cmp w4, w5
48 ; GISEL-NEXT: and w8, w8, w9
49 ; GISEL-NEXT: cset w9, ne
50 ; GISEL-NEXT: and w0, w8, w9
52 %7 = icmp ult i32 %0, %1
53 %8 = icmp ugt i32 %2, %3
54 %9 = select i1 %7, i1 %8, i1 false
55 %10 = icmp ne i32 %4, %5
56 %11 = select i1 %9, i1 %10, i1 false
57 %12 = zext i1 %11 to i32
61 ; (x0 < x1) && (x2 > x3) && (x4 != x5) && (x6 == x7)
62 define i32 @cmp_and4(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7) {
63 ; SDISEL-LABEL: cmp_and4:
65 ; SDISEL-NEXT: cmp w2, w3
66 ; SDISEL-NEXT: ccmp w0, w1, #2, hi
67 ; SDISEL-NEXT: ccmp w4, w5, #4, lo
68 ; SDISEL-NEXT: ccmp w6, w7, #0, ne
69 ; SDISEL-NEXT: cset w0, eq
72 ; GISEL-LABEL: cmp_and4:
74 ; GISEL-NEXT: cmp w2, w3
75 ; GISEL-NEXT: cset w8, hi
76 ; GISEL-NEXT: cmp w0, w1
77 ; GISEL-NEXT: cset w9, lo
78 ; GISEL-NEXT: cmp w4, w5
79 ; GISEL-NEXT: cset w10, ne
80 ; GISEL-NEXT: cmp w6, w7
81 ; GISEL-NEXT: and w8, w8, w9
82 ; GISEL-NEXT: cset w11, eq
83 ; GISEL-NEXT: and w9, w10, w11
84 ; GISEL-NEXT: and w0, w8, w9
86 %9 = icmp ugt i32 %2, %3
87 %10 = icmp ult i32 %0, %1
88 %11 = select i1 %9, i1 %10, i1 false
89 %12 = icmp ne i32 %4, %5
90 %13 = select i1 %11, i1 %12, i1 false
91 %14 = icmp eq i32 %6, %7
92 %15 = select i1 %13, i1 %14, i1 false
93 %16 = zext i1 %15 to i32
97 ; (x0 < x1) || (x2 > x3)
98 define i32 @cmp_or2(i32 %0, i32 %1, i32 %2, i32 %3) {
99 ; SDISEL-LABEL: cmp_or2:
101 ; SDISEL-NEXT: cmp w0, w1
102 ; SDISEL-NEXT: ccmp w2, w3, #0, hs
103 ; SDISEL-NEXT: cset w0, ne
106 ; GISEL-LABEL: cmp_or2:
108 ; GISEL-NEXT: cmp w0, w1
109 ; GISEL-NEXT: cset w8, lo
110 ; GISEL-NEXT: cmp w2, w3
111 ; GISEL-NEXT: cset w9, ne
112 ; GISEL-NEXT: orr w0, w8, w9
114 %5 = icmp ult i32 %0, %1
115 %6 = icmp ne i32 %2, %3
116 %7 = select i1 %5, i1 true, i1 %6
117 %8 = zext i1 %7 to i32
121 ; (x0 < x1) || (x2 > x3) || (x4 != x5)
122 define i32 @cmp_or3(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
123 ; SDISEL-LABEL: cmp_or3:
125 ; SDISEL-NEXT: cmp w0, w1
126 ; SDISEL-NEXT: ccmp w2, w3, #2, hs
127 ; SDISEL-NEXT: ccmp w4, w5, #0, ls
128 ; SDISEL-NEXT: cset w0, ne
131 ; GISEL-LABEL: cmp_or3:
133 ; GISEL-NEXT: cmp w0, w1
134 ; GISEL-NEXT: cset w8, lo
135 ; GISEL-NEXT: cmp w2, w3
136 ; GISEL-NEXT: cset w9, hi
137 ; GISEL-NEXT: cmp w4, w5
138 ; GISEL-NEXT: orr w8, w8, w9
139 ; GISEL-NEXT: cset w9, ne
140 ; GISEL-NEXT: orr w0, w8, w9
142 %7 = icmp ult i32 %0, %1
143 %8 = icmp ugt i32 %2, %3
144 %9 = select i1 %7, i1 true, i1 %8
145 %10 = icmp ne i32 %4, %5
146 %11 = select i1 %9, i1 true, i1 %10
147 %12 = zext i1 %11 to i32
151 ; (x0 < x1) || (x2 > x3) || (x4 != x5) || (x6 == x7)
152 define i32 @cmp_or4(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7) {
153 ; SDISEL-LABEL: cmp_or4:
155 ; SDISEL-NEXT: cmp w0, w1
156 ; SDISEL-NEXT: ccmp w2, w3, #2, hs
157 ; SDISEL-NEXT: ccmp w4, w5, #0, ls
158 ; SDISEL-NEXT: ccmp w6, w7, #4, eq
159 ; SDISEL-NEXT: cset w0, eq
162 ; GISEL-LABEL: cmp_or4:
164 ; GISEL-NEXT: cmp w0, w1
165 ; GISEL-NEXT: cset w8, lo
166 ; GISEL-NEXT: cmp w2, w3
167 ; GISEL-NEXT: cset w9, hi
168 ; GISEL-NEXT: cmp w4, w5
169 ; GISEL-NEXT: cset w10, ne
170 ; GISEL-NEXT: cmp w6, w7
171 ; GISEL-NEXT: orr w8, w8, w9
172 ; GISEL-NEXT: cset w11, eq
173 ; GISEL-NEXT: orr w9, w10, w11
174 ; GISEL-NEXT: orr w0, w8, w9
176 %9 = icmp ult i32 %0, %1
177 %10 = icmp ugt i32 %2, %3
178 %11 = select i1 %9, i1 true, i1 %10
179 %12 = icmp ne i32 %4, %5
180 %13 = select i1 %11, i1 true, i1 %12
181 %14 = icmp eq i32 %6, %7
182 %15 = select i1 %13, i1 true, i1 %14
183 %16 = zext i1 %15 to i32
187 ; (x0 != 0) || (x1 != 0)
188 define i32 @true_or2(i32 %0, i32 %1) {
189 ; SDISEL-LABEL: true_or2:
191 ; SDISEL-NEXT: orr w8, w0, w1
192 ; SDISEL-NEXT: cmp w8, #0
193 ; SDISEL-NEXT: cset w0, ne
196 ; GISEL-LABEL: true_or2:
198 ; GISEL-NEXT: cmp w0, #0
199 ; GISEL-NEXT: cset w8, ne
200 ; GISEL-NEXT: cmp w1, #0
201 ; GISEL-NEXT: cset w9, ne
202 ; GISEL-NEXT: orr w0, w8, w9
204 %3 = icmp ne i32 %0, 0
205 %4 = icmp ne i32 %1, 0
206 %5 = select i1 %3, i1 true, i1 %4
207 %6 = zext i1 %5 to i32
211 ; (x0 != 0) || (x1 != 0) || (x2 != 0)
212 define i32 @true_or3(i32 %0, i32 %1, i32 %2) {
213 ; SDISEL-LABEL: true_or3:
215 ; SDISEL-NEXT: orr w8, w0, w1
216 ; SDISEL-NEXT: orr w8, w8, w2
217 ; SDISEL-NEXT: cmp w8, #0
218 ; SDISEL-NEXT: cset w0, ne
221 ; GISEL-LABEL: true_or3:
223 ; GISEL-NEXT: cmp w0, #0
224 ; GISEL-NEXT: cset w8, ne
225 ; GISEL-NEXT: cmp w1, #0
226 ; GISEL-NEXT: cset w9, ne
227 ; GISEL-NEXT: cmp w2, #0
228 ; GISEL-NEXT: orr w8, w8, w9
229 ; GISEL-NEXT: cset w9, ne
230 ; GISEL-NEXT: orr w0, w8, w9
232 %4 = icmp ne i32 %0, 0
233 %5 = icmp ne i32 %1, 0
234 %6 = select i1 %4, i1 true, i1 %5
235 %7 = icmp ne i32 %2, 0
236 %8 = select i1 %6, i1 true, i1 %7
237 %9 = zext i1 %8 to i32
240 ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: