rdna2spirv: write out a carry-out subtract of a register from itself (AMD Windows driver crash) (SHADER-SUB-CO-SAME) #930

Merged
fin-github merged 1 commit from upstream-pr/930 into main 2026-11-24 22:12:01 +00:00
fin-github commented 2026-11-24 15:17:08 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fin-github on 2026-11-24T15:17:08Z.


Claimed in the coordination issue as: SHADER-SUB-CO-SAME (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135362620)

Supersedes draft #324, carried over from the original repository. This is the same commit rebased onto current main, with the original author (Wail) kept and git cherry-pick -x recording where it came from. The change and its explanation are theirs; see #324 for the original description.

Rebase note: one conflict in docs/design.md, where main had rewritten the neighbouring push-constant row. I kept main's row and inserted the new carry-out row before it.

Tested

  • tests/semantic/test_sub_co_same_operand.py: 6 tests pass.
  • Full translator suite python -I scripts/run_semantic_tests.py tests/semantic: 466 files, 6114 tests, 0 failed.
  • Not yet confirmed on hardware. The crash repro (crosslane_fuzz.py --seed 880317 --wave 64 --w64-native on AMD's proprietary Windows driver 25.30, Ryzen 5 7600X iGPU, gfx1036) needs llvm-mc with the AMDGPU target, which isn't installed on this machine yet. I'll post the before/after result here.
  • python -I scripts/check_no_game_data.py on the changed files: clean.

Windows 11 (10.0.26200), Python 3.14.4. No game files, nothing online.

AI-assisted (Claude Code): rebasing, conflict resolution and test runs.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5474955218 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/930). Originally posted by [fin-github](https://github.com/fin-github) on 2026-11-24T15:17:08Z. --- Claimed in the coordination issue as: `SHADER-SUB-CO-SAME` (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135362620) Supersedes draft #324, carried over from the original repository. This is the same commit rebased onto current `main`, with the original author (Wail) kept and `git cherry-pick -x` recording where it came from. The change and its explanation are theirs; see #324 for the original description. Rebase note: one conflict in `docs/design.md`, where `main` had rewritten the neighbouring push-constant row. I kept `main`'s row and inserted the new carry-out row before it. ### Tested - `tests/semantic/test_sub_co_same_operand.py`: 6 tests pass. - Full translator suite `python -I scripts/run_semantic_tests.py tests/semantic`: 466 files, 6114 tests, 0 failed. - **Not yet confirmed on hardware.** The crash repro (`crosslane_fuzz.py --seed 880317 --wave 64 --w64-native` on AMD's proprietary Windows driver 25.30, Ryzen 5 7600X iGPU, gfx1036) needs llvm-mc with the AMDGPU target, which isn't installed on this machine yet. I'll post the before/after result here. - `python -I scripts/check_no_game_data.py` on the changed files: clean. Windows 11 (10.0.26200), Python 3.14.4. No game files, nothing online. AI-assisted (Claude Code): rebasing, conflict resolution and test runs.
SweatierKey commented 2026-11-24 15:35:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by SweatierKey on 2026-11-24T15:35:29Z.

Review: APPROVED


Independent verification on origin/main@a28927849:

  • tests/semantic/test_sub_co_same_operand.py (LEONIDA_REQUIRE_SPIRV_TOOLS=1): 6/6 PASS (wave32, native wave64, --wave64-emulate; with and without clamp; verifies no OpISubBorrow is emitted for same-register operands and distinct equal-value registers still use OpISubBorrow).
  • tests/semantic/test_carry_exec_mask.py (LEONIDA_REQUIRE_SPIRV_TOOLS=1): 9/9 PASS.
  • spirv-as --target-env vulkan1.3 + spirv-val --target-env vulkan1.3: 24/24 PASS across all 4 ops (v_sub_co_u32, v_subrev_co_u32, v_sub_co_ci_u32, v_subrev_co_ci_u32) × {clamp=False, True} × {wave32, wave64-native, wave64-emulate}.
  • tests/test_docs_links.py: 16/16 PASS; scripts/check_no_game_data.py: clean.

Clean workaround for the amdvlk64.dll pipeline-creation AV while preserving exact borrow/clamp/EXEC semantics.

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6042344943 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/930#pullrequestreview-6042344943). Originally posted by [SweatierKey](https://github.com/SweatierKey) on 2026-11-24T15:35:29Z. **Review:** APPROVED --- Independent verification on `origin/main@a28927849`: - `tests/semantic/test_sub_co_same_operand.py` (`LEONIDA_REQUIRE_SPIRV_TOOLS=1`): `6/6` PASS (wave32, native wave64, `--wave64-emulate`; with and without `clamp`; verifies no `OpISubBorrow` is emitted for same-register operands and distinct equal-value registers still use `OpISubBorrow`). - `tests/semantic/test_carry_exec_mask.py` (`LEONIDA_REQUIRE_SPIRV_TOOLS=1`): `9/9` PASS. - `spirv-as --target-env vulkan1.3` + `spirv-val --target-env vulkan1.3`: `24/24` PASS across all 4 ops (`v_sub_co_u32`, `v_subrev_co_u32`, `v_sub_co_ci_u32`, `v_subrev_co_ci_u32`) × `{clamp=False, True}` × `{wave32, wave64-native, wave64-emulate}`. - `tests/test_docs_links.py`: `16/16` PASS; `scripts/check_no_game_data.py`: clean. Clean workaround for the `amdvlk64.dll` pipeline-creation AV while preserving exact borrow/clamp/EXEC semantics. AI-assisted: yes
aslan2142 commented 2026-11-24 22:12:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-24T22:12:03Z.


Merged. Checked locally on main 4a50cafc7 + 474dbe2be:

  • Claim: valid. SHADER-SUB-CO-SAME was posted at 15:02 UTC, before this PR, and is unedited. #739 and #1093 carried the same patch and were closed as duplicates of this one.
  • The change is value-preserving: for x - x the difference is 0 with no borrow, so D = 0 - carry in and the borrow out is the carry in. That is what the general path computes, written without OpISubBorrow %x %x.
  • tests/semantic/test_sub_co_same_operand.py: against main's translator it fails (6 tests, 24 failures); with this PR it passes (6 tests).
  • Semantic suite on the merge: 472 files, 6,183 tests, 0 files failed.
  • Also clean: the 12 test_docs_* files and check_no_game_data.py on the three changed files. The contract row is in docs/design.md.
  • Others' runs of the same patch (posted on #739): macOS on an Apple M5 Pro, Windows on gfx1036 with driver 32.0.21045.29003 and on an RX 9070, and the full GPU suite on an RTX 3080 Ti, all passing.

One open point, moved here from #739: snain0511's minimal repro does not crash the driver on the base translator either, so the exact shape that crashes amdvlk64.dll is still not reproduced. If you have it, a note here would help.

AI-assisted (Claude Code, Claude Fable 5.2).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7145931863 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/930#issuecomment-7145931863). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-24T22:12:03Z. --- Merged. Checked locally on `main` `4a50cafc7` + `474dbe2be`: - **Claim:** valid. `SHADER-SUB-CO-SAME` was posted at 15:02 UTC, before this PR, and is unedited. #739 and #1093 carried the same patch and were closed as duplicates of this one. - **The change is value-preserving:** for `x - x` the difference is 0 with no borrow, so D = 0 - carry in and the borrow out is the carry in. That is what the general path computes, written without `OpISubBorrow %x %x`. - **`tests/semantic/test_sub_co_same_operand.py`:** against `main`'s translator it fails (6 tests, 24 failures); with this PR it passes (6 tests). - **Semantic suite on the merge:** 472 files, 6,183 tests, 0 files failed. - **Also clean:** the 12 `test_docs_*` files and `check_no_game_data.py` on the three changed files. The contract row is in `docs/design.md`. - **Others' runs of the same patch** (posted on #739): macOS on an Apple M5 Pro, Windows on gfx1036 with driver 32.0.21045.29003 and on an RX 9070, and the full GPU suite on an RTX 3080 Ti, all passing. One open point, moved here from #739: snain0511's minimal repro does not crash the driver on the base translator either, so the exact shape that crashes `amdvlk64.dll` is still not reproduced. If you have it, a note here would help. AI-assisted (Claude Code, Claude Fable 5.2).
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!930
No description provided.