Recompiler: 16-bit compares read their low halves whatever op_sel says (#1293) #1286
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1296"
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 tiagonogueiraa-bit on 2026-11-24T14:27:28Z.
On RDNA2, 16-bit compares (
v_cmp_*/v_cmpx_*over f16, u16, i16) take both sources from the low halves and ignoreop_sel. This was measured on gfx1036 in Marvisak/VIctory#833.vopchonouredop_sel, soop_sel:[1,0]on0x4000_3C00 < 0x3C00_3E00compared 2.0 < 1.5 instead of 1.0 < 1.5.v_cmp_class_f16was not measured and keepsop_sel, as the issue suggests. Fixes #1293.What is in it
crates/xcl/src/gpu/recomp/emit.rs(vopc): the 16-bit halves come from the low 16 bits except forclass.crates/xcl/src/gpu/recomp/tests.rs:gpu_cmp_16_ignores_op_sel, one f16, u16 and i16 compare each, withop_selset and high halves that give the opposite answer.Tested
cargo check -p xcl --lib --tests --target x86_64-pc-windows-msvcpasses with no errors (C stubbed, not linked).gpu::recompfrommainand from this branch and ran the emitted HLSL as C++ on one lane with the test's registers. Onmainall four compares are false, so the test fails. With this change all four are true.8b247b0:gpu_cmp_16_ignores_op_selpasses in the workspace suite and run on its own. The suite's failures under Wine are also failures on the base930e8b4. (report)main):cargo test -p xcl --lib recomp, 190 passed, 0 failed, 18 ignored. (report)Later, the whole lib with
--test-threads=1: all passed, 0 failed, 21 ignored. (report)scripts/test.ps1752 passed, 0 failed, 41 ignored, noSKIPPED. With theemit.rschange reverted,gpu_cmp_16_ignores_op_selfails atwave64 v_cmp_lt_f16 op_sel:[1,0]. (report)Regression run
By @IvyNotFound:
scripts/smoke.ps1 -Seconds 60,XCL_PRESS_A_AT=15, unedited, from the report.main:
PR:
Not tested
op_selset (#1293), so this path is not reached there.AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T14:33:29Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:Thanks!
Imported from ivall/xcl. Originally posted by tiagonogueiraa-bit on 2026-11-24T14:34:13Z.
@DavidM1911 thank you! Two details would make this count for the merge:
8b247b0. Whichmaincommit was it merged with?gpu::recomp::tests::gpu_cmp_16_ignores_op_selactually ran on the GPU rather than printingSKIPPED. Runningcargo test -p xcl --lib gpu_cmp_16_ignores_op_sel -- --nocaptureshows it.If you get the chance, the whole suite (
cargo test --workspace -- --test-threads=4, with its counts) is what CONTRIBUTING asks for.Written with Claude Code (Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by vitor127wt on 2026-11-24T14:57:15Z.
Test report on RTX 5070 Ti under Wine
Following up on #1243. I tested the exact PR head
8b247b0f1068fcca07b0752a46ffea160f83b46din a separate checkout and build directory.gpu::recomp::tests::gpu_cmp_16_ignores_op_selpassed in the workspace suite and in an isolated rerun with--exact gpu::recomp::tests::gpu_cmp_16_ignores_op_sel --nocapture --test-threads=1(1 passed, 0 failed, 0 ignored, 0 skipped). The test log confirmed the RTX 5070 Ti and DXC were in use.Tested
7.3.5-2-cachyos, Wine 11.22, DXVKv2.7.1-498-ga6764047e587178, vkd3d-proton 3.1.0 from Proton-CachyOS (0bb64c56c8f0dcc), DXC 1.9.2609.5. Rust 1.100.0 and cargo-xwin 0.24.1, Windows MSVC debug target.cargo xwin build --offline --locked --target x86_64-pc-windows-msvc --workspacesucceeded.cargo xwin test --offline --locked --target x86_64-pc-windows-msvc --workspace --no-fail-fast -- --test-threads=4ran under Wine and reported 686 passed, 66 failed, 41 ignored (exit 101). Four capability skips are included in the harness's passed count and listed below.930e8b49c1c2ec683d22c724a398b39111cd0e56reported 683 passed, 68 failed, 41 ignored, with the same four skips. All 66 failure names from the PR also appeared on the base. The two additional base failures weregpu_nonfused_mad_and_mac_prevent_fma_contraction(device removed) andnever_picks_xcl_itself(file copy error). The baseline build used an on-disk target directory after a linker error on tmpfs.Not tested
Native Windows, AMD hardware and retail-title smoke runs. Retail sample environment variables were unset.
AI use
Codex (GPT-6, exact variant unavailable) cross-built and ran the tests, compared the failure lists and drafted this report.
Imported from ivall/xcl. Originally posted by tiagonogueiraa-bit on 2026-11-24T14:59:09Z.
Thank you, @vitor127wt! I added your run to Tested and marked the PR ready for review.
Written with Claude Code (Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by ySKELLETONX on 2026-11-24T15:10:56Z.
Test report on head
8b247b0(asked for in #1243). AI-written (Claude Code, Claude Opus 5.5) from real runs; checked by me.Tested
scripts/test.ps1(cargo test --workspace -- --test-threads=4): 752 passed, 0 failed, 41 ignored; noSKIPPEDlinesgpu::recomp::tests::gpu_cmp_16_ignores_op_sel: okemit.rschange reverted (test kept, base930e8b4):gpu_cmp_16_ignores_op_selfails at tests.rs:7195 (wave64 v_cmp_lt_f16 op_sel:[1,0]), so the test catches the change.Not tested
Imported from ivall/xcl. Originally posted by tiagonogueiraa-bit on 2026-11-24T15:13:22Z.
Thank you, @ySKELLETONX: the native Windows suite plus the revert check is what this PR was missing. It's in Tested now. The only thing left is an
xcl-smokepair (mainand8b247b0, same title and time) from anyone who has a title.Written with Claude Code (Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by IvyNotFound on 2026-11-24T15:23:05Z.
Regression runs for
8b247b0on Windows, thexcl-smokepair this PR still needs. Same retail title, same 60 s, unedited, made withscripts/smoke.ps1 -Seconds 60andXCL_PRESS_A_AT=15. The PR head as is (base930e8b4) andmain930e8b4, clean trees, one after the other.main:
this PR:
Not tested: the suite at this head (see the other reports here); AMD.
AI use: Claude Code, Claude Opus 5.5 ran the runs and wrote this comment.
Imported from ivall/xcl. Originally posted by tiagonogueiraa-bit on 2026-11-24T15:25:07Z.
Thank you, @IvyNotFound! Both blocks are under Regression run exactly as posted, with credit. With them the PR has everything CONTRIBUTING asks for.
Written with Claude Code (Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T16:02:04Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib -- --test-threads=1: all passed, 0 failed, 21 ignored. (Parallel runs intermittently abort with 0xc0000005 — same harness flake seen on unmodifiedmain.)Thanks!
Imported from ivall/xcl. Originally posted by tiagonogueiraa-bit on 2026-11-24T20:14:47Z.
Thank you @DavidM1911, the whole-lib run is in Tested, next to your earlier
recompone.Imported from ivall/xcl. Originally posted by milesah3ad on 2026-11-25T01:01:41Z.
The direct DXIL backend counterpart of this fix, from @regiumlepidi's parity sweep on #1269:
gpu_cmp_16_ignores_op_selpass withXCL_DIRECT_DXIL=1with the patch below. Without it they fail on the direct path.vopcingpu/dxil/lower_valu.rstook each 16-bit source from the halfop_selnamed, sov_cmp_lt_f16 op_sel:[1,0]compared the high half (your test:(0, 0)against(0xFFFFFFFF, 0)). The patch appliesop_seltoclassonly, as your HLSL change does. (#1214 / #1980 changeclass's src1 handling in the same function, so whichever lands second may need a small rebase.)How to take it: this PR predates the direct backend on
main, so rebase it ontomainfirst (your commit rebases cleanly onto7994cd1), thengit amthe patch below. Feel free to fold it into your PR with aCo-Authored-By: milesah3ad <[email protected]>line. I didn't open a separate PR, so this doesn't add another review.patch (1 commit, for
git am)Tested
main7994cd1plus this patch:gpu_cmp_16_ignores_op_selpass with and withoutXCL_DIRECT_DXIL=1.cargo test -p xcl --lib --no-fail-fast -- --test-threads=4onmain7994cd1with #587, #686, #1159 and #1296 all merged and the four direct patches applied: 948 passed, 4 failed, 25 ignored, the same in both settings. The 4 failures aregpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3, which fail the same way on plainmainhere (944 passed, 4 failed). The +4 are the PRs' own tests.Not tested: wave64 hardware (the wave64 cases SKIP here), AMD, any title, the full workspace suite (lib only).
AI use: Claude Code (Claude Opus 5.5) wrote the fix and ran the tests on the machine above. I checked the results.
upstream-sync referenced this pull request2026-11-25 04:08:41 +00:00
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-28T08:00:00Z.
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 saintwolf on 2026-11-30T16:40:27Z.
merge-check claim
head:
8b247b0f10Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-30T16:58:48Z.
merge-check
base:
9dfbe3ea66head:
8b247b0f10merge: clean (trial merge 3c5907af3bbb69e967b009e4e72078f2f07933e6; git diff --check clean; +34/-1 in crates/xcl/src/gpu/recomp/emit.rs and tests.rs)
build: cargo build --workspace -> ok (pre-existing warnings only, none from the PR's lines)
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2885 passed, 2 failed, 51 ignored; SKIPPED: 27 (22 "no wave64" — wave32-only GPU, 2 "no heap windows", 1 "cannot disable the driver cache (Developer Mode)", 2 "no xgameruntime.dll"). Failing: (1) gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, pre-existing on this machine (identical on base
9dfbe3ea); (2) the new gpu_cmp_16_ignores_op_sel: in the default environment the kernel tests run on the direct-DXIL backend (XCL_DIRECT_DXIL unset enables it, dxil/kernel.rs:63), and the same op_sel behavior still lives there (dxil/lower_valu.rs:1256) — I reproduced the identical failure on a clean base worktree with the test file copied over, so this PR is not regressing it; on the HLSL path this PR actually changes (XCL_DIRECT_DXIL=0) the test fails on base and passes with the change, confirmed first-hand on this card.review: read the whole diff and the surrounding code. The bug is real: vopc's half closure (recomp/emit.rs:4322) took each 16-bit compare source from the half op_sel named, but #1293 measured on gfx1036 that RDNA2's 16-bit compares read both sources from the low halves whatever op_sel says; the new guard keeps op_sel only for v_cmp_class_f16, which was not measured and so stays as-is. The closure is used only in the f16/u16/i16 arms of vopc, so 32/64-bit compares are untouched, and the f16 class mask (full 32-bit src1) is unchanged on both backends. All four test vectors check out by hand (f16 1.0/1.5/2.0 encodings, u16 5>2 vs 1>9, i16 -1<0 vs 32767 vs -32768) and each one discriminates high-vs-low halves. I also verified first-hand that the post-fix HLSL for the op_sel variants is byte-identical to the op_sel=0 form (dumped and diffed the generated shader and the DXC output). Thread: ySKELLETONX's RX 7600 XT full suite 752/0/41 with a revert check (the test fails with the emit.rs change reverted, so it catches the change); RTX 5070 Ti/Wine and RTX 3060 Ti runs pass; IvyNotFound's xcl-smoke main-vs-PR pair on RTX 5080 shows no regression. The direct-DXIL counterpart (same one-line guard in lower_valu.rs) is posted in-thread by milesah3ad for the author to fold in; it is not part of this PR. No unsafe, no new dependencies, no stop-criteria files touched.
performance: none; the generated condition is the same size, always low-half masked.
verdict: safe to merge
hardware / tool and model: RTX 4070 SUPER (driver 32.0.16.2140), Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 / OpenCode, Qwen 3.8 27B
Imported from ivall/xcl. Originally posted by brainhay5 on 2026-11-30T17:15:01Z.
merge-check claim
head:
8b247b0f10Imported from ivall/xcl. Originally posted by brainhay5 on 2026-11-30T20:29:01Z.
merge-check
base:
9dfbe3ea66head:
8b247b0f10merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2884 passed, 3 failed, 51 ignored; 29 SKIPPED lines; failing: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16 (fails on base too), test_title_runs_and_game_folder_is_untouched (fails on base too), gpu::recomp::tests::gpu_cmp_16_ignores_op_sel (does not exist on base — this PR adds it, and it fails)
review: automated check: diff inspected for safety only (no build/CI/toolchain/script changes, no process/network/runtime-loading code); no line-by-line review and no duplicate search performed.
performance: not assessed beyond the suite.
verdict: not yet: adds failing test(s): gpu::recomp::tests::gpu_cmp_16_ignores_op_sel
hardware / tool and model: RTX 5070 Ti 16 GB, driver 610.88 (32.0.16.1088); Ryzen 7 5800X3D, 64 GB; Windows 11 22631; OpenCode agent, DeepSeek V4.1 Flash 1017
Imported from ivall/xcl. Originally posted by Chrysana on 2026-12-01T00:13:39Z.
merge-check
base:
d0832e614fhead:
8b247b0f10merge: clean (git diff --check clean)
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2882 passed, 10 failed, 51 ignored (base: 2882 passed, 9 failed, 51 ignored); SKIPPED: 6, the same as on base (2 no heap windows, 1 cannot disable the driver cache without Developer Mode, 3 no D3D12 debug layer). This card runs wave64, so the wave64 halves of the GPU tests run here too. failing: the same 8 tests as on base (fuzz_validate_and_gpu_1, fuzz_validate_and_gpu_3, gpu_smem_flat_descriptor_windows_and_limits, f32_programs_on_the_gpu, gpu_f32_compares_with_nan, gpu_float_compares_random, gpu_ps_readfirstlane_loop_on_a_primitive_edge_ends, two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs, counted twice), plus this PR's new gpu_cmp_16_ignores_op_sel: "wave64 v_cmp_lt_f16 op_sel:[1,0]", left (0, 0), right (4294967295, 4294967295). Run alone with XCL_DIRECT_DXIL=0 it passes in wave32 and wave64.
review: I read the whole diff. The HLSL change (op_sel kept only for class) does what the description says, and on the HLSL path it passes on AMD too. The default direct-DXIL path isn't changed: vopc in gpu/dxil/lower_valu.rs:1256 still takes the high half whenever op_sel is set, for every 16-bit compare. So the new test fails on AMD exactly as brainhay5 saw on NVIDIA, and on the default path titles still get the op_sel reading this PR calls wrong. I can't confirm the RDNA 2 hardware behaviour (#1293) itself: these tests run XCL's translation on a PC GPU, not the console ISA.
performance: none expected; it changes which half a 16-bit compare reads. Not measured (Tier 1, no title run).
verdict: not yet: gpu/dxil/lower_valu.rs vopc (the
halfclosure at line 1256) needs the same rule, or the default path keeps reading op_sel and the new test fails (AMD RDNA 4 and NVIDIA)hardware / tool and model: AMD Radeon RX 9070 XT 16 GB (RDNA 4, driver 32.0.32015.2008), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 25H2 build 26200.9974, rustc 1.100.1 / Claude Code (Claude Opus 5.5)
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:21:46Z.
Triage (#1607) – head
8b247b0#1572 made the same change (ignore op_sel on 16-bit VOPC compares) and was closed as a duplicate of this PR, which was opened first. Main's
emit.rsstill applies op_sel there, so the fix is not on main.Only the HLSL path is changed; the direct DXIL counterpart posted in the thread is not part of the PR.
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.