IT lexicon › Programming › CFG simplification (SimplifyCFG)

CFG simplification (SimplifyCFG)

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

A clean-up pass that shrinks the control-flow graph: merging blocks, deleting empty and unreachable ones, and folding branches whose outcome is already known.

Other optimisations leave debris in the graph — blocks that do nothing but jump onwards, branches on constants, two consecutive blocks that might as well be one. LLVM's SimplifyCFG deals with all of it, and also does more aggressive things: a short if-else that merely picks between two values becomes a branch-free select, and a chain of comparisons against the same variable becomes a switch.

It runs many times across LLVM's pipeline, because nearly every other transformation creates fresh work for it. GCC keeps the equivalent logic in cfgcleanup. Nobody writes papers about it, but a compiler without it would have every later pass wasting time on hundreds of blocks that do nothing at all.

← Back to the lexicon