https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91680
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- It is not that easy. For C99 1 << 31 is UB, but for C89 it is unclear, and I believe in C++ it is well defined, similarly in the middle-end it is well defined. So, while 1 << x is a power of 2, possibly negative, (unsigned long long) (1 << x) is only power of two if x is not 31, otherwise it is -2147483648ULL. Guess for 256 / q we could still optimize it because 256 / -2147483648ULL == 0 == 256 >> 31, but we can't do that for arbitrary dividend (e.g. variable), where we can't prove that it makes no difference.