int code (void) { int i, j; int c = 0; i = 1; loop: j = 1; loop2: c = c + i + j; j++; if (j <= 7) goto loop2; i++; if (i <= 1000) goto loop; return c; }Each of the two if statement corresponds to a conditional branch. How many mispredictions will there be? Your answer may be correct within a tolerance of 10 mispredictions, i.e., if the correct answer is n and your answer is n±10 then your answer is still counted as correct.
int code2 (void) { int i, j; int c = 0; i = 1; loop: j = 1; loop2: c = c + i + j; j++; if (j <= 3) goto loop2; loop3: c = c + i + j; j++; if (j <= 7) goto loop3; i++; if (i <= 1000) goto loop; return c; }Each of the three if statements corresponds to a conditional branch. How many mispredictions will there be? Again, your answer may be correct within a tolerance of 10 mispredictions.
|
|
|
|
|
|
|
L.D F1,0(R1) | ||||||
MUL.D F1,F1,F6 | ||||||
L.D F2,0(R2) | ||||||
ADD.D F2,F2,F1 | ||||||
S.D F2,0(R1) | ||||||
DADDIU R1,R1,#8 | ||||||
DADDIU R2,R2,#8 |
|
|
|
|
|
|
|
L.D F1,0(R1) | ||||||
MUL.D F1,F1,F6 | ||||||
L.D F2,0(R2) | ||||||
ADD.D F2,F2,F1 | ||||||
S.D F2,0(R1) | ||||||
DADDIU R1,R1,#8 | ||||||
DADDIU R2,R2,#8 |
|
|
|
|
|
|
|
L.D F1,0(R1) | ||||||
MUL.D F1,F1,F6 | ||||||
L.D F2,0(R2) | ||||||
ADD.D F2,F2,F1 | ||||||
S.D F2,0(R1) | ||||||
DADDIU R1,R1,#8 | ||||||
DADDIU R2,R2,#8 |