GATE Computer ScienceVery hardGATE CS (PYQ pattern)

The back-edge branch of an inner loop executes the outcome pattern T T T N (three taken, one exit), repeated for 6 consecutive outer iterations (24 executions in all). A 2-bit saturating counter (0,1 predict not-taken; 2,3 predict taken; taken increments, not-taken decrements) starts at state 0. How many mispredictions occur?

  1. A. 8
  2. B. 7
  3. C. 6
  4. D. 12

Correct answer: A. 8

From state 0 it mispredicts the first two T's (0→1→2), then predicts taken; each N costs one misprediction (3→2) and the counter stays in the taken half. That gives 2 + 6 exits = 8 versus a 1-bit predictor which mispredicts twice per iteration.

More Computer Organization and Architecture questions

Exams that ask this topic