Recompiler: apply abs and neg bitwise for v_cmp_class_f32 #1318
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!1318
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1318/head"
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?
@mahfuzinam0045-spec on GitHub · 2026-11-24 14:39 UTC · original
mahfuzinam0045-spec:fix/recomp-v-cmp-class-f32-bitwise-modifiers→main· +81 −12 · 2 files · 2 commits · closed without mergingApply VOP3
absandnegmodifiers bitwise forv_cmp_class_f32, and take rawuintbit patterns directly infclassandfclass64.Fixes #1281
What is in it
crates/xcl/src/gpu/recomp/emit.rs:v_cmp_class_f32: applym.abs[0]as({a} & 0x7FFFFFFFu)andm.neg[0]as({a} ^ 0x80000000u)directly on the rawuintbits instead of callingSelf::fsrc(abs(asfloat(u))/(-asfloat(u))). This prevents denormal flushing and signaling NaN quieting.fclass(uint u): update HLSL preamble function to acceptuint udirectly, eliminating the redundantasuint(asfloat(u))round-trip.fclass64(uint l, uint h)&v_cmp_class_f64: pass low and high dwords directly intofclass64(lo_hi[0].0, hi)withoutasdouble/asuintconversion.crates/xcl/src/gpu/recomp/tests.rs:v_cmp_class_f32_emits_bitwise_modifiers_without_asfloat: verify emitted HLSL applies bitwise mask/flip on the sign bit and avoidsasfloat.gpu_cmp_class_f32_preserves_snan_and_denormals: synthetic test asserting that sNaN, qNaN, -subnormal with ABS, and sNaN with NEG match their respective class bits without being quieted or flushed.Tested
link.exe/gcc.exe) are absent on this development environment. Full validation and regression suite run via GitHub Actions CI (PR checks).v_cmp_class_f32_emits_bitwise_modifiers_without_asfloatandgpu_cmp_class_f32_preserves_snan_and_denormals.Regression run
Regression testing requires Windows SDK and DXC toolchains. Relying on project CI.
Not tested
AI use
Antigravity (Gemini 3.8 Flash) was used to analyze the modifier lowering discrepancy in
crates/xcl/src/gpu/recomp/emit.rs, implement bitwise modifiers on rawuintbits, updatefclassandfclass64, and author the recompiler unit tests.github-bot referenced this pull request2026-11-26 04:59:09 +00:00
@futurepro62 on GitHub · 2026-11-24 14:47 UTC · original
Full-suite run, since this PR has no test report yet. Tested exact head
25c44a6(on its base930e8b4): two tests fail, both on the expected HLSL text rather than the emitter.Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: the xcl lib run ends with 2 failed (707 passed, 21 ignored), so cargo stops before the remaining test binaries. Reproduced 3 of 3 times withcargo test -p xcl --lib -- f64_class_compare_vopc_and_vop3 v_cmp_class_f32_emits_bitwise_modifiers_without_asfloat.f64_class_compare_vopc_and_vop3(existing test,tests.rs:474) still expects(v12) >> fclass64(asdouble(v10, v11)). Withfclass64now taking(uint l, uint h), the emitted text is(v12) >> fclass64(v10, v11),fclass64(v10, (v11 & 0x7FFFFFFFu))andfclass64(v10, (v11 ^ 0x80000000u)), so the threecontainschecks need theasdouble(...)dropped.v_cmp_class_f32_emits_bitwise_modifiers_without_asfloat(new,tests.rs:7180): the emitted compare is right (fclass(((v0 & 0x7FFFFFFFu) ^ 0x80000000u))), but!t.hlsl.contains("asfloat(")checks the whole shader, and the shared helper preamble always hasasfloat((e.g.fract_f). The check needs to look at the compare line only, or forfclass(asfloat(.XCL_ADAPTER=radeon): the same two failures.v_cmp_class_f32to the sign bit; #1308 and #1309 were opened about five minutes before this one, and both pass the full suite here.Not tested
AI use
@DavidM1911 on GitHub · 2026-11-24 15:34 UTC · original
Test report — RTX 3060 Ti (Windows 11),
cargo test -p xcl --libon the PR head merged with currentmain:2 failures (707 passed, 2 failed, 21 ignored; single-threaded run — parallel runs also intermittently abort with 0xc0000005, same harness flake seen on unmodified
main):gpu::recomp::tests::f64_class_compare_vopc_and_vop3— pre-existing test still asserts the old helper signature: it expectsfclass64(asdouble(v10, v11)), but this PR changedfclass64to take(uint l, uint h). The test needs updating to the new call shape (e.g.fclass64(v10, v11)/fclass64(v10, (v11 & 0x7FFFFFFFu))).gpu::recomp::tests::v_cmp_class_f32_emits_bitwise_modifiers_without_asfloat(new in this PR) —assert!(!t.hlsl.contains("asfloat("))can never hold: the shared kernel prelude emitsasfloat(unconditionally (e.g.fract_f,f16tof32helpers), regardless of which instructions the program uses. The assertion needs to be scoped to the emitted compare expression rather than the wholet.hlsl.The GPU-side behaviour itself looks right —
gpu_cmp_class_f32_preserves_snan_and_denormalspasses on this card.@mahfuzinam0045-spec on GitHub · 2026-11-24 16:26 UTC · original
Thanks @futurepro62 and @DavidM1911 for the test reports!
Pushed commit
c02943aresolving both test assertions:f64_class_compare_vopc_and_vop3to match thefclass64(uint l, uint h)argument shape (droppedasdouble(...)).asfloatcheck inv_cmp_class_f32_emits_bitwise_modifiers_without_asfloatto!t.hlsl.contains("fclass(asfloat(")so it doesn't match the preamble helpers.@futurepro62 on GitHub · 2026-11-24 16:51 UTC · original
Retest of the new head
c02943a: both tests I reported now pass on both GPUs.XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 753 passed, 0 failed, 41 ignored.XCL_ADAPTER=radeon, same command: 753 passed, 0 failed, 41 ignored, nothing skipped.f64_class_compare_vopc_and_vop3andv_cmp_class_f32_emits_bitwise_modifiers_without_asfloatareokon both.AI use
@ivall on GitHub · 2026-11-24 20:50 UTC · original
Closing this as a duplicate of #1306 (group D2 in #1607), which makes the same f32 change and was opened first. The f64 part here hands the two words to the helper instead of
asdoubleof them.mainalready applies abs / neg to the sign bit there, so no result changes.This says nothing about the quality of the code here. If this PR covers a case the other one does not, or #1306 is closed without being merged, say so and I'll reopen it.
Thank you for the work.
AI use: Claude Code (Claude Opus 5.5) read the diffs and the checks in #1607 and wrote this comment, on the maintainer's behalf.
@DavidM1911 on GitHub · 2026-11-26 04:53 UTC · original
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