[llvm-dev] [IR canonicalization] 6 ways to choose {-1,0,1}

Sanjay Patel via llvm-dev llvm-dev at lists.llvm.org
Mon Jul 10 10:34:22 PDT 2017


On Mon, Jul 10, 2017 at 11:13 AM, David Majnemer <david.majnemer at gmail.com>
wrote:

>
>> 5. Subs and shifts
>> int neg101_sub_shifty(int x, int y) {
>>   int r = (x - y) >> 31;
>>
>
> What if x is INT_MIN and y is greater than zero? Won't r be poison?
>
>
>>   r += (unsigned)(y - x) >> 31;
>>
>
> Ditto with respect to y being INT_MIN and x greater than zero.
>

Oops - yes. Ignore this option. When I initially modelled this case in
Alive, I only checked that the 'sub nsw' form could be transformed into a
form with cmp/select rather than the other way around:
http://rise4fun.com/Alive/SKBN
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170710/a2da432b/attachment.html>


More information about the llvm-dev mailing list