Static
-
always not taken
-
always taken
-
BTFN (backward taken, forward not taken)
- predict
Twhen the branch goes backward (loops for ex) - predict
Nwhen the branch goes forward (jump to section further in the code)
- predict
-
FTBN (forwards taken, backwards not taken)
- opposite of BTFN
-
Profile based (likely direction)
-
program analysis based (likely direction)
The compiler can optimise for this if it’s architecture aware.
Dynamic Branch Prediction
we can either have a GHR (global history) that indexes into a PHT
- so if we globally last saw TT → index into PHT with that and get 01 or something back
or we can have local branch history, with a PHT for each branch index
2-bit Counter


This means that we just take the last branch outcome and use it as the FSM input. No PHT needed.
Two-level Global Branch Prediction

Instead of only indexing into the PHT via two last seen states, we instead use the previous branch direction as well.
Example of what a table in use looks like:

- TT → 01 means that when it sees TT prev access, it’s weakly not taken.
The architecture of this looks like:

Example:

Adding more Context

We can also index using branch address as well, to add more “context”.
Local Branch History


Implementation:

Aside - Taxonomy

Hybrid Predictors
There is heterogeneity → ifs, loops, etc…
so we use multiple predictors and predict which predictor to use.
More Advanced
Perceptron
TAGE
Different History lengths for different branches, chosen dynamically.