[Bug c/48812] optimizing integer power of 2

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Apr 29 09:45:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48812

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-04-29 09:43:16 UTC ---
We do not exploit the fact that shifts bigger than the width of the type
are undefined (in fact we even try to preserve the fact that some CPUs
truncate the shift count when constant folding ...).

We also have to make sure the shift count does not get negative, which
we can't in this case.  Thus (1U<<(b-2)) is not equivalent to
(1U<<b) / 4.



More information about the Gcc-bugs mailing list