<div dir="ltr"><div>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.</div><div><br></div><div>Ryan</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 16, 2017 at 2:23 PM, Tim Northover <span dir="ltr"><<a href="mailto:t.p.northover@gmail.com" target="_blank">t.p.northover@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On 16 February 2017 at 10:15, Ryan Taylor <<a href="mailto:ryta1203@gmail.com">ryta1203@gmail.com</a>> wrote:<br>
> The issue is saturation is treated differently for signed than it is for<br>
> unsigned.<br>
<br>
</span>Saturation is overflow, which means it's not allowed in C for unsigned<br>
integer types (they have to wrap) and irrelevant for signed (as soon<br>
as you overflow you're in undefined behaviour territory). LLVM IR<br>
follows C and doesn't represent saturation -- in particular<br>
optimization passes before CodeGen will be very happy to change your<br>
results if you're relying on it, with or without "nsw".<br>
<br>
ARM has some saturating instructions too. The only way to access them<br>
is via intrinsics, both at the C level and LLVM IR.<br>
<span class="HOEnZb"><font color="#888888"><br>
Tim.<br>
</font></span></blockquote></div><br></div>