Value Numbering and Common Subexpressions
Recognize two computations with the same value and check that a reusable definition dominates the second use.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 2
- Reading time
- 1 min
In this article2 chapters
Assign identities to expressions, not just source variables
For a pure operation, form a signature from its operation, result type, relevant semantic flags and operand value numbers. Reusing a signature says the computations agree under those semantics. If a block computes \(a+b\) twice with unchanged operands, the second can reuse the first. For an associative or commutative operation the language must justify the precise normalization. Floating-point reassociation often changes rounding.
Availability is a path property
A particular computed value must be available on every path to the replacement point. The same signature occurring separately on two branches may require a phi at their merge. Loads need stronger justification because a store or call could change their result. Alias analysis helps identify conflicting memory effects. Dominance provides a structural availability check. Equality saturation retains many equivalent expressions rather than one chosen representative.[1][2]