7 The Strength Reduction optimization technique (SR)
8 tries to replace expensive operators
10 in order to decrease the execution time
12 A classical example is replacing a 'multiplication by 2'
13 by an addition or a shift instruction.
14 These kinds of local transformations are already
15 done by the EM Peephole Optimizer.
16 Strength reduction can also be applied
17 more generally to operators used in a loop.
22 while i < 100 loop\ \ \ \ \ \ \ --> TMP := i * 118;
23 put(i * 118); while i < 100 loop
30 Fig. 6.1 An example of Strenght Reduction
32 In Fig. 6.1, a multiplication inside a loop is
33 replaced by an addition inside the loop and a multiplication
35 Clearly, this is a global optimization; it cannot
36 be done by a peephole optimizer.
38 In some cases a related technique, \fItest replacement\fR,
39 can be used to eliminate the
41 This technique will not be discussed in this report.
43 In the example above, the resulting code
44 can be further optimized by using
46 Obviously, this is not the task of the
47 Strength Reduction phase.