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

Open
github-bot wants to merge 1 commit from github-bot/gh-978 into main AGit
Owner

@⁠OlaiFG7 on GitHub · 2026-11-24 16:10 UTC · original
OlaiFG7:worktree-agent-a0eac686e6011802d → main · +145 −3 · 3 files · 1 commits · draft

Claimed in the coordination issue as: SHADER-SALU-LITERAL-SEXT (#14)

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

**@⁠OlaiFG7** on GitHub · 2026-11-24 16:10 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/978) `OlaiFG7:worktree-agent-a0eac686e6011802d` → `main` · +145 −3 · 3 files · 1 commits · draft Claimed in the coordination issue as: SHADER-SALU-LITERAL-SEXT (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### 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)
llvm-mc prints a negative SALU literal as 0xffffff9c; the signed 64-bit ops
took it zero-extended, so it disagreed with the decimal spelling and the
explicit pair. Unsigned ops keep zero-extending. Contract-table row and a
hand-written CPU semantic test added.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:31:35 +00:00
Author
Owner

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

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.

**@⁠KernelSmoker** on GitHub · 2026-11-24 16:19 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/978#pullrequestreview-6043105850) · **approved these changes** 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.
Author
Owner

@⁠thesubtleties on GitHub · 2026-11-24 20:07 UTC · original

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** on GitHub · 2026-11-24 20:07 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/978#issuecomment-7143075986) 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)
Author
Owner

@⁠thesubtleties on GitHub · 2026-11-24 23:50 UTC · original

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)

**@⁠thesubtleties** on GitHub · 2026-11-24 23:50 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/978#issuecomment-7147848458) 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)
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/978/head:github-bot/gh-978'
git switch 'github-bot/gh-978'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-978'
git switch 'github-bot/gh-978'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-978'
git switch 'github-bot/gh-978'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-978'
git switch 'main'
git merge --squash 'github-bot/gh-978'
git switch 'main'
git merge --ff-only 'github-bot/gh-978'
git switch 'main'
git merge 'github-bot/gh-978'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.