Closed Kmeakin closed 1 month ago
@llvm/issue-subscribers-backend-aarch64
Author: Karl Meakin (Kmeakin)
Hi @Kmeakin
Orthogonal to the root issue, shouldn't (x & -C) != 0
be (x & -C) == 0
instead?
Because, as per my understanding, tst a, b
will set Z
flag only if a&b
is zero, and unless Z
flag is set cset a, eq
will not set a
.
I'd like to work on this issue, if possible? Please assign me?
Hi @Kmeakin Orthogonal to the root issue, shouldn't
(x & -C) != 0
be(x & -C) == 0
instead?Because, as per my understanding,
tst a, b
will setZ
flag only ifa&b
is zero, and unlessZ
flag is setcset a, eq
will not seta
.
Yes, that was a typo, thanks
https://godbolt.org/z/Mh7q8TY99
InstCombine is able to fold
(x & 0xFF) < C)
into(x & -C) == 0
eg:
produces
But the same transform is not done in later stages, so if the and is introduced due to eg passing a u8 in a u32 register, the fold is not performed: