Modulo Scheduling of Multicycle Loops
6-59
Optimizing Assembly Code via Linear Assembly
6.6.3
Determining the Minimum Iteration Interval
Example 6–35 includes three memory operations in the inner loop (two LDHs
and the STH) that must each use a .D unit. Only two .D units are available on
any single cycle; therefore, this loop requires at least two cycles. Because no
other resource is used more than twice, the minimum iteration interval for this
loop is 2.
Memory operations determine the minimum iteration interval in this example.
Therefore, before scheduling this assembly code, unroll the loop and perform
LDWs to help improve the performance.
6.6.3.1
Unrolling the Weighted Vector Sum C Code
Example 6–36 shows the C code for an unrolled version of the weighted vector
sum.
Example 6–36. Weighted Vector Sum C Code (Unrolled)
void w_vec(short a[],short b[],short c[],short m)
{
int i;
for (i=0; i<100; i+=2) {
c[i] = ((m * a[i]) >> 15) + b[i];
c[i+1] = ((m * a[i+1]) >> 15) + b[i+1];
}
}