[std-interval] passing by value vs reference

Guillaume Melquiond guillaume.melquiond at ens-lyon.fr
Thu Apr 6 10:18:09 PDT 2006


Le mercredi 05 avril 2006 à 13:55 -0300, Fernando Cacciola a écrit :

> If  the FPU registers are stacked, like in the x86 family, it wouldn't
> be too uncommon, IMHO, for a compiler to do:

[...]

As a matter of fact, it would be really uncommon. For example, x86 ABIs
require the FPU stack to be empty (except maybe for arguments) at the
beginning of every functions. Otherwise the functions would cause FPU
stack overflows since they would have very little or no space left to do
their computations. Thanks to the empty stack, the compiler knows that
it can use eight FPU registers without crashing the whole process. So
for the particular example of (a*b)*(c*d), there is no way for a
compiler to avoid temporarily storing the result of a*b on the memory
stack.

> That is, stacked FPU registers allows the compiler to allocate the
> function frames (which is the problem in your example) without using
> the external memory-based stack or rearranging the registers
> manually. 

As a side note on this topic, stacked FPU registers seemed like a good
idea thirty years ago. But now that the technology has evolved and has
gone past GHz speeds, this good idea has become a nightmare for
processor designers. Translating stack positions to standard bank
positions incur a huge latency in decoding FPU instructions in the
processor. This translation work is better done once and for all at
compilation time. I would be really surprised if a modern processor
(that is not plagued by backward compatibility concerns) implements
stacked FPU registers.

Best regards,

Guillaume




More information about the Std-interval mailing list