On Dec 20, 2007, at 5:03 PM, Vincent Lefevre wrote:
On 2007-12-20 17:59:25 +1100, Joshua Root wrote:
[1] <http://lixom.net/~olof/64bit-perf.pdf> [2] <http://www.geekpatrol.ca/2006/09/32-bit-vs-64-bit-performance/>
I don't understand why they say that 5 instructions are needed for constants in 64-bit binaries. Can't the PowerPC load the constant from the memory with a single instruction? This is the solution chosen on the ARM for complex constants (if they are in the cache, this should be fast enough). But many constants are simple enough to be loaded with a single instruction (on the ARM, these are 8-bit values rotated by an even number of positions), in particular after optimizing the code.
If I remember correctly, all powerpc instructions have a length of 32 bit. Given that you need some bits for the opcode, a mere 16 bit remain to stuff a constant value to it (for the load high/add intermediate instructions). So, for a 64 bit value to load, you need to do a -2x loadhigh (2x high 16 bit) -2x add immediate (2x low 16 bit) -1x some combine statement (some shift operation or whatever) Keep in mind that these 64 bit constants only cost you for pointers. If you want a 32 bit integer, you don't need to load 64 bit -- even in 64 bit mode. Regards, -Markus -- Dipl. Inf. (FH) Markus W. Weissmann http://www.macports.org/ http://www.mweissmann.de/