[llvm-commits] [PATCH] Replace SUB with CMP if possible on X86

Duncan Sands baldrick at free.fr
Thu May 31 08:24:24 PDT 2012


Hi Manman,

> (x -y<  0) is not equivalent to (x<  y) due to overflowing cases.

I guess that's why Nadav's example had the nsw flag.  Thanks to that flag,
either x-y overflows and thus it doesn't matter what the result of the test
is because you invoked undefined behaviour; or x-y does not overflow, in
which case x-y<0 will have the same result as x<y.

Ciao, Duncan.

>
> Thanks,
> Manman
>
> On May 31, 2012, at 1:14 AM, Rotem, Nadav wrote:
>
>> Hi Manman,
>>
>> I think that I missed the previous discussion, but I have a general questions.
>>
>> Why don't you replace the sequence:
>>
>> +  %sub = sub nsw i64 %x, %y
>> +  %cmp = icmp slt i64 %sub, 0
>>
>> With
>>
>> cmp slt %x, %y ?
>>
>>
>> Nadav
>>
>> -----Original Message-----
>> From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits-bounces at cs.uiuc.edu] On Behalf Of Manman Ren
>> Sent: Wednesday, May 30, 2012 23:55
>> To: llvm-commits at cs.uiuc.edu
>> Subject: Re: [llvm-commits] [PATCH] Replace SUB with CMP if possible on X86
>>
>>
>> SUB with memory operand should not be optimized.
>> Updated patch is attached.
>>
>> Manman
>> ---------------------------------------------------------------------
>> Intel Israel (74) Limited
>>
>> This e-mail and any attachments may contain confidential material for
>> the sole use of the intended recipient(s). Any review or distribution
>> by others is strictly prohibited. If you are not the intended
>> recipient, please contact the sender and delete all copies.
>>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list