[Bug middle-end/64309] if (1 & (1 << n)) not simplified to if (n == 0)
glisse at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Dec 15 20:19:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64309
--- Comment #6 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to Marek Polacek from comment #5)
> I don't think so. I tried to come up with a more general transformation
> that would simplify ((CST << n) & CST) != 0, but I haven't found anything
If both CST are (possibly different) powers of 2 it works. ((c<<n)&c)==c also
works. ((pow2<<p)&(pow2<<n))!=0.
> yet. So maybe just this?
> ((1 << n) & 1) != 0 -> n == 0
That looks like what richi posted. For scalars, != 0 is useless and this could
just be:
(1<<n)&1 -> n==0
> ((1 << n) & 1) == 0 -> n != 0
More information about the Gcc-bugs
mailing list