Composing Transformations to Optimize Linear Code

We study the effect of an optimizing algorithm for straight-line code which first constructs a directed acyclic graph representing the given program and then generates code from it. We show that this algorithm produces optimal code with respect to the classical transformations known as Constant Folding, Common Subexpression Elimination, and Dead Code Elimination. In contrast to the former, the latter are also applicable to iterative code containing loops. We can show that the graph-based algorithm essentially corresponds to a combination of the three classical optimizations in conjunction with Copy Propagation. Thus, apart from its theoretical importance, this result is relevant for practical compiler design as it potentially allows to exploit the optimization potential of the graph-based algorithm for non-linear code as well.

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

[2]  Thomas Noll,et al.  Optimization of Straight-Line Code Revisited , 2006, Softwaretechnik-Trends.

[3]  Alfred V. Aho,et al.  A formal approach to code optimization , 1970 .

[4]  Alfred V. Aho,et al.  Compilers: Principles, Techniques, and Tools , 1986, Addison-Wesley series in computer science / World student series edition.

[5]  Alfred V. Aho,et al.  Optimal code generation for expression trees , 1975, STOC.

[6]  Oscar H. Ibarra,et al.  The complexity of the equivalence problem for straight-line programs , 1980, STOC '80.

[7]  Alfred V. Aho,et al.  Code Generation for Expressions with Common Subexpressions , 1977, J. ACM.