Complete Loop Unrolling Example

NB: this is not the same as the more common definition of "loop unrolling" which replicates a loop body by a factor U and then steps the loop by U
Before:
	#define K 4
        y[i] = 0;
        for(j=0; j<K; j++) {
               y[i] = y[i] + x[i+K-j-1] * (j+1);
        }

After:

        y[i] = 0;
        j = 0;
        y[i] = y[i] + x[i + 4 - j - 1] * (j + 1);
      cont_lab10:
        j = j + 1;
        y[i] = y[i] + x[i + 4 - j - 1] * (j + 1);
      cont_lab11:
        j = j + 1;
        y[i] = y[i] + x[i + 4 - j - 1] * (j + 1);
      cont_lab12:
        j = j + 1;
        y[i] = y[i] + x[i + 4 - j - 1] * (j + 1);
      cont_lab13:
        j = j + 1;
      brk_lab9:;

After porky cleanup:

        y[i] = 0;
        y[i] = y[i] + x[i + 3];
        y[i] = y[i] + x[i + 2] * 2;
        y[i] = y[i] + x[i + 1] * 3;
        y[i] = y[i] + x[i] * 4;

Back to SUIF passes index.

Back to Tim's home page.