HomeAlgorithms & AIRegister Allocation via Graph Coloring

Register Allocation via Graph Coloring

Watch a compiler's interference graph get simplified, spilled and colored in real time: Chaitin's simplify/select register-allocation algorithm rendered as a live 3D force-directed graph with K physical registers.

Algorithms & AI3DAdvanced60 FPS📱 Mobile-adapted⇄ 2D version
graph-coloring-register-allocation ↗ Open standalone

Compilers cannot give every variable its own physical register — CPUs only have a handful (K), while a function may juggle dozens of live values. The classic solution, due to Chaitin, models the problem as graph coloring: build an interference graph where virtual registers that are live at the same time are connected, then try to K-color it so connected registers get different physical registers. This simulator runs the real simplify/select algorithm — repeatedly stripping low-degree, guaranteed-colorable nodes onto a stack, optimistically spilling when none remain, then popping the stack and assigning the lowest free color — on a live 3D force-directed interference graph, so you can watch exactly which virtual registers get a physical register and which get spilled to memory as K, graph size, and density change.

⚙ Under the hood

Watch a compiler's interference graph get simplified, spilled and colored in real time with Chaitin's simplify/select register-allocation algorithm, rendered as a live 3D force-directed graph with a configurable number of physical registers.

compilersgraph-coloringregister-allocationalgorithmschaitindata-structures

3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)