Live-Too-Long Issues
6-105
Optimizing Assembly Code via Linear Assembly
Because a0 is written at the end of cycle 6, it must be live from cycle 7 to
cycle 10, or four cycles. No value can be live longer than the minimum iteration
interval, because the next iteration of the loop will overwrite that value before
the current iteration can read the value. Therefore, if the value has to be live
for four cycles, the minimum iteration interval must be at least 4. A minimum
iteration interval of 4 means that the loop executes at half the performance that
it could based on available resources.
6.10.4.2 Unrolling the Loop
One way to solve this problem is to unroll the loop, so that you are doing twice
as much work in each iteration. After unrolling, the minimum iteration interval
is 4, based on both the resources and the data dependencies of the split-join
path. Although unrolling the loop allows you to achieve the highest possible
loop throughput, unrolling the loop does increase the code size.
6.10.4.3 Inserting Moves
Another solution to the live-too-long problem is to break up the lifetime of a0
and b0 by inserting move (MV) instructions. The MV instruction breaks up the
left path of the split-join path into two smaller pieces.
6.10.4.4 Drawing a New Dependency Graph
Figure 6–20 shows the new dependency graph with the MV instructions. Now
the left paths of the split-join paths are broken into two pieces. Each value, a0
and a0’, can be live for minimum iteration interval cycles. If MPY a0 is sched-
uled on cycle 5 and ADD a3 is scheduled on cycle 10, you can achieve a mini-
mum iteration interval of 2 by scheduling MV a0’ on cycle 8. Then a0 is live on
cycles 7 and 8, and a0’ is live on cycles 9 and 10. Because no values are live
more than two cycles, the minimum iteration interval for this graph is 2.