IT lexicon › Programming › DAGCombiner

DAGCombiner

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

LLVM's peephole optimizer for the SelectionDAG: thousands of patterns rewriting nodes into cheaper nodes, before and between the stages of instruction selection.

Lowering a function to a SelectionDAG creates fresh redundancies the IR-level optimizer never saw, mostly through type legalization, which splits wide integers and widens narrow ones. So DAGCombiner runs several times: right after the graph is built, after type legalization and after operation legalization. It folds (add x, 0), simplifies shifts and masks, merges loads, and hands every target a hook, PerformDAGCombine, for patterns of its own.

It's a sibling of InstCombine and shares its affliction: a long list of hand-written rules in one of LLVM's largest source files, where two rules occasionally rewrite back and forth forever. GlobalISel replaces it with a combiner whose rules are written in TableGen instead.

← Back to the lexicon