Recompiler: direct DXIL folds EXEC selects no lane observes, and the bitcast pairs they leave #2576
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!2576
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2576"
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?
@Kalmarv on GitHub · 2026-11-25 23:38 UTC · original
Kalmarv:op-diet/on-1906→main· +798 −36 · 7 files · 3 commits · draftStacked on #1906: review only the last two commits; this rebases onto main when #1906 lands.
The direct RDNA2 → DXIL translator writes a VGPR under EXEC as
select(exec, new, old). Two passes inModule::optimizeshrink the DXIL handed to the driver. Part of #1096.old. The pass tracks, per value, where it is observed (unused, only where one condition holds, all lanes) and reads through those selects; DCE drops the selects left without uses. Phis, memory, wave ops, derivatives and integer division observe all lanes and keep their selects.select(exec, bitcast(f), old)turns a float operation'sbitcast(select)operand intobitcast(bitcast(f)). The CSE peephole that folds such pairs runs before the select fold, so a linear pass after it mapsbitcast(bitcast(x))back toxwhen the types match (64-bit kept, as in the peephole).#1972 (@raylitebull) had the select-guard idea first (
propagate_select_guards). The fold here tracks observation per value and reaches more selects: on the bench below it saves 8.1 % of the bytes on main against 4.1 % for #1972, and #1972 adds 0.5 % on top of it. Our offer on #1972 (#1972) to combine the two still stands. This PR came out of @Decodere's suggestion on #1906 to keep these passes separate from it.What is in it
Recompiler: fold direct DXIL EXEC selects no lane observes:fold_guarded_selectsandlane_localincrates/xcl/src/gpu/dxil/module/opt.rs, run after CSE (XCL_DXIL_NO_OPT=selectleaves it out);NO_SELECT_FOLD(tests only), handed to the translator thread inkernel.rs; unit testguarded_selects_fold_where_no_lane_sees_the_other_arm; GPU testgpu_select_fold_keeps_inactive_lanesincrates/xcl/src/gpu/dxil/select_tests.rs.Recompiler: fold the bitcast pairs the EXEC select fold leaves:fold_bitcast_pairsinmodule/opt.rs(XCL_DXIL_NO_OPT=pairs);NO_PAIR_FOLD(tests only); unit testbitcast_pairs_left_by_the_select_fold_fold(fails with the pass left out); GPU testgpu_bitcast_pair_fold_keeps_words.v_readlaneand DPP reads while lanes are off, NaN (quiet and signalling payloads), signed-zero, infinity and denormal operands, and sentinels in lanes that never run. They run in wave32 and wave64, whole and split, and the folded form must be smaller.Tested
Size, offline (no GPU): a release
xcl.exetranslates and binds the 802 compute programs that a retail title (title: ea3b5e4d) has in use at its device-memory crash.6d12f58a894e29d6That is −10.6 % bytes and −12.8 % instructions on top of #1906.
Native code on the NVIDIA driver, RTX 5070 Ti, measured on main with and without the select fold: 4 of the largest of these programs go from 3.60 to 3.40 MB of driver blob (−5.4 %). The bitcast-pair fold changes only the DXIL: on a synthetic chain of 512
v_mul_legacy_f32the driver's code is the same with and without it.Graphics, measured on main by our graphics size bench (runtime path,
XCL_DIRECT_DXIL=all): VS DXIL 30.41 → 26.73 MiB (−12.1 %), PS of the cold pipelines 104.41 → 94.73 MiB (−9.3 %), 0 failed translations.GPU tests at
71b76742, on an RTX 2060 (NVIDIA 595.91) under Wine 11.21 + vkd3d-proton master30b0eb9, DXC 1.9.2609, release test executables:select_tests module::opt: 11 passed, 0 failed, 0 ignored, no SKIPPED (maine1d84b7d: 7 / 0 / 0). Both new GPU tests ran on the GPU and passed.gpu::dxil --test-threads=4: 186 passed, 2 failed, 3 ignored (maine1d84b7d: 181 / 2 / 3). The same two tests fail on main on that stack:raw_loads_in_root_windows_respect_exec_and_bounds(memory-window gap of that Wine build) anddirected_reference_basics(fma precision under vkd3d). SKIPPED:dispatch_chain_native_wave64_builds_whole(no wave64).Whole suite at
71b76742on an RTX 5070 Ti (NVIDIA 610.74), Windows 11 Pro 26200, rustc 1.99.0, DXC 1.9.2609, debug:cargo test --workspace --no-fail-fast -- --test-threads=4: 1,428 passed, 0 failed, 46 ignored. 25 SKIPPED notices, none from the new tests: 21no wave64, 3 forms refused inf16_programs_on_the_gpu/f32_programs_on_the_gpu(#1426 semantics), 1no heap windows. Thenselect_tests --nocapture: both new GPU tests ran and passed.Output of a retail compute program (title: ea3b5e4d, program
6f3a2502a8d6b129) on the GPU, RTX 5070 Ti, native Windows D3D12, one seeded 8×16 group, guest wave64 split on wave32, full buffer and texture readback: main6d12f58a, main + the select fold, and main + both passes each change 2,048 words, 0 different from main, and match the expected 256/256 texels; two repeated main controls also match. DXIL 477,884 → 454,064 → 437,536 bytes. The pass code is this head's, except thatsimplify_optakes #1906's extra argument.Tested by others
71b7674on an RTX 3080 Ti (NVIDIA 621.35), Windows 11 26300, rustc 1.99.1, DXC 1.8.2502.11, debug.gpu_select_fold_keeps_inactive_laneswithXCL_DXIL_NO_OPT=pairs(the select fold on its own): 1 passed.gpu_bitcast_pair_fold_keeps_words: 1 passed.cargo test --workspace --no-fail-fast -- --test-threads=4: 1,428 passed, 0 failed, 46 ignored, 25 SKIPPED notices; both new GPU tests ran without a skip.cargo test -p xcl --lib: all passed, 0 failed, 26 ignored (no commit or pass count given).71b76742on an AMD Radeon RX 6800M (driver 30.0.13002.13003), Windows 11 26200, Rust 1.99.0, DXC 1.9.2609.5, debug,XCL_DIRECT_DXIL=1 XCL_REQUIRE_GPU=wave64:gpu_select_fold_keeps_inactive_lanes1 passed,gpu_bitcast_pair_fold_keeps_words1 passed, no SKIPPED line. The log does not show whether the native wave64 form ran.71b7674against #1906894e29d, both merged onto main08db802, on an AMD RX 9070 XT (driver 32.0.32029.2010), Windows 11, release, offlinexcl shaders --precompile --only cs --pipelineswith every build cold. Direct DXIL over all 2,689 retail compute programs: 875.1 → 808.7 MB (−7.6 % against #1906).CreateComputePipelineStateover 26 large programs, 3 interleaved rounds: mean 80.5 → 76.0 s (−5.7 %), 0 failed pipelines; faster in every round, but by 1 % in the first, which they read as a modest gain. The six split programs give 47 pieces instead of 55. Not covered by that run: heap windows, GPU output, a title run.GetCachedBlob) on an RTX 3060 (NVIDIA 617.14), Windows 11, debug, one run. Their tree is71b76742with #1906894e29d6, on mainb49be183with #2427, #2428, #2496 and #2567. 60 compute programs of one retail title, one pipeline each (XCL_DIRECT_SPLIT_INSTRUCTIONS=0), withXCL_DIRECT_DXIL=1,XCL_WINDOW_NO_CARRY=1,XCL_DXIL_OUTLINE=1, flat heap windows and translated caches off. The two passes,XCL_DXIL_NO_OPT=selectagainst unset in the same build: driver code 32.863 → 30.536 MB (−7.1 %; 54 programs smaller, 3 the same, 3 larger), DXIL 24.170 → 21.196 MB (−12.3 %), all 120 containers pass both validators, 60/60 pipelines built per arm. #1906's own folds come to about 0 there (−0.04 %, from two builds). Not covered by that run: the pair fold on its own, the suite or any correctness check with the passes on, timing, a title run, graphics.b49be18against main +71b7674(with #1906's commit),XCL_DIRECT_DXIL=1, heap windows, split wave64. The firstCreateComputePipelineStateof three large retail compute programs, 3 interleaved cold builds per tree: whole forms −7.1 %, −17.6 % and −7.3 % (medians), every build with this PR quicker than every build of main; DXIL −11 to −12 %. Built as dispatch-chain pieces one after another (9, 12, 10 pieces → 7, 10, 8), the summed time is −12 %, −7 % and −13 %, while the longest single piece got a little slower (medians 1.14 → 1.33 s, 1.16 → 1.21 s, 1.27 → 1.32 s). Not covered by that run: other NVIDIA cards and drivers, a title run.Regression run
Title smoke pair, 60 s each, RTX 5070 Ti, NVIDIA 610.74, release builds. The base side is #1906's head
894e29d6, the base of this stacked PR, not main. It ran after one warm-up run of the base and back to back with it, as one job beside a CPU-bound shader precompile on the same machine that was running at both ends of both sides. Frames 1,291 against 1,318 (98 %), peak commit 26,833 against 26,885 MB, no crash or device removal.Base, #1906's head
894e29d6:This head,
71b76742:Not tested
AI use
🤖 Generated with Claude Code
@thehollowedone on GitHub · 2026-11-25 23:51 UTC · original
Independent NVIDIA GPU check of
71b7674on Windows 11 build 26300, RTX 3080 Ti / 621.35, rustc 1.99.1, DXC 1.8.2502.11 (debug build).Tested
XCL_DXIL_NO_OPT=pairs,cargo test -p xcl --lib gpu_select_fold_keeps_inactive_lanes -- --nocapture --test-threads=1: 1 passed, 0 failed, 0 ignored. Disabling the pair pass makes this comparison isolate the EXEC-select fold.cargo test -p xcl --lib gpu_bitcast_pair_fold_keeps_words -- --nocapture --test-threads=1: 1 passed, 0 failed, 0 ignored.cargo build --workspace: passed. With the variable cleared,cargo test --workspace --no-fail-fast -- --test-threads=4: 1,428 passed, 0 failed, 46 ignored; 25 explicitSKIPPEDGPU notices. The two new GPU tests passed without skips.Not tested: AMD or native hardware wave64, production title smoke, native driver blob size, memory use, or world-load time.
AI use: Codex (GPT-6.2 Sol) reviewed the test setup, ran these commands, and drafted this report.
@DavidM1911 on GitHub · 2026-11-26 00:01 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.Thanks!
— Devin
@luckyteagirl on GitHub · 2026-11-26 00:54 UTC · original
RX 6800M focused GPU report for #2576: both new select/bitcast fold parity fixtures passed on the exact PR head.
Setup: clean detached head
71b76742803a7055d1feb9083cdd290c56a96abc; Windows 11 Home build 26200; Ryzen 9 5980HX; AMD Radeon RX 6800M, driver30.0.13002.13003; Rust 1.99.0 MSVC; DXC/dxil 1.9.2609.5.XCL_ADAPTER=6800M XCL_REQUIRE_GPU=wave64 XCL_DIRECT_DXIL=1, pinnedXCL_DXC_DIR, debug lib-test build in an isolated Cargo target.Tested:
cargo test --locked -p xcl --lib -j 1 gpu_select_fold_keeps_inactive_lanes -- --test-threads=1 --show-outputunder a free-memory guard: 1 passed, 0 failed, 0 ignored, 0 measured, 1328 filtered out, 1.27 s, noSKIPPEDline, guard did not stop the run. Then the exactgpu::dxil::select_tests::gpu_bitcast_pair_fold_keeps_wordsfixture was run directly from the just-built test binary with--exact --test-threads=1 --nocaptureand the same environment: 1 passed, 0 failed, 0 ignored, 0 measured, 1328 filtered out, 0.59 s, noSKIPPEDline. This second run did not rebuild.Both fixtures compare folded and unfolded GPU results across all tested lanes/registers. The source always runs wave32 whole and split-wave64 forms, and conditionally runs native wave64 when
runner::wave64_supported()reports true. The test output does not record that capability or print which forms ran, so I cannot confirm the native-wave64 branch from this log alone.Not tested: full workspace suite, title smoke pair, other GPU vendors, or a measured native-wave64-only run. No game files were used.
AI use: Codex (GPT-6) and a Codex Luna subagent prepared the clean worktree, ran the focused tests, checked the counts and source-level form coverage, and wrote this report.
@bielfreedom on GitHub · 2026-11-26 01:55 UTC · original
AMD Windows driver timing for #2576 (the last two commits, on top of #1906): on the RX 9070 XT the EXEC-select fold cuts direct DXIL by 7.6 % over all 2,689 retail compute programs, and AMD's
CreateComputePipelineStateis about 6 % faster over 26 large ones. No pipeline failed.Setup
main08db802:894e29d;71b7674(#1906 plus the two commits).xcl shadersthat writes each program's DXIL size and eachCreateComputePipelineStatetime to a file.xcl shaders <retail shaders.rpf> --precompile --only cs --pipelineswithXCL_DIRECT_DXIL=1, switch windows,XCL_PSO_DISK_CACHE=0, one driver thread, a fresh translation cache and a fresh executable name for every run (the AMD driver keys its own cache on the exe name, so every build is cold).DXIL size, all 2,689 compute programs (translation only)
mainmainDriver time, 26 large programs, 3 interleaved rounds
Mean 80.5 → 76.0 s (−5.7 %). The PR was faster in every round, but by 1 % in the first, so read it as a modest gain. Per program, the larger ones gain the most; small ones move in both directions, within noise:
620491641aa9bad66d1e4583f81297716f3a2502a8d6b1296fd9a5ebc95aee46With the fold, the six split programs produce 47 pieces instead of 55.
Not tested: heap windows, GPU output, and a title run.
AI use: Claude Code (Claude Opus 5.5) built the binaries, ran the measurements and wrote this report; I posted it.
@pvfreis on GitHub · 2026-11-26 03:42 UTC · original · edited 2026-11-26 04:48 UTC
Test report for
71b76742(on #1906894e29d6), stacked on flat heap + no-carry and #2567: NVIDIA driver code size (GetCachedBlob) on Ampere.Tested
--test-threads=4, NVIDIA 32-lane waves only. One run per setting.3bc3b7c6:mainb49be183+ #2427c8c2b7a6+ #2428970823e4+ #249678bba5ca+ #256789e1a91d+ this PR71b76742(with #1906894e29d6). #2428 has since been pushed toc6e5af86; not rerun on it (its new commit doesn't change compute translation).core_tests.rs(#2567's and #1906's appended tests) andkernel.rs(this PR's test-onlyNO_SELECT_FOLD/NO_PAIR_FOLDhand-over around #2496'swith_no_carryand #2567'soutlineargument). Below it:kernel.rs(#2496 againstmain's doc line; #2567'soutlineargument next towith_no_carry),real.rs(#2567's vendor id next to #2428'sset_adapter_vendor).cargo test --workspace --locked --offline --no-fail-fast -- --test-threads=4with only the size test enabled.CreateComputePipelineStateand sumsGetCachedBlobsizes. Settings:XCL_DIRECT_DXIL=1,XCL_WINDOW_NO_CARRY=1,XCL_DXIL_OUTLINE=1, flat heap windows (0x304), translated caches off;XCL_DIRECT_SPLIT_INSTRUCTIONS=0(dispatch chains off, one pipeline per record) except in the chains-on run below.XCL_DXIL_NO_OPT=selectvs unset in the same build:XCL_DIRECT_SPLIT_INSTRUCTIONSunset, so the default 12,500 instructions per piece; the same 60 records, tree and other settings; a split record is built as one pipeline per piece and the blobs are summed):XCL_DXIL_NO_OPT=selectvs unset in the same build: driver code 38.745 → 35.430 MB (−8.6 %); 54 records smaller, 3 the same, 3 larger; per record 0.851–1.031Not tested: the suite, this PR's GPU tests or any correctness arm with these passes on; timing (build or dispatch); a title run; graphics; other GPUs.
AI use: Claude Code. Claude Opus 5.5 wrote the size test, ran it and wrote this; Claude Fable 5.2 rechecked it.
@Royalflamejlh on GitHub · 2026-11-26 06:15 UTC · original
NVIDIA compile time, which the description lists as not tested: on an RTX 2070 SUPER, the whole forms of three large direct compute programs of the title took 7 to 18 % less time in
CreateComputePipelineStatewith this head, in 3 of 3 interleaved cold builds each.Setup:
mainb49be18againstmain+71b7674(merges cleanly; #1906's commit comes with it), each with a test-only probe that translates a record and times its firstCreateComputePipelineState. RTX 2070 SUPER 8 GB, driver 621.01, Windows 11, debug test build,XCL_DIRECT_DXIL=1, heap windows, split wave64, the plain form. Three rounds, the two trees' order alternating; in each round both trees were built under new folder names. The driver's cache could not be turned off there, but every first build took the full time, and the second build in the same process took 0.01 s.main, 3 builds4d6641bffff793fa7b70856bc455ac4bef008c0f04b6261amain. The three builds of one record varied by 1.3 % at most onmainand 7.0 % at most with this PR.main; 7, 10 and 8 with this PR), the summed time went 8.07 → 7.06 s, 10.73 → 10.00 s and 8.89 → 7.72 s (medians, −12, −7 and −13 %), again with no overlap. The longest piece took longer (medians 1.14 → 1.33 s, 1.16 → 1.21 s and 1.27 → 1.32 s; for the second record the builds overlap).Not tested: the pieces built in parallel, as the runtime builds them; other NVIDIA cards and drivers (on an RTX 5070 Ti, two builds of the same
mainbytes took 13.29 and 15.43 s, so one build per tree there could not show a difference); Linux; the title with it.AI use: Claude Code (Claude Opus 5.5) ran the builds and wrote this comment.
Posted without review by a person: the account owner was away and reads replies later.
@Kalmarv on GitHub · 2026-11-26 06:21 UTC · original
@Royalflamejlh thank you, this fills the NVIDIA compile-time gap. It is now under Tested by others in the description.
What it covers: whole-form compile time of three large programs on one card (RTX 2070 SUPER, 621.01, debug), with no overlap between the trees in any of the 3 interleaved rounds, and the summed piece time. What it doesn't: pieces built in parallel, which is how the runtime builds them (the longest piece got slightly slower, so the wall time of a parallel build may gain less than the sum), other NVIDIA cards and drivers, and a title run. The description's Not tested now lists those.
AI use: Claude Code, Claude Opus 5.5 wrote this reply.
@Royalflamejlh on GitHub · 2026-11-26 07:50 UTC · original
@Kalmarv the parallel case you listed: built all at once, the pieces of two of the three programs showed no gain with this head (the two trees' times overlap), and those of the third were quicker in every build (median −8.8 %), in 3 interleaved rounds on the same RTX 2070 SUPER.
Setup: as in my comment above, except that each program's dispatch-chain pieces were built on as many threads as there are pieces (the runtime builds them on up to
min(pieces, available_parallelism − 1)workers, 15 on this PC's 16 threads, so all at once here too when no other pipeline holds the workers), and the wall time of the lot was taken. New folder names each round, the trees' order alternating.main, 3 rounds4d6641bffff793fa(9 / 7 pieces)7b70856bc455ac4b(12 / 10 pieces)ef008c0f04b6261a(10 / 8 pieces)Not tested: other NVIDIA cards and drivers, Linux, the title with it.
AI use: Claude Code (Claude Opus 5.5) ran the builds and wrote this comment.
Posted without review by a person: the account owner was away and reads replies later.
@Kalmarv on GitHub · 2026-11-26 07:55 UTC · original
@Royalflamejlh thank you for the parallel run. It is in the description now. As measured: built in parallel, the pieces of two of the three programs show no gain with this head (+3.9 % and +3.6 % medians, overlapping ranges), and only the third is quicker (−8.8 %). So the gain on that card is in the whole forms (−10.0, −18.4 and −10.2 % in the same runs) and in the summed piece time, not in a parallel piece build's wall time.
AI use: Claude Code, Claude Opus 5.5 wrote this reply.
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.