https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68000

--- Comment #2 from Marc Glisse <glisse at gcc dot gnu.org> ---
Independently of hoisting,

    mov   eax, edx
    add   edx, 1
    add   eax, 1

apparently we fail to CSE this because at the time of CSE, one addition is done
in mode QI and the other in SI, and it is only in split2 that the QI one is
promoted to SI, which is too late for CSE.


Actually, it is quite hard to notice that foo is equivalent to the other
versions. If you wrote: return (uint8_t)(p->x + 1) == p->y ? 0 : p->x + 1; it
would be much easier, and indeed I get better code. For the equivalence, the
compiler has to notice that the only case where the cast matters is when x is
255 and y is 0, and in that case both branches (after sinking the cast to
uint8_t from the return type) are equivalent.

Reply via email to