[fpc-devel] Tail recursion optimization

Florian Klaempfl florian at freepascal.org
Tue Oct 10 10:34:52 CEST 2006


Jonas Maebe wrote:
> 
> On 10 okt 2006, at 10:05, Daniƫl Mantione wrote:
> 
>> If the optimization needs significant processing power, -O3. If it
>> doesn't
>> but is debug safe, -O1, if it is not debug safe, -O2.
> 
> It's definitely not debug safe, since it messes up stack information.

Not really. I didn't try it yet but it shouldn't mess up much. The optimziation
is done completely on the node level, the pascal code would look like
http://www.hu.freepascal.org/fpcircbot/cgipastebin?msgid=156 except that there
are temps involved to calculate the new parameters because calculating one
parameter could require the original value of another one.

> 
>> A separate option -OoTAILREC is IMHO not necessary.
> 
> All possible optimizations have their -Oo-switch for individual enabling
> disabling (like regvars, peepholeopt, asmcse, stackframe, loopunroll).
> It's both useful for debugging the individual optimizations and in case
> a user's program is incompatible with a particular optimization (either
> due to a bug in the optimization or an inherent requirement -- 

So it will probably -OoTAILREC and automatically included in -O2.

> e.g., we
> could add -Oonostackframe at the end of the compiler switches for the
> RTL's object unit when compiling for x86).

What we still need are switches in the sources to enable particular optimizations.



More information about the fpc-devel mailing list