Software Pipelining the Outer Loop
6-131
Optimizing Assembly Code via Linear Assembly
6.13 Software Pipelining the Outer Loop
In previous examples, software pipelining has always affected the inner loop.
However, software pipelining works equally well with the outer loop in a nested
loop.
6.13.1 Unrolled FIR Filter C Code
Example 6–70 shows the FIR filter C code after unrolling the inner loop (identi-
cal to Example 6–66 on page 6-122).
Example 6–70. Unrolled FIR Filter C Code
void fir(short x[], short h[], short y[])
{
int i, j, sum0, sum1;
short x0,x1,x2,x3,h0,h1,h2,h3;
for (j = 0; j < 100; j+=2) {
sum0 = 0;
sum1 = 0;
x0 = x[j];
for (i = 0; i < 32; i+=4){
x1 = x[j+i+1];
h0 = h[i];
sum0 += x0 * h0;
sum1 += x1 * h0;
x2 = x[j+i+2];
h1 = h[i+1];
sum0 += x1 * h1;
sum1 += x2 * h1;
x3 = x[j+i+3];
h2 = h[i+2];
sum0 += x2 * h2;
sum1 += x3 * h2;
x0 = x[j+i+4];
h3 = h[i+3];
sum0 += x3 * h3;
sum1 += x0 * h3;
}
y[j] = sum0 >> 15;
y[j+1] = sum1 >> 15;
}
}