Branch predictor
CPU component that guesses the outcome of if/loop branches before the condition is actually evaluated, so the pipeline doesn't stall. Modern predictors hit 95-99% — without them, modern CPUs would be 2-5x slower.
Designs: bimodal (2-bit counter per branch), two-level adaptive (history pattern), perceptron-based (TAGE in modern Intel/AMD). A misprediction costs 15-20 cycles (pipeline flush). Spectre (2018) exploited training of the branch predictor to leak data via side channels. Code tip: sort arrays before the loop so branches become predictable — can yield 2-6x speedup on branch-heavy kernels. __builtin_expect in GCC gives a compiler hint for predictable branches.