ABSTRACT

This chapter aims to improve the optimizer significantly by the end of 2004. It discusses the optimizations conceptually, and explains more detail on how they are implemented. Two optimizations, copy propagation and forward substitution, are performed on basic blocks. The chapter considers a fairly naive method to reduce the amount of copying called forward substitution. A very important optimization for shader programs is dead code removal. Graph straightening is a very simple optimization. Both common subexpression elimination and value numbering are important optimizations with similar goals. Common subexpression elimination searches for two equal statements in a program and replaces duplicates by copies if the operand values have not changed between the two statements. Algebraic simplification is a set of optimizations that aims to find expressions which can be simplified due to some algebraic property. An addition of zero to a number can be removed completely, as it will have no effect.