10.1.2 Local 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

When one of the factors is a small integer such as 2, it is worth replacing the operator.

EXAMPLE 2 Local common subexpression elimination

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.


Send questions and comments to: Karen Lemone