[llvm-dev] Unsigned int displaying as negative
Jonas Maebe via llvm-dev
llvm-dev at lists.llvm.org
Thu Feb 16 11:35:55 PST 2017
On 16/02/17 20:23, Tim Northover via llvm-dev wrote:
> Saturation is overflow, which means it's not allowed in C for unsigned
> integer types (they have to wrap) and irrelevant for signed (as soon
> as you overflow you're in undefined behaviour territory). LLVM IR
> follows C and doesn't represent saturation -- in particular
> optimization passes before CodeGen will be very happy to change your
> results if you're relying on it, with or without "nsw".
Surely "signed overflow" does not result in undefined behaviour in LLVM
IR unless nsw is specified? Otherwise, the wording at
http://llvm.org/docs/LangRef.html should be changed, because right now
it strongly suggests to me that signed overflow will not cause any
problems unless nsw is specified.
Jonas
More information about the llvm-dev
mailing list