StarCore code optimizer ( sco ) is capable of handling different coding techniques that often used to implement many of DSP algorithms.
For example the classical DSP kernel for "NTAPS"-tap FIR filter processing "NPOINTS" points


void fir( int *input,        /* pointer to input sample array of NTAPS points*/
             int *output,       /* pointer to output array of NPOINTS points */
             int *coefficient /* pointer to coefficient array of NTAPS values */
           )
 {
  int i, j;
  int *data, *coef, *initial;
  int sum;
  int tmp1, tmp2;

  initial = input;
  for ( i = 0; i < NPOINTS; i++ )
   {
    data = input++;
    coef = coefficient;
    sum = 0;
    for (j = 0; j < NTAPS; j++)
     {
      tmp1 = *data;
      if ( data == initial )
       {
        data = initial + ( NTAPS - 1 );
       }
      else
       {
        data--;
        }
      tmp2 = *coef++;
      sum += tmp1 * tmp2;
     }
    *output++ = sum;
   }
}

 


may be coded with:


1. use of "pointers":

 

void fir( int *input,        /* pointer to input sample array of NTAPS points*/
             int *output,      /* pointer to output array of NPOINTS points */
             int *coefficient /* pointer to coefficient array of NTAPS values */
           )
 {
  int i, j;
  int *data, *coef, *initial;
  int sum;
  int tmp1, tmp2;

  initial = input;
  for ( i = 0; i < NPOINTS; i++ )
   {
    data = input++;
    coef = coefficient;
    sum = 0;
    for (j = 0; j < NTAPS; j++)
     {
      tmp1 = *data;
      if ( data == initial )
       {
        data = initial + ( NTAPS - 1 );
       }
      else
       {
        data--;
       }
      tmp2 = *coef++;
      sum += tmp1 * tmp2;
     }
    *output++ = sum;
   }
 }


2. use of "pointers with a swap":


void fir( int *input,         /* pointer to input sample array of NTAPS points*/
             int *output,       /* pointer to output array of NPOINTS points */
             int *coefficient /* pointer to coefficient array of NTAPS values */
           )
 {
  int i, j;
  int *data, *coef, *initial;
  int sum;
  int tmp1, tmp2;

  initial = input;
  for ( i = 0; i < NPOINTS; i++ )
   {
    data = input++;
    coef = coefficient;
    sum = 0;
    tmp1 = *data;
    if ( data==initial )
     {
      data = initial + ( NTAPS - 1 );
     }
   else
    {
     data--;
    }
   tmp2 = *coef++;
   for ( j = 1; j < NTAPS; j++ )
    {
     sum += tmp1 * tmp2;
     tmp1 = *data;
     if ( data == initial )
      {
       data = initial + ( NTAPS - 1 );
      }
    else
      {
       data--;
      }
     tmp2 = *coef++;
    }
   sum += tmp1 * tmp2;
   *output++ = sum;
   }
}

 

3. use of "arrays":


void fir( int input[],        /* input sample array of NTAPS points */
             int output[],      /* output array of NPOINTS points */
             int coefficient[] /* array of NTAPS coefficients */
           )
 {
  int i;
  int j;
  int sum;

  for ( i = 0; i < NPOINTS; i++ )
   {
    sum = 0;
    for ( j = 0; j < NTAPS; j++ )
     {
      if ( ( i - j ) < 0 )
       {
        sum += input[i-j+NTAPS] * coefficient[j];
       }
      else
       {
        sum += input[i-j] * coefficient[j];
       }
     }
    output[i] = sum;
   }
}

 

4. use of "arrays with a swap":

 

void fir( int input[],        /* input sample array of NTAPS points */
             int output[],      /* output array of NPOINTS points */
             int coefficient[] /* array of NTAPS coefficients */
           )
 {
  int i;
  int j;
  int sum, tmp1, tmp2;

  for ( i = 0; i < NPOINTS; i++ )
   {
    sum = 0;
    tmp1 = input[i];
    tmp2 = coefficient[0];
    for (j = 1; j < NTAPS; j++)
     {
      sum += tmp1 * tmp2;
      if ( ( i - j ) < 0 )
       {
        tmp1 = input[i-j+NTAPS];
       }
      else
       {
        tmp1 = input[i-j];
       }
      tmp2 = coefficient[j];
     }
    sum += tmp1 * tmp2;
    output[i] = sum;
   }
}

 

The following table lists execution time improvements achieved by sco over different implementations of the
256-tap FIR filter processing 64 points

 

>256-tap FIR filter processing 64 points

pointers 28%
pointers with a swap 24%
arrays 27%
arrays with a swap 24%