Branch Prediction

  • Tomasulo Algorithm eliminates name dependencies (WAW and WAR)
  • Control dependencies still a problem
    • In long pipelines, branches may take many cycles before they reach the execute stages
IFIDALUWBMEMbeqxybeqxbeqsquashedbecomesa no-opNTT

Basic Branch Predictor#

a 2-bit predictor0 00 1prediction istaken1 01 1prediction isnot taken10 lowest bitsof PC01023address of branches (PC)

If everything is 0 in the table at the beginning, so it's predicted not taken. Then, when that branch is run again, the table entry is updated to 01. When the branch is run again, and it is taken, it is updated to 11.

This can be shown as: NT โ†’ NT โ†’ T

This branch predictor is known as a local branch predictor.

Better Branch Predictor (Correlating Branch Predictor)#

IFIDALUWBMEMYou are watching if thebranch is taken/not taken0000016-bit shift register000010000101Watches if branches are taken ornot and updates the shift registerThis register gets taken, and treated as a number.This time, you use the 6-bit GHR to index into a tablea 2-bit predictor0 00 1prediction istaken1 01 1prediction isnot taken063Global History Register (GHR)(On diagram, arrows show how to update the table based on actual branch outcomes)

Combining Branch Predictor (Tournament Branch Predictor)#

PCpredictionLocal BPGHRpredictionCorrelatingPredictorPCwhich predictorSelector0 00 1local1 01 1correlatinglocal correctcorrelating incorrectUpdatedecrement selectorlocal incorrectcorrelating correctincrement selectorlocal correctcorrelating correctleave it alonelocal incorrectcorrelating incorrectleave it alone
Last updated on