Search

A technology, a device or an article

Why a CPU computes ahead but commits in order

Out-of-order execution through the difference between an early result and accepted architectural state: dependencies, renaming and precise exceptions.

A kinetic wooden sculpture representing early computation and ordered acceptance of results.
A kinetic wooden sculpture representing early computation and ordered acceptance of results. Conceptual illustration created with AI.ITNWS · Original ITNWS AI-assisted editorial illustration

Consider an imaginary scene in which nothing has gone wrong. A program asks a processor to read a value from memory, add another value to it, and then perform a multiplication that does not depend on either result. The memory response is late. The multiplication is ready to go. Making it wait merely because it appears later in the program would waste an opportunity. Inside a modern high-performance core, that multiplication can therefore finish before the addition. The program can still behave as though its required instruction order has been respected.

That last qualification matters more than the apparent trick. A processor is not licensed to rearrange what a program means. It can choose when to do internal work provided the architectural result remains correct. Computing a value early and accepting an instruction as definitively executed are different events. Temporary results, dependency tracking, older operations and possible cancellation occupy the space between them. Forget that distinction and out-of-order execution looks like an arrangement that ought to fall apart at the first exception.

An exception, however, explains why the discipline exists.

Continue the same hypothetical scene. The memory access turns out to violate the access rules. Meanwhile, the multiplication has finished. What should the exception handler see? It needs a meaningful boundary: preceding instructions have completed, the faulting instruction is identifiable, and later instructions have not arbitrarily changed architectural state. A random mixture of early and late results is not a usable account of what happened. A precise exception requires a defined state rather than a vague notification that some activity somewhere became troublesome.

The Intel architecture manuals distinguish software-visible behaviour from the internal mechanisms that implement it. That separation is useful even without reading every manual. Software deals with architectural registers, instructions, addresses and exceptions. A core can maintain a much richer internal machine. Moving between these descriptions does not suspend the architectural rules. Those rules define which optimisations are allowed. Reordering is useful only while the processor preserves the behaviour that software is entitled to expect. Source: Intel architecture manuals.

An older value is still needed

Put memory aside briefly. Several instructions write successive values to the same architectural register. The name stays the same, but the computations refer to different versions of its contents. Treating that register as one literal box makes an early write threaten a value that another instruction still needs. Separate the architectural name from the physical place holding a value, and several versions can coexist. This is the point of register renaming: one name in the program need not imply one irreplaceable internal storage location.

Renaming cannot remove a genuine data dependence. When a calculation needs the result of an earlier calculation, that input really does not exist yet. Replacing a name does not manufacture the missing number. What renaming can remove is some apparent dependence created by reusing a limited set of architectural names. The processor is releasing independent work, not predicting every arithmetic answer. The grand claim that it executes out of order becomes more precise when the reason a particular operation can advance is made explicit.

Real programs seldom resemble tidy lines of classroom arithmetic. They follow pointers, test conditions, update counters and call functions. Some dependencies are immediately clear; others become clear later. The internal machine must see enough upcoming work, retain its description and find operations whose inputs and execution resources are available. That capacity is finite. A long delay cannot be hidden behind an unlimited collection of later operations, because the space for waiting work and temporary results will eventually run out.

We often call this an execution window. Its size does not equal the amount of guaranteed useful parallel work. The window may contain a dependent chain, operations competing for one resource, or activity on a wrongly predicted branch. A larger view helps discover independence when the program contains it. It does not transform a sequence in which every result is needed by the next operation into unrelated tasks. Different programs can consequently benefit very differently from the same core’s ability to look ahead.

Return to the word finish. An execution unit can produce a result that the core forwards to dependent internal operations. That does not necessarily make the result irrevocable from software’s perspective. Useful calculation can continue internally while the processor retains the ability to abandon it cleanly. Without this separation, moving beyond a delayed instruction would lose much of its value: every use of an early result would have to wait for the older work, leaving much potential overlap unavailable.

The moment an answer is accepted

In a conventional explanation of a high-performance x86 core, architectural completion is associated with retirement. The machine checks whether its oldest waiting work can be accepted without breaking the rules, then advances the boundary of accepted execution. In a teaching model, this resembles approving records in program order. It should not be mistaken for a fixed blueprint of every real processor. Queue sizes, retirement width and the implementation of the relevant structures vary. We are discussing a principle, not inventing a universal CPU specification.

