Re:How many registers does an x86-64 CPU have?
by gpderetta on Monday November 30, 2020 @11:31AM
(#25255539)
The number of architectural registers are still relevant for register allocation because of course overlapping and independent code sequences cannot share the same architectural register name. This is not very important for integer loads, but still relevant for FP where optimal scheduling requires having multiple computations in flight at the same time. In some cases 16 FP registers are not enough and Intel had to add 16 more FP registers with AVX512.
[ Parent
| on HN ]
Re:How many registers does an x86-64 CPU have?
by nx7487 on Monday November 30, 2020 @05:53PM
(#25260086)
Oh: to clarify, you mean that the compiler could just use stack slots for everything, but some instructions are only allowed to operate on architectural registers, right? If you have to execute a lot of those instructions, the number of architectural registers can be the bottleneck in performance?
Re:How many registers does an x86-64 CPU have?
by easde on Monday November 30, 2020 @10:46PM
(#25262077)
Yes, consider vector floating point fused multiply-add (FMA). On a typical AVX implementation like Skylake, this instruction has a latency of 4 cycles and a throughput of 2 instructions per cycle. To avoid stalls, you'd need 4 * 2 = 8 instructions to run independently, and 8 architectural registers to simply store the results. You could store the results onto the stack and reuse the same architectural registers, but usually you want to use the values immediately in the next loop iteration (eg. matrix multiply) so this would be expensive. You probably want a few more architectural registers (at the very least 2, up to 16) to hold the inputs as well.
Re:How many registers does an x86-64 CPU have?
by gpderetta on Tuesday December 01, 2020 @05:26AM
(#25264026)
exactly this. Thanks for the practical example.
The reason it is less relevant for integer computations is that integer ops have normally lower latency and tend to have shorter loop carried dependency chains.