Sometimes two loops may be replaced by one. Consider the following loops:
LOOP I = 1 to 100
These two loops can be "fused":
LOOP I = 1 to 100
The loop overhead is reduced, resulting in a speed-up in execution, as well as a reduction in code space. Once again, instructions are exposed for parallel execution.
The conditions for performing this optimization are that the loop indices be the same, and the computations in one loop cannot depend on the computations in the other loop.
Sometimes loops may be fused when one loop index is a subset of the other:
FOR I := 1 TO10000 DO
FOR J := 1 TO 5000 DO
FOR I := 1 to 10000 DO