Loop Unrolling
6-96
6.9.3
Drawing a Dependency Graph
Although there are numerous ways to split the dependency graph, the main
goal is to achieve a minimum iteration interval of 3 and meet these conditions:
-
You cannot have more than nine non-.M instructions on either side.
-
Only three non-.M instructions can execute per cycle.
Figure 6–18 shows the dependency graph for the unrolled if-then-else code.
Nine instructions are on the A side, and seven instructions are on the B side.
Figure 6–18. Dependency Graph of If-Then-Else Code (Unrolled)
ADD
cntr
Loop
1
B
1
CMPEQ
ifi+1
sumi+1
1
SUB
!(!(condi+1))
1
MVK
A side
B side
ADD
1
1
1
LDH
ai+1
5
5
maski+1
1
1
sumi+1
1
1
SHL
condi+ 1
1
AND
LDH
ai
5
5
maski
SHL
1
CMPEQ
ifi
sumi
1
SUB
!(!(condi)
1
MVK
ADD
1
1
1
sumi
1
1
condi
1
AND
1