This is the mail archive of the
mailing list for the GCC project.
Re: forcing tail/sibling call optimization
- To: "law at redhat dot com" <law at redhat dot com>
- Subject: Re: forcing tail/sibling call optimization
- From: "Geert Bosch" <bosch at gnat dot com>
- Date: Mon, 27 Nov 2000 12:39:46 -0500
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Reply-To: "Geert Bosch" <bosch at gnat dot com>
On Mon, 27 Nov 2000 09:26:06 -0700, Jeffrey A Law wrote:
If you _must_ have tail calls optimized to gotos, then write them that way
or use a language which guarantees tail calls will turn into gotos. If
tail call optimizations are merely convenience, then write them as calls :-)
The original request by Fergus Henderson was:
<<This feature is important for compilers of high-level functional and
logic programming languages that target C. For such languages,
recursion is the primary form of iteration, and it is important that
sibling calls be optimized. Often the high-level language compiler has
more information about when it is safe to do tail calls than gcc has,
but currently there is no way for the high-level language compiler to
communicate that to gcc.
The language C-- (see <www.cminusminus.org>), which is designed to be
ideal as a target language, provides this feature. I would like GNU C
to provide it too.>>
I think that adding extentions to GNU C in order to support the (changing)
C-- language is a bad idea. On the other hand, extending GCC to allow
front-ends to implement such a language seems like a worthwhile goal.
In order to write a GCC front-end for any language with proper
tail-recursion, there should be a way in the tree to represent a tail call.
If the GCC backend is not able to compile this on a certain architecture,
it abandons the compilation with an error.