Normalized loop

A non-normalized loop may begin at different indexes, increment by not-unitary amounts and have exit conditions complicated to define.

A simple example, where it doesn't start at the beginning and increments by more than one: A more complicated example, with an additional exit condition: Loops can also have non-predictable behavior during compilation time, where the exit condition depends on the contents of the data being modified: Or even dynamic calculations by means of function calls: Reverse loops are also very simple, and can be easily normalized: If the non-normalized doesn't have dynamic behaviour, it's normally very easy to transform it to a normalized one.

For instance, the first example (Example 1) above can easily be converted to: While the third example can be partially normalized to allow some parallelization, but still lack the ability to know the loop span (how many iterations there will be), making it harder to vectorize by using multi-media hardware.

When multiple statements inside the loop use the index, some private temporary variables may be created to cope with the different iteration paces.

For instance, a normal error when using iterators is to remove items from a list while modifying it, or relying on sizes (for exit condition) that are not true any more.