Sub topic 17
Beyond the Basic Pipeline: Superscalar and Out-of-Order Execution
This chapter assumes that you understand the five-stage pipeline, pipeline hazards, forwarding, stalls, and branch prediction. The basic pipeline overlaps instructions, but it usually starts at most one instruction per clock cycle. Modern processors go further.
Superscalar execution
A superscalar processor can issue more than one instruction in a clock cycle. Its hardware has multiple execution units, such as integer arithmetic units, load/store units, and floating-point units.
For example, a two-issue processor might try to start two instructions per cycle:
| Cycle | Instruction 1 | Instruction 2 |
|---|---|---|
| 1 | `add` | `sub` |
| 2 | `load` | `and` |
The issue width is the maximum number of instructions that can begin in one cycle. A four-issue processor has a theoretical peak of four instructions per cycle, but dependencies, branches, cache misses, and limited execution units often reduce the actual rate.
Superscalar execution is different from simply adding pipeline stages. Deeper pipelining reduces the work performed in each stage and may increase clock frequency. Superscalar execution increases the number of instructions processed in parallel.
In-order and out-of-order execution
An in-order superscalar processor issues instructions in program order. If the next instruction is waiting for a slow load, later independent instructions may also wait.
An out-of-order processor looks for ready instructions and executes them when suitable hardware is available. It can preserve the program's required result while changing the internal execution order.
Consider:
lw r1, 0(r2) # may take a long time
add r3, r1, r4 # depends on the load
sub r5, r6, r7 # independentThe add must wait for r1, but the sub can execute during that wait. This hides some latency.
The processor usually uses these structures:
- An instruction window holds decoded instructions that are waiting to execute.
- Reservation stations or issue queues track which operands are ready.
- Register renaming gives different physical registers to separate writes, removing false dependencies.
- A reorder buffer records the original program order.
- Retirement, also called commit, updates the architectural state in order.
The reorder buffer is important. Instructions may execute out of order, but they retire in order. This preserves precise exceptions: if an instruction faults, the processor can present a state that appears to result from sequential execution.
Trade-offs and failure modes
Out-of-order hardware improves performance when independent work exists, but it uses more power, silicon area, and control logic. A larger instruction window can find more parallel work, yet it also increases complexity.
Performance can still collapse when:
- Instructions form a long dependency chain.
- A cache miss delays a required value.
- Branch prediction is wrong and speculative work is discarded.
- Multiple instructions compete for one execution unit.
- Register or reorder-buffer capacity is exhausted.
A useful GATE rule is to separate the issue limit, execution latency, dependencies, and retirement order. The issue width alone does not determine execution time.
Exercise
A two-issue out-of-order processor receives two independent instructions and then one instruction dependent on both results. What limits the dependent instruction?
Show answer
It cannot execute until both source results are available, even if an issue slot is free. The dependency latency, not the issue width, is the immediate limit.