Recompiler: direct DXIL folds 64-bit and float constants #1923
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!1923
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1923/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:21 UTC · original
dxil-fold-i64→main· +128 −20 · 4 files · 1 commits · closed without mergingThe direct DXIL backend's optimizer (
Module::optimize) skipped every i64 instruction, so that theInt64Opsflag set while building kept matching the code. The memory-window address math is i64 (zext,shl,or,addof an offset,lshr,trunc), and much of it has constant operands, so it reached the driver as written. Float literals also stayed asbitcast i32 <constant> to floatinstructions. Part of #1269.i64 instructions are now folded and removed like 32-bit ones, and
Shader::infer_type_featuresdropsInt64Opsonce no i64 instruction is left (the validator refuses the flag without one: "Flags must match usage"). Doubles are unchanged. A bitcast of a 32-bit constant becomes the constant of the other type, andfcmpof two float constants is decided at build time, except for denormals, which a driver may flush. A legacy multiply by a literal loses its "is the literal zero" compare.On a retail shader pack, against
main689f2db(xcl shaders --direct --sample 3000 --seed 7 --split 1 --windows 4): DXIL 1.41 % smaller in total over 2 989 programs (median −1.30 %; 2 913 smaller, 58 up to 0.64 % larger). On a 292-program sample: 2.9 % fewer instructions (3 011 771 instead of 3 102 808 in thedxc -dumpbinlistings), lines with an i64 101 495 instead of 153 220. A small, safe cut; it does not change the per-lane work or the EXEC guards.What is in it
Recompiler: direct DXIL folds 64-bit and float constantscrates/xcl/src/gpu/dxil/module/opt.rs: i64 folding and dead-code removal (doubles excluded as before), float constant bitcasts and compares, alow_bitshelper for 64-bit masks.crates/xcl/src/gpu/dxil/shader.rs:infer_type_featuresremovesInt64Opswhen no i64 instruction remains.crates/xcl/src/gpu/dxil/ops_tests.rs:constant_i64_and_float_operations_fold_awaychecks the listing (no i64 left, the literal's compare gone, the denormal's kept), the validator and the GPU results. Without theshader.rschange the validator rejects it ("Flags must match usage").crates/xcl/src/gpu/dxil/kernel.rs:TRANSLATOR_VERSION7 → 8 (the containers change).Tested
df10025.cargo test --workspace -- --test-threads=4with the SDK's DXC 1.7.2308.16: 976 passed, 0 failed, 45 ignored; 88SKIPPED, 65 of them the validation step (validator 1.7 < 1.8).XCL_DXC_DIRset to DXC 1.9.2602.17, so the DXIL tests run their validation step: 976 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).XCL_DIRECT_DXIL=1, an earlier pair of 120 s runs of the same tree (main689f2dbagainst this change): both built the same three compute pipelines, with 3.2 %, 1.7 % and 1.9 % less DXIL here (80 520 → 77 928, 27 500 → 27 032, 38 888 → 38 168 B), 1 776 against 1 772 frames, no device removal or crash.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. In these two the title took the first A press only after 100 s, so they stay in its first menus (mainbuilt one compute pipeline, this branch none).Not tested
CreateComputePipelineState) of the smaller DXIL was not measured; the three title pipelines are too few to time.no wave64).AI use
🤖 Generated with Claude Code
Module::optimize left every i64 instruction alone so that the Int64Ops shader flag, set while building, kept matching the code. The memory window address math of the direct translator is i64 (zext, shl, or, add of an offset, lshr, trunc), and much of it has constant operands, so it reached the driver as written. i64 instructions are now folded and removed like 32-bit ones, and Shader::infer_type_features drops Int64Ops when no i64 instruction is left: the validator refuses the flag without one ("Flags must match usage"). Doubles stay as they were. Float constants fold too: a bitcast of a 32-bit constant is the constant of the other type (registers are i32, so every float literal arrives as a bitcast), and fcmp of two constants is decided at build time, except for denormals, which a driver may flush. A legacy multiply by a literal loses its "is the literal zero" compare. Measured on 2 989 programs of a retail shader pack (xcl shaders --direct --sample 3000 --seed 7 --split 1 --windows 4, against main689f2db): DXIL 1.41 % smaller in total (median -1.30 %, 2 913 smaller, 58 up to 0.64 % larger); all 3 000 validate with DXC 1.9.2602. On a 292-program sample (seed 1): 2.9 % fewer instructions (3 011 771 instead of 3 102 808 in the dxc -dumpbin listings), lines with an i64 101 495 instead of 153 220 (on main177cd40). TRANSLATOR_VERSION goes to 8: the emitted containers change. Assisted-by: Claude Code (Claude Opus 5.5) Co-Authored-By: Claude Opus 5.5 <[email protected]>@upipibi on GitHub · 2026-11-24 23:24 UTC · original
NVIDIA run: RTX 3070 8 GB (Ampere, split wave64), driver 616.56, Windows 11, debug,
df10025merged ontomain689f2db(clean).constant_i64_and_float_operations_fold_away: passes.XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu_ --skip gpu_sparse_vram --test-threads=4: 110 passed, 0 failed, 1 ignored, the same asmainon this machine. That run also covers the memory-window i64 address math and theInt64Opsflag change (the validator accepted every program). The sparse test was skipped because of #1727.Overlap with #1906 is proposed on #1607.
AI-assisted (Claude Code). Synthetic tests only.
@DavidM1911 on GitHub · 2026-11-25 02:33 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!
github-bot referenced this pull request2026-11-26 06:18:31 +00:00
Pull request closed