A pipeline stall is a temporary pause in instruction-pipeline progress. One or more execution units become idle while waiting for information or a resource before continuing. These idle cycles, often called bubbles, reduce the potential throughput of a full pipeline. section 8.1.1
Pipeline stalls matter because:
- Instruction pipelining overlaps fetch, decode, execute, and write-back stages, aiming to complete one instruction per cycle after the pipeline fills. section 8.1.1 section 8.3
- A conditional branch can leave the pipeline waiting because the CPU does not yet know which instruction path to fetch. section 8.1.1 section 8.3
- Branch prediction reduces these stalls by guessing the branch outcome before the condition is evaluated. section 8.3
A conditional branch
Consider an if/else statement. Its pseudo-assembly loads and compares a value, executes BEQ ELSE, and then calls either foo() or bar(). Until the branch outcome is known, fetching the correct next instructions may pause or follow the wrong path, creating wasted cycles. section 8.1.1
... ; Something before
LOAD R1, a ; i1: Load a into register R1
CMP R1, #0 ; i2: Compare R1 with 0 (the result is checked in the next instruction)
BEQ ELSE ; i3: If a == 0, branch to ELSE
CALL foo ; i4: Call foo() if a == 0
JMP END ; i5: Skip ELSE section
ELSE:
CALL bar ; i6: Call bar() if a != 0
END:
; Something after
foo:
... ; Starts from i100
bar:
... ; Starts from i200
Browse the pseudo-assembly listing for the conditional-branch example. section 8.1.1
