Architecture

Branch Prediction

A technique where processors guess the outcome of conditional branches before they're resolved to maintain pipeline flow.

Detailed Explanation

Branches create uncertainty in pipelined processors—the next instruction to fetch depends on a comparison that won't complete for several cycles. Branch prediction guesses the outcome, allowing speculative instruction fetch. If wrong, the pipeline flushes and restarts from the correct path.

Predictors range from simple (always taken, backward taken/forward not taken) to complex (two-level adaptive, neural predictors). Modern predictors achieve >95% accuracy on typical code, but mispredictions cost 10-20 cycles each.