[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.

Ryan

On Thu, Feb 16, 2017 at 2:23 PM, Tim Northover <t.p.northover at gmail.com>
wrote:

> 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.
>
> Tim.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170216/1e8f6900/attachment.html>


More information about the llvm-dev mailing list