[fpc-devel] Tail recursion optimization

Jonas Maebe jonas.maebe at elis.ugent.be
Tue Oct 10 10:45:44 CEST 2006


On 10 okt 2006, at 10:34, Florian Klaempfl wrote:

> 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.

Which means that the parameter values cannot be properly seen in the  
debugger, no? Also, do you actually insert goto/label nodes? That  
would degrade the performance of the register variable assignment  
because of the current limitations concerning flow analysis (i.e.,  
for sufficiently complex routines, the tail recursion optimization  
may currently result in performance degradation rather than  
improvement compared to using regvars without it).

>> 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.

{$optimization nostackframe}

should work.


Jonas



More information about the fpc-devel mailing list