Shaders/ir: keep skips when body can resurrect EXEC or has scalar sid… #517

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

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


…e effects

In ir::without_skips, removing s_cbranch_execz causes waves with EXEC == 0 to fall through and execute the skipped region inside. Previously skipped() exempted Reg::S(126 | 127) (EXEC_LO/EXEC_HI) from join-phi checks without verifying that inside keeps EXEC == 0, and did not check inside for EXEC-independent scalar side effects.

  1. Reject skipping regions containing EXEC-independent scalar side effects (s_store_*, s_buffer_store_*, s_scratch_store_*, s_atomic_*, s_buffer_atomic_*, s_sendmsg, s_sendmsghalt, s_barrier, s_round_mode, s_denorm_mode).
  2. Compute a least fixpoint of values inside inside that may be nonzero when EXEC enters as 0 (seeded with external values other than the skip branch's own EXEC dwords), propagating zero through narrowing v_cmpx_*, s_and*/s_andn2*, s_mov_b32/s_mov_b64, and pure whole-wave sections (s_or_saveexec/s_nand_saveexec paired with an exact full-width restore). Reject if any EXEC write or phi inside inside (outside a pure whole-wave section) or incoming EXEC phi at target can become nonzero, or if a live VGPR phi at target takes a value written inside a whole-wave section.
  3. Add synthetic unit tests verifying outer-EXEC restores, s_or_b64/s_andn2_b64 EXEC widening, inner narrowing (still allowed), s_sendmsg, s_barrier, and s_buffer_store_dword.
<!-- greyfinch-sync:fxceless/victory-fork:issue:6595373859 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/517). Originally posted by [pug205gti6](https://github.com/pug205gti6) on 2026-11-25T01:57:31Z. --- …e effects In `ir::without_skips`, removing `s_cbranch_execz` causes waves with `EXEC == 0` to fall through and execute the skipped region `inside`. Previously `skipped()` exempted `Reg::S(126 | 127)` (`EXEC_LO`/`EXEC_HI`) from join-phi checks without verifying that `inside` keeps `EXEC == 0`, and did not check `inside` for EXEC-independent scalar side effects. 1. Reject skipping regions containing EXEC-independent scalar side effects (`s_store_*`, `s_buffer_store_*`, `s_scratch_store_*`, `s_atomic_*`, `s_buffer_atomic_*`, `s_sendmsg`, `s_sendmsghalt`, `s_barrier`, `s_round_mode`, `s_denorm_mode`). 2. Compute a least fixpoint of values inside `inside` that may be nonzero when `EXEC` enters as `0` (seeded with external values other than the skip branch's own `EXEC` dwords), propagating zero through narrowing `v_cmpx_*`, `s_and*`/`s_andn2*`, `s_mov_b32`/`s_mov_b64`, and pure whole-wave sections (`s_or_saveexec`/`s_nand_saveexec` paired with an exact full-width restore). Reject if any `EXEC` write or phi inside `inside` (outside a pure whole-wave section) or incoming `EXEC` phi at `target` can become nonzero, or if a live VGPR phi at `target` takes a value written inside a whole-wave section. 3. Add synthetic unit tests verifying outer-EXEC restores, `s_or_b64`/`s_andn2_b64` EXEC widening, inner narrowing (still allowed), `s_sendmsg`, `s_barrier`, and `s_buffer_store_dword`.
Revens2 commented 2026-11-25 08:09:01 +00:00 (Migrated from github.com)

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


Duplicate of #443: @AscilCH opened this patch 65 minutes earlier, and gh pr diff returns the same bytes for both (+429/-7 on 1 file(s), same title).

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

<!-- greyfinch-sync:fxceless/victory-fork:comment:7156049009 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/517#issuecomment-7156049009). Originally posted by [Revens2](https://github.com/Revens2) on 2026-11-25T07:36:22Z. --- Duplicate of #443: @AscilCH opened this patch 65 minutes earlier, and `gh pr diff` returns the same bytes for both (+429/-7 on 1 file(s), same title). Please continue in #443 so the review history and any test data stay in one place. Thanks.
Headache3318 commented 2026-11-25 08:09:05 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Headache3318 on 2026-11-25T07:51:47Z.


Independent verification: PR #517 merges cleanly onto main, touches only crates/victory-shader/src/ir.rs. Build: success. Tests: 252 passed, 1 failed, 6 ignored. Single failure (modules::net::tests::only_loopback_is_reachable) is pre-existing Wine environment issue (ws2_32.dll lacks WSAConnectByList) unrelated to the PRs shader IR changes. PR builds and passes all relevant tests. Machine: Arch Linux, kernel 7.3.5-arch1-1, 3x RTX 4090 driver 620.73.04, Proton, AI-assisted.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7156335872 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/517#issuecomment-7156335872). Originally posted by [Headache3318](https://github.com/Headache3318) on 2026-11-25T07:51:47Z. --- Independent verification: PR #517 merges cleanly onto main, touches only crates/victory-shader/src/ir.rs. Build: success. Tests: 252 passed, 1 failed, 6 ignored. Single failure (modules::net::tests::only_loopback_is_reachable) is pre-existing Wine environment issue (ws2_32.dll lacks WSAConnectByList) unrelated to the PRs shader IR changes. PR builds and passes all relevant tests. Machine: Arch Linux, kernel 7.3.5-arch1-1, 3x RTX 4090 driver 620.73.04, Proton, AI-assisted.
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/517:upstream-pr/517'
git switch 'upstream-pr/517'

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/517'
git switch 'upstream-pr/517'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/517'
git switch 'upstream-pr/517'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/517'
git switch 'main'
git merge --squash 'upstream-pr/517'
git switch 'main'
git merge --ff-only 'upstream-pr/517'
git switch 'main'
git merge 'upstream-pr/517'
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!517
No description provided.