IT lexicon › Programming › Phase-ordering problem

Phase-ordering problem

Programming På svenska → Updated: 2026-11-06

The fact that an optimizing compiler's output depends on the order its passes run in, and that no fixed order is best for every program.

Every pass both creates and destroys opportunities for the others. Inlining exposes constants for constant folding; folding makes branches dead; removing dead code shrinks functions until they are small enough to inline. Run the passes in the wrong order and something is missed; run everything repeatedly until nothing changes and you burn compile time with no guarantee of terminating. Register allocation versus instruction scheduling is the textbook pair: schedule first and register pressure rises, allocate first and the scheduler loses its freedom.

That is why -O2 is in practice a hand-tuned list, adjusted against benchmarks over decades. Research has tried exhaustive search, genetic algorithms and reinforcement learning — Meta's CompilerGym from 2021 turned the problem into a gym environment. E-graphs attack it from the other side by refusing to choose until the very end.

← Back to the lexicon