A practical and fast iterative algorithm for φ-function computation using DJ graphs

We present a new and practical method of computing φ-function for all variables in a function for Static Single Assignment (SSA) form. The new algorithm is based on computing the Merge set of each node in the control flow graph of a function (a node here represents a basic block and the terms will be used interchangeably). Merge set of a node n is the set of nodes N, where φ-functions may need to be placed if variables are defined in n. It is not necessary for n to have a definition of a variable in it. Thus, the merge set of n is dictated by the underlying structure of the CFG. The new method presented here precomputes the merge set of every node in the CFG using an iterative approach. Later, these merge sets are used to carry out the actual φ-function placement. The advantages are in examples where dense definitions of variables are present (i.e., original definitions of variables---user defined or otherwise, in a majority of basic blocks). Our experience with SSA in the High Level Optimizer (optimization levels +O3/+O4) shows that most examples from the Spec2000 benchmark suite require a high percentage of basic blocks to have their φ points computed. Previous methods of computing the same relied on the dominance frontier (DF) concept, first introduced by Cytron et al. The method presented in this paper gives a new effective iterative solution to the problem. Also, in cases, where the control flow graph does not change, our method does not require any additional computation for new definitions introduced as part of optimizations. We present implementation details with results from Spec2000 benchmarks. Our algorithm runs faster than the existing methods used.

[1]  Bowen Alpern,et al.  Detecting equality of variables in programs , 1988, POPL '88.

[2]  M. Wegman,et al.  Global value numbers and redundant computations , 1988, POPL '88.

[3]  Mark N. Wegman,et al.  Efficiently computing static single assignment form and the control dependence graph , 1991, TOPL.

[4]  G. Ramalingam,et al.  On loops, dominators, and dominance frontiers , 2002, TOPL.

[5]  Ron Cytron,et al.  Efficiently Computing phi-Nodes On-The-Fly (Extended Abstract) , 1993, LCPC.

[6]  Robert E. Tarjan,et al.  Symbolic Program Analysis in Almost-Linear Time , 1982, SIAM J. Comput..

[7]  Keith D. Cooper,et al.  Practical improvements to the construction and destruction of static single assignment form , 1998, Softw. Pract. Exp..

[8]  Flemming Nielson,et al.  International Workshop on Principles of Program Analysis , 1999 .

[9]  Michael Weiss The transitive closure of control dependence: the iterated join , 1992, LOPL.

[10]  Guang R. Gao,et al.  A linear time algorithm for placing φ-nodes , 1995, POPL '95.

[11]  Vugranam C. Sreedhar,et al.  Efficient program analysis using DJ graphs , 1996 .

[12]  Timothy J. Harvey,et al.  Practical improvements to the construction and destruction of static single assignment form , 1998 .

[13]  Robert M. Shapiro,et al.  THE REPRESENTATION OF ALGORITHMS , 1969 .

[14]  Keshav Pingali,et al.  Algorithms for computing the static single assignment form , 2003, JACM.

[15]  John H. Reif Symbolic program analysis in almost linear time , 1978, POPL '78.

[16]  Flemming Nielson,et al.  Principles of Program Analysis , 1999, Springer Berlin Heidelberg.

[17]  Ron Cytron,et al.  Efficiently computing Φ-nodes on-the-fly , 1993, TOPL.