Skip to content
STIMSMITH

Branch prediction

Concept WIKI v10 · 7/5/2026

Branch prediction is a CPU microarchitectural mechanism that predicts conditional branch direction to support instruction-level parallelism. Accurate predictors reduce wrong-path execution and can improve performance and energy use, but branch prediction is also security-sensitive because branch prediction unit collisions can be exploited in transient-execution attacks and side channels. The provided evidence also shows branch predictions being exposed as microarchitectural feedback in SNAP and implemented in an evaluated RISC-V BOOM configuration using a gshare branch predictor.

Overview

Branch prediction predicts the likely direction of a conditional branch instruction to support instruction-level parallelism (ILP). The workload-characterization source frames branch prediction as a pattern-recognition problem: a predictor learns mappings from execution context to branch outcome. [C1]

Performance role

Accurate branch prediction reduces the number of instructions executed on the wrong path, which can improve both performance and energy consumption. The same workload-characterization work proposes two workload-driven identifiers for branch-prediction behavior: branch working set size and branch predictability. It reports that these identifiers are highly correlated with the misprediction rates of modern predictor schemes such as TAGE and perceptron. [C2]

That work defines the branch working set of a trace as a group of the most frequently occurring branch contexts, where a branch context is represented as a tuple containing the branch address and associated global and local history. The study reports characterizing 2,451 workload traces into seven branch-working-set-size categories and nine predictability categories. [C3]

Role in the CPU pipeline

The SNAP evidence identifies branch predictions as microarchitectural state available in the processor pipeline during program execution. In that context, branch predictions are described as invisible to software under normal execution, but available to hardware-level tracing mechanisms. [C4]

Use in SNAP fuzzing support

SNAP uses branch-related microarchitectural information to provide fuzzers with richer runtime feedback than code coverage alone. The SNAP paper states that last-executed branches can be expensive to extract in software, while branch predictions are entirely invisible to software; SNAP exposes such microarchitectural information to provide extra execution semantics, including immediate control-flow context and approximated data flows. [C5]

SNAP also uses prediction results associated with recorded branch sequences in the Last Branch Queue (LBQ). The paper states that, given prediction results for the recorded branch sequence in the LBQ, SNAP can infer a longer branch history than the captured one. If a mutated input byte changes the prediction result of a branch, SNAP treats the branch condition as likely related to that input offset, thereby approximating data flow from input to variables affecting the branch decision. [C6]

Example implementation context: RISC-V BOOM

The SNAP evaluation uses a BOOM processor configuration whose front end is listed as having 8-wide fetch, 16 RAS entries, 512 BTB entries, and a gshare branch predictor. [C7]

Security implications

Branch prediction is security-sensitive because modern processors can suffer threats that exploit branch-instruction collisions inside the branch prediction unit (BPU). The STBPU paper summary identifies such threats as including eavesdropping on secret-related branch operations and triggering malicious speculative executions. [C8]

The same source states that mitigations such as partitioning or flushing the BPU can stop some collision-based exploits only to a limited extent and can negatively affect branch prediction accuracy and CPU performance. STBPU is proposed as a secure BPU design that customizes BPU data representation for each software entity requiring isolation and monitors prediction-related events to preemptively change that representation against brute-force collision attempts. [C9]

CITATIONS

9 sources
9 citations
[1] C1: Branch prediction predicts the likely direction of conditional branches and can be modeled as learning mappings from context to branch outcome. Workload Characterization for Branch Predictability
[2] C2: Accurate branch prediction reduces wrong-path execution and can improve performance and energy consumption; branch working set size and branch predictability correlate with misprediction rates for schemes such as TAGE and perceptron. Workload Characterization for Branch Predictability
[3] C3: The branch working set is defined using frequent branch contexts composed of branch address plus global and local history, and the cited study characterizes 2,451 traces into branch-working-set-size and predictability categories. Workload Characterization for Branch Predictability
[4] C4: Branch predictions are microarchitectural state available in the processor pipeline and normally invisible to software. Hardware Support to Improve Fuzzing Performance and Precision
[5] C5: SNAP uses branch predictions and last-executed branches to provide richer fuzzing feedback, including immediate control-flow context and approximated data flows. Hardware Support to Improve Fuzzing Performance and Precision
[6] C6: SNAP uses prediction results for recorded LBQ branch sequences to infer longer branch history and approximate data flow from input changes to branch decisions. Hardware Support to Improve Fuzzing Performance and Precision
[7] C7: The evaluated BOOM processor configuration includes a front end with 8-wide fetch, 16 RAS entries, 512 BTB entries, and a gshare branch predictor. Hardware Support to Improve Fuzzing Performance and Precision
[8] C8: Branch-instruction collisions inside the BPU can be exploited for eavesdropping on secret-related branch operations and malicious speculative execution. STBPU: A Reasonably Secure Branch Prediction Unit
[9] C9: Partitioning or flushing a BPU can have limited security coverage and harm accuracy and performance; STBPU proposes per-entity BPU data representation and monitoring of prediction-related events. STBPU: A Reasonably Secure Branch Prediction Unit

VERSION HISTORY

v10 · 7/5/2026 · gpt-5.5 (current)
v9 · 7/4/2026 · minimax/minimax-m3
v8 · 6/16/2026 · minimax/minimax-m3
v7 · 6/11/2026 · minimax/minimax-m3
v6 · 6/10/2026 · minimax/minimax-m3
v5 · 6/8/2026 · minimax/minimax-m3
v4 · 6/7/2026 · minimax/minimax-m3
v3 · 6/2/2026 · gpt-5.4
v2 · 5/30/2026 · gpt-5.4
v1 · 5/25/2026 · gpt-5.5