Detecting Equalities of Variables: Combining Efficiency with Precision
Detecting whether different variables have the same value at a program point is generally undecidable. Though the subclass of equalities, whose validity holds independently from the interpretation of operators (Herbrand-equivalences), is decidable, the technique which is most widely implemented in compilers, value numbering, is restricted to basic blocks. Basically, there are two groups of algorithms aiming at globalizations of value numbering: first, a group of algorithms based on the algorithm of Kildall, which uses data flow analysis to gather information on value equalities. These algorithms are complete in detecting Herbrand-equivalences, however, expensive in terms of computational complexity. Second, a group of algorithms influenced by the algorithm of Alpern, Wegman and Zadeck. They do not fully interpret the control flow, which allows them to be particularly efficient, however, at the price of being significantly less precise than their Kildall-like counterparts. In this article we discuss how to combine the best features of both groups by aiming at a fair balance between computational complexity and precision. We propose an algorithm, which extends the one of Alpern, Wegman and Zadeck. The new algorithm is polynomial and, in practice, expected to be almost as efficient as the original one. Moreover, for acyclic control flow it is as precise as Kildall’s one, i. e. it detects all Herbrand-equivalences.
Unable to display preview. Download preview PDF.
- 1.B. Alpern, M. Wegman, and F. K. Zadeck. Detecting equality of variables in programs. In Conf. Record of the 15 th ACM Symposium on the Principles of Programming Languages (POPL), January 1988.Google Scholar
- 6.A. Fong, J. B. Kam, and J. D. Ullman. Application of lattice algebra to loop optimization. In Conf. Record of the 2 nd ACM Symposium on the Principles of Programming Languages (POPL), pages 1–9, Palo Alto, CA, 1975.Google Scholar
- 7.J. Hopcroft. An n log n algorithm for minimizing the states of a finite automaton. The Theory of Machines an Computations, pages 189–169, 1971.Google Scholar
- 8.G. A. Kildall. A unified approach to global program optimization. In Conf. Record of the 1 st ACM Symposium on the Principles of Programming Languages (POPL), pages 194–206, Boston, MA, 1973.Google Scholar
- 9.J. Knoop, O. Rüthing, and B. Steffen. Code motion and code placement: Just synonyms? In Proc. 6 th European Symposium on Programming (ESOP), Lecture Notes in Computer Science 1381, pages 154–196, Lisbon, Portugal, 1998. Springer-Verlag.Google Scholar
- 10.S. S. Muchnick. Advanced Compiler Design & Implementation. Morgan Kaufmann, San Francisco, CA, 1997.Google Scholar
- 12.J. H. Reif and R. Lewis. Symbolic evaluation and the gobal value graph. In Conf. Record of the 4 th ACM Symposium on the Principles of Programming Languages (POPL), pages 104–118, Los Angeles, CA, 1977.Google Scholar
- 13.B. K. Rosen, M. N. Wegman, and F. K. Zadeck. Global value numbers and redundant computations. In Conf. Record of the 15 th ACM Symposium on the Principles of Programming Languages (POPL), pages 12–27, San Diego, CA, 1988.Google Scholar
- 14.L. T. Simpson. Value-driven redundancy elimination. Technical Report TR98-308, Rice University, April 6, 1998.Google Scholar
- 15.B. Steffen. Optimal run time optimization. Proved by a new look at abstract interpretations. In Proc. 2 nd International Joint Conference on the Theory and Practice of Software Development (TAPSOFT), Lecture Notes in Computer Science 249, pages 52–68, Pisa, Italy, 1987. Springer-Verlag.Google Scholar
- 16.B. Steffen, J. Knoop, and O. Rüthing. The value flow graph: A program representation for optimal program transformations. In Proc. 3 rd European Symposium on Programming (ESOP), Lecture Notes in Computer Science 432, pages 389–405, Copenhagen, Denmark, 1990. Springer-Verlag.Google Scholar