[Bug middle-end/64309] if (1 & (1 << n)) not simplified to if (n == 0)
rguenther at suse dot de
gcc-bugzilla@gcc.gnu.org
Tue Dec 16 08:54:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64309
--- Comment #13 from rguenther at suse dot de <rguenther at suse dot de> ---
On December 15, 2014 10:11:13 PM CET, "glisse at gcc dot gnu.org"
<gcc-bugzilla@gcc.gnu.org> wrote:
>https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64309
>
>--- Comment #12 from Marc Glisse <glisse at gcc dot gnu.org> ---
>(In reply to Marc Glisse from comment #11)
>> ((pow2<<p)&(pow2<<n))!=0 -> p==n
>
>Oups, it wasn't supposed to be the same power of 2, so:
>(((1<<k)<<p)&((1<<l)<<n))!=0 -> p==n+(l-k)
>(k and l are constants)
As others noted the transforms are only generally beneficial if they feed
comparisons. Otherwise we may of course want to find a canonical form, but
possibly that shouldn't be a comparison unless expansion knows how to undo this
and rewrite them as bit operation.
Richard.
More information about the Gcc-bugs
mailing list