Recompiler: legacy FMA with a zero product returns +0 for c = -0 (#679) #720
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!720
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/720/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?
@dadnotdaddy on GitHub · 2026-11-24 04:03 UTC · original
dadnotdaddy:fix-679→main· +37 −1 · 2 files · 1 commits · closed without mergingFixes #679. With a zero factor,
fma_legacyreturnedc; the hardware returnsc + (+0), so c = -0 gave -0 instead of +0. The helper now returnsasfloat(select(c == 0.0f, 0u, asuint(c))): on the bits, so DXC can't fold it back toc(the approach the issue suggests).Test:
gpu_fma_legacy_with_a_zero_factor_adds_plus_zero, VOP3 and VOP2 forms, c = -0 with 05, -05, 5*-0, 0inf, -0NaN, plus pass-through cases. Fails on main (lane 0 returns 0x80000000), passes with the fix on an RTX 2070 SUPER;cargo test --workspacepasses.Overlaps draft #670 (same bug,
preciseadd instead of bits, bundled with an XAsync change); this is the fix alone.AI-assisted (Claude Code).
@dadnotdaddy on GitHub · 2026-11-24 04:11 UTC · original
Closing in favour of #670; the bit-based version and its test are suggested there.
@MesshM on GitHub · 2026-11-24 04:14 UTC · original
Test run of
2b5f6741f37542281d388df748737f9fad39a58fon AMD RDNA4. I merged it onto currentmainf4ce27clocally (clean merge) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 702 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 661 passed, 0 failed, 21 ignoredSKIPPED;gpu_fma_legacy_with_a_zero_factor_adds_plus_zeropasses, VOP3 and VOP2 forms.Review: Returning
c + (+0)on the bits (select(c == 0.0f, 0u, asuint(c))) gives +0 for c = −0 and keeps every other c, and DXC cannot fold it back toc. Related to #719, which tests the same instruction and describes a zero product as "returning c"; that is exactly the case this PR corrects for c = −0. None of #719's cases uses c = −0, so the two do not conflict, but #719's wording could say c + 0. I found nothing to change here.Not tested: no retail title or regression run (I have no unpacked game), no
XCL_SAMPLE_*tests, release build; the PR's head on its old base was not run, only its merge ontomain.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
@lordon1a on GitHub · 2026-11-24 04:15 UTC · original
Independent test report on
2b5f674:Tested
616.64, wave32, SM 6.6), Intel i7-12700H, Windows 11 Home 26H2 (build 26200),rustc 1.100.0(x86_64-pc-windows-gnullvm), debug build, DXC1.9.2609.5(01b62ad4)cargo test -p xcl --lib gpu_fma_legacy_with_a_zero_factor_adds_plus_zero -- --nocapture0.71sNot tested
xcl-smoke)AI use
2b5f674in a detached worktree, audited the diff, ran the test suite, and posted this report.Pull request closed