This MIPS code is given:
loopA: lw $t0, 0($s1) # $ array element
addu $t0, $t0, $s3 # add scalar in s3
sw $t0, 0($s1) # store result
addi $s1, $-4 # decrement pointer
bne $s1, $zero, loopA # branch if s1!=0
loopB: lw $t0, 0($s2) # $ array element
addu $t0, $t0, $s3 # add scalar in s3
sw $t0, 0($s2) # store result
addi $s2, $-4 # decrement pointer
bne $s2, $zero, loopB # branch if s2!=0
The code is going from top to bottom, passing first trough loopA, and the loopB accordingly. After every passing a constant in $s3 is added to each element(which value is not important).
The address of the last element of field A is given in the register $s1 and it is equal to 80;
The address of the last element of field B is given in the register $s2 and it is equal to 100;
We need to use static predictor for branching with strategy that predicts that there will NOT be branching. How many times will there not be stop because of control conflict, in other words how many times the predictions will be right?
The other two question are the same, but:
- What if we use dynamic predictor with 1 bit, initially set to 0(there will not be branching)?
- What if we use dynamic predictor with 2 bits, initially set to 11(there will be branching)?