Course contentsShow
← Computer Science
Lesson 1171 of 2,87227. Pipelining and PerformanceFree lesson

Load-Use Hazards

Special case where a load instruction is followed immediately by an instruction using the loaded value, requiring one stall.

Load-Use Hazards

You'll learn about a critical timing problem that occurs when an instruction immediately needs data that's still being loaded from memory.

What Is a Load-Use Hazard?

A load-use hazard is a special, unavoidable type of data hazard that happens when:

  1. A load instruction fetches data from memory
  2. The very next instruction needs to use that loaded value

Even with data forwarding (bypassing), you can't avoid a pipeline stall here. Why? Because the load instruction doesn't retrieve its data until the Memory Access stage, but the next instruction needs that value during its Execute stage—and these happen at the same time!

Why Forwarding Can't Help

Think of it like ordering food delivery:

  • You place an order (load instruction starts)
  • Your friend arrives at your house expecting to eat your food immediately (next instruction needs the data)
  • But the delivery driver is still on the way! (data hasn't arrived from memory yet)

No matter how efficiently you organize things, the driver needs time to arrive. Similarly, memory access takes at least one full clock cycle, creating a timing gap that forwarding paths cannot bridge.

The One-Cycle Stall

When the pipeline detects a load-use hazard, it must insert exactly one pipeline bubble (stall) after the load instruction. This delays the dependent instruction by one cycle, giving the load time to complete and make its data available for forwarding.

Example sequence:

LOAD R1, 0(R2)    # Load data into R1
ADD R3, R1, R4    # Needs R1 immediately → STALL required!

Key Takeaway: Load-use hazards require a mandatory one-cycle stall because memory data arrives too late for immediate use, even with forwarding—it's a fundamental timing constraint of pipelined processors.