http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56051
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED AssignedTo|unassigned at gcc dot |jakub at gcc dot gnu.org |gnu.org | --- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-01-20 16:46:04 UTC --- Created attachment 29227 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29227 gcc48-pr56051.patch Untested fix. As the testcase shows, also a widening conversion can be a problem, if it extends from signed integral type to wider unsigned one, because then for Y equal to bitsize of the narrower type - 1 we get more than one bit set. On the other side, the optimization doesn't hit when X isn't an ARRAY_REF, but just an integral variable, because then arg0 and arg1 are swapped. Guess for 4.9 we should handle those cases too.