Recompiler: drop redundant IsNaN checks in direct DXIL cvt_u32 and f16_rtz #2289
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!2289
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2289"
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 12:28 UTC · original
ramon-victor:opt/dxil-drop-redundant-isnan-cvt→main· +72 −7 · 1 files · 1 commits · openRemoves redundant explicit
dx.op.isSpecialFloat(IsNaN)guards in two hot direct DXIL float-conversion helpers (Lw::cvt_u32andLw::f16_rtz):Lw::cvt_u32(v_cvt_u32_f32): replacesisnan(f) || (f <=o 0.0)(3 ops) with a single unorderedfcmp ule float %f, 0.0(Pred::FULe, 1 op), which already evaluates totruefor bothNaNandf <= 0.0.Lw::f16_rtz(v_cvt_pkrtz_f16_f32): drops!isnan(f)from(!isnan(f)) && nz && (abs(back) >o abs(f))(3 ops removed per half, 6 perv_cvt_pkrtz_f16_f32), because orderedfcmp ogt(Pred::FOGt) already evaluates tofalsewhenf(and thereforeabs(f)) isNaN.Part of #1269.
What is in it
crates/xcl/src/gpu/dxil/prelude.rs:Lw::cvt_u32toPred::FULeandLw::f16_rtztoself.land(nz, gt)(+5/-8lines in production code).cvt_isnan_tests::gpu_direct_cvt_u32_and_pkrtz_drop_isnan_and_match_isaverifying DXIL validation, disassembly (zerodx.op.isSpecialFloatcalls,fcmp ule floatemitted), and GPU execution across±0.0, negative values, rounding boundaries,>= 2^32,±Inf,qNaN, andsNaN.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,224,580 B(-99,156 B,-0.24%)263.12 ms -> 255.59 ms(-2.9%)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::cvt_isnan_tests(debug):1 passed; 0 failed(DXIL validation, disassembly check, and RTX 3070 GPU verification)..\scripts\test.ps1(debug, full workspace):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
Lw::cvt_u32andLw::f16_rtzinprelude.rs, added DXIL disassembly and GPU execution tests, and ran the workspace test suite, 573-shader validation benchmark, and 60 s smoke regression run.@DarkPanda69 on GitHub · 2026-11-25 12:59 UTC · original
The AMD native wave64 run listed as untested, plus an RTX 3060: passes on both. I checked this one closely on AMD because #2258 (removing NaN guards from float compares) fails there; here, with the NaN checks dropped from
cvt_u32andf16_rtz, the NaN cases still come out right on the RX 9070 XT.Head
eaa509dapplied onmain1a0bbe3, debug, Windows 11 Pro 26200:cargo test -p xcl --lib -- gpu:: --test-threads=4:gpu_direct_cvt_u32_and_pkrtz_drop_isnan_and_match_isaok on both cards. RX 9070 XT (RDNA4, 32.0.32029.2010, waves 32..64): 630 passed, 2 failed, 22 ignored (the 2 are the AMD fuzz seeds tracked in #2115, the same onmain). RTX 3060 (32.0.16.1088): 632 passed, 0 failed.mainwithXCL_DIRECT_DXIL=1for the wholegpu::filter: on both cards the only difference is the new test (ok); no existing test changes result or skip state.Not tested: a title with
XCL_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:00 UTC · original
Independent GPU check on
eaa509ddbcb77ef688895a73873bc446e3afb7fa, with extra packed-half boundary values.Tested
cargo test --locked -p xcl --lib cvt_isnan_tests -- --nocapture --test-threads=1with each GPU selected viaXCL_ADAPTERgave 1 passed, 0 failed, 0 ignored and no skips on each. All 15 input pairs and the existing validator and disassembly assertions passed. The temporary fixture changes were restored.Not tested
Retail inputs, performance, the parent, native wave64 execution of this wave32 fixture, and the full workspace suite.
AI use
OpenAI Codex (GPT-6.2 Sol) added the temporary boundary values, ran the tests and wrote this report.
@DavidM1911 on GitHub · 2026-11-25 17:17 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
eaa509d, 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.