Recompiler: lower S_LSHL_B64, S_LSHR_B64, and S_ASHR_I64 in per-lane … #2328
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2328
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2328"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@siam4201 on GitHub · 2026-11-25 14:37 UTC · original
siam4201:per-lane-salu-shift64→main· +63 −0 · 1 files · 1 commits · openLower
S_LSHL_B64,S_LSHR_B64, andS_ASHR_I64in the per-lane Direct DXIL recompiler (recomp::lower).What is in it
crates/xcl/src/gpu/recomp/lower.rs: addedS_LSHL_B64,S_LSHR_B64, andS_ASHR_I64tosalu_opusingsrc64on 32-bit pairs (sh < 32/sh >= 32without shift-by-32 UB) and updatingSCCcrates/xcl/src/gpu/recomp/lower.rs: added unit testscalar_shift64covering 0-bit, <32-bit, >=32-bit, and negative arithmetic shiftsTested
32.0.16.2101), AMD Ryzen 9 7900X, Windows, Rust1.97.1cargo test -p xcl --lib gpu::recomp::lower: 54 passed, 0 failed (includingscalar_shift64).\scripts\test.ps1(cargo test --workspace -- --test-threads=4): 1095 passed, 4 failed (pre-existingfuzz_validate_and_gpu_0..3E_OUTOFMEMORY#1905, same asmain568e7db), 26 ignoredno wave64, 3per-lane form: refused(V_CVT_F16_F32,V_MUL_F16,V_PK_MUL_F16)Regression run
main:PR head:
Not tested
AI use
@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 targetx86_64-pc-windows-gnurun 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 plainorigin/mainon 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).scalar_shift64passes 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.
@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), thens_lshr_b64 s[2:3], s[0:1], s20. One case withm0as SSRC1 would cover the special-register path too.Read from the diff only; nothing run.
AI-assisted (Claude Code).
@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_shift64passed 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_gpupassed 1/0/0, noSKIPPEDline, and printedinteger 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 checkedS_LSHL_B64by 4,S_LSHR_B64by 36 and 0, andS_ASHR_I64by 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.
@nnonno91 on GitHub · 2026-11-25 14:44 UTC · original · edited 2026-11-25 15:27 UTC
@siam4201 I retested the updated head
2b70ed830d57f639068f26dd51c0214576d4e5b1on the same Windows/Radeon and RTX 5090 setup as below.cargo test --locked -p xcl --lib gpu::recomp::lower -- --nocapture --test-threads=1reported 54 passed, 0 failed, 0 ignored on each adapter withXCL_REQUIRE_GPUunset. The checked-inscalar_shift64passed with both new cases, the register-supplied count0xffff_ffe4and them0count.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
local_scalar_shift64_gpu_boundariesfixture 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=1ran the checked-in test and the temporary GPU fixture in separate processes withXCL_ADAPTER=AMD RadeonandXCL_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.
@siam4201 on GitHub · 2026-11-25 15:29 UTC · original
Added both cases (
s20 = 0xffffffe4with upper bits set andm0 = 4asSSRC1) toscalar_shift64incrates/xcl/src/gpu/recomp/lower.rs, amended, and re-verified (cargo test -p xcl --lib gpu::recomp::lower: 54 passed, 0 failed;smoke.ps1updated above).@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!
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.Merge
Merge the changes and update on Forgejo.