Closed
Description
https://godbolt.org/z/Mh7q8TY99
InstCombine is able to fold (x & 0xFF) < C)
into (x & -C) == 0
eg:
bool ult32_u32(u32 x) { return (x & 0xFF) < 32; }
produces
ult32_u32:
tst w0, #0xe0
cset w0, eq
ret
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:
bool ult32_u8(u8 x) { return x < 32; }
ult32_u8:
and w8, w0, #0xff
cmp w8, #32
cset w0, lo
ret