Science  People  Locations  Timeline
Index: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Home > Loop splitting


 

Loop splitting is a compiler optimization. It

attempts to simplify a loop or eliminate dependencies by breaking it into multiple loops which have the same bodies but iterate over different contiguous portions of the index range.

A useful special case is loop peeling, which can simplify a loop with a problematic first (or first few) iteration by performing that iteration separately before entering the loop.

Here is an example of loop peeling, suppose the original code looks like this:

for i from 1 to 100 do x[i] = x[1] + y[i]; od;

Since the assignment to the array x depends on the array x itself, the compiler cannot safely use parallization in this loop. However if we omit the first iteration, thereby removing the problematic self reference to x[1] this problem is solved. We get the following after loop peeling:

x[1] = x[1] + y[1] for i from 2 to 100 do x[i] = x[1] + y[i]; od;

The optimization loop peeling was introduced to gcc in version 3.4.



Read more »

Non User