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 a1Both instructions target
a1. IfLIcompletes beforeLW(e.g. due to a cache miss on the load), the register holds4instead 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_forOne WAW dependency exists:
Write Write Register LW t1, 0(a0)ADD t1, t1, t2t1The register
t1is reused: first to holda[i], then to hold the suma[i] + b[i]. In out-of-order execution,ADDmust not write its result beforeLWcompletes.