10.2.4 Loop Unrolling

Loop unrolling decreases the number of iterations of a loop. Consider the following loop:

Unrolling by 2 gives

The number of instructions executed is reduced because the number of increments and tests is halved.

Another example of loop unrolling is:

      WHILE Condition                  WHILE Condition
         A                              A
      ENDWHILE                           IF NOT Condition THEN Exit
                                            A
                                       ENDLOOP

Loop unrolling also exposes instructions for parallel execution since the two statements can be executed at the same time if they are independent (see Chapter 13).

The disadvantage here is that increased instruction space is required.

Send questions and comments to: Karen Lemone