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]

Re: proper tail recursion for gcc


On Wed, Jul 19, 2000 at 11:06:08PM -0700, Geoff Keating wrote:
> 
> Mark Probst <schani@mips.complang.tuwien.ac.at> writes:
> 
> > i want to implement proper tail recursion for a much broader set of
> > cases than is currently implemented.
> ...
> 
> I think you'll find this has already been done in the development gcc.
> It's the 'sibling call' optimisation.

It's not as complete as a Scheme compiler is required to implement.
The Scheme standard requires sibcall optimization for *every* function
call followed immediately by a return from the current function.  We
only seem to do the optimization when the argument lists and return
types are identical.

Consider, for instance:

foo(a, b)
{
  c = calculate_bar(a, b);
  foo_with_bar(a, b, c);
}

foo_with_bar(a, b, c)
{
  ...
}

We don't sibcall optimize this, but we could and probably should.
[Perhaps this is the sort of thing that would be handled by the
"better tree-based sibcall optimizer" coming RSN?]

zw

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