[llvm-commits] [Patch] Optimize away a cmp instruction on X86

Chandler Carruth chandlerc at google.com
Tue May 29 12:42:34 PDT 2012


On Tue, May 29, 2012 at 12:27 PM, Manman Ren <mren at apple.com> wrote:

>
>
> This patch is to replace sub+cmp with X86ISD::SUB when possible, it does
> not touch the decision of whether we should use 'cmp+jmp' or 'cmov'.
>

Hmm, the oddity is that you do directly produce the CMOV ISD node. It looks
like this will only fire on 'sub+cmp+cmov', not 'sub+cmp+jmp'. I suppose
this is an artifact of this transform happening deep inside of the x86
backend, and so the decision of whether or not to use a branch vs. cmov has
long since happened? Making sure I understand what you're doing here...

If I've understood this correctly, wouldn't that mean that the same logic
will be needed again for code that emits the 'sub+cmp+jmp'? Is that already
handled somewhere?

All in all, I'm agreeing with a comment on this bit of code: should this
really be so specific? I'm seeing the possibility for a third copy of the
core functionality here, it would be great if there were a way to put this
into the dag-combine step, maybe even the target-independent dag-combine?
Haven't thought much about the feasibility of that though...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120529/20d1c6ad/attachment.html>


More information about the llvm-commits mailing list