next up previous contents
Next: Code motion Up: Optimizer Previous: Static Single-Assignment Form

Conditional Constant Propagation

Wegman and Zadeck's Sparse Conditional Constant (SCC) algorithm was used to find constant expressions, constant conditions, and unreachable code [WZ91]. Figure 3 shows the optimization extent possible.


  
Figure 3: SCC code optimization.
\begin{figure}
\begin{center}
{\tt
\begin{tabular}
{lcl}
$i_1 \leftarrow 1$\spac...
 ...rrow$\space & $k_1 \leftarrow 5$\space \\ \end{tabular}}\end{center}\end{figure}

The output of the SCC algorithm is an association of variables to one of $\lbrace \bot, c, \top \rbrace$, where $\bot$ marks a variable that is never defined, c indicates a constant value, and $\top$ signifies an over-defined variable (which may be assigned any one of a number of values). In addition, every flow-graph node (corresponding to a quadruple) is marked as executable or non-executable. We then walk the flow-graph, eliminating dead-code (quadruples marked non-executable), replacing constant variables with their values, and changing constant conditional branches to goto statements.



C. Scott Ananian
10/11/1997