On Mon, 2007-10-22 at 16:32 +0200, Paolo Bonzini wrote: > I don't know what you mean, but yes, there is value in going to SSA and > back. SSA makes global optimization much easier, and that's the main > improvement introduced in GCC 4.0 and later refined.
IMHO gcc was pretty crappy until 4.0. Now it generates good code. SSA is a robust representation which allows strong assurances that vagaries of the way the user wrote the source won't interfere with generating good assembler. Still .. the Felix generated version of Ackermann's function outperforms the almost identical C code by almost 2:1 on AMD64 .. I have no idea why, although I know what matters: the number of words pushed onto the stack each recursion is the only thing that actually affects performance. Gcc pointlessly unrolls the recursion -- this has no effect on the number of words pushed. It also makes a fairly serious mistake, in that the recursion calls the externally visible function, which is ABI compliant. It should generate a non-recursive wrapper, and then use a recursive inner function which uses an optimal but not necessarily ABI compliant interface. -- John Skaller <skaller at users dot sf dot net> Felix, successor to C++: http://felix.sf.net