Value numbering
Value numbering is a technique of determining when two computations in a program are equivalent and eliminating one of them with a semantics-preserving optimization.[src]
Value numbering is a technique of determining when two computations in a program are equivalent and eliminating one of them with a semantics-preserving optimization.[src] ==Global value numbering== Global value numbering (GVN) is a compiler optimization based on the static single-assignment form (SSA) intermediate representation.[src] It sometimes helps eliminate redundant code that common subexpression elimination (CSE) does not.[src] At the same time, however, CSE may eliminate code that GVN does not, so both are often found in modern compilers.[src] Global value numbering is distinct from local value numbering in that the value-number mappings hold across basic block boundaries as well, and different algorithms are used to compute the mappings.[src] Global value numbering works by assigning a value number to variables and expressions.[src] The same value number is assigned to those variables and expressions which are equivalent.[src] For instance, in the following code: w := 3 x := 3 y := x + 4 z := w + 4 a good GVN routine would assign the same value number to w and x , and the same value number to y and z .[src] For instance, the map \left\{ {w} \mapsto 1, {x} \mapsto 1, {y} \mapsto 2, {z} \mapsto 2 \right\} would constitute an optimal value-number mapping for this block.[src] Using this information, the previous code fragment may be safely transformed into: w := 3 x := w y := w + 4 z := y Depending on the code following this fragment, copy propagation may be able to remove the assignments to x and to z .[src] The reason that GVN is sometimes more powerful than CSE comes from the fact that CSE matches lexically identical expressions whereas the GVN tries to determine an underlying equivalence.[src] For instance, in the code: a := c × d e := c f := e × d Without copy propagation, CSE would not eliminate the recomputation assigned to f , but even a poor GVN algorithm should discover and eliminate this redundancy.[src] In IRs and source languages where rebinding (assigning to the same variable more than once) is possible, SSA form is required to perform GVN so that false \left\{ \text{variable name} \mapsto \text{value number} \right\} mappings are not created.[src] ==Local value numbering== Local value numbering (LVN) is a compiler optimization that aims to find multiple instances of equivalent expressions (i.e.[src] expressions which yield the same result) and replace them with the first occurrence.[src] LVN is a local optimization, meaning that unlike global value numbering, it operates on a single basic block at a time.[src] Local value numbering works by assigning a unique number to each operation and remembering these associations.[src] Subsequent instructions are then looked up and, in case an identical instruction has already been registered, replaced with the previous instruction's result.[src] For example: a ← 4 a is tagged as #1 b ← 5 b is tagged as #2 c ← a + b c (#1 + #2) is tagged as #3 d ← 5 d is tagged as #2, the same as b e ← a + d e, being '#1 + #2' is tagged as #3 By assigning numbers to instructions, comparing for duplicates is turned into simple integer comparisons.[src] In this particular example, c and e are assigned the same number (#3), thus signalling to the compiler that any references to e may simply be replaced with ones to c .[src] ==Further reading== Alpern, Bowen, Wegman, Mark N., and Zadeck, F.[src] Kenneth.[src] "Detecting Equality of Variables in Programs.", Conference Record of the Fifteenth Annual ACM Symposium on Principles of Programming Languages (POPL), ACM Press, San Diego, CA, USA, January 1988, pages 1–11.[src] L.[src] Taylor Simpson, "Value-Driven Redundancy Elimination." Technical Report 96-308, Computer Science Department, Rice University, 1996.[src] (Author's Ph.D.[src] thesis)[src]
28 sentences · 28 cited inline · 0 references stored
References
No reference rows published for this article.
Cite this article
MLA
"Value numbering." encyclopegia.org, 2026, https://encyclopegia.org/wiki/value-numbering. Accessed 28 November 2026.
Chicago
"Value numbering." encyclopegia.org. Accessed November 28, 2026. https://encyclopegia.org/wiki/value-numbering.
APA
encyclopegia.org. (2026). Value numbering. Retrieved November 28, 2026, from https://encyclopegia.org/wiki/value-numbering
Accessed November 28, 2026 · CC BY-SA 4.0 · citation page · JSON