[llvm-commits] [llvm] r100233 - in /llvm/trunk: ./ include/llvm/Support/ lib/Target/ARM/ lib/Target/ARM/Disassembler/ test/MC/Disassembler/ utils/TableGen/

Jakob Stoklund Olesen stoklund at 2pi.dk
Mon Apr 5 07:42:05 PDT 2010

On Apr 4, 2010, at 10:10 PM, Chris Lattner wrote:

> On Apr 4, 2010, at 9:30 PM, Jakob Stoklund Olesen wrote:
>>>> If you left-shift a positive number until it goes negative, that's an
>>>> overflow. At least that's how I understand it.
>>> You can shift left an N bit number between 0 and N-1 bits safely without overflow.
>> Only an unsigned number. From the C++0X working draft:
> LLVM makes this assumption all over the place, just like it assumes a two's complement representation and that 'unsigned' is 32-bits.  It is safe to rely on.

Hmm. Those are implementation defined. That's fine to rely on. This is undefined behaviour. We shouldn't rely on that.

Hey, we should add support for "shl nsw" to LLVM IR! Evaluating "shl nsw i32 %x, N" effectively asserts that the high N+1 bits of %x are 0. That would enable a number of optimizations and wonderfully educational surprises for users.

More information about the llvm-commits mailing list