Live-Too-Long Issues
6-101
Optimizing Assembly Code via Linear Assembly
6.10 Live-Too-Long Issues
When the result of a parent instruction is live longer than the minimum iteration
interval of a loop, you have a live-too-long problem. Because each instruction
executes every iteration interval cycle, the next iteration of that parent over-
writes the register with a new value before the child can read it. Section 6.6.6.1,
Resource Conflicts, on page 6-65 showed how to solve this problem simply
by moving the parent to a later cycle. This is not always a valid solution.
6.10.1 C Code With Live-Too-Long Problem
Example 6–56 shows C code with a live-too-long problem that cannot be
solved by rescheduling the parent instruction. Although it is not obvious from
the C code, the dependency graph in Figure 6–19 on page 6-103 shows a
split-
join path that causes this live-too-long problem.
Example 6–56. Live-Too-Long C Code
int live_long(short a[],short b[],short c, short d, short e)
{
int i,sum0,sum1,sum,a0,a2,a3,b0,b2,b3;
short a1,b1;
sum0 = 0;
sum1 = 0;
for(i=0; i<100; i++){
a0 = a[i] * c;
a1 = a0 >> 15;
a2 = a1 * d;
a3 = a2 + a0;
sum0 += a3;
b0 = b[i] * c;
b1 = b0 >> 15;
b2 = b1 * e;
b3 = b2 + b0;
sum1 += b3;
}
sum = sum0 + sum1;
return(sum);
}