Recompiler: sign-extend 32-bit literals for 64-bit signed integer operands #1248
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1258"
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?
Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T13:49:28Z.
In RDNA2 ISA, a 32-bit literal constant (
code == 255) used for a 64-bit signed integer (i64) operand is sign-extended to 64 bits, whileu64/b64literals are zero-extended andf64literals occupy the upper 32 bits.code64only distinguishedf64vs non-f64, so negative 32-bit literals on_i64instructions (v_cmp*_i64,v_ashrrev_i64,s_ashr_i64,s_bfe_i64,s_flbit_i32_i64,v_mad_i64_i32) were zero-extended instead.This replaces
f64: booloncode64/read64withLit64 { U64, I64, F64 }, sign-extending 32-bit literals fori64instructions while keepingu64/b64andf64unchanged.What is in it
crates/xcl/src/gpu/recomp/emit.rs: addLit64 { U64, I64, F64 }and sign-extend 32-bit literals incode64/read64fori64operations insalu64andvalu64.crates/xcl/src/gpu/recomp/tests.rs: add GPU testgpu_i64_literal_is_sign_extendedcoveringV_CMP_EQ_I64,V_ASHRREV_I64,S_ASHR_I64,V_MAD_I64_I32, andV_CMP_EQ_U64control across wave32 and split wave64 (verified failing before the fix).Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1).\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 752 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2no wave64—gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware)cargo test -p xcl --lib gpu_i64_literal_is_sign_extended: 1 passed, 0 failed across wave32 and split wave64 (failed on the GPU before the fix)Regression run
main:
PR:
Not tested
AI use
emit.rs, wrote the fix and GPU test, ran the test suite andscripts/smoke.ps1regression runs, and drafted this PR description.Imported from ivall/xcl. Originally posted by dcastell1 on 2026-11-24T14:01:16Z.
Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on
main@930e8b4(baseline 751 passed, 0 failed, 41 ignored on this box):One more than the baseline; sign-extending 32-bit literals for 64-bit forms is exercised and green.
Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T14:02:20Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:Thanks!
upstream-sync referenced this pull request2026-11-24 19:06:45 +00:00
upstream-sync referenced this pull request2026-11-24 23:06:49 +00:00
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T05:00:14Z.
Tested — xcl-dev/xcl PR #1258 was open at
ba00224055aeb359476ad614ad5ec971d360836fbefore and after the run. The checkout was clean and detached at that SHA both times.STOR-WINLAB ran Windows 11 Enterprise Evaluation 25H2 x64 (
26200.9974) on a Ryzen 7 3800X and Intel Arc A770 (driver32.0.101.9175), using Rust and Cargo 1.100.0 (x86_64-pc-windows-msvc) and DXC/DXIL 1.9.2609.5.cargo test --locked -p xcl --lib --no-runcompleted outside the Arc lock in 1m 45s with exit 0. The debug build used two jobs, incremental compilation and debug info disabled, the assigned target slot, and privateTEMPandTMP.L:/XclTooling/Invoke-ArcTest.ps1in a fresh PowerShell process with process-scopedRemoteSigned. It usedXCL_ADAPTER=A770,XCL_DIRECT_DXIL=0, andXCL_DXC_DIR=%LOCALAPPDATA%/XclTooling/dxc-1.9.2609/bin/x64.Result — 1 passed, 0 failed, 0 ignored, 0 GPU skips, 728 filtered out, 0.56s. The fixture and wrapper both exited 0. The stock fixture ran standalone wave32. Both comparison masks read back as
0x00000000_FFFFFFFF, covering signed-17sign extension and the unsigned zero-extension control. The scalar arithmetic shift read back-4. On all 32 lanes, the vector arithmetic shift read back-4and the multiply-add read back-100.Not tested — Native or split wave64, direct DXIL, other adapters, the full suite, and retail smoke.
AI use — T3 Code / Codex (
gpt-6.2-sol) ran and reported the verification.Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-25T07:03:28Z.
Independent native wave64 GPU check of exact PR head
ba00224055aeb359476ad614ad5ec971d360836f. The PR description lists AMD/native wave64 as untested.Tested
30.0.13002.13003; Rust 1.99.0 MSVC; DXC/DXIL 1.9.2609.5; debug test build.XCL_ADAPTER=6800M,XCL_REQUIRE_GPU=wave64,XCL_DIRECT_DXIL=0;cargo test --locked -p xcl --lib -j 2 gpu_i64_literal_is_sign_extended -- --test-threads=1 --show-output: 1 passed, 0 failed, 0 ignored, 0 SKIPPED.gpu_waves()runs this fixture in both wave64 and wave32 on the selected AMD adapter. It exercises the HLSL emitter's signed i64 literal path and includes the unsigned control case.This is the focused GPU regression only. I did not run the full workspace suite, direct DXIL mode, or a paired title smoke on this PR; the existing RX 6800M full-suite baseline has GPU device-suspension failures unrelated to this focused test.
AI-assisted checkout, testing, log verification, and report drafting with OpenAI Codex (GPT-6). No game data was used.
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-26T16:26:17Z.
@b3IKK this PR fixes the HLSL path; the direct-DXIL path (
XCL_DIRECT_DXIL=1) has the same zero-extension:read64/code64ingpu/dxil/lower.rsalways zero-extend a 32-bit literal into a 64-bit operand, so a negative literal of a signed 64-bit operand gets a zero high word there.A direct-path change with a GPU test is on a branch you are welcome to take into this PR:
github.com/upipibi/xcl@6fd538f3(lower.rs+12/-4:read64marks the signed 64-bit operands, i.e._I64names andV_MAD_I64_I32's third operand, andcode64fills the high word with 0xFFFFFFFF for a negative literal there). The testgpu_direct_i64_literal_is_sign_extendedcoversv_cmp_eq/lt_i64,s_ashr_i64,s_bfe_i64,s_flbit_i32_i64,v_ashrrev_i64,v_mad_i64_i32, withv_cmp_eq_u64as a control. The commit also carries a test-only check that the direct path orders -0 below +0 in float min/max (it passes onmain).RTX 3070 8 GB, driver 616.56, Windows 11, debug, on
main8b957bec: the new test fails 3/3 without the change (every signed case; the unsigned control right) and passes 3/3 with it;cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4with it: 1311 passed, 0 failed, 27 ignored. Not tested: AMD/Intel, a title run.AI-assisted (Claude Code, Claude Opus 5.5): found it by porting VIctory #447's fix, wrote the change and test, ran them, wrote this.
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-12-01T02:35:09Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:15:39Z.
Triage (#1607) – head
ba00224No open or merged PR changes how emit.rs:code64 widens 32-bit literals for 64-bit integer operands.
The PR picks sign- vs zero-extension from the opcode name (
_i64suffix,v_mad_i64_i32). The literal expansion is done per operand by the hardware, and the rest of the tree assumes zero-extension for integer operands (mod.rsS_MOV_B64literal, upper_lanes.rs:src64 which says it matchesEm::code64); please cite the RDNA2 ISA or a hardware result for sign-extension on_i64ops only. If it holds, upper_lanes.rs:src64 needs the same change.The new
enum Lit64is inserted below the/// A destination register (pair).doc comment, which now documentsLit64instead ofDst.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.