11.7 PEEPHOLE OPTIMIZATION


11.6 USING ALGEBRAIC PROPERTIES TO REDUCE THE REGISTER REQUIREMENT

It is possible to make use of algebraic properties like operator commutativity and associativity to reduce the register requirements of the tree. For example, consider the tree shown in Figure 11.10.

click to expand
Figure 11.10: Tree with a label of two.

The label of the tree in Figure 11.10 is two, but since + is a commutative operator, we can interchange the left and the right subtrees, as shown in Figure 11.11. This brings the register requirement of the tree down to one.

click to expand
Figure 11.11: The left and right subtrees have been interchanged, reducing the register requirement to one.

Similarly, associativity can be used to reduce the register requirement. Consider the tree shown in Figure 11.12.

click to expand
Figure 11.12: Associativity is used to reduce a tree's register requirement.



Algorithms for Compiler Design
Algorithms for Compiler Design (Electrical and Computer Engineering Series)
ISBN: 1584501006
EAN: 2147483647
Year: 2005
Pages: 108
Authors: O G Kakde

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net