Definition
Write-after-Read Dependency
A write-after-read (WAR) dependency (also anti-dependency) is a data hazard in which an instruction writes to a register that a preceding instruction reads.
must not overtake in the pipeline. If writes before reads it, reads the wrong value.
This is a false dependency: does not depend on any value produced by . The conflict arises only because both instructions share the same register name. Register renaming eliminates WAR hazards by assigning a fresh physical register.
Examples
Vector Addition Loop
Consider a loop body that computes :
LW t1, 0(a0) # reads a0 LW t2, 0(a1) # reads a1 ADD t1, t1, t2 # t1 = a[i] + b[i] SW t1, 0(a2) # c[i] = t1, reads a2 ADDI a0, a0, 4 # writes a0 ADDI a1, a1, 4 # writes a1 ADDI a2, a2, 4 # writes a2Three WAR dependencies exist:
Read Write Register LW t1, 0(a0)ADDI a0, a0, 4a0LW t2, 0(a1)ADDI a1, a1, 4a1SW t1, 0(a2)ADDI a2, a2, 4a2If any
ADDIovertakes its preceding read, the base address is corrupted and the subsequent memory access uses the wrong pointer.