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: optimising recursive functions


On Sat, 2007-10-27 at 12:54 +0200, Richard Guenther wrote:
> On 10/27/07, Robert Dewar <dewar@adacore.com> wrote:
> > skaller wrote:
> >
> > > So I am guessing the Felix version is lucky there are
> > > no gratuitous temporaries to be saved when this happens,
> > > and the C code is unlucky and there are.
> > >
> > > Maybe someone who knows how the optimiser works can comment?
> >
> > One problem with departing from the ABI even on a local level
> > like this is that it wipes out lots of tools that depend on
> > ABI compliance for the entire call chain. I suspect the overall
> > gain is too small to be worth this hit.
> 
> If you make the function static then gcc can chose ABI-incompatible
> calling conventions.

Yes, but to do so is reasonably hard because the choice of ABI
now depends on usage, which is scoped to the whole translation unit.

With a nested local function, it is scoped only to the parent
function, and in the simple wrapper case there is only one
call from the parent to the nested child, which doesn't have
any performance constraints on it. So the only calls that
matter when chosing the parameter passing model are the 
recursive ones inside the local wrapper.

It is probably still 'hard' to choose a good parameter passing
model even then. I used to write a lot of assembler code
and always grappled with this.

-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


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