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

Open
pug205gti6 wants to merge 1 commit from upstream-pr/514 into main
pug205gti6 commented 2026-11-25 01:56:40 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by pug205gti6 on 2026-11-25T01:56:40Z.


… 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.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6595363369 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/514). Originally posted by [pug205gti6](https://github.com/pug205gti6) on 2026-11-25T01:56:40Z. --- … 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.
Revens2 commented 2026-11-25 08:09:00 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Revens2 on 2026-11-25T07:36:11Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7156045429 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/514#issuecomment-7156045429). Originally posted by [Revens2](https://github.com/Revens2) on 2026-11-25T07:36:11Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/514:upstream-pr/514'
git switch 'upstream-pr/514'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/514'
git switch 'upstream-pr/514'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/514'
git switch 'upstream-pr/514'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/514'
git switch 'main'
git merge --squash 'upstream-pr/514'
git switch 'main'
git merge --ff-only 'upstream-pr/514'
git switch 'main'
git merge 'upstream-pr/514'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
fxceless/victory-fork!514
No description provided.