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

--- Comment #11 from thopre01 at gcc dot gnu.org ---
Confirmed. This is because the compiler will detect that the result of (a >> 8)
depends on the sign of a and thus prevent the optimization. Before this check
incorrect code could be generated. Of course in this case since the high bit or
discarded with a bitwise AND it is safe.

It is possible to detect this by marking the byte with unknown content with a
special marker (say 0xff) instead of cancelling the optimization and modify a
few places which checks for marker. This can be done for 4.10 but seems to me
to invasive for 4.8 and 4.9 where this patch was backported. If you disagree
with this we can discuss with the release manager once the patch made to see if
they would agree for a backport.

Thanks for your report.

Reply via email to