rdna2spirv: SDWA selects of v_{add,sub,subrev}_co_ci_u32 go to the sources, not the carry-out (SHADER-SDWA-CARRY-SEL) #1004

Manually merged
github merged 1 commit from gh-pr/1004/head into gh-pr/1004/base 2026-11-26 09:33:00 +00:00
Owner

@⁠thesubtleties on GitHub · 2026-11-24 16:43 UTC · original
thesubtleties:sdwa-carry-sel → main · +113 −1 · 3 files · 1 commits · merged 2026-11-24 22:19 UTC

Claimed in the coordination issue as: SHADER-SDWA-CARRY-SEL

What and why

v_add_co_ci_u32_sdwa, v_sub_co_ci_u32_sdwa and v_subrev_co_ci_u32_sdwa print the carry-out between the destination and the sources (v4, vcc_lo, v2, v3, vcc_lo). The SDWA setup assumed the sources start at operand 1, so src0_sel went to the carry-out (and was lost) and src1_sel went to src0. Any non-DWORD source selector gave a wrong value with no error. The selects now go to operands 2 and 3 for the printed form.

Tested

  • New tests/semantic/test_sdwa_carry.py (all 49 selector pairs per op in wave32, a sample in wave64, sext(), dst_sel): 164 failures without the fix, all pass with it.
  • scripts/run_semantic_tests.py on base 3ed8e50b: 470 files / 6165 tests, 0 failed; with the fix 471 / 6170, 0 failed. Rebased since; the SDWA and carry tests were rerun after the rebase.
  • run_gpu_tests.py on 3ed8e50b, per-test results identical with and without the fix: 201/252 (3080 native), 233/252 (3080, LEONIDA_W64_EMULATE=1), 234/252 (gfx1036 RADV); the only failures are the two known tfe fixtures (#31). No GPU fixture uses the new path, so these are regression checks.
  • Not measured on RDNA2 hardware, and no corpus run (I don't have the game), so I can't say whether any game shader uses these forms.

GPUs tested: NVIDIA RTX 3080 (620.73.04) and AMD RDNA2 iGPU gfx1036 (RADV, Mesa 26.3.1), CachyOS Linux 7.3.5

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.
**@⁠thesubtleties** on GitHub · 2026-11-24 16:43 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1004) `thesubtleties:sdwa-carry-sel` → `main` · +113 −1 · 3 files · 1 commits · merged 2026-11-24 22:19 UTC Claimed in the coordination issue as: SHADER-SDWA-CARRY-SEL ### What and why `v_add_co_ci_u32_sdwa`, `v_sub_co_ci_u32_sdwa` and `v_subrev_co_ci_u32_sdwa` print the carry-out between the destination and the sources (`v4, vcc_lo, v2, v3, vcc_lo`). The SDWA setup assumed the sources start at operand 1, so `src0_sel` went to the carry-out (and was lost) and `src1_sel` went to src0. Any non-DWORD source selector gave a wrong value with no error. The selects now go to operands 2 and 3 for the printed form. ### Tested - New `tests/semantic/test_sdwa_carry.py` (all 49 selector pairs per op in wave32, a sample in wave64, `sext()`, `dst_sel`): 164 failures without the fix, all pass with it. - `scripts/run_semantic_tests.py` on base `3ed8e50b`: 470 files / 6165 tests, 0 failed; with the fix 471 / 6170, 0 failed. Rebased since; the SDWA and carry tests were rerun after the rebase. - `run_gpu_tests.py` on `3ed8e50b`, per-test results identical with and without the fix: 201/252 (3080 native), 233/252 (3080, `LEONIDA_W64_EMULATE=1`), 234/252 (gfx1036 RADV); the only failures are the two known tfe fixtures (#31). No GPU fixture uses the new path, so these are regression checks. - Not measured on RDNA2 hardware, and no corpus run (I don't have the game), so I can't say whether any game shader uses these forms. GPUs tested: NVIDIA RTX 3080 (620.73.04) and AMD RDNA2 iGPU gfx1036 (RADV, Mesa 26.3.1), CachyOS Linux 7.3.5 AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:32:58 +00:00
github manually merged commit 073b8bb3a8 into gh-pr/1004/base 2026-11-26 09:33:00 +00:00
Author
Owner

@⁠KernelSmoker on GitHub · 2026-11-24 16:55 UTC · original · approved these changes

Reviewed exact head 073b8bb3a8 on current main 82a2aabcc. The new test_sdwa_carry.py passed 5/5, covering all 49 selector pairs per opcode in wave32, wave64 samples, sign extension, destination selection and the short form. The full semantic suite passed 471 files / 6,170 tests / 0 failures in Fedora 45 with SPIRV-Tools. The mutation runner caught all five relevant mutants, including removal of first = 2 (164 test failures). Docs rows 5/5, docs links 16/16, no-game-data scan and diff check passed. Synthetic CPU validation only; the PR notes no GPU fixture exercises these opcodes. Hosted label check was queued.

**@⁠KernelSmoker** on GitHub · 2026-11-24 16:55 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1004#pullrequestreview-6043677808) · **approved these changes** Reviewed exact head 073b8bb3a84c05c739d95760e4d43d3482702698 on current main 82a2aabcc. The new `test_sdwa_carry.py` passed 5/5, covering all 49 selector pairs per opcode in wave32, wave64 samples, sign extension, destination selection and the short form. The full semantic suite passed 471 files / 6,170 tests / 0 failures in Fedora 45 with SPIRV-Tools. The mutation runner caught all five relevant mutants, including removal of `first = 2` (164 test failures). Docs rows 5/5, docs links 16/16, no-game-data scan and diff check passed. Synthetic CPU validation only; the PR notes no GPU fixture exercises these opcodes. Hosted label check was queued.
Author
Owner

@⁠QemmHD on GitHub · 2026-11-24 22:19 UTC · original

Merging.

Why merged: SHADER-SDWA-CARRY-SEL: SDWA src selects on v_{add,sub,subrev}_co_ci_u32 skip the carry-out operand, so the select lands on the right source. KernelSmoker checked it.

Why it's good: Its test plus the sdwa_hw, sdwa_broadcast and sdwa_dst_mask tests: 47 passed, 2323 subtests.

Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main 4a50cafc7. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests) gives 573 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. git merge-tree against current main: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls, new subprocesses, new env vars or CI changes.

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

**@⁠QemmHD** on GitHub · 2026-11-24 22:19 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1004#issuecomment-7146083195) Merging. **Why merged:** SHADER-SDWA-CARRY-SEL: SDWA src selects on v_{add,sub,subrev}_co_ci_u32 skip the carry-out operand, so the select lands on the right source. KernelSmoker checked it. **Why it's good:** Its test plus the sdwa_hw, sdwa_broadcast and sdwa_dst_mask tests: 47 passed, 2323 subtests. Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main 4a50cafc7. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests) gives 573 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. git merge-tree against current main: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls, new subprocesses, new env vars or CI changes. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.