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

Sean Silva silvas at purdue.edu
Sun Jun 3 12:16:54 PDT 2012


Can you check that the `SubInstr->setDesc(get(*));` calls all get factored
out of the switch into a single call? I have seen cases where similar
constructs do not get factored out and it causes code bloat. If they
aren't, replacing the cases with something like

case X86::SUB64rr:   NewOpcode = X86::CMP64rr;   break;

and then doing `SubInstr->setDesc(get(NewOpcode));` at the bottom should
help reduce code size.

--Sean Silva

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

>
> SUB with memory operand should not be optimized.
> Updated patch is attached.
>
> Manman
>
>
> On May 30, 2012, at 11:44 AM, Manman Ren wrote:
>
> >
> > Hi All,
> >
> > This patch is to optimize generated code from
> >       movq    %rdi, %rax
> >       subq    %rsi, %rax
> >       cmovsq  %rsi, %rdi
> >       movq    %rdi, %rax
> >
> > to
> >       cmpq    %rsi, %rdi
> >       cmovsq  %rsi, %rdi
> >       movq    %rdi, %rax
> >
> > The only criterion to perform this optimization is that the actual
> result of SUB is not used.
> >
> > Thanks,
> > Manman
> >
> > <convert_sub_to_cmp.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/20120603/4f5a583f/attachment.html>


More information about the llvm-commits mailing list