LLVM generates sub-optimal code for sequences of chained comparions - ie code of the form
(x1 relop1 y1) boolop1 (x2 relop2 y2) boolop2 ... (xn relopn yn)
where relop is one of {<=, <, >=, >, ==, !=} and boolop is one of {&&, ||}.
LLVM currently emits chains of CMP+CSET for each comparison, and then AND/ORR to combine the results of the comparisons. This can be replaced by a chain of CCMPs and a single CSET at the end.
For example.
(x1 < x2) && (x3 > x4) && (x5 != x6) && (x7 == x8)
generates
cmp w2, w3 cset w8, hi cmp w0, w1 cset w9, lo cmp w4, w5 and w8, w8, w9 cset w9, ne cmp w6, w7 and w8, w8, w9 cset w9, eq and w0, w8, w9
but the more efficient code would be:
cmp w2, w3 ccmp w0, w1, #2, hi ccmp w4, w5, #4, lo ccmp w6, w7, #0, ne cset w0, eq
This patch generalizes https://reviews.llvm.org/D118327 to cases where results of comparisons are ORRed together, and where the comparison is performed with CCMP instead of CMP/SUBS
This is only used in one place? If so it might be simpler inline, or at least closer to the use.