Shaders/structure: preserve EXEC in s_bcnt1_i32_b* SCC tracking and require matching wave width #788
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!788
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-788"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@AscilCH on GitHub · 2026-11-25 07:35 UTC · original
AscilCH:fix/shader-structure-sbcnt1-exec-and-wave-width→main· +95 −4 · 1 files · 1 commits · openSummary
Fix two
s_bcnt1_i32_b*SCC tracking bugs incrates/victory-shader/src/structure.rs(Lanes::step):Preserving narrowed
EXECinscc_lane(exitsandscc_some).Lanes::step()previously insertedown = self.b.given(m, e)intoself.scc_laneinstead ofm. WhenEXECwas narrowed inside the block (for examplev_cmp_eq_u32 vcc, 0, v0; s_and_saveexec_b32 s0, vcc_lo; s_bcnt1_i32_b32 s1, exec_lo),given(Lane(vcc), Lane(vcc))collapsed toBool::TRUE, erasingEXEC.s_cbranch_scc0lowered towhen = Bool::FALSE(dead skip branch / unguarded fallthrough even whenEXEC == 0), andStructured::scc_some[scc]evaluated to constanttrue(waveAnyTrue(true)) instead ofwaveAnyTrue(Lane(vcc)).mdirectly (self.scc_lane.insert(scc, m)).finish()still simplifiesb.given(when, cond[b])to a ballot-free uniform condition wheneverEXECmatches block reach, while preserving narrowedEXECin bothexitsandscc_some.Wave-width matching for
s_bcnt1_i32_b{32,64}.name.starts_with("s_bcnt1_i32_b")matcheds_bcnt1_i32_b64in wave32 (ignoring the high dword) ands_bcnt1_i32_b32in wave64 (counting only lanes0..31whileoperand()read the 64-bit pair).name.strip_prefix("s_bcnt1_i32_b") == Some(width), matchings_cmp_eq/lg_u{32,64}directly above.Verification
cargo test -p victory-shader --locked -- structure:::14 passed; 0 failed; 0 ignored(including news_bcnt1_preserves_narrowed_exec_in_exits_and_scc_someands_bcnt1_ignores_mismatched_wave_width).cargo test -p victory-shader --locked -- emit::tests:12 passed; 0 failed; 0 ignored.cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings: 0 warnings.cargo xtask policy:171 files ok.(AI-assisted; synthetic unit tests only, no game data.)
Fix two bugs in `Lanes::step()` for `s_bcnt1_i32_b*` (`crates/victory-shader/src/structure.rs`): 1. `self.scc_lane.insert(scc, own)` stored `own = b.given(m, e)` instead of `m`. When `EXEC` was narrowed inside the block (e.g. `s_and_saveexec_b32 s0, vcc_lo` followed by `s_bcnt1_i32_b32 s1, exec_lo`), `given(Lane(vcc), Lane(vcc))` collapsed to `Bool::TRUE`, erasing `EXEC` completely. That caused `s_cbranch_scc0` to lower to `when = Bool::FALSE` (dead skip branch / unguarded execution even when `EXEC == 0`) and caused `Structured::scc_some[scc]` to evaluate to constant `true` instead of `waveAnyTrue(Lane(vcc))`. Storing `m` directly preserves narrowed `EXEC` for both exits and `scc_some`, while `finish()` still simplifies `b.given(when, cond[b])` to a ballot-free uniform condition whenever `EXEC` matches block reach. 2. `name.starts_with("s_bcnt1_i32_b")` matched `s_bcnt1_i32_b64` in wave32 (missing the high dword) and `s_bcnt1_i32_b32` in wave64 (counting only lanes 0..31 while `operand()` read the 64-bit pair). Require the width suffix to match the shader's wave width (`name.strip_prefix("s_bcnt1_i32_b") == Some(width)`), matching `s_cmp_eq/lg_u{32,64}` directly above. Add unit tests covering narrowed-EXEC `s_bcnt1_i32_b32` branch/scc_some tracking and mismatched-width `s_bcnt1_i32_b{32,64}` rejection in wave32 and wave64.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.