[llvm-commits] [PATCH] Simplify negated bit test

Eli Friedman eli.friedman at gmail.com
Mon Dec 10 14:43:02 PST 2012


On Mon, Dec 10, 2012 at 2:36 PM, Jakub Staszak <kubastaszak at gmail.com> wrote:
> Benjamin,
>
> This optimization doesn't seem to change SHL right value, so I don't fully understand how it can invalidate the code.
> "isPowerOfTwo" from VT seems to be much better idea though.
>
> I am also a little bit surprised, that 1 << 32 is undef, but 2 << 31 is 0. LLVM docs say so, I just don't get why :)

Basically, we do this because the behavior of 2 << 31 is consistent
across architectures, but the behavior of 1 << 32 isn't (IIRC, the
latter returns 0 on PPC and 1 on x86).  Also, the C standard says the
same thing.

-Eli



More information about the llvm-commits mailing list