Acceptance may sound like unnecessary administration. Bring back the prohibited memory read. While later results remain provisional, the processor can discard them and present the required boundary to the handler. If those results had already become irreversible architectural changes, recovery would be a different problem. Keeping work tentative lets the core move quickly without asking the application to untangle its internal haste. A completed internal micro-operation and a completed architectural instruction are therefore not convenient interchangeable descriptions.

Layers of provisional sketchwork and one retained line representing cancellable work.
Layers of provisional sketchwork and one retained line representing cancellable work. Conceptual illustration created with AI. — ITNWS · Original ITNWS AI-assisted editorial illustration

There is a particularly attractive wrong story here: the machine simply rewinds physical time. It does not. It can remove a result from accepted architectural execution and restore the required state mapping. That does not erase the energy already spent or guarantee that every internal trace never existed. Caches and other microarchitectural structures behave more subtly than a drawing rubbed clean. This distinction becomes important when discussing speculative execution and side channels, because architectural cancellation is a narrower promise than the disappearance of every observable effect.

A branch introduces another unknown. Until its condition is resolved, preparing subsequent work is difficult. Prediction lets the core choose a provisional direction. A correct guess preserves useful time. A wrong one requires work on the incorrect path to be abandoned and execution redirected. Neither a good prediction rate nor an abundance of arithmetic units permits results from an untaken path to become the program’s accepted result. Speculation creates an opportunity, accompanied by an obligation to check it.

Why work before everything is known? Waiting has a cost too, and the guessed path is often right. Whether the policy helps depends on the code. Conditions tied to irregular data can behave differently from a regular loop. Nor can the cost of a wrong guess honestly be given as one fixed number for every processor and situation. It depends on where the error is detected, what work is abandoned and how quickly useful progress resumes. A dramatic universal penalty is usually less informative than those conditions.

The Intel optimisation manual considers these questions alongside dependencies, execution resources and memory behaviour. That is more useful than an isolated slogan about more instructions per cycle. Ready operations still need suitable execution opportunities. If they all require the same busy resource, rearranging their waiting order is insufficient. Hiding a delay and executing any arbitrary collection of operations simultaneously are different capabilities, even when a specification encourages readers to combine them into one impression of width.

Memory adds another ambiguity. Two accesses may be independent or may refer to the same location. A later load’s address can become known before an earlier store’s address. Scheduling must therefore account for possible memory relationships as well as register dependencies. Prediction and verification details depend on the implementation. The broad requirement remains strict: a mistaken internal assumption must not silently change the program’s required answer. Discovering uncertainty is not permission to ignore it.

None of this means that observations made by several cores always follow a naive picture of one global queue. The architecture’s memory model supplies its own visibility and ordering rules. Those rules cannot be reduced to retirement order within one core. Correctly synchronised software uses the mechanisms specified by its language and architecture rather than trusting that instructions retire in order somewhere inside a processor. Local retirement discipline does not replace the agreement between participants sharing memory.

Some waiting remains unavoidable

Imagine a long dependent pointer chain. A value read from memory determines the next address; that value determines the address after it. Future addresses are not yet available. Even a very wide core does not receive a ready collection of unrelated requests. Other work might be found alongside the chain, but the chain itself remains dependent. This explains why considerable internal CPU complexity can sometimes do little to shorten one program’s wait without anything being broken.

When independent work is plentiful, the window, register resources and execution machinery can overlap delays. Instruction delivery and data availability still matter. It would be misleading to attribute all improvement to one mechanism merely because it has an appealing name. Performance analysis normally identifies a limiting condition and tests the explanation with measurements. This article supplies no original measurements: its imagined scenes explain causality rather than predicting the speed of a particular laptop or server.

The opening multiplication is worth revisiting. It finished early because its inputs were ready and an execution opportunity existed, not because the core received general permission to disregard order. Its result retained a particular status. It could assist further internal work before joining accepted history. If the older load succeeds, that history advances. If the load faults, execution is presented at a different, precisely defined boundary. The same early calculation fits either outcome because its acceptance was conditional.

Maintaining that boundary takes storage, checks, energy and recovery machinery. The reward is a chance to use time that would otherwise pass in idle waiting. Provisional internal activity is not a departure from a disciplined machine. It is one way to build a disciplined machine capable of considering several results that have not yet earned architectural acceptance. The distinction also explains how very different implementations can honour the same software contract without sharing an identical internal timetable.

In our imagined scene the multiplication is still ready first. It does not hurry the exception handler or demand a rewritten application. It waits until its work can become an acceptable answer. The processor gained speed by distinguishing the order of internal activity from the order of its obligations to the program.

Sources & documentation

  1. Intel architecture manuals ↗
  2. Intel optimization manual ↗