Recompiler: simplify self-squared and constant factors in direct DXIL mul_legacy #2262
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!2262
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2262"
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?
@ramon-victor on GitHub · 2026-11-25 11:46 UTC · original
ramon-victor:opt/dxil-mul-legacy-fastpath→main· +154 −4 · 2 files · 1 commits · openSpecializes
Lw::mul_legacy(loweringv_mul_legacy_f32, the most frequent instruction in retail console shaders) in the direct DXIL translator for self-squared operands (x * x), constant±0.0factors, and non-zero non-subnormal constant factors while preserving exact IEEE-754 / RDNA2 zero-override semantics.x * x(including identicalbitcast i32 -> f32wrappers and(-x) * (-x)): emits plainfmul(a, a)(1 op instead of 5), bit-identical for all2^{32}f32 values ((±0)^2 = +0.0,(±Inf)^2 = +Inf,NaN^2 = NaN).±0.0: folds directly to+0.0(0 ops instead of 5).fcmp oeq 0.0andorwhile keeping the other operand's zero check so e.g.2.0 * -0.0and+Inf * 0.0still yield+0.0(3 ops instead of 5).fmul(a, b).Part of #1269.
What is in it
crates/xcl/src/gpu/dxil/module.rs: addModule::const_f32_bits(resolving constantf32,bitcast i32 -> f32of integer constants, andfsub -0.0, kon non-subnormal/zero constants) andModule::same_f32(matching identicalbitcastwrappers emitted per operand byLw::fsrc).crates/xcl/src/gpu/dxil/prelude.rs: add self-square, constant-zero, and non-zero-constant fast paths toLw::mul_legacy, plusmul_legacy_fastpath_tests::gpu_direct_mul_legacy_fastpaths_validate_and_match_ieeechecking DXIL validation, disassembly (0/1fcmp oeqcounts), and GPU bit-exactness across+0.0,-0.0, finite,±Inf,qNaN, andsNaNinputs.On a seeded 600-program sample (
xcl shaders <archive> --direct --sample 600 --seed 3 --max-bytes 40000 --validate --threads 8, 573 programs within the cap), all 573/573 validate cleanly (0validator failures):41,323,736 B -> 41,147,056 B(-176,680 B,-0.43%)263.12 ms -> 250.88 ms(-4.7%)Tested
621.24, wave32), AMD Ryzen 7 5700X, Windows 11 Pro26300,rustc 1.99.0(x86_64-pc-windows-msvc), DXC/DXIL1.8.2502.11(Windows SDK10.0.26100.0).cargo test -p xcl --lib gpu::dxil::prelude::mul_legacy_fastpath_tests(debug):1 passed; 0 failed..\scripts\test.ps1(debug, full workspace on headb0c2efd):1251 passed; 0 failed; 46 ignored(25 GPU sub-checks skipped on this wave32 adapter: 21no wave64, 1no heap windows, 3 per-lane#1426refusals).cargo build --release -p xcl+ direct DXIL validation sweep on 573 sampled retail shader programs:573/573translated anddxil.dll-validated (0failures).Regression run
Not tested
XCL_SAMPLE_*env vars unset).AI use
const_f32_bits,same_f32, and themul_legacyfast paths, added validation/disassembly/GPU parity tests, rebased ontoorigin/main(1a0bbe3), and ran the workspace test suite, 573-shader benchmark, and 60 s smoke regression run.@DarkPanda69 on GitHub · 2026-11-25 12:35 UTC · original · edited 2026-11-25 13:00 UTC
Update for head
b0c2efd(rebased ontomain1a0bbe3, tested as is): same result. The new test passes on both cards; wholegpu::filter: RX 9070 XT 630 passed, 2 failed (only the #2115 fuzz seeds now); RTX 3060 632 passed, 0 failed.The AMD native wave64 run listed as untested, plus an RTX 3060: the new test passes on both.
Head
2ae104ftested as is (it no longer applies cleanly on currentmain; its base is426a5a7), debug, Windows 11 Pro 26200,cargo test -p xcl --lib -- gpu:: --test-threads=4:gpu_direct_mul_legacy_fastpaths_validate_and_match_ieeeok. 627 passed, 3 failed, 22 ignored, 6 SKIPPED. All three failures also fail on the base without this PR: the AMD fuzz seeds tracked in #2115 andgpu_image_get_resinfo_past_last_level(fixed onmainsince).Not tested: the head rebased onto current
main, a title withXCL_DIRECT_DXIL=1.AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
@nnonno91 on GitHub · 2026-11-25 15:28 UTC · original
Independent Windows check of
b0c2efde0a9c3ba6e8e5a9476398bc556e7ee9f7. The legacy multiply shortcut cases matched the reference on Radeon integrated graphics and RTX 5090, including the upper half of a logical wave64.Tested
cargo test --locked -p xcl --lib mul_legacy_fastpath_tests -- --nocapture --test-threads=1on each selected adapter. The wave32 fixture reported 1 passed, 0 failed, 0 ignored, no logged skips per adapter.Not tested
Parent revision, performance, retail titles, or the full workspace suite.
AI use
OpenAI Codex (GPT-6.2 Sol) prepared and ran the tests, verified the results, and wrote this report.
@DavidM1911 on GitHub · 2026-11-25 16:53 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@raylitebull on GitHub · 2026-11-25 18:41 UTC · original
Diff review, CI, and both AMD and NVIDIA checks passed on
b0c2efd, but recentorigin/mainmerges turned this branchCONFLICTING/DIRTY. Please rebase ontoorigin/mainso it becomes mergeable again.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.