Branch prediction
Branch prediction is a processor technique that forecasts the outcome or path of a control-flow branch before it is resolved.
Hacking Cryptography
Branch prediction is a processor mechanism that forecasts the outcome or target of a control-flow branch to keep instruction execution supplied.
- How it is used
- Explains how data-dependent control flow changes processor performance and motivates branchless techniques for cryptographic implementations.
- How deep it goes
- Demonstrates prediction patterns, compares timings, and reaches CMOV-based code, but does not detail predictor hardware internals.
- Examples
- Uses a threshold-summing loop, sorted and unsorted arrays, CMOV inline assembly, and measured GCC program output.
- What you can do after
- Diagnose performance variation by comparing branch patterns and apply conditional moves to construct a branchless implementation.
100 Go Mistakes and How to Avoid Them
Branch prediction is a processor technique that forecasts the outcome of a conditional branch so subsequent instructions can be executed speculatively.
- How it is used
- Explains how processors mitigate conditional-branch stalls while exploiting instruction-level parallelism.
- How deep it goes
- Explains control hazards, prediction, pipeline flushing, and penalties, but stops short of predictor implementation details.
- Examples
- Uses Go increment loops, conditional checks, execution diagrams, and contrasting dependency structures.
- What you can do after
- Diagnose performance effects by relating conditional branches and data dependencies to speculative execution and pipeline stalls.
Read how 100 Go Mistakes and How to Avoid Them explains branch prediction →
Related concepts
- control hazardaddresses · A control hazard is an instruction-execution dependency caused by a conditional branch whose outcome determines subsequent instructions.
- CPUuses · A central processing unit (CPU) is a general-purpose processor that executes computer instructions and performs computational operations.
- hardwarepart of · Hardware is the physical equipment and components of a computing system that provide resources for computation and software execution.
- branchaddresses · Branching is the selection among alternative execution paths according to a condition, outcome, or program state.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

