the branch target buffer
Predicting whether a branch is taken is only half the problem; if it is taken, you also need to know where it jumps to, immediately, so the very next fetch can start from the right place. Computing the target address normally takes a few pipeline stages — too late to fetch the next instruction this cycle. The branch target buffer (BTB) solves this by remembering, for branches it has seen before, where they jumped last time, so the predicted target is available the instant the branch is even recognized.
Concretely, the BTB is a small cache indexed by the address of the branch instruction itself. Each entry stores the target address that branch went to previously (and often a direction-prediction bit or pointer too). During fetch, the current instruction address is looked up in the BTB; on a hit, the buffer immediately supplies the predicted target, and the front end redirects fetch there in the same cycle — before the branch has even been decoded, let alone executed. On a miss, the machine simply assumes sequential (fall-through) fetch until the branch resolves and then records its target for next time. So the BTB answers 'where to', while the direction predictor answers 'whether'.
The BTB is essential for keeping fetch flowing across taken branches without a bubble, and it is especially valuable for indirect branches and function returns, whose targets are not encoded in the instruction. The honest caveats: a BTB is finite, so it can miss or hold a stale target after the program changes behavior, costing a misfetch; and, like the rest of the prediction machinery, its shared, address-keyed state has been a vector for speculative side-channel attacks. Returns are often handled by a dedicated return address stack rather than the general BTB, because call/return nesting is so predictable.
A function call at address 0x4000 jumped to 0x9100 last time. The BTB records 0x4000 -> 0x9100. Next time fetch reaches 0x4000, the BTB instantly redirects fetch to 0x9100, with no bubble waiting for the target to be computed.
Cache where each branch went last time so the next fetch starts there immediately.
The BTB predicts the target, not the direction — the two are separate mechanisms. A stale or shared BTB entry can both waste cycles on a misfetch and, in attacks like Spectre-BTB, be poisoned to steer speculation maliciously.