Recompiler: drop redundant IsNaN checks in direct DXIL cvt_u32 and f16_rtz #2279
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from ivall/xcl. Originally posted by ramon-victor on 2026-11-25T12:28:18Z.
Removes 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.Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-25T12:59:29Z.
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.
upstream-sync referenced this pull request2026-11-25 14:08:43 +00:00
Imported from ivall/xcl. Originally posted by nnonno91 on 2026-11-25T15:00:16Z.
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.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T17:17:38Z.
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!
Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T18:41:00Z.
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.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:45:22Z.
Triage (#1607) – head
eaa509dNo open or merged PR makes the same change. Main's
cvt_u32andf16_rtzingpu/dxil/prelude.rsstill callisnan.fcmp ule f, 0.0is true for NaN and forf <= 0, and the orderedogtinf16_rtzis already false for NaN, so the results stay the same. Unordered predicates are already used elsewhere in direct DXIL (v_cmp_n*). The PR conflicts with main.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.