IT lexicon Hardware Speculative execution

Speculative execution

Hardware På svenska → Updated: 2026-05-29

When a CPU guesses which way the code will go (e.g. the outcome of a condition) and starts executing instructions ahead of time, before it knows for sure. If it guesses right, time is saved; if it guesses wrong, the results are discarded. One of the most important techniques behind modern CPU speed — and the root of Spectre/Meltdown.

Why: waiting for a condition's outcome (or data from memory) would stall the pipeline. Instead the branch predictor forecasts the most likely path and the CPU runs on speculatively; if it turns out wrong, the state is rolled back as if nothing happened. Win: keeps the deep pipeline full → much higher throughput. The downside: even though architectural state is rolled back, speculation leaves traces in the cache → side-channel attacks (Spectre, Meltdown, 2018) can read secrets via timing. Mitigations cost performance and spawned a whole research wave. Related to out-of-order and branch prediction.

← Back to the lexicon