|
|
10.1.2 Local Common Strength Reduction
Computers add faster than they multiply, multiply faster than they
raise to powers, etc. Replacing an operator by its definition is
termed strength reduction. For example, if B
is a compile-time constant
A * B = A + A + A ... (B times)
When one of the factors is a small integer such as 2, it is worth
replacing the operator.
EXAMPLE 2 Local common subexpression elimination
T1 := 2 * A T1 := A + A
Example 2 replaces a multiplication by 2 with an addition. If the
factor is not a small number like 2, then sometimes a combination
of multiplications and shifts may be done.
|