This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR/34012, fwprop does not look at rtx_costs


On Nov 8, 2007 6:18 PM, Paolo Bonzini <bonzini@gnu.org> wrote:
>
> Paolo Bonzini wrote:
> > Unlike CSE, fwprop has never looked at rtx_costs except for addressing
> > mode selection.  This causes pessimizations, for example when the same
> > expensive constant is used in many insns.  Then it is:
> >
> > 1) moved to a register by CSE
> >
> > 2) moved back as an immediate by fwprop
> >
> > 3) split, or reloaded, into a different register for every insn, causing
> > worse code overall.
> >
> > Example with -fno-forward-propagate:
> >
> >         movabsq $578721382704613384, %rax
> >         movq    %rsp, %rdi
> >         movq    %rax, (%rsp)
> >         movq    %rax, 8(%rsp)
> >         movq    %rax, 16(%rsp)
> >         movq    %rax, 24(%rsp)
> >         movq    %rax, 32(%rsp)
> >         movq    %rax, 40(%rsp)
> >         movq    %rax, 48(%rsp)
> >         movq    %rax, 56(%rsp)
> >         movq    %rax, 64(%rsp)
> >         movq    %rax, 72(%rsp)
> >
> > becomes with fwprop enabled:
> >
> >         movabsq $578721382704613384, %rax
> >         movabsq $578721382704613384, %r11
> >         movq    %rax, (%rsp)
> >         movabsq $578721382704613384, %rax
> >         movq    %rsp, %rdi
> >         movq    %rax, 8(%rsp)
> >         movabsq $578721382704613384, %r10
> >         movabsq $578721382704613384, %r9
> >         movabsq $578721382704613384, %r8
> >         movabsq $578721382704613384, %rsi
> >         movabsq $578721382704613384, %rcx
> >         movabsq $578721382704613384, %rdx
> >         movabsq $578721382704613384, %rax
> >         movq    %r11, 16(%rsp)
> >         movq    %r10, 24(%rsp)
> >         movq    %r9, 32(%rsp)
> >         movq    %r8, 40(%rsp)
> >         movq    %rsi, 48(%rsp)
> >         movq    %rcx, 56(%rsp)
> >         movq    %rdx, 64(%rsp)
> >         movq    %rax, 72(%rsp)
> >
> > The solution is to reject replacing a value if it makes the destination
> > of the propagation more expensive.
> >
> > Ok?
>
> Bootstrapped/regtested by Jakub on x86_64-linux, ppc64-linux (-m64
> default) and ia64-linux.  No regressions.

This is ok.  Please watch for any negative effects of this.

Thanks,
Richard.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]