Redundant Load Elimination
6-111
Optimizing Assembly Code via Linear Assembly
6.11.1.2 New FIR Filter C Code
Example 6–61 shows that after eliminating redundant loads, there are four
memory-read operations for every four multiply-accumulate operations. Now
the memory accesses no longer limit the performance.
Example 6–61. FIR Filter C Code With Redundant Load Elimination
void fir(short x[], short h[], short y[])
{
int i, j, sum0, sum1;
short x0,x1,h0,h1;
for (j = 0; j < 100; j+=2) {
sum0 = 0;
sum1 = 0;
x0 = x[j];
for (i = 0; i < 32; i+=2){
x1 = x[j+i+1];
h0 = h[i];
sum0 += x0 * h0;
sum1 += x1 * h0;
x0 = x[j+i+2];
h1 = h[i+1];
sum0 += x1 * h1;
sum1 += x0 * h1;
}
y[j] = sum0 >> 15;
y[j+1] = sum1 >> 15;
}
}