shader: omit native subgroup votes for dead scalar conditions #1272

Closed
Kadamitas wants to merge 1 commit from upstream-pr/1272 into main
Kadamitas commented 2026-11-24 21:08:15 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Kadamitas on 2026-11-24T21:08:15Z.


Claimed in the coordination issue as: dead scalar condition votes

What and why

Use the existing scalar condition liveness analysis for native wave32 and wave64. When the shader overwrites the condition before another instruction reads it, omit the vote that would compute that condition. Preserve the mask result and keep the vote at control-flow joins where it remains live.

Tested

  • On the Nov 27 rebase onto 43a9d562d, all 62 focused SALU, wave64, WREXEC, and DPP tests passed.
  • A hand-written control reduced one subgroup vote to zero. Lane outputs matched before and after. Both votes remained in a separate live branch-join control.
  • 675 translator tests passed before the latest-main rebase. On the final branch, 135 focused semantic and SPIR-V checks passed with one platform skip.
  • The WREXEC positive control explicitly consumes SCC so that it continues to verify vote emission when the value is live.
  • The broader run on the earlier base covered 6,169 tests in 470 files. WREXEC was the only failing file. Its two vote-emission assertions used a dead result. The updated WREXEC case passed on the final branch.
  • The design contract records the rule. Verification uses synthetic inputs and SPIR-V validation.

GPUs tested: n/a (translator and semantic tests)

AI-assisted: yes

  • One topic with synthetic inputs and no game data.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5480362492 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1272). Originally posted by [Kadamitas](https://github.com/Kadamitas) on 2026-11-24T21:08:15Z. --- Claimed in the coordination issue as: [dead scalar condition votes](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7144523872) ### What and why Use the existing scalar condition liveness analysis for native wave32 and wave64. When the shader overwrites the condition before another instruction reads it, omit the vote that would compute that condition. Preserve the mask result and keep the vote at control-flow joins where it remains live. ### Tested - On the Nov 27 rebase onto `43a9d562d`, all 62 focused SALU, wave64, WREXEC, and DPP tests passed. - A hand-written control reduced one subgroup vote to zero. Lane outputs matched before and after. Both votes remained in a separate live branch-join control. - 675 translator tests passed before the latest-main rebase. On the final branch, 135 focused semantic and SPIR-V checks passed with one platform skip. - The WREXEC positive control explicitly consumes SCC so that it continues to verify vote emission when the value is live. - The broader run on the earlier base covered 6,169 tests in 470 files. WREXEC was the only failing file. Its two vote-emission assertions used a dead result. The updated WREXEC case passed on the final branch. - The design contract records the rule. Verification uses synthetic inputs and SPIR-V validation. GPUs tested: n/a (translator and semantic tests) AI-assisted: yes - [x] One topic with synthetic inputs and no game data.
PierreEbele commented 2026-11-25 14:45:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-25T14:45:31Z.


Reviewed e7e359fa: ran the touched semantic test files on the PR tree and its merge base (the new and the flipped tests fail without the fix, the rest pass) and the whole translator suite on the PR tree: 471 files, 6178 tests, 0 failures. Probed the gate with hand-built shaders: loop back-edge carries the SCC, s_cbranch_scc joins, dead+live pairs and wave64 native joins give identical values to main, with votes dropped only for provably dead SCC writes. test_translate skips on this host (llvm-mc/spirv-tools), so the WQM_MASK edit is unverified. No findings; heads-up that the docs/design.md contract row conflicts on merge with current main. AI-assisted review.

Recommendation: Merge

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7165768319 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1272#issuecomment-7165768319). Originally posted by [PierreEbele](https://github.com/PierreEbele) on 2026-11-25T14:45:31Z. --- Reviewed e7e359fa: ran the touched semantic test files on the PR tree and its merge base (the new and the flipped tests fail without the fix, the rest pass) and the whole translator suite on the PR tree: 471 files, 6178 tests, 0 failures. Probed the gate with hand-built shaders: loop back-edge carries the SCC, s_cbranch_scc joins, dead+live pairs and wave64 native joins give identical values to main, with votes dropped only for provably dead SCC writes. test_translate skips on this host (llvm-mc/spirv-tools), so the WQM_MASK edit is unverified. No findings; heads-up that the docs/design.md contract row conflicts on merge with current main. AI-assisted review. **Recommendation:** Merge
MoonEyes commented 2026-11-28 02:52:41 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T02:52:41Z.


Hi @Kadamitas, thanks for this pull request. It currently conflicts with main (conflicting file(s): tools/rdna2spirv.py), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232651164 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1272#issuecomment-7232651164). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T02:52:41Z. --- Hi @Kadamitas, thanks for this pull request. It currently conflicts with `main` (conflicting file(s): `tools/rdna2spirv.py`), so it carries the `needs rebase` label. CONTRIBUTING.md asks authors to rebase their branch on `main`; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here. AI-assisted (Claude Code, Claude Opus 5.5).
aslan2142 commented 2026-12-01 11:30:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:30:25Z.

Review: CHANGES_REQUESTED


The dead-SCC vote elision logic looks sound across both straight-line and branchy native wave32/wave64 shaders (wave64_emulate_opt.scc_live_outs accounts for every %scc reader in tools/rdna2spirv.py), and all touched semantic/contract tests pass locally once rebased onto main.

Please rebase onto current main and get a fresh green CI run before merge — the branch currently conflicts in:

  • tools/rdna2spirv.py:563-565 (Gen.__init__, where self.ms_serial was added right above self.scc_live)
  • tools/rdna2spirv.py:19729-19736 (_translate, where tid computation was added inside if g.emulate:)

Once rebased cleanly with green CI checks, this is ready to merge.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6130337397 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1272#pullrequestreview-6130337397). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T11:30:25Z. **Review:** CHANGES_REQUESTED --- The dead-SCC vote elision logic looks sound across both straight-line and branchy native wave32/wave64 shaders (`wave64_emulate_opt.scc_live_outs` accounts for every `%scc` reader in `tools/rdna2spirv.py`), and all touched semantic/contract tests pass locally once rebased onto `main`. Please rebase onto current `main` and get a fresh green CI run before merge — the branch currently conflicts in: - `tools/rdna2spirv.py:563-565` (`Gen.__init__`, where `self.ms_serial` was added right above `self.scc_live`) - `tools/rdna2spirv.py:19729-19736` (`_translate`, where `tid` computation was added inside `if g.emulate:`) Once rebased cleanly with green CI checks, this is ready to merge. *(AI-assisted review.)*
aslan2142 commented 2026-12-01 17:22:39 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T17:22:39Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7319201308 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1272#issuecomment-7319201308). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T17:22:39Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

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
ProjectLeonida/mandy!1272
No description provided.