Question: 6. Consider the following code containing nested loops: Loop2 is nested within Loop1. Branch prediction is used for both conditional branch instructions (the bnez and
6. Consider the following code containing nested loops:
Loop2 is nested within Loop1.
Branch prediction is used for both conditional branch instructions (the bnez and the bgtz) and both instructions employ delayed branching.
a) As described in module 8, a separate single-bit can be used to predict the behavior of each branch instruction (0 means predicted not taken, 1 means predicted taken). The initial value for each prediction bit is 0 (predicted not taken). What is the total number of mis-predictions for each branch instruction when the code shown above is executed on our 5-stage scalar pipeline?
(5) Number of mispredictions for the bnez = ____
(5) Number of mispredictions for the bgtz = ____
b) Suppose that instead of using a single branch prediction bit, the system uses a separate pair of branch prediction bits for each conditional branch instruction. What is the total number of mispredictions for each of the two conditional branch instructions in this case? The initial value of the branch prediction bits for each branch instruction = 00 (strongly not taken) and the bits are updated based on the diagram below:

(5) Number of mispredictions for the bnez = _____
(5) Number of mispredictions for the bgtz = ____
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
