Rat's register allocator: a 584-line priority bin-packing allocator that beats its 1392-line predecessor

Rat, a compiler backend, replaced its 1392-line linear scan allocator with a 584-line priority bin-packing allocator. The new allocator visits live ranges by importance, assigns registers to bundles, and spills when necessary. It produces better code, automatically placing values that cross calls into callee-saved registers without explicit rules. The design omits eviction, splitting, and iterative passes, yet measurements show minimal loss.

No code in the allocator says "put values that cross a call in callee-saved registers". It falls out of the design, and that is my favourite part.

More from this day

2026-10-11