IT lexicon › Programming › Worklist algorithm

Worklist algorithm

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

How to solve a data-flow problem without recomputing what hasn't changed: keep a list of what needs another look, and pay only for that.

The naive way to solve a data-flow analysis is to sweep every basic block over and over until nothing changes. A worklist does the same thing with less waste. Every block goes on the list at the start; when one is taken off, its output is recomputed, and only if the result changed do its successors — or predecessors, for backward problems such as liveness analysis — go back on. An empty list means you have reached the fixed point.

Termination is guaranteed because facts only ever move in one direction through a lattice of finite height, which was Gary Kildall's insight in 1973. The order doesn't affect the answer, only the time: reverse postorder for forward problems usually gets most of the work done on the first pass. The same pattern turns up everywhere. SCCP keeps two worklists, one for edges and one for SSA values, and InstCombine is at heart a worklist with pattern rules attached.

← Back to the lexicon