Recompiler: direct DXIL decides compares of two float constants #1943
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!1943
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1943/head"
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?
@nFaktorial on GitHub · 2026-11-24 23:46 UTC · original
dxil-fold-fcmp→main· +435 −37 · 5 files · 2 commits · closed without mergingStacked on #1906; only the top commit (
bbd6dd0) belongs here. Part of #1269.The direct translator keeps registers as i32, so a float literal reaches an
fcmpas a bitcast of an integer constant. #1906 folds that bitcast, but the compare of two constants stays in the code, for example the "is the literal zero" test of every legacy multiply by a literal. This PR decidesfcmpof two 32-bit float constants at build time, for all ordered and unordered predicates, except where an operand is a denormal (a driver may flush it to zero). It replaces the float part of my #1923, which duplicated #1906.On a retail shader pack, against #1906's head
9ea9ad1(xcl shaders --direct --sample 3000 --seed 7 --split 1 --windows 4): DXIL 0.31 % smaller in total over 2 990 programs (2 335 smaller, none larger, 655 the same). In the first 400 of them (dxc -dumpbin): 142 469fcmpinstead of 148 570 (−4.1 %), 4 340 854 instructions instead of 4 359 046.What is in it
Recompiler: direct DXIL decides compares of two float constantscrates/xcl/src/gpu/dxil/module/opt.rs: anfcmparm insimplify_opand aconst_f32helper (a null float is +0).crates/xcl/src/gpu/dxil/ops_tests.rs:float_constant_compares_fold_awaychecks the listing (only the compare of a variable and the denormal's stay), the validator and the GPU results of a legacy multiply by 1.5 and five predicates on constants (−0 against +0 among them). It fails without theopt.rschange.crates/xcl/src/gpu/dxil/kernel.rs:TRANSLATOR_VERSION8 → 9.opt.rs, the version line), test +48.Tested
bbd6dd0(on #1906's9ea9ad1, basemain689f2db).cargo test --workspace -- --test-threads=4with the SDK's DXC 1.7.2308.16: 977 passed, 0 failed, 45 ignored; 89SKIPPED, 66 of them the validation step (validator 1.7 < 1.8), 18no wave64.XCL_DXC_DIRset to DXC 1.9.2602.17: 977 passed, 0 failed, 45 ignored; 23SKIPPED: 18no wave64, 3 per-lane f16 /V_CVT_F16_F32refusals,no heap windows, and the PSO measurement (Developer Mode off).xcl shaders --direct ... --validateover the 3 000-program sample: 0 validator failures (DXC 1.9.2602.17), on this branch and on #1906.Regression run
main:This PR:
Both runs:
XCL_DIRECT_DXIL=1 XCL_PSO_PRELOAD=0, A pressed every 4 s from 20 s, 120 s. Both built the same three compute pipelines through the direct backend: 80 520, 27 500 and 38 888 B of DXIL onmain, 74 008, 26 112 and 36 824 B with #1906 and this commit.Not tested
CreateComputePipelineState) of the smaller DXIL.no wave64).AI use
🤖 Generated with Claude Code
@anes66 on GitHub · 2026-11-25 00:58 UTC · original
CPU-only predicate matrix on exact head
bbd6dd08133071838708cd5d0e37461d271fe2afpassed. Optional test companion 859243e is directly on that head and adds tests only.Tested
cargo test --locked -p xcl --lib cpu_float_tests:: -- --nocapture --test-threads=1: 1 passed / 0 failed / 0 ignored, no skips.FONe(+0,qNaN)=1instead of0; removing the denormal filter violated the preservation check. The latter checks policy, not a wrong arithmetic result for every denormal predicate. Both edits were restored before the final passing run and commit.Not tested
Serialized bitcode/validator, GPU or driver denormal behavior, release, full workspace suite, retail execution, performance or newer-main integration. This checks integer-IR constant outcomes and the documented conservative guard, not complete shader correctness. No competing upstream PR.
AI use
Codex (GPT-6; exact variant unavailable) wrote the test and temporary controls, ran CPU validation and prepared this report.
@DavidM1911 on GitHub · 2026-11-25 02:50 UTC · original
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.Pull request closed