What are the benefits of using smaller registers, e.g. al vs eax / rax
assembly, compiler-construction
Solution
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.
Problem
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?