Recompiler: direct DXIL folds 64-bit and float constants #1913
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1923"
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 nFaktorial on 2026-11-24T23:21:47Z.
The 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
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-24T23:24:43Z.
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.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T02:33:47Z.
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!
Pull request closed