What is Branch delay slot?

An ISA rule that the instruction right after a branch always executes, taken or not. Found in older ISAs such as MIPS, it exposed a pipeline detail in the ISA and later became a burden.

Field: ISA & Assembly

Japanese name: 分岐遅延スロット

Why it came about

The branch delay slot was devised for RISC processors with few-stage pipelines. By the time it was decided whether a branch would be taken, the instruction after the branch was already in the pipeline. Discarding it would waste a cycle. So it was decided that, since the instruction had been fetched anyway, it would always be executed. The compiler chooses an instruction that precedes the branch and does not affect its outcome and moves it to just after the branch. If no suitable instruction is found, an instruction that does nothing is inserted.

Hard to read

In an ISA with this rule, the instruction written just after a branch is executed whether or not the branch is taken. Reading the program from top to bottom, an instruction that looks as if it runs after the branch actually runs before control moves to the target. This is a source of mistakes when reading and writing assembly language.

Why it became a burden

As pipelines gained stages, the branch outcome was decided later, and a slot of one instruction could no longer fill the waste. Meanwhile branch prediction advanced, making waste-free execution possible without the slot. Processors nevertheless had to go on honoring the rule in order to run old programs. Out-of-order execution and exception handling need special machinery that treats the slot instruction as a pair with its branch. The cause was putting a convenience of the implementation, the pipeline, into the ISA, a contract that lasts a long time. Most major ISAs designed afterwards, such as Alpha, 64-bit Arm and RISC-V, have not adopted it.

Try it: questions about Branch delay slot

What is true of the branch delay slot found in early ISAs such as MIPS (the rule that the one instruction right after a branch always executes, taken or not)?

  1. AIt makes branch prediction 100% accurate and is essential in high-performance CPUs
  2. BRISC-V adopts it too, so a nop must follow every branch
  3. CIt exposed a quirk of the pipelines of its time in the ISA and later became a burden for CPU designs
Show answer and explanation

Answer: C. It exposed a quirk of the pipelines of its time in the ISA and later became a burden for CPU designs

In a simple five-stage pipeline, the next instruction has already been fetched by the time a branch resolves, so the delay slot made it always execute to avoid waste. In later CPUs with deep pipelines, branch prediction and multiple issue, the benefit vanished and only the burden of special handling for compatibility remained. RISC-V avoids it so as not to bake implementation-dependent rules into the ISA.

FAQ

How can branch waste be reduced without a delay slot?

They use branch prediction. They predict whether the branch is taken and its target, and execute the instructions ahead before the outcome is decided. Only when the prediction is wrong do they redo the work.

Are there other similar mechanisms?

Yes. The original MIPS instruction set also has a rule that a value read from memory cannot be used by the very next instruction.

Books on ISA & Assembly Ad

As an Amazon Associate I earn from qualifying purchases.

This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.

Back to the glossary