Shaders/structure: require masks in scc_some, active, and wave_any to… #514

Open
github-bot wants to merge 1 commit from github-bot/gh-514 into main AGit
Owner

@⁠pug205gti6 on GitHub · 2026-11-25 01:56 UTC · original
pug205gti6:pr/445-shaders-structure → main · +127 −9 · 1 files · 1 commits · open

… vanish outside block reach

In structure::Builder::finish:

  1. scc_some exported every non-scc_every entry of scc_lane without checking that the mask is 0 in lanes not reaching its defining block b (cond[b]). Because Lower::scc_some evaluates waveAnyTrue over only the lanes running b, masks with set bits in inactive lanes (such as s_not_b32 s2, exec_lo, s_cmp_lg_u32 exec_lo, -1, or s_andn2_b32 s2, s_outer, exec_lo inside a divergent branch) returned false instead of hardware SCC = 1.
  2. active could retain a widened EXEC (e.g. s_or_saveexec_b32 s5, -1) written inside a divergent block even though lanes outside cond[b] do not participate in b's waveActiveBallot.
  3. wave_any[b] advertised wave-wide waveAnyTrue/waveAllTrue lowering even when a lane outside cond[b] could decide the branch.
  4. branch() needlessly ANDed vcc with exec on s_cbranch_vccz/s_cbranch_vccnz (only a no-op because s_cbranch_vccz omits EXEC from inst.reads).

Enforce implies(m, cond[b]) (or uniform support) when populating scc_some, pruning active, and validating wave_any[b], simplify s_cbranch_vccz/vccnz, and add synthetic unit tests.

**@⁠pug205gti6** on GitHub · 2026-11-25 01:56 UTC · [original](https://github.com/fxceless/victory-fork/pull/514) `pug205gti6:pr/445-shaders-structure` → `main` · +127 −9 · 1 files · 1 commits · open … vanish outside block reach In `structure::Builder::finish`: 1. `scc_some` exported every non-`scc_every` entry of `scc_lane` without checking that the mask is 0 in lanes not reaching its defining block `b` (`cond[b]`). Because `Lower::scc_some` evaluates `waveAnyTrue` over only the lanes running `b`, masks with set bits in inactive lanes (such as `s_not_b32 s2, exec_lo`, `s_cmp_lg_u32 exec_lo, -1`, or `s_andn2_b32 s2, s_outer, exec_lo` inside a divergent branch) returned `false` instead of hardware `SCC = 1`. 2. `active` could retain a widened `EXEC` (e.g. `s_or_saveexec_b32 s5, -1`) written inside a divergent block even though lanes outside `cond[b]` do not participate in `b`'s `waveActiveBallot`. 3. `wave_any[b]` advertised wave-wide `waveAnyTrue`/`waveAllTrue` lowering even when a lane outside `cond[b]` could decide the branch. 4. `branch()` needlessly ANDed `vcc` with `exec` on `s_cbranch_vccz`/`s_cbranch_vccnz` (only a no-op because `s_cbranch_vccz` omits `EXEC` from `inst.reads`). Enforce `implies(m, cond[b])` (or uniform support) when populating `scc_some`, pruning `active`, and validating `wave_any[b]`, simplify `s_cbranch_vccz`/`vccnz`, and add synthetic unit tests.
In `structure::Builder::finish`:
1. `scc_some` exported every non-`scc_every` entry of `scc_lane` without checking that the mask is 0 in lanes not reaching its defining block `b` (`cond[b]`). Because `Lower::scc_some` evaluates `waveAnyTrue` over only the lanes running `b`, masks with set bits in inactive lanes (such as `s_not_b32 s2, exec_lo`, `s_cmp_lg_u32 exec_lo, -1`, or `s_andn2_b32 s2, s_outer, exec_lo` inside a divergent branch) returned `false` instead of hardware `SCC = 1`.
2. `active` could retain a widened `EXEC` (e.g. `s_or_saveexec_b32 s5, -1`) written inside a divergent block even though lanes outside `cond[b]` do not participate in `b`'s `waveActiveBallot`.
3. `wave_any[b]` advertised wave-wide `waveAnyTrue`/`waveAllTrue` lowering even when a lane outside `cond[b]` could decide the branch.
4. `branch()` needlessly ANDed `vcc` with `exec` on `s_cbranch_vccz`/`s_cbranch_vccnz` (only a no-op because `s_cbranch_vccz` omits `EXEC` from `inst.reads`).

Enforce `implies(m, cond[b])` (or uniform support) when populating `scc_some`, pruning `active`, and validating `wave_any[b]`, simplify `s_cbranch_vccz`/`vccnz`, and add synthetic unit tests.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:45:05 +00:00
Author
Owner

@⁠Revens2 on GitHub · 2026-11-25 07:36 UTC · original

Duplicate of #445: @⁠AscilCH opened this patch 64 minutes earlier, and gh pr diff returns the same bytes for both (+127/-9 on 1 file(s), same title).

Please continue in #445 so the review history and any test data stay in one place.
Thanks.

**@⁠Revens2** on GitHub · 2026-11-25 07:36 UTC · [original](https://github.com/fxceless/victory-fork/pull/514#issuecomment-7156045429) Duplicate of #445: @⁠AscilCH opened this patch 64 minutes earlier, and `gh pr diff` returns the same bytes for both (+127/-9 on 1 file(s), same title). Please continue in #445 so the review history and any test data stay in one place. Thanks.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/514/head:github-bot/gh-514'
git switch 'github-bot/gh-514'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-514'
git switch 'github-bot/gh-514'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-514'
git switch 'github-bot/gh-514'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-514'
git switch 'main'
git merge --squash 'github-bot/gh-514'
git switch 'main'
git merge --ff-only 'github-bot/gh-514'
git switch 'main'
git merge 'github-bot/gh-514'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.