Recompiler: lower direct DXIL float_compare to ordered/unordered fcmp #2258
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!2258
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2258"
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:40 UTC · original
ramon-victor:opt/dxil-float-compare-fcmp→main· +115 −50 · 1 files · 1 commits · openLowers RDNA2 floating-point comparisons (
Lw::float_compare, coveringv_cmp*_f16,v_cmp*_f32, andv_cmp*_f64) in the direct DXIL translator directly to IEEE-754 ordered (FO*) and unordered (FU*) LLVMfcmppredicates instead of emitting explicitdx.op.isSpecialFloat(IsNaN)/splitDoubleNaN checks around each compare.Because the direct DXIL builder emits
fcmpwith zero fast-math flags, LLVM/DXILolt,oeq,ole,ogt,one,oge,ord,uno,ult,ueq,ule,ugt,une, andugealready define exact NaN semantics in a single instruction (1 instruction instead of 3–8 per compare).Part of #1269.
What is in it
crates/xcl/src/gpu/dxil/lower_valu.rs:Lw::float_compare's explicitisnan_any+or+xor+andwrapper with direct 1-to-1Pred::FO*/Pred::FU*fcmpemission, and remove the now-unusedLw::isnan_anyhelper (+18/-51production lines).float_compare_tests::gpu_direct_float_compare_uses_fcmp_and_matches_ieeeverifying DXIL validation and disassembly (every predicate emits the expectedfcmpwith nodx.op.isSpecialFloatorsplitDoubleNaN guards) and checking all 14v_cmp_*_f32predicates on the GPU across±0.0, finite,±Inf,qNaN, andsNaNpairs.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 -> 40,857,992 B(-465,744 B,-1.13%)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::lower_valu::float_compare_tests(debug):1 passed; 0 failed.XCL_DIRECT_DXIL=1 cargo test -p xcl --lib gpu_f32_compares(debug):1 passed; 0 failed(gpu_f32_compares_with_nanon RTX 3070)..\scripts\test.ps1(debug, full workspace on headc204653):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
float_compareinlower_valu.rs, simplified it to direct LLVMfcmppredicates, wrote unit and GPU tests, rebased ontoorigin/main(1a0bbe3), and ranXCL_DIRECT_DXIL=1compare tests, the full workspace test suite, the 573-shader validation benchmark, and the 60 s smoke regression run.@DarkPanda69 on GitHub · 2026-11-25 12:35 UTC · original
Fails on AMD (native wave64), passes on NVIDIA. On an RX 9070 XT, the ordered not-equal compare returns true for a NaN input, in the new test and in the existing
f32_programs_on_the_gpu, which passes onmain.Tested at head
c204653(as is, onmain1a0bbe3), debug, Windows 11 Pro 26200, DXC 1.9.2602.17,cargo test -p xcl --lib -- gpu_direct_float_compare_uses_fcmp_and_matches_ieee f32_programs_on_the_gpu --test-threads=1:c7940b3):gpu_direct_float_compare_uses_fcmp_and_matches_ieee:V_CMP_LG_F32 lane 8 (NaN, 0.0): got true, want false(core_tests.rs:673).f32_programs_on_the_gpu:f32 compares, wave32: s10,left: 4294967291,right: 4008636138(lower_dxil.rs:738).main1a0bbe3:f32_programs_on_the_gpupasses, so this PR introduces the second failure.main.So on this AMD driver the
fcmp one(ordered not-equal) thatV_CMP_LG_F32now lowers to does not come out false for a NaN operand, where the removed explicitisnanguard did. Wholegpu::filter atc7940b3: RX 9070 XT 625 passed, 5 failed (these 2, plus the #2115 fuzz seeds andgpu_image_get_resinfo_past_last_levelthat its old base still had); RTX 3060 630 passed, 0 failed.Not tested: the other 13 predicates past the first failing assertion on AMD, RDNA2/RDNA3.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
@luckyteagirl on GitHub · 2026-11-25 12:47 UTC · original
Independent RDNA2 confirmation of the AMD NaN regression reported above, at exact PR head
c2046530321844e65a64df2ef2ff78e15ac095eaversus main1a0bbe3a2ba91ea8f5b6fc29130a053868d3c9e6.Environment: Windows 11 build 26200; Ryzen 9 5980HX; Radeon RX 6800M driver
30.0.13002.13003(native wave64); Rust 1.99.0 MSVC; DXC/DXIL 1.9.2609.5. Isolated worktrees and Cargo targets. Debug tests useXCL_ADAPTER=6800M,XCL_REQUIRE_GPU=wave64,-j 2,--test-threads=1,--show-output.Results
cargo test --locked -p xcl --lib gpu_direct_float_compare_uses_fcmp_and_matches_ieeewithXCL_DIRECT_DXIL=1: 0 passed, 1 failed, 0 ignored, no skip. The assertion is exactlyV_CMP_LG_F32 lane 8 (NaN, 0.0): got true, want falseatlower_valu.rs:1420. This is a value mismatch after GPU execution, not a PSO/device-removal failure.f32_programs_on_the_gpu: main 1/0/0, PR 0/1/0 withXCL_DIRECT_DXIL=1. The PR failsf32 compares, wave32: s10(left: 4294967291,right: 4008636138) atlower_dxil.rs:738.XCL_DIRECT_DXIL=0also passes on main 1/0/0 and fails on this PR 0/1/0 with the sames10values. That test exercises its own DXIL path, so changing the environment flag does not remove the regression.This extends the reported failure from RX 9070 XT/RDNA4 to RX 6800M/RDNA2. It is a reproducible PR-head regression against this main revision. I ran focused synthetic tests only; no full workspace suite or retail-title smoke on this head. No game data was used.
AI use: OpenAI Codex (GPT-6; exact variant not exposed in this session) ran the native Windows GPU tests and main/PR controls, checked the exact assertions, and drafted this report.
@nnonno91 on GitHub · 2026-11-25 15:21 UTC · original
Independent Windows check of
c2046530321844e65a64df2ef2ff78e15ac095eaand parent1a0bbe3a2ba91ea8f5b6fc29130a053868d3c9e6. The Radeon iGPU also reproduces the NaN comparison regression in a wave32 fixture. The RTX 5090 passed the two focused head tests I ran there.Tested
cargo test --locked -p xcl --lib <filter> -- --nocapture --test-threads=1withXCL_DIRECT_DXIL=1and explicit adapter selection.float_compare_testson the head: Radeon 0 passed, 1 failed.V_CMP_LG_F32lane 8 returned true for(NaN, 0.0), expected false. The RTX 5090 reported 1 passed, 0 failed. The new fixture uses wave32.gpu_f32_compares_with_nan: Radeon parent 1 passed, 0 failed; head 0 passed, 1 failed. On the head, all three NaN input pairs returned true forv_cmp_lt_f32and false forv_cmp_nlg_f32, opposite the expected values. RTX 5090 head reported 1 passed, 0 failed.f32_programs_on_the_gpuon Radeon: parent 1 passed, 0 failed with two logged skips for unsupported per-lane f16 conversions; head 0 passed, 1 failed atf32 compares, wave32: s10(4294967291 vs 4008636138).Not tested
RTX 5090 parent or its broader f32 fixture, double-precision GPU execution, retail titles, or the full workspace suite.
AI use
OpenAI Codex (GPT-6.2 Sol) 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!
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.