News for hackers. Stuff that matters.
Re:CPU registers and OCaml by userbinator on Sunday June 21, 2015 @10:27PM (#9755843)
The fact that x86 is not a "pure" register-only architecture also matters --- it also has register-memory/memory-register operations, and push/pop (1 byte each) for efficient saving and restoring of values.

I've looked at a lot of compiler-generated code, and compared to hand-written Asm (which I have also done quite a bit of), register allocation is one of the things that compilers are very noticeably worse at. Thanks to their use of spilling, which doesn't really apply to something like x86, they shuffle data between registers and memory far more than they have to, instead of keeping values in memory or registers and using memory-register operations (which automatically "allocate" one of the many unnamed registers on the CPU, via register renaming.) A nested use structure could be handled easily with push/pop. It's good to see that compilers are slowly moving in the direction of allocating registers like a human programmer would.

There are no comments on this comment yet.