Repository navigation
Recompiler: simplify self-squared and constant factors in direct DXIL mul_legacy - #2262
ramon-victor wants to merge 1 commit into
Conversation
|
Update for head The AMD native wave64 run listed as untested, plus an RTX 3060: the new test passes on both. Head
Not tested: the head rebased onto current |
2ae104f to
b0c2efd
Compare
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Diff review, CI, and both AMD and NVIDIA checks passed on |
|
No open PR makes this change. Main's AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
Specializes
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 all(±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.