Index

Lecture 08

Duff's Device

for (i=0; i < count; i ++)
    A[i] = A[i] + B[i];

n = (count + 3)/4;
i = 0;
switch (count % 4) {
    case 0: do {    A[i++] = A[i] + B[i];
    case 1:         A[i++] = A[i] + B[i];
    case 2:         A[i++] = A[i] + B[i];
    case 3:         A[i++] = A[i] + B[i];
                } while (--n > 0);
}

5.2 Software Pipeline

08-01

08-01

// prolog
L.D     F2, (R1)
ADDI    R1, R1, -8
ADD.D   F4, F2, F0
L.D     F2, (R1)
ADDI    R1, R1, -8
Loop4:
S.D     F4, 16(R1)
ADD.D   F4, F2, F0
L.D     F2, (R1)
BGT     R1, R2, Loop4
ADDI    R1, R1, -8
// epilog
S.D     F4, 16(R1)
ADD.D   F4, F2, F0
ADDI    R1, R1, -8
S.D     F4, 16(R1)

Index