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 <faith.ekstrand@collabora.com>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34563>
(cherry picked from commit de1ed48325)
This commit is contained in:
Mel Henning 2025-04-16 18:07:03 -04:00 committed by Eric Engestrom
parent fe3c767841
commit 53c8864428
2 changed files with 3 additions and 2 deletions

View file

@ -1484,7 +1484,7 @@
"description": "nak/spill_values: Spill constants across edges if needed",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "7b82e26e3c289b2937df65f610d6ffc734e3bbde",
"notes": null

View file

@ -1003,7 +1003,8 @@ fn spill_values<S: Spill>(
}
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);
}
}