Loop-Invariant Computations and Code Motion

Induction Variable Detection and Elimination

Strength Reduction

Loop Unrolling

Loop Jamming (Fusion)

Counting up to Zero

Unswitching

Loop Collapse

10.2.6 Count up to Zero

This transformation simplifies the termination test (computers often have separate instructions to test for 0):

     LOOP FOR I := 1 TO N DO         LOOP FOR I := 1 - N TO 0
 
            ...I...                         ...I + N...
 
      ENDLOOP                         ENDLOOP