[LLVMdev] [RFC] Integer Saturation Intrinsics

Herbie Robinson HerbieRobinson at verizon.net
Thu Jan 15 09:39:55 PST 2015


I would recommend that such optimizations not be done.  At least where I 
have seen saturation arithmetic done before is with thing like digital 
signal processing.  In that cse, the programmers will generally be very 
careful to craft exactly what they want... efficiently.

On 1/15/15 5:33 AM, David Chisnall wrote:
> 2) How do you imagine this being used and what are the guarantees for sequences of operations with respect to optimisation?  If I do a+b-c (or +c where c is negative), and a+b would saturate, but a+(b-c) would not, then is it allowed for an optimiser to generate the second rather than the first?  If it's an intrinsic that's opaque to optimisers, then that's not a problem for correctness, but then you'll miss some potentially beneficial optimisations.
>
> David
>
>> On 14 Jan 2015, at 22:08, Ahmed Bougacha <ahmed.bougacha at gmail.com> wrote:
>>
>> Hi all,
>>
>> The patches linked below introduce a new family of intrinsics, for
>> integer saturation: @llvm.usat, and @llvm.ssat (unsigned/signed).
>> Quoting the added documentation:
>>
>>




More information about the llvm-dev mailing list