I noticed that GHC's code generator does not currently output assembly that uses any of the lower machine registers like al
. Even byte-size operations are implemented using rax
on 64 bit and eax
on 32 bit machines. GCC, however, frequently makes use of these smaller registers.
Are there any real performance benefits of using small registers like al
?
One suggestion I've heard so far is that the opcode for inc al
is smaller than inc rax
(but not smaller than inc eax
). Are there other, non-performance considerations why to use small registers?
Using the 64-bit registers (rxx) on x86-64 requires opcode-prefixes. Thus the instructions are longer, taking more space in memory and the instruction cache. I don't know if it also slows down decoding. The code-size could hurt performance if the bigger code is used in a loop that doesn't fit into the L1 instruction cache.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With