[PDF][PDF] Detecting equality of variables in programs

B Alpern, MN Wegman, FK Zadeck - … of the 15th ACM SIGPLAN-SIGACT …, 1988 - dl.acm.org
B Alpern, MN Wegman, FK Zadeck
Proceedings of the 15th ACM SIGPLAN-SIGACT symposium on Principles of …, 1988dl.acm.org
Introduction paper presents an algorithm for detecting when two computations produce
equivalent values. The equivalence of programs, and hence the equivalence of values, is in
general undecidable. Thus, the best one can hope to do is to give an efficient algorithm that
detects a large subclass of all the possible equivalences in a program. Two variables are
said to be equivalent at a point p if those variables contain the same values whenever
control reaches p during any possible execution of the program. We will not examine all …
Introduction paper presents an algorithm for detecting when two computations produce equivalent values. The equivalence of programs, and hence the equivalence of values, is in general undecidable. Thus, the best one can hope to do is to give an efficient algorithm that detects a large subclass of all the possible equivalences in a program. Two variables are said to be equivalent at a point p if those variables contain the same values whenever control reaches p during any possible execution of the program. We will not examine all possible executions of the program. Instead, we will develop a static property called congruence. Congruence implies, but is not implied by, equivalence. Our approach is conservative in that any variables detected to be e: quivalent will in fact be equivalent, but not all equivalences are detected.
Previous work has shown how to apply a technique c. alled value numbering in basic blocks [CS70]. Value numbering is essentially symbolic execution on straight-line programs (basic blocks). Symbolic execution implies that two expressions are assumed to be equal only when they consist of the same functions and the corresponding arguments of these functions are equal. An expression DAG is associated with each assignment statement. A hashing algorithm assigns a unique integer, the value number, to each different expression tree. Two variables that are assigned the same integer are guaranteed to be equivalent. After the code BcA+ 3
ACM Digital Library