From 7a55a9afcce85b589b66e5636ef33e4bf696c953 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 24 Feb 2025 16:29:37 +1000 Subject: [PATCH] nak: add reads after setting writes Otherwise we schedule this sort of thing wrong, r0 = iadd3 r0 c[0x0][0x0] rZ r0 = shf.l.w.i32 r0 rZ 0x2 r0 p0 = iadd3 r0 c[0x1][0x0] rZ since raw latencies are more important than waw, but we go do a waw for the first two instructions instead of a raw which is correct. Fixes: 2d4e4450999d ("nak/calc_instr_deps: Rewrite calc_delays() again") Reviewed-by: Faith Ekstrand Part-of: --- src/nouveau/compiler/nak/calc_instr_deps.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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;