This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: inlining inefficiencies
- From: Daniel Berlin <dberlin at dberlin dot org>
- To: Dan Nicolaescu <dann at godzilla dot ICS dot UCI dot EDU>
- Cc: Kurt Garloff <garloff at suse dot de>, <gcc at gcc dot gnu dot org>,Andreas Jaeger <aj at suse dot de>
- Date: Thu, 30 May 2002 12:32:34 -0400 (EDT)
- Subject: Re: inlining inefficiencies
On Thu, 30 May 2002, Dan Nicolaescu wrote:
> Daniel Berlin <dberlin@dberlin.org> writes:
>
> > On Thu, 30 May 2002, Kurt Garloff wrote:
> >
> > > Hi Dan,
> > >
> > > On Wed, May 29, 2002 at 10:31:46PM -0700, Dan Nicolaescu wrote:
> > > > Andreas Jaeger <aj@suse.de> writes:
> > > >
> > > > > Can you have a look at Kurt Garloff's patches which have been
> > > > > discussed here some weeks agao? A current version is at
> > > > > http://www.garloff.de/kurt/freesoft/gcc/
> > > >
> > > > Those patches deal with deciding what functions to inline.
> > > > What I've shown is that the code generated after inlining all the
> > > > functions (desired in that case) is inefficient and the optimizers
> > > > can't deal with it.
> > >
> > > The problem that I spotted in gcc is that it's unable to remove
> > > temporaries too often. I have some Matrix class whose [] operator
> > > return a temporary object, basically having a pointer to the
> > > Matrix and the information which line was selected. This can
> > > be used to create a Vector or an element with a second [] and
> > > the temporary should be removed by the compiler.
> >
> > Just out of curiosity, does the patch I posted yesterday to make the
> > inliner
> > generate proper statement expressions help at all?
>
> It doesn't help the testcase I posted. The generated code is identical
> before and after your patch.
Yeah, I already tested it and found that out right before i got this.
ssa-ccp seems to help the bar function a lot, by noting that the values
it's storing into memory are constant.
The end result is that the stores get eliminated later:
[dberlin@dberlin dberlin]$ diff -c3pwBb before.s inlineeff.s
*** before.s 2002-05-30 11:43:47.000000000 -0400
--- inlineeff.s 2002-05-30 12:26:45.000000000 -0400
*************** _Z3barv:
*** 82,99 ****
.LFB3:
subl $20, %esp
.LCFI2:
- movl $123, 8(%esp)
- movl 8(%esp), %eax
- movl $428, 12(%esp)
- movl 12(%esp), %edx
- leal (%eax,%eax), %ecx
- movl %ecx, (%esp)
- leal (%edx,%edx), %eax
- movl %eax, 4(%esp)
- movl 4(%esp), %ecx
- movl (%esp), %eax
- movl %ecx, Zi+4
movl %eax, Zi
addl $20, %esp
ret
.LFE3:
--- 82,89 ----
.LFB3:
subl $20, %esp
.LCFI2:
movl %eax, Zi
+ movl %edx, Zi+4
addl $20, %esp
ret
.LFE3:
>