rdna2spirv: sign-extend 32-bit literals in s_ashr_i64, s_bfe_i64, s_flbit_i32_i64 (SHADER-SALU-LITERAL-SEXT) #978

Closed
OlaiFG7 wants to merge 1 commit from upstream-pr/978 into main
OlaiFG7 commented 2026-11-24 16:10:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OlaiFG7 on 2026-11-24T16:10:53Z.


Claimed in the coordination issue as: SHADER-SALU-LITERAL-SEXT (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7136924696)

What and why

s_ashr_i64, s_bfe_i64 and s_flbit_i32_i64 now sign-extend a 32-bit SALU literal (Gen.imm64_signed). llvm-mc prints -100 as 0xffffff9c; the translator zero-extended it, so s_flbit_i32_i64 s8, 0xffffff9c gave 32 instead of 57 and s_ashr_i64/s_bfe_i64 gave 0 instead of all-ones. Unsigned ops still zero-extend. Finding by akimfomin in #14.

  • docs/design.md: contract-table row, confirmed by the CPU test and the llvm-mc encoding in the finding; not measured on hardware.
  • tests/semantic/test_salu_signed_literal64.py: hand-written, no game data; fails 3/5 on main, passes 5/5.

Touches the same op families as #212 / #224 (SHADER-930); a rebase conflict should be trivial.

Tested

Semantic suite: 470 files, 6148 tests; only test_sopc_validation and test_unary_f16_validation fail, because spirv-as/spirv-val are not installed here. No GPU run, no corpus count (no game files). Windows 11, CPU only.

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly
  • One topic
  • No game data, keys or decryption
  • New translator rule is in the contract table of docs/design.md

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5475887316 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/978). Originally posted by [OlaiFG7](https://github.com/OlaiFG7) on 2026-11-24T16:10:53Z. --- Claimed in the coordination issue as: SHADER-SALU-LITERAL-SEXT (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7136924696) ### What and why `s_ashr_i64`, `s_bfe_i64` and `s_flbit_i32_i64` now sign-extend a 32-bit SALU literal (`Gen.imm64_signed`). llvm-mc prints `-100` as `0xffffff9c`; the translator zero-extended it, so `s_flbit_i32_i64 s8, 0xffffff9c` gave 32 instead of 57 and `s_ashr_i64`/`s_bfe_i64` gave 0 instead of all-ones. Unsigned ops still zero-extend. Finding by akimfomin in #14. - `docs/design.md`: contract-table row, confirmed by the CPU test and the llvm-mc encoding in the finding; not measured on hardware. - `tests/semantic/test_salu_signed_literal64.py`: hand-written, no game data; fails 3/5 on main, passes 5/5. Touches the same op families as #212 / #224 (SHADER-930); a rebase conflict should be trivial. ### Tested Semantic suite: 470 files, 6148 tests; only `test_sopc_validation` and `test_unary_f16_validation` fail, because `spirv-as`/`spirv-val` are not installed here. No GPU run, no corpus count (no game files). Windows 11, CPU only. GPUs tested: n/a AI-assisted: yes ### Checklist - [ ] Based on current `main` and merges cleanly - [x] One topic - [x] No game data, keys or decryption - [x] New translator rule is in the contract table of `docs/design.md` 🤖 Generated with [Claude Code](https://claude.com/claude-code)
KernelSmoker commented 2026-11-24 16:19:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KernelSmoker on 2026-11-24T16:19:23Z.

Review: APPROVED


Verified the submitted head baee47d7a5075360ff70171c37331fd2fbc64cc0. Focused signed-literal tests passed 5/5; related BFE, FLBIT, ASHR and SALU fixture suites passed 90/90; check_no_game_data.py and diff checks passed. I also cherry-picked this exact change onto current upstream main 42d705c85bdb4a8450c2e576bca7bee8d6770c93 in an isolated worktree; the Fedora 45/Python 3.15.2 semantic suite with SPIRV-Tools passed 471 files / 6,170 tests / 0 failures (16 workers). No GPU run claimed. The PR remains a draft and GitHub has not reported its current hosted checks as green; this approval covers the tested codec/translator change.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6043105850 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/978#pullrequestreview-6043105850). Originally posted by [KernelSmoker](https://github.com/KernelSmoker) on 2026-11-24T16:19:23Z. **Review:** APPROVED --- Verified the submitted head `baee47d7a5075360ff70171c37331fd2fbc64cc0`. Focused signed-literal tests passed 5/5; related BFE, FLBIT, ASHR and SALU fixture suites passed 90/90; `check_no_game_data.py` and diff checks passed. I also cherry-picked this exact change onto current upstream main `42d705c85bdb4a8450c2e576bca7bee8d6770c93` in an isolated worktree; the Fedora 45/Python 3.15.2 semantic suite with SPIRV-Tools passed 471 files / 6,170 tests / 0 failures (16 workers). No GPU run claimed. The PR remains a draft and GitHub has not reported its current hosted checks as green; this approval covers the tested codec/translator change.
thesubtleties commented 2026-11-24 20:07:33 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by thesubtleties on 2026-11-24T20:07:33Z.


CPU check of baee47d7a merged onto main 3aa97542 (CachyOS, Python 3.14).

  • test_salu_signed_literal64.py: 5 pass; 3 failures with main's rdna2spirv.py.
  • run_semantic_tests.py tests/semantic: 471 files / 6,173 tests, 0 failed.
  • salu_diff.py (2 runs of 8,000: --inline64, --branches) is clean on both, so it doesn't reach this case.

Not tested: GPU, hardware, game corpus. AI-assisted (Claude Code)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7143075986 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/978#issuecomment-7143075986). Originally posted by [thesubtleties](https://github.com/thesubtleties) on 2026-11-24T20:07:33Z. --- CPU check of `baee47d7a` merged onto main `3aa97542` (CachyOS, Python 3.14). - `test_salu_signed_literal64.py`: 5 pass; 3 failures with main's `rdna2spirv.py`. - `run_semantic_tests.py tests/semantic`: 471 files / 6,173 tests, 0 failed. - `salu_diff.py` (2 runs of 8,000: `--inline64`, `--branches`) is clean on both, so it doesn't reach this case. Not tested: GPU, hardware, game corpus. AI-assisted (Claude Code)
thesubtleties commented 2026-11-24 23:50:11 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by thesubtleties on 2026-11-24T23:50:11Z.


Native RDNA2 result (gfx1036, tools/hw_oracle): with the literal 0xffffff9c, s_ashr_i64 by 32, s_bfe_i64 (offset 32, width 32) and s_flbit_i32_i64 give all ones, all ones and 57, so the signed ops sign-extend it, as this PR does. The unsigned forms (s_lshr_b64, s_bfe_u64, s_flbit_i32_b64) give 0, 0 and 32.

GPU suite: per-test identical to main 3aa97542 on an RTX 3080 and gfx1036, native and emulated. One chip, one literal. AI-assisted (Claude Code)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7147848458 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/978#issuecomment-7147848458). Originally posted by [thesubtleties](https://github.com/thesubtleties) on 2026-11-24T23:50:11Z. --- Native RDNA2 result (gfx1036, `tools/hw_oracle`): with the literal `0xffffff9c`, `s_ashr_i64` by 32, `s_bfe_i64` (offset 32, width 32) and `s_flbit_i32_i64` give all ones, all ones and 57, so the signed ops sign-extend it, as this PR does. The unsigned forms (`s_lshr_b64`, `s_bfe_u64`, `s_flbit_i32_b64`) give 0, 0 and 32. GPU suite: per-test identical to main `3aa97542` on an RTX 3080 and gfx1036, native and emulated. One chip, one literal. AI-assisted (Claude Code)
aslan2142 commented 2026-12-01 12:00:40 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:00:40Z.

Review: COMMENTED


Draft review against current main: this branch conflicts with main, has failing CI, and earlier independent CPU/hardware checks noted test_salu_signed_literal64.py failures and gfx1036 literal sign-extension discrepancies to reconcile in tools/rdna2spirv.py:6509-6518. Please address those findings, rebase onto current main, and mark Ready for Review so CI runs green.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6130850864 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/978#pullrequestreview-6130850864). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T12:00:40Z. **Review:** COMMENTED --- Draft review against current `main`: this branch conflicts with `main`, has failing CI, and earlier independent CPU/hardware checks noted `test_salu_signed_literal64.py` failures and gfx1036 literal sign-extension discrepancies to reconcile in `tools/rdna2spirv.py:6509-6518`. Please address those findings, rebase onto current `main`, and mark Ready for Review so CI runs green. *(AI-assisted review.)*
aslan2142 commented 2026-12-01 12:18:48 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:18:48Z.


Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review.

(AI-assisted triage.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7310952700 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/978#issuecomment-7310952700). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T12:18:48Z. --- Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review. *(AI-assisted triage.)*
aslan2142 commented 2026-12-01 12:59:26 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:59:26Z.

Review: CHANGES_REQUESTED


Now ready for review, requesting changes before merge:

  • Merge conflicts (CONFLICTING/DIRTY): conflicts with main in docs/design.md and tools/rdna2spirv.py.
  • Review/CI: address the tests/semantic/test_salu_signed_literal64.py findings, rebase onto current main, and get fresh green CI (existing 2026-11-25 runs failed).

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6131724985 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/978#pullrequestreview-6131724985). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T12:59:26Z. **Review:** CHANGES_REQUESTED --- Now ready for review, requesting changes before merge: - **Merge conflicts (`CONFLICTING`/`DIRTY`)**: conflicts with `main` in `docs/design.md` and `tools/rdna2spirv.py`. - **Review/CI**: address the `tests/semantic/test_salu_signed_literal64.py` findings, rebase onto current `main`, and get fresh green CI (existing 2026-11-25 runs failed). *(AI-assisted review.)*
aslan2142 commented 2026-12-01 16:32:44 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:32:44Z.


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:7317783488 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/978#issuecomment-7317783488). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:32:44Z. --- 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!978
No description provided.