[llvm-commits] [PATCH] optimization of max-like struct for x86

Stephen Canon scanon at apple.com
Wed Apr 25 13:56:37 PDT 2012


I assume that should be cmova or cmovg; you can't determine if b > a from the sign of b - a (due to overflow).

- Steve

On Apr 25, 2012, at 4:52 PM, Manman Ren <mren at apple.com> wrote:

> Hi Sean,
> 
> Thanks for providing the feedback.
> This patch will generate 
> xorl %ecx, %ecx
> subl %edx, %eax
> cmovsl %ecx, %eax
> while the proposed sequence has a dependency chain from 1st instruction to 2nd then to 3rd.
> 
> -- Manman
> 
> On Apr 25, 2012, at 11:01 AM, Sean Silva <silvas at purdue.edu> wrote:
> 
>> Why not turn it into e.g.
>> 
>> cmp ebx, eax
>> cmovg ebx, eax
>> sub ebx, eax
>> 
>> ?
>> 
>> --Sean Silva
>> 
>> 
>> 
>> On Wed, Apr 25, 2012 at 12:33 PM, Manman Ren <mren at apple.com> wrote:
>> 
>> This patch is intended to optimize the following cases for x86:
>> (b > a) ? (b-a) : 0
>> (a < b) ? (b-a) : 0
>> It will use cmovs in generated x86 code.
>> 
>> The patch modified one source file: lib/Target/X86/X86ISelLowering.cpp
>> 
>> Please review & provide feedback.
>> Thanks,
>> 
>> 
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120425/bd7e3d36/attachment.html>


More information about the llvm-commits mailing list