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

Chris Lattner clattner at apple.com
Mon Apr 5 13:09:55 PDT 2010

On Apr 5, 2010, at 7:42 AM, Jakob Stoklund Olesen wrote:
>> 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.

Implementations are free to define undefined behavior.  If you want to use an unsigned shift left to be really careful, go for it.


More information about the llvm-commits mailing list