loop combination

loop combination

A program transformation where the bodies of two loops aremerged into one thus reducing the overhead of manipulating andtesting the control variable and branching. Furtheroptimisation of the merged code may then become possible.

In horizontal loop combination the bodies of the loops arelargely independent so only the loop overhead is saved.Vertical loop combination applies where the results of thefirst loop are used by the second. Combining the two allowsthe intermediate results to be used immediately (inregisters) rather than requiring them to be stored in anarray.

The functional equivalent of horizontal and vertical loopcombination are tupling and fusion.