|
Loop interchange
|
|
|
-
Following loops can not be interchanged
for I = 2,n
for j = 1, m
A[I,j] = A[i-1, j+1] + 1
endfor
endfor
|
Loop Limits in Loop Interchange
- When the loop limits of the inner loop are invariant in outer loop the loops can be changed without changing limits
- When the limits vary in the outer loop the limits can change
- Interchanging two loops is equivalent to transposing the iteration space
- Fourier Motzkin projections are used for finding new limits
For I = 1, 10
for j = I, 12
A[I,j] = A[I, j+1]
endfor
Endfor |
- The lower limit of j varies in I
- The limits before interchanging are:
-I ≤ -1 |
I ≤ 10 |
i-j ≤ 0 |
j ≤ 12 |
- The iteration space is shown in the figure on next foil
|