From de1ed48325ce70565ee2c159a1911eef43d663c4 Mon Sep 17 00:00:00 2001 From: Mel Henning Date: Wed, 16 Apr 2025 18:07:03 -0400 Subject: [PATCH] nak/spill_values: Spill constants across edges if needed In a previous iteration of the spilling code, we added an extra check to only spill across edges if the value being spilled is in the W set. This was due to a misunderstanding of the modeling of S and W in Braun and Hack. In the current implementation, we maintain the invariant that every live value is in at least one of S or W so we don't need that check but it was left in by mistake. One exception to this rule was added when we special-cased constant values. Now the invariant is that every live value is in S, in W, or is a constant. When we made this change, the check we accidentally left in bit us because now if a value is constant but not in W, it wasn't getting spilled across the edge. This can result in a value getting filled later which was never spilled, leading to undefined values. Fixes: 7b82e26e3c ("nak: Don't spill/fill const values") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12993 Co-authored-by: Faith Ekstrand Reviewed-by: Faith Ekstrand Part-of: --- src/nouveau/compiler/nak/spill_values.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/nouveau/compiler/nak/spill_values.rs b/src/nouveau/compiler/nak/spill_values.rs index 36132ecf9fe..b75470f18e3 100644 --- a/src/nouveau/compiler/nak/spill_values.rs +++ b/src/nouveau/compiler/nak/spill_values.rs @@ -1003,7 +1003,8 @@ fn spill_values( } for ssa in s_in.s.iter() { - if p_out.w.contains(ssa) && !p_out.s.contains(ssa) { + if !p_out.s.contains(ssa) { + assert!(p_out.w.contains(ssa) || spill.is_const(ssa)); spills.push(*ssa); } }