Recompiler: lower S_LSHL_B64, S_LSHR_B64, and S_ASHR_I64 in per-lane … #2328

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

@⁠siam4201 on GitHub · 2026-11-25 14:37 UTC · original
siam4201:per-lane-salu-shift64 → main · +63 −0 · 1 files · 1 commits · open

Lower S_LSHL_B64, S_LSHR_B64, and S_ASHR_I64 in the per-lane Direct DXIL recompiler (recomp::lower).

What is in it

  • crates/xcl/src/gpu/recomp/lower.rs: added S_LSHL_B64, S_LSHR_B64, and S_ASHR_I64 to salu_op using src64 on 32-bit pairs (sh < 32 / sh >= 32 without shift-by-32 UB) and updating SCC
  • crates/xcl/src/gpu/recomp/lower.rs: added unit test scalar_shift64 covering 0-bit, <32-bit, >=32-bit, and negative arithmetic shifts

Tested

  • Hardware: NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.2101), AMD Ryzen 9 7900X, Windows, Rust 1.97.1
  • cargo test -p xcl --lib gpu::recomp::lower: 54 passed, 0 failed (including scalar_shift64)
  • .\scripts\test.ps1 (cargo test --workspace -- --test-threads=4): 1095 passed, 4 failed (pre-existing fuzz_validate_and_gpu_0..3 E_OUTOFMEMORY #1905, same as main 568e7db), 26 ignored
  • Skipped GPU tests on this adapter: 14 no wave64, 3 per-lane form: refused (V_CVT_F16_F32, V_MUL_F16, V_PK_MUL_F16)

Regression run
main:

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: NVIDIA GeForce RTX 5070 Ti
title: 9cc6a39e
seconds: 30
exit: 0x0
frames shown: 740 (PresentX 740)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15434 MB

PR head:

xcl-smoke v1
commit: 2b70ed830d57f639068f26dd51c0214576d4e5b1
gpu: NVIDIA GeForce RTX 5070 Ti
title: 9cc6a39e
seconds: 30
exit: 0x0
frames shown: 730 (PresentX 730)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14741 MB

Not tested

  • Not tested on AMD RDNA / wave64 GPUs

AI use

  • Antigravity (Gemini 4 Neon)
**@⁠siam4201** on GitHub · 2026-11-25 14:37 UTC · [original](https://github.com/xcl-dev/xcl/pull/2328) `siam4201:per-lane-salu-shift64` → `main` · +63 −0 · 1 files · 1 commits · open Lower `S_LSHL_B64`, `S_LSHR_B64`, and `S_ASHR_I64` in the per-lane Direct DXIL recompiler (`recomp::lower`). **What is in it** - `crates/xcl/src/gpu/recomp/lower.rs`: added `S_LSHL_B64`, `S_LSHR_B64`, and `S_ASHR_I64` to `salu_op` using `src64` on 32-bit pairs (`sh < 32` / `sh >= 32` without shift-by-32 UB) and updating `SCC` - `crates/xcl/src/gpu/recomp/lower.rs`: added unit test `scalar_shift64` covering 0-bit, <32-bit, >=32-bit, and negative arithmetic shifts **Tested** - Hardware: NVIDIA GeForce RTX 5070 Ti (driver `32.0.16.2101`), AMD Ryzen 9 7900X, Windows, Rust `1.97.1` - `cargo test -p xcl --lib gpu::recomp::lower`: 54 passed, 0 failed (including `scalar_shift64`) - `.\scripts\test.ps1` (`cargo test --workspace -- --test-threads=4`): 1095 passed, 4 failed (pre-existing `fuzz_validate_and_gpu_0..3` `E_OUTOFMEMORY` #1905, same as `main` `568e7db`), 26 ignored - Skipped GPU tests on this adapter: 14 `no wave64`, 3 `per-lane form: refused` (`V_CVT_F16_F32`, `V_MUL_F16`, `V_PK_MUL_F16`) **Regression run** `main`: ``` xcl-smoke v1 commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb gpu: NVIDIA GeForce RTX 5070 Ti title: 9cc6a39e seconds: 30 exit: 0x0 frames shown: 740 (PresentX 740) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15434 MB ``` PR head: ``` xcl-smoke v1 commit: 2b70ed830d57f639068f26dd51c0214576d4e5b1 gpu: NVIDIA GeForce RTX 5070 Ti title: 9cc6a39e seconds: 30 exit: 0x0 frames shown: 730 (PresentX 730) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14741 MB ``` **Not tested** - Not tested on AMD RDNA / wave64 GPUs **AI use** - Antigravity (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:27:41 +00:00
Author
Owner

@⁠SlopTart on GitHub · 2026-11-25 14:44 UTC · original

Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).

  • gpu_ suite (--release --locked, --test-threads=2): 142 passed / 3 failed / 1 ignored, identical to plain origin/main on this rig (rig's known baseline: fuzz seed 1003 of #2115, gpu_nonfused_mad_and_mac_prevent_fma_contraction, gpu_depth_buffer_created_for_unordered_access_is_placed).
  • Targeted run of the new unit test: scalar_shift64 passes on this lane.

The 64-bit shift lowering behaves the same on RDNA3 under Wine as on the native lanes.

Not tested: retail titles (no title data on this lane, counts only).

AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.

**@⁠SlopTart** on GitHub · 2026-11-25 14:44 UTC · [original](https://github.com/xcl-dev/xcl/pull/2328#issuecomment-7165736499) **Tested**: current PR head merged onto current `origin/main` (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target `x86_64-pc-windows-gnu` run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29). - `gpu_` suite (`--release --locked`, `--test-threads=2`): 142 passed / 3 failed / 1 ignored, identical to plain `origin/main` on this rig (rig's known baseline: fuzz seed 1003 of #2115, `gpu_nonfused_mad_and_mac_prevent_fma_contraction`, `gpu_depth_buffer_created_for_unordered_access_is_placed`). - Targeted run of the new unit test: `scalar_shift64` passes on this lane. The 64-bit shift lowering behaves the same on RDNA3 under Wine as on the native lanes. **Not tested**: retail titles (no title data on this lane, counts only). **AI use**: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.
Author
Owner

@⁠upipibi on GitHub · 2026-11-25 14:59 UTC · original

A test suggestion. The shifts here mask SSRC1 to 6 bits as a 32-bit value, which matches the ISA. But the test's shift amounts are all inline constants (SSRC1 132, 164 and 128, i.e. 4, 36 and 0). shadPS4 hit this bug through register shift amounts: SSRC1 = M0, VCC_HI or EXEC_HI read as a 64-bit pair (shadps4-emu/shadPS4#5725).

A case with the shift amount in an SGPR whose upper bits are set would check that only bits [5:0] of the 32-bit source are used and that no second dword is read. For example, s_mov_b32 s20, 0xffffffe4 (low 6 bits = 36), then s_lshr_b64 s[2:3], s[0:1], s20. One case with m0 as SSRC1 would cover the special-register path too.

Read from the diff only; nothing run.

AI-assisted (Claude Code).

**@⁠upipibi** on GitHub · 2026-11-25 14:59 UTC · [original](https://github.com/xcl-dev/xcl/pull/2328#issuecomment-7166126775) A test suggestion. The shifts here mask SSRC1 to 6 bits as a 32-bit value, which matches the ISA. But the test's shift amounts are all inline constants (SSRC1 132, 164 and 128, i.e. 4, 36 and 0). shadPS4 hit this bug through *register* shift amounts: SSRC1 = M0, VCC_HI or EXEC_HI read as a 64-bit pair (shadps4-emu/shadPS4#5725). A case with the shift amount in an SGPR whose upper bits are set would check that only bits [5:0] of the 32-bit source are used and that no second dword is read. For example, `s_mov_b32 s20, 0xffffffe4` (low 6 bits = 36), then `s_lshr_b64 s[2:3], s[0:1], s20`. One case with `m0` as SSRC1 would cover the special-register path too. Read from the diff only; nothing run. AI-assisted (Claude Code).
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-25 15:04 UTC · original

Independent RX 6800M native-wave64 check of exact PR head 9e38599d230a2793cd8e8fec7ad67e321b5a6cd2.

Environment: Windows 11 build 26200; Ryzen 9 5980HX; AMD Radeon RX 6800M driver 30.0.13002.13003; Rust 1.99.0 MSVC; DXC/DXIL 1.9.2609.5. XCL_ADAPTER=6800M, XCL_REQUIRE_GPU=wave64; isolated debug Cargo target.

Clean-head test: gpu::recomp::lower::tests::scalar_shift64 passed 1/0/0, covering left, logical right, arithmetic right and zero shifts in the checked-in CPU fixture.

Local GPU fixture extension: I added those four shift operations to the existing integer GPU program, with a negative 64-bit source value. I also asserted the expected HLSL-side 64-bit register pairs and printed the selected adapter. gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu passed 1/0/0, no SKIPPED line, and printed integer GPU adapter: AMD Radeon RX 6800M. That test runs both wave32 and native wave64 on this card and compares the per-lane Direct DXIL SGPR readback against the HLSL route. The added operations checked S_LSHL_B64 by 4, S_LSHR_B64 by 36 and 0, and S_ASHR_I64 by 36. I removed all test-only changes and verified the exact-head worktree is clean.

Limits: The GPU result is from a local fixture extension, separate from the unchanged-head unit test. It does not cover dynamically supplied shift counts, all count boundaries on native wave64, the full workspace suite, a title smoke pair, or GPU timing. A separate title smoke attempt for another PR had stopped under the available-commit memory guard.

AI use: OpenAI Codex (GPT-6; exact variant unavailable in this session) ran the native Windows tests, made and restored the test-only extension, and drafted this report. No game data was used.

**@⁠luckyteagirl** on GitHub · 2026-11-25 15:04 UTC · [original](https://github.com/xcl-dev/xcl/pull/2328#issuecomment-7166250668) Independent RX 6800M native-wave64 check of exact PR head `9e38599d230a2793cd8e8fec7ad67e321b5a6cd2`. **Environment:** Windows 11 build 26200; Ryzen 9 5980HX; AMD Radeon RX 6800M driver `30.0.13002.13003`; Rust 1.99.0 MSVC; DXC/DXIL 1.9.2609.5. `XCL_ADAPTER=6800M`, `XCL_REQUIRE_GPU=wave64`; isolated debug Cargo target. **Clean-head test:** `gpu::recomp::lower::tests::scalar_shift64` passed **1/0/0**, covering left, logical right, arithmetic right and zero shifts in the checked-in CPU fixture. **Local GPU fixture extension:** I added those four shift operations to the existing integer GPU program, with a negative 64-bit source value. I also asserted the expected HLSL-side 64-bit register pairs and printed the selected adapter. `gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu` passed **1/0/0**, no `SKIPPED` line, and printed `integer GPU adapter: AMD Radeon RX 6800M`. That test runs both wave32 and native wave64 on this card and compares the per-lane Direct DXIL SGPR readback against the HLSL route. The added operations checked `S_LSHL_B64` by 4, `S_LSHR_B64` by 36 and 0, and `S_ASHR_I64` by 36. I removed all test-only changes and verified the exact-head worktree is clean. **Limits:** The GPU result is from a local fixture extension, separate from the unchanged-head unit test. It does not cover dynamically supplied shift counts, all count boundaries on native wave64, the full workspace suite, a title smoke pair, or GPU timing. A separate title smoke attempt for another PR had stopped under the available-commit memory guard. **AI use:** OpenAI Codex (GPT-6; exact variant unavailable in this session) ran the native Windows tests, made and restored the test-only extension, and drafted this report. No game data was used.
Author
Owner

@⁠nnonno91 on GitHub · 2026-11-25 14:44 UTC · original · edited 2026-11-25 15:27 UTC

@⁠siam4201 I retested the updated head 2b70ed830d57f639068f26dd51c0214576d4e5b1 on the same Windows/Radeon and RTX 5090 setup as below.

  • cargo test --locked -p xcl --lib gpu::recomp::lower -- --nocapture --test-threads=1 reported 54 passed, 0 failed, 0 ignored on each adapter with XCL_REQUIRE_GPU unset. The checked-in scalar_shift64 passed with both new cases, the register-supplied count 0xffff_ffe4 and the m0 count.
  • Logged skips within those results: Radeon six unsupported per-lane float subcases. RTX 5090 three unsupported per-lane float subcases and 18 native-wave64 subcases.
  • The first Radeon run used XCL_REQUIRE_GPU=wave64, which turned two unrelated unsupported float cases into failures (52 passed, 2 failed, 0 ignored). The shift test passed on that run too.

My temporary GPU boundary probe below was run on the earlier head. This retest used the checked-in tests on the new head.


Independent GPU check of scalar 64-bit shifts on 9e38599d230a2793cd8e8fec7ad67e321b5a6cd2.

Tested

  • Windows 11 25H2 build 26200.9974, Ryzen 7 9800X3D, AMD Radeon(TM) Graphics driver 32.0.21042.62 and GeForce RTX 5090 driver 32.0.16.1742, Rust 1.100.0 MSVC, SDK DXC/DXIL 1.8.2502.11, unoptimized profile.
  • I added a temporary local_scalar_shift64_gpu_boundaries fixture that compiled the three instructions through the per-lane DXIL kernel. It loaded the value and shift count from SGPRs, so the shift count was not a compile-time constant. It compared all three outputs to Rust for positive, negative and zero values and shift counts 0, 1, 31, 32, 33, 63, 64 and 127, using the low six bits of the count for the expected result.
  • cargo test --locked -p xcl --lib scalar_shift64 -- --nocapture --test-threads=1 ran the checked-in test and the temporary GPU fixture in separate processes with XCL_ADAPTER=AMD Radeon and XCL_ADAPTER=NVIDIA GeForce RTX 5090. Both gave 2 passed, 0 failed, 0 ignored and no skips. The GPU fixture printed the requested adapter and all 72 readbacks matched on each. The temporary fixture was removed.

Not tested

SCC readback, native wave64 execution of this fixture, the parent, retail smoke and the full workspace suite.

AI use

OpenAI Codex (GPT-6.2 Sol) added the temporary fixture, ran the tests and wrote this report.

**@⁠nnonno91** on GitHub · 2026-11-25 14:44 UTC · [original](https://github.com/xcl-dev/xcl/pull/2328#issuecomment-7165734813) · edited 2026-11-25 15:27 UTC @⁠siam4201 I retested the updated head `2b70ed830d57f639068f26dd51c0214576d4e5b1` on the same Windows/Radeon and RTX 5090 setup as below. - `cargo test --locked -p xcl --lib gpu::recomp::lower -- --nocapture --test-threads=1` reported 54 passed, 0 failed, 0 ignored on each adapter with `XCL_REQUIRE_GPU` unset. The checked-in `scalar_shift64` passed with both new cases, the register-supplied count `0xffff_ffe4` and the `m0` count. - Logged skips within those results: Radeon six unsupported per-lane float subcases. RTX 5090 three unsupported per-lane float subcases and 18 native-wave64 subcases. - The first Radeon run used `XCL_REQUIRE_GPU=wave64`, which turned two unrelated unsupported float cases into failures (52 passed, 2 failed, 0 ignored). The shift test passed on that run too. My temporary GPU boundary probe below was run on the earlier head. This retest used the checked-in tests on the new head. --- Independent GPU check of scalar 64-bit shifts on `9e38599d230a2793cd8e8fec7ad67e321b5a6cd2`. **Tested** - Windows 11 25H2 build 26200.9974, Ryzen 7 9800X3D, AMD Radeon(TM) Graphics driver 32.0.21042.62 and GeForce RTX 5090 driver 32.0.16.1742, Rust 1.100.0 MSVC, SDK DXC/DXIL 1.8.2502.11, unoptimized profile. - I added a temporary `local_scalar_shift64_gpu_boundaries` fixture that compiled the three instructions through the per-lane DXIL kernel. It loaded the value and shift count from SGPRs, so the shift count was not a compile-time constant. It compared all three outputs to Rust for positive, negative and zero values and shift counts 0, 1, 31, 32, 33, 63, 64 and 127, using the low six bits of the count for the expected result. - `cargo test --locked -p xcl --lib scalar_shift64 -- --nocapture --test-threads=1` ran the checked-in test and the temporary GPU fixture in separate processes with `XCL_ADAPTER=AMD Radeon` and `XCL_ADAPTER=NVIDIA GeForce RTX 5090`. Both gave 2 passed, 0 failed, 0 ignored and no skips. The GPU fixture printed the requested adapter and all 72 readbacks matched on each. The temporary fixture was removed. **Not tested** SCC readback, native wave64 execution of this fixture, the parent, retail smoke and the full workspace suite. **AI use** OpenAI Codex (GPT-6.2 Sol) added the temporary fixture, ran the tests and wrote this report.
Author
Owner

@⁠siam4201 on GitHub · 2026-11-25 15:29 UTC · original

A test suggestion. The shifts here mask SSRC1 to 6 bits as a 32-bit value, which matches the ISA. But the test's shift amounts are all inline constants (SSRC1 132, 164 and 128, i.e. 4, 36 and 0). shadPS4 hit this bug through register shift amounts: SSRC1 = M0, VCC_HI or EXEC_HI read as a 64-bit pair (shadps4-emu/shadPS4#5725).

A case with the shift amount in an SGPR whose upper bits are set would check that only bits [5:0] of the 32-bit source are used and that no second dword is read. For example, s_mov_b32 s20, 0xffffffe4 (low 6 bits = 36), then s_lshr_b64 s[2:3], s[0:1], s20. One case with m0 as SSRC1 would cover the special-register path too.

Read from the diff only; nothing run.

AI-assisted (Claude Code).

Added both cases (s20 = 0xffffffe4 with upper bits set and m0 = 4 as SSRC1) to scalar_shift64 in crates/xcl/src/gpu/recomp/lower.rs, amended, and re-verified (cargo test -p xcl --lib gpu::recomp::lower: 54 passed, 0 failed; smoke.ps1 updated above).

**@⁠siam4201** on GitHub · 2026-11-25 15:29 UTC · [original](https://github.com/xcl-dev/xcl/pull/2328#issuecomment-7166912523) > A test suggestion. The shifts here mask SSRC1 to 6 bits as a 32-bit value, which matches the ISA. But the test's shift amounts are all inline constants (SSRC1 132, 164 and 128, i.e. 4, 36 and 0). shadPS4 hit this bug through _register_ shift amounts: SSRC1 = M0, VCC_HI or EXEC_HI read as a 64-bit pair ([shadps4-emu/shadPS4#5725](https://github.com/shadps4-emu/shadPS4/pull/5725)). > > A case with the shift amount in an SGPR whose upper bits are set would check that only bits [5:0] of the 32-bit source are used and that no second dword is read. For example, `s_mov_b32 s20, 0xffffffe4` (low 6 bits = 36), then `s_lshr_b64 s[2:3], s[0:1], s20`. One case with `m0` as SSRC1 would cover the special-register path too. > > Read from the diff only; nothing run. > > AI-assisted (Claude Code). Added both cases (`s20 = 0xffffffe4` with upper bits set and `m0 = 4` as `SSRC1`) to `scalar_shift64` in `crates/xcl/src/gpu/recomp/lower.rs`, amended, and re-verified (`cargo test -p xcl --lib gpu::recomp::lower`: 54 passed, 0 failed; `smoke.ps1` updated above).
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 18:04 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 18:04 UTC · [original](https://github.com/xcl-dev/xcl/pull/2328#issuecomment-7170404509) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/gpu/recomp/lower.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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