This is the mail archive of the gcc@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: optimizing calling conventions for function return


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 
> similar
> and place them out-of-line as a new function, and have that inline the 
> original
> 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)
  {
    if (!p)
      return;
    /* 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.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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