Value Numbering - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

Value Numbering

Description:

Value numbering is an optimization that assigns numbers to expressions in such a ... 'Value Numbering & CSE: What a Team!' fin. ... – PowerPoint PPT presentation

Number of Views:42
Avg rating:3.0/5.0
Slides: 12
Provided by: lac84
Category:
Tags: fin | numbering | value

less

Transcript and Presenter's Notes

Title: Value Numbering


1
Value Numbering
  • Presented by
  • Ben Graver
  • Wayne Eggert

2
Overview
  • Value numbering is an optimization that assigns
    numbers to expressions in such a way that two
    expressions are assigned the same number if the
    compiler can prove they are equal.
  • Used by GCC when it does a CSE pass
  • Originally developed by Balke in 1967

3
Problems With Basic CSE
  • Expressions that look identical only produce the
    same results if none of the values of variables
    referenced by the two expressions change between
    their evaluations.
  • Even if we only looked for examples of identical
    expressions, we would need to find an efficient
    way to look for matching subtrees.
  • Expressions that don't look identical may produce
    identical results, as in the following example
  • Example - CSE fails, but Value Numbering works
  • a ? b c
  • d ? b
  • e ? d c
  • Notice a e have the same value but are not
    lexically identical.

4
Value Numbering Setup
  • Based on the form of a lookup table.
  • The table will associate expressions with their
    "value numbers".
  • For each expression we encounter as we traverse
    the subtrees of a basic block we envoke the
    following algorithm ..

5
Value Numbering Algorithm
  • Look the expression up in our table.
  • If the expression is not in out table, we will
    assign it the next unused value number and enter
    the expression/number pair in the table.
  • If an expression is already in the table, we will
    associate it with its already assigned value
    number.

6
Efficiency of Table Lookups
  • Tables can be partitioned into two parts.
  • 1 Value numbers and descriptors for simple
    variables which are stored in a new field.
  • 2 The hash table used for all expressions
    except references to simple variables.

7
Accounting for Assignments
  • Value numbers are assigned to variables used in
    expressions when they are first encountered.
  • For each assignment encountered, a new value
    number is assigned to the variable so that when
    the variable is referenced in subsequent
    expressions we will recognize the variable may
    produce distinct values from earlier,
    syntactically identical expressions.

8
Accounting for Assignments Cont.
  • Brand new value numbers are not given to the
    targets of assignments. Instead, when processing
    the assignment
  • x E
  • E's value number is assigned to x since future
    references to x will produce the same value as E.

9
Processing An Expression
  • To process an expression, we
  • Process its sub-expressions (receiving their
    value numbers as return values).
  • Build the appropriate key based on the expression
    type and the value numbers of its
    sub-expressions.
  • Look the key up in the hash table, and
  • make a new table entry associating the key with
    the next value number if no match is found, or
  • recognize that we have found a CSE if a match is
    found (and then return the associated value
    number).

10
Summary
  • Value Numbering looks for equations that have
    value equivalence as opposed to matching
    lexical patterns as in CSE.

11
fin.
Value Numbering CSE What a Team!
Write a Comment
User Comments (0)
About PowerShow.com