[llvm-dev] Unsigned int displaying as negative
Ryan Taylor via llvm-dev
llvm-dev at lists.llvm.org
Thu Feb 16 11:34:24 PST 2017
Yes, I saw that ARM has them as intrinsics. Hexagon has them also ( most
embedded archs are going to support saturate is my understanding) but I'm
not sure yet how they are doing it, it doesn't look like intrinsics though.
On Thu, Feb 16, 2017 at 2:23 PM, Tim Northover <t.p.northover at gmail.com>
> On 16 February 2017 at 10:15, Ryan Taylor <ryta1203 at gmail.com> wrote:
> > The issue is saturation is treated differently for signed than it is for
> > unsigned.
> 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".
> ARM has some saturating instructions too. The only way to access them
> is via intrinsics, both at the C level and LLVM IR.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev