Some Optimization Techniques

Some good optimization techniques include:

  1. Generation of good code for common special cases, such as I := 0. These occur frequently enough to provide a good savings, and testing for them is fairly easy.

  2. Generation of good code for subscript expressions. These often occur in loops.

  3. Assigning variables to registers.

  4. Moving invariant code out of loops:
    for i := 1 to 1000 do
      x[i] := y[i] * sqrt(a);
    The code sqrt(a) does not change within the loop, so it could be moved above the loop and its value reused.

  5. Reduction in strength: x * 8 &rarr x < < 3

Contents    Page-10    Prev    Next    Page+10    Index