This is the mail archive of the
mailing list for the GCC project.
Re: optimizing calling conventions for function return
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Joern RENNECKE <joern dot rennecke at st dot com>
- Cc: Jon Smirl <jonsmirl at gmail dot com>, Geert Bosch <bosch at adacore dot com>, gcc at gcc dot gnu dot org
- Date: Fri, 26 May 2006 11:37:34 +0930
- Subject: Re: optimizing calling conventions for function return
- References: <4475F36F.firstname.lastname@example.org>
On Thu, May 25, 2006 at 07:11:59PM +0100, Joern RENNECKE wrote:
> In http://gcc.gnu.org/ml/gcc/2006-05/msg00604.html, you wrote:
> >The sequence of call, test, jne (or slight variations) occurs in
> >1000's of places, if a better alternative can be found there could be
> >significant perofrmance gains.
> If the time taken to do the test and branch is really significant compared
> to the time taken by the called function, the called function probably has
> the grong interface; the loop should be in the callee.
> I.e. like using fgetc when you should be using fread.
> Now, and interesting compiler project would be to do this re-factoring
> automatically in the compiler... standard inlining will do that, but with
> a lot of code expansion. It might be more useful to find loops that are
> and place them out-of-line as a new function, and have that inline the
> callee. Maybe something for the next Summer Of Code...
Another optimisation that would really help is avoiding function
prologue and epilogue code for functions that make an early exit.
eg. code like
void foo (void *p)
/* do lots of stuff here. */
Currently we make a stack frame, save all callee saved regs used by "do
lots of stuff", then test p. On the early exit, we restore all those
regs and tear down the stack frame. It would be nice if all this work
could be avoided, particularly since the register restores can cause
load-hit-store cache stalls.
Both of these problems could be solved (at least for static functions)
by some sort of partial function inlining.
IBM OzLabs - Linux Technology Centre