https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59533
--- Comment #8 from Oleg Endo <olegendo at gcc dot gnu.org> ---
(In reply to Oleg Endo from comment #7)
> If a shll is followed by a cbranch:
>
> unsigned int
> test_09_0 (int x, unsigned int y, unsigned int z)
> {
> return ~(x >> 31) ? y : z;
> }
>
> shll r4
> bf .L4
> mov r6,r5
> .L4:
> rts
> mov r5,r0
>
> it's better to use cmp/pz and invert the branch condition.
> Combine is looking for the following pattern:
>
... however, if the result of the shll is used afterwards, it's better to keep
it. For example triggered by this:
uint16_t crc16_ccitt(const uint8_t *buf, size_t size) {
size_t i;
uint32_t c, n;
for(i = 0, n = 0; i < size; i++) {
n ^= (buf[i] << 24);
for(c = 0; c < 8; c++) {
if(n & 0x80000000)
n = (n << 1) ^ 0x10210000;
else
n = (n << 1);
}
}
return n >> 16;
}