|
Loop Un-switching
- Removes loop independent conditionals from a loop
- Reduces frequency of execution of conditional statements
- Makes loop structure more complex
For I = 1, n
for j = 2, n
if T[i] > 0 then
A[i,j]=A[i,j-1]*T[i]+B[j]
else
A[I,j] = 0.0
endif
endfor
Endfor |
for I = 1, n
if T[i]>0 then
for j=2,n
A[i,j]=A[i,j-1]*T[i]+B[j]
endfor
else
for j=2,n
A[I,j]=0.0
endfor
endif
endfor
|
Loop Peeling
- Used to handle wrap around variables
- Removes first or the last iteration of the loop into separate code
- Peeling can also be used to remove loop invariant code by executing it only in the first iteration (assuming n ≥ 1)
for I = 1,n
A[i]=(x+y)*B[i]
endfor |
A[1] = (t=x+y)*B[1]
for I = 2,n
A[i]=t*B[i]
endfor
|
Index Set Splitting
- Generalization of loop peeling
- Used to remove conditionals from the loops
For I = 1, 100
A[i]=B[i]+C[i]
if i>10 then
D[i]=A[i]+A[i-10]
endif
Endfor |
for I = 1,10
A[i]=B[i]+C[i]
endfor
for I = 11 to 100
A[i]=B[i]+C[i]
D[i]=A[i]+A[i-10]
endfor
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|