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

Closed
opened 2026-11-26 20:19:53 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1004
Author: @thesubtleties
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @QemmHD

Base: main ← Head: sdwa-carry-sel


📝 Commits (1)

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

📊 Changes

3 files changed (+113 additions, -1 deletions)

View changed files

📝 docs/design.md (+1 -1)
➕ tests/semantic/test_sdwa_carry.py (+110 -0)
📝 tools/rdna2spirv.py (+2 -0)

📄 Description

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.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1004 **Author:** [@thesubtleties](https://github.com/thesubtleties) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/24/2026 **Merged by:** [@QemmHD](https://github.com/QemmHD) **Base:** `main` ← **Head:** `sdwa-carry-sel` --- ### 📝 Commits (1) - [`073b8bb`](https://github.com/ubiquitarianism/leonida/commit/073b8bb3a84c05c739d95760e4d43d3482702698) rdna2spirv: SDWA selects of v_{add,sub,subrev}_co_ci_u32 go to the sources, not the carry-out (SHADER-SDWA-CARRY-SEL) ### 📊 Changes **3 files changed** (+113 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -1) ➕ `tests/semantic/test_sdwa_carry.py` (+110 -0) 📝 `tools/rdna2spirv.py` (+2 -0) </details> ### 📄 Description 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:19:53 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1042
No description provided.