IT lexicon › Programming › Three-address code

Three-address code

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

An intermediate representation in which each instruction has at most three operands, typically x = y op z.

An expression like a = b * c + d gets flattened into t1 = b * c and a = t1 + d, with t1 a temporary the compiler made up. Every intermediate result now has a name, and that is what makes optimisation possible: you can reason about t1, move it, reuse it or throw it away. The form got its textbook treatment in Aho, Sethi and Ullman's 1986 "Dragon Book", which distinguishes quadruples (operation, two operands, result) from triples, where a result is identified by its position.

Underneath, nearly every modern IR is three-address code. LLVM IR is three-address code in SSA form, where each temporary may be assigned only once. What really separates the generations is how many temporaries the compiler is willing to pretend it has registers for.

← Back to the lexicon