https://outerproduct.net/boring/2023-03-22_cpu-compiler-gc-ohmy.html A CPU is a compiler 2023-03-22 Strictly speaking, a CPU is an interpreter; it is certainly not a compiler and, unless you can come up with a second implementation of physics, the standard tricks to turn it into one won't work either. And yet, when comparing with software implementations of programming languages, a CPU seems closest to the back end of an optimising compiler; all sorts of duals seem to show up: Compiler CPU Notes Instruction Instruction scheduling scheduling JIT Microcoding, uop cache Branch Branch probability prediction I find the contrast here particularly analysis interesting. Inline cache Branch target buffer Instruction Fusion selection Register Register allocation renaming Coalescing Move elimination Alias analysis Memory disambiguation Scalar Memory replacement of renaming aggregates For instance, a compiler might recognise a sequence for performing a Peephole rotate, byte-swap, or population count, optimisations, Idioms when such functionality is supported idioms natively by the target, but not by the source. A CPU might recognise an xor or subtraction of a register from itself as producing a zero. Parallelising Superscalar compiler, CPU scheduler Pipelining, Pipelining memory-level Very different types of pipelining! parallelism Block, trace Trace I find it somewhat irksome that we don't refer to static register allocation and dynamic register allocation--etc.--as this would make the relationship between CPUs and compilers much clearer. Some of the ties here are admittedly too tenuous for this to really work out, but many are not. Here's some garbage collection, as a bonus: Garbage collector CPU Notes Generational garbage QLRU cache collection replacement Write barrier Snooping Read barrier TLB lookup Particularly a use barrier. Self-healing TLB miss/update Forwarding pointer Page table entry Snapshot or recolour roots TLB shootdown