| |||||||||
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:
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:
The optimization loop peeling was introduced to gcc in version 3.4.