Developer replaces rat compiler's linear-scan allocator with a 584-line priority bin-packing design
The creator of the rat compiler backend rewrote its x86-64 register allocator, discarding a 1392-line linear scan implementation that had grown incrementally over time. The replacement is a priority bin-packing allocator of 584 lines that assigns virtual registers to physical registers or stack slots by visiting live ranges in order of importance rather than program order, similar in approach to LLVM's greedy allocator.
GoKawiil's interpretation of the reporting above, not reported fact.
The author reports that measuring which parts of the old allocator actually helped allowed most of its complexity to be discarded, suggesting that incremental software often accumulates unnecessary complexity over time. The change could offer a useful case study for compiler engineers on simplifying heuristic-based systems like register allocation, where optimal solutions are NP-hard and practical tools rely on approximations.
- rat's new register allocator shrank from 1392 lines to 584 lines while reportedly producing better code.
- The new allocator uses a priority bin-packing strategy, assigning important live ranges to registers first, akin to LLVM's greedy allocator.
- Register allocation must respect x86-64 calling conventions, including caller-saved and callee-saved register rules.
Source: hexrat.cc, 2026-10-10
Published there as: “Rat's Register Allocator”
Read the original report → The summary and analysis above are GoKawiil's own, written from reporting by the source above. Facts and quotes belong to the original publisher.