Interprocedural Constant Propagation using Dependence Graphs and a Data-Flow Model David Binkley Loyola College in Maryland 4501 North Charles Street, Baltimore Maryland 21210-2699, USA. binkley@cs.loyola.edu Abstract. Aggressive compilers employ a larger number of well understood optimizations in the hope of improving compiled code quality. Unfortunately, these optimizations require a variety of intermediate program representations. A first step towards unifying these optimiza- tions to a common intermediate representation is described. The representation chosen is the program dependence graph, which captures both control-flow and data-flow information from a program. The optimization of (interprocedural) constant propagation is studied. The algorithm developed combines a program dependence graph called the system dependence graph (SDG) with the ideas of data-flow computing and graph rewriting. The algorithm safely finds the classes of constants found by other intraprocedural and intraprocedural constant propagation algorithms. In addition, the SDG allows constants to propagate through procedures. This enables the algorithm to discover constants in a calling procedure even thought no constants exist in the called procedure. 1. Introduction Optimizing compilers employ a larger number of well understood optimizations in the hope of improving object code quality. These include, for example, code motion, call inlining, constant propagation, dead code elimination, loop interchanging, and register allocation [1, 2]. Unfortunately, these optimizations often require different intermedi- ate representations of the program. This paper describes the first step toward reducing the number of intermediate representations by unifying optimizations onto a common intermediate representation. The representation chosen is a variation of the program dependence graph [12, 17] called the system dependence graph (SDG) [15]. Program dependence graphs have been successfully used as an intermediate representation in parallelizing and vectoriz- ing compilers to perform loop interchanging, strip mining, loop skewing, and other optimizations [2, 17]. A key feature of the SDG is its representation for programs with procedures and procedure calls. Recent trends toward programs with small pro- cedures and a high proportion of procedure calls (typical of object oriented programs) have intensified the need for better interprocedural optimizations. The optimization considered in this paper is interprocedural constant propagation [8, 19]. The goal of any constant propagation algorithm is to identify variables whose values are constant throughout all possible executions of the program. If a compiler can identify such variables it can improve the quality of the object code by replacing the variable with the constant and by propagating this constant to other expressions in the program. Interprocedural constant propagation concerns the propagating of con- stants to, from, and through called procedures. The interprocedural constant propagation algorithm developed in this paper uses a data-flow interpretation of the SDG, incorporates symbolic execution, and uses live code analysis. The algorithm safely finds the same classes of constants found by trad- itional interprocedural and intraprocedural constant propagation algorithms [16, 19].