Recompiler: v_cmp_class_f32 applies ABS / NEG to the sign bit (#1281) #1299
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1309"
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 upipibi on 2026-11-24T14:34:26Z.
v_cmp_class_f32took its operand throughfsrc, so ABS became HLSLabs()and NEG a float negation. DXIL makes the negationfsub -0.0, x. On a GPU that flushes f32 denormals, which NVIDIA does under D3D12's default,-(+denormal)came out as -0 and was classed as a zero. The f16 and f64 forms already apply the modifiers to the sign bit (emit.rs, the f64 comment explains why). The f32 form now does the same, andfclasstakes the bits (fclass(uint u), likefclass16), so there is no float on the way at all. Found by @hyperland956-lgtm by reading the source (#1281); this PR measures it and fixes it.Fixes #1281.
What is in it
gpu/recomp/emit.rs, VOPC f32class: ABS is& 0x7FFFFFFFuand NEG is^ 0x80000000uon the raw bits, infsrc's order (ABS, then NEG), andfclasstakesuint(its only caller). The other f32 compares are unchanged.gpu/recomp/tests.rs:gpu_cmp_class_f32_modifiers_keep_denormals_and_snanhas 8 cases, in wave32 and wave64 (split here):-(+denormal)is a negative denormal and not -0;|-denormal|is a positive denormal and not +0;-sNaNand|-sNaN|are signalling NaNs and not quiet ones.Tested
main930e8b4at its first case (-(+denormal) is -denormal: the class comes out as -0) and passes with the change.gpu_cmp_class_f16_preserves_snanstill passes.cargo build --workspace+cargo test --workspace --no-fail-fast -- --test-threads=4atd8a3129: 751 passed, 1 failed, 41 ignored.hle::xaudio2::tests::opus_source_voice_decodes_and_manages_lifetime(the voice never starts:STARTED0). It failed the same way onmain930e8b4while a parallel 24-thread C++ build had the CPU, and passed in a later full suite on this PC once that build was done: it gives the voice 3 s to start, so it is load-sensitive here, not affected by this change.gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.Regression run
From Kalmarv's run (https://github.com/ivall/xcl/pull/1309#issuecomment-7138104622), thanks:
main:
PR:
Not tested
v_cmp_class_f32with modifiers.AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T14:44:41Z.
Full-suite run, since this PR has no test report yet. Tested exact head
63ac4aa(on its base930e8b4).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.gpu_cmp_class_f32_modifiers_keep_denormals_and_snan.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored, no skips.v_cmp_class_f32to the sign bit; all three were opened within six minutes (#1308 23 s before this one).Not tested
AI use
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T15:42:02Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 21 ignored. (One run aborted with 0xc0000005 under parallel scheduling; clean on rerun — same flake seen on unmodifiedmain.)Thanks!
Imported from ivall/xcl. Originally posted by eizispark on 2026-11-24T15:48:23Z.
Hardware test report — commit
63ac4aaVerified clean merge with
main(930e8b4) on63ac4aa64e8f01971d61fde856116dbdac5bba82: pass.Tested
rustc 1.100.0 (0ef1bc386 2026-11-09), release + test profilecargo test --workspace --no-fail-fast -- --test-threads=4:752 passed, 0 failed, 41 ignored(GPU tests skipped on this adapter:none), includinggpu::recomp::tests::gpu_cmp_class_f32_modifiers_keep_denormals_and_snan(native wave32 and native wave64) andhle::xaudio2::tests::opus_source_voice_decodes_and_manages_lifetimeXCL_SPLIT_WAVE64=1 cargo test -p xcl --lib gpu::recomp::tests::gpu_cmp_class_f32_modifiers_keep_denormals_and_snan -- --exact:1 passed, 0 failed, 0 skippedRegression run
main(930e8b4):PR (
63ac4aa):Not tested
XCL_D3D12_DEBUG=1; gameplay past the menusAI use
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-24T16:43:18Z.
Regression pair for
d8a3129againstmain930e8b4(this PR's base), for the Regression run section. Both runs pass: no device removal, no crash, 94 % ofmain's frames, 94 % of its peak commit.Tested
scripts/smoke.ps1, the same retail title for 60 s each:mainat930e8b4(this PR's base) first, then this PR's head, one after the other on the same machine.main930e8b4:this PR,
d8a3129:Presents per 2 s over the whole run (from the
activity (2 s)lines):main: 0 31 59 52 31 60 60 60 60 60 60 60 60 60 59 46 52 60 60 60 45 58 19 3 2 8 28 44 47 16The first 44 s are close (1113 frames against 1153). Most of the 84-frame gap is a slow phase from about 44 s that both runs have, which lasted longer in the PR's run (123 frames in the last 16 s against 167). We see the same shape in other pairs today where the PR runs second, and are checking whether run order explains it, so one pair can't separate this from run-to-run spread.
Not tested
v_cmp(x)_class_f32with ABS or NEG: not counted.AI use: Claude Code (Claude Opus 5.5)
Imported from ivall/xcl. Originally posted by throny on 2026-11-24T20:29:49Z.
Two contributors checked independently and found that this PR makes the same change as #1306 #1340 #1569 (for #1281): #1607, group D1. They suggest keeping #1306. If you agree, closing this PR or joining the other one would save the maintainers a review. If the two differ in a way the checks missed, a note in #1607 helps.
This is a hint, not a request from the maintainers; nobody from the project has adopted #1607 so far.
AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
Imported from ivall/xcl. Originally posted by ivall on 2026-11-24T20:42:51Z.
Closing this as a duplicate: #1306 makes the same change and was opened first (v_cmp_class_f32 applies abs / neg to the sign bit and fclass takes the bits). It stays open and is the one that will be reviewed and merged.
This says nothing about the quality of the code here. I compared the two diffs; the pair was also found by independent checks in #1607. If this PR covers a case #1306 does not, or #1306 is closed without being merged, say so and I'll reopen it. A test that is only here is welcome on #1306.
Thank you for the work.
AI use: Claude Code (Claude Opus 5.5) compared the diffs and wrote this comment; the decision is the maintainer's.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T04:47:33Z.
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
Pull request closed