Lukas' Notes

computer-architecture

Definition

Write-after-Write Dependency

A write-after-write (WAW) dependency (also output dependency) is a data hazard in which two instructions write to the same register.

must not overtake in the pipeline. If writes its result before , the architectural register holds the wrong value — the value from instead of the value from .

This is a false dependency: neither instruction reads the value produced by the other. The conflict arises only because both instructions share the same register name. Register renaming eliminates WAW hazards by assigning each write a distinct physical register.

Examples

LW / LI Pair

LW  a1, 0(a2)    # writes a1
LI  a1, 4        # writes a1

Both instructions target a1. If LI completes before LW (e.g. due to a cache miss on the load), the register holds 4 instead of the loaded value.

Vector Addition Loop

Consider a loop body that computes :

LW  t1, 0(a0)     # writes t1
LW  t2, 0(a1)     # writes t2
ADD t1, t1, t2    # writes t1
SW  t1, 0(a2)
ADDI a0, a0, 4
ADDI a1, a1, 4
ADDI a2, a2, 4
ADDI t0, t0, 1
BLTU t0, t3, vec_add_for

One WAW dependency exists:

WriteWriteRegister
LW t1, 0(a0)ADD t1, t1, t2t1

The register t1 is reused: first to hold a[i], then to hold the sum a[i] + b[i]. In out-of-order execution, ADD must not write its result before LW completes.