Advanced Computer Architecture, Imperial
College 2001
Instructions for predication
•Idea #2: predicated instructions
–
if (fluid[i][j]==0) {
U[i][j] =
U[i-1,j]+U[i,j-1];
}
..R1
is address of fluid[i,j]
..R2
is address of U[i,j]
..R3
is address of U[i-1,j]
LW
R4, (R1)
CMP
P1, R4, 0
(P1)
LD F1, (R3)
(P1)
LD F2, -1(R2)
(P1)
ADDD F3, F1, F2
(P1)
SD (R2), F3
CMP P1, R4, 0
If R4=0, set predicate register P1 to
true
(P1) LD F1, (R3)
If P1=true, execute load (F1=Mem[R3])