This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Recursion Optimization
- To: Kevin Atkinson <kevinatk at home dot com>
- Subject: Re: Recursion Optimization
- From: Andreas Schwab <schwab at suse dot de>
- Date: 16 Aug 1999 11:02:22 +0200
- Cc: gcc at gcc dot gnu dot org
- References: <37B7C021.4068385F@home.com>
Kevin Atkinson <kevinatk@home.com> writes:
|> Does gcc optimize in any way to minimize the cost of recursive functions
|> calls. In particular:
|>
|> ONE:
|>
|> Does gcc optimize tail recursive functions into simple loops?
|>
|> TWO:
|>
|> In a function call like this:
|>
|> int sum(int i, int stop) {
|> if (i == stop) return i;
|> else return sum(i+1, stop) + i;
|> }
This is not a tail recursive function.
|> Will gcc recognize that the value of the second parameter never changes
|> so that it can avoid allocating multiple copies of it on the stack.
This cannot be avoided.
--
Andreas Schwab "And now for something
schwab@suse.de completely different."
SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg