diff --git a/src/nouveau/compiler/nak/calc_instr_deps.rs b/src/nouveau/compiler/nak/calc_instr_deps.rs index ca7102f7c7d..074134506c6 100644 --- a/src/nouveau/compiler/nak/calc_instr_deps.rs +++ b/src/nouveau/compiler/nak/calc_instr_deps.rs @@ -427,15 +427,18 @@ fn calc_delays(f: &mut Function, sm: &dyn ShaderModel) -> u32 { instr.deps.set_delay(delay); instr_cycle[ip] = min_start; + + // Set the writes before adding the reads + // as we are iterating backwards through instructions. + uses.for_each_instr_dst_mut(instr, |i, c| { + c.set_write((ip, i)); + }); uses.for_each_instr_pred_mut(instr, |c| { c.add_read((ip, usize::MAX)); }); uses.for_each_instr_src_mut(instr, |i, c| { c.add_read((ip, i)); }); - uses.for_each_instr_dst_mut(instr, |i, c| { - c.set_write((ip, i)); - }); for (bar, c) in bars.iter_mut().enumerate() { if instr.deps.wt_bar_mask & (1 << bar) != 0 { *c = min_start;