[fpc-devel] Tail recursion optimization

Jonas Maebe jonas.maebe at elis.ugent.be
Tue Oct 10 11:27:03 CEST 2006


On 10 okt 2006, at 11:09, Florian Klaempfl wrote:

>> 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).
>
> The recursive call is usually inside an if anyways so the ssa  
> optimizer is lost
> anyways, no?

For the part inside the if: yes. But not for the part coming before  
it. What's more important however is that goto/label not only removes  
the usage of SSA, it also means that all register variables are  
allocated at the start of the function and only freed at the end.  
Without goto/label, register variables are only allocated between  
their first and last use (usage in a loop means allocation until the  
end of that loop).

> BTW: Does the assembler optimizer track flag usage? Then we could  
> remove some of
> the 	
>
> movl	%esi,%eax
> incl	%eax
>
> like pairs.

There's a FlagsUsed field in the ttaiprop record which is set to true  
if the flags result of that instruction is used.


Jonas



More information about the fpc-devel mailing list