[llvm-commits] [PATCH] Peephole optimization to remove redundant cmp instruction for X86

Chandler Carruth chandlerc at google.com
Wed May 30 23:16:02 PDT 2012


Please ping within the same thread... Pretty sure we already talked about
this patch on another thread, but hard to remember.


Anyways, I'm not an x86 backend expert, but from my limited experience, I
have some concerns with the patch as currently implemented. At a high
level, it seems overly focused on the 'sub' instruction. Given the model of
the EFLAGS set by each instruction, could you turn this into a generic
optimization which tries to remove 'cmp' instructions (which have no
side-effects other than to set EFLAGS) by using those flags set by
arbitrary preceding instructions?

Also, I wonder if the backend should have a model for equivalent
instruction forms where one does set EFLAGS and the other doesn't so that
we can flip instructions back and forth as needed.

Finally, I feel like a lot of the large switches over instructions could be
simplified by querying the nature of the EFLAGS usage, or some other shared
aspect embedded in the instruction via the tablegen file.


A minor style nit-pick: the coding guidelines recommend 'camelCase'
function and method names, not 'CamelCase'.



On Wed, May 30, 2012 at 8:55 PM, Manman Ren <mren at apple.com> wrote:

>
> PING
>
> On May 30, 2012, at 11:30 AM, Manman Ren wrote:
>
> >
> > Hi All,
> >
> > This patch optimizes away the redundant cmp instruction if there exists
> a sub instruction which produces the same EFLAGS.
> >
> > Please review and provide feedback.
> >
> > Thanks,
> > Manman
> >
> > <peephole_x86.patch>
>
> _______________________________________________
> 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/20120530/ab65a53f/attachment.html>


More information about the llvm-commits mailing list