Prev Up
Go backward to Announcements
Go up to Top

Value Numbering (cont.)

  1. Last time I explained a procedure for identifying subexpressions that are guaranteed to produce the same value at runtime.

  2. This scheme will work fairly well for straight line code containing nothing but references to simple, local variables. In the real world, unfortunately, there are a few more complications to deal with.

  3. I had these problems in mind when I had you make each refvar node point to the variable descriptor associated with the variable being referenced. In particular, that is why I had you create dummy nodes for array element variables.

  4. The handling of array elements and record components is a fine example of the conservative nature of the analysis algorithms one uses when performing optimization. Such algorithms do not give exact information, but they only make "safe" mistakes. In this case, the algorithm will often fail to identify pairs of expressions that actually are CSE's. The result will be that the code generated will be less efficient (but correct!). On the other hand, the alternative of sometimes accidentally concluding that two expressions are CSE's when they are not is unacceptable. It would result in the generation of incorrect (though efficient) code.

  5. While we can't be sure whether array references like a[i] and a[j] are different, we can sometimes tell when they are the same.

  6. BUT WAIT! It get's worse. We still need to account for assignments involving reference parameters and for the effects of calls.

  7. Suppose that a global variable X is passed as a var parameter P to some procedure. If a value is assigned to X, then the value of P will change. Similarly, assigning to P will change the value of X. In such a situation, we say that X and P are aliases of one another.

  8. Basically, when we process an assignment to a non-local variable or a reference parameter it is not enough to change the value number in the descriptor of the target of the assignment. In addition, we have to change the value numbers associated with all variables that might be aliases of the assignment's target.

    Since we can't be sure that an alias relations exists, we must set the value numbers of possible aliases of the target of an assignment to the "unknown" value number rather than to the value number of the right hand side.

  9. Finally, if we find a call, we must:

Computer Science 434
Department of Computer Science
Williams College

Prev Up