Recompiler: skip scalar-load analysis for direct compact emission #2766

Open
github-bot wants to merge 1 commit from github-bot/gh-2766 into main AGit
Owner

@⁠KOLESNiii on GitHub · 2026-11-26 11:15 UTC · original
KOLESNiii:recomp/skip-reload-compact → main · +3 −2 · 1 files · 1 commits · open

The direct DXIL backend ran reload::analyze for every compute and kernel entry, including those it then emits in the compact form. Only the plain block loop reads the result, and that loop runs only when plan.is_none(). Compact emission lowers its blocks without the analysis, so on that path the fixed-point pass over the whole CFG was thrown away. The call is now guarded with plan.is_none(). Fixes #2746.

What is in it

  • crates/xcl/src/gpu/dxil/kernel.rs: run reload::analyze only when there is no compact plan (one line, plus the comment above it).

Tested

  • AMD Ryzen 5 3600XT, NVIDIA GeForce RTX 2070 SUPER (driver 32.0.16.2140), Windows 11 build 26300, rustc 1.100.0.

  • cargo test --workspace -- --test-threads=4 (debug): 1435 passed, 0 failed, 47 ignored. 25 SKIPPED: 21 no wave64, 1 no heap windows, 3 others.

  • Probe (a throwaway in-crate #[cfg(test)] module, not part of this PR), release build, medians of 5 passes. Synthetic wave32 kernels with 28,673 instructions and 8,193 reachable blocks, 16 / 128 / 256 distinct s_load_dwordx4 offsets. For each program, automatic selection and forced compact (translate_full_as(.., true)) give the same bytes.

    distinct loads whole compact translation, main (b49be183) this PR DXIL
    16 161.4 ms 47.0 ms identical (7,092 B)
    128 869.4 ms 51.1 ms identical (27,596 B)
    256 1,675.1 ms 55.4 ms identical (49,900 B)

    reload::analyze alone takes 114 / 816 / 1,614 ms on these programs, the difference between the two columns. Full numbers are in #2746.

  • The smoke title translates two compute shaders in the compact form (14,377 and 13,890 blocks), in both runs.

Regression run

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 2070 SUPER
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 978 (PresentX 978)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15900 MB
xcl-smoke v1
commit: f276e58d0fd307e0654aae45fe664eee956f0818
gpu: NVIDIA GeForce RTX 2070 SUPER
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1414 (PresentX 1415)
presents per 2 s (last 3): 58 60 22
device removals: 0
crashes: 0
peak commit: 17230 MB

The frame counts differ, but the runs also differ in timing: according to the log timestamps, the main run reached the two compact shaders at about 43 s and this PR's run at about 17 s. I did not look into why, and I do not attribute the frame difference to this change.

Not tested

  • No new unit test: the change affects only time spent, and its output is byte-identical, so no assertion can fail without it. The plain path's reload reuse is still covered by reload::tests::the_translator_emits_a_repeated_load_once.
  • Translation time of the title's two compact shaders was not measured on its own (the log has no per-translation timing).
  • Wave64 GPUs (AMD), and the 25 tests skipped on this adapter.

AI use

  • Claude Code with Claude Opus 5.5: wrote the change and the probe, ran the tests, probe and smoke runs on the hardware above, and wrote this description.

🤖 Generated with Claude Code

https://claude.ai/code/session_015csBcd63KUE2T1kW2P15nC

**@⁠KOLESNiii** on GitHub · 2026-11-26 11:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/2766) `KOLESNiii:recomp/skip-reload-compact` → `main` · +3 −2 · 1 files · 1 commits · open The direct DXIL backend ran `reload::analyze` for every compute and kernel entry, including those it then emits in the compact form. Only the plain block loop reads the result, and that loop runs only when `plan.is_none()`. Compact emission lowers its blocks without the analysis, so on that path the fixed-point pass over the whole CFG was thrown away. The call is now guarded with `plan.is_none()`. Fixes #2746. **What is in it** - `crates/xcl/src/gpu/dxil/kernel.rs`: run `reload::analyze` only when there is no compact plan (one line, plus the comment above it). **Tested** - AMD Ryzen 5 3600XT, NVIDIA GeForce RTX 2070 SUPER (driver 32.0.16.2140), Windows 11 build 26300, rustc 1.100.0. - `cargo test --workspace -- --test-threads=4` (debug): 1435 passed, 0 failed, 47 ignored. 25 `SKIPPED`: 21 `no wave64`, 1 `no heap windows`, 3 others. - Probe (a throwaway in-crate `#[cfg(test)]` module, not part of this PR), release build, medians of 5 passes. Synthetic wave32 kernels with 28,673 instructions and 8,193 reachable blocks, 16 / 128 / 256 distinct `s_load_dwordx4` offsets. For each program, automatic selection and forced compact (`translate_full_as(.., true)`) give the same bytes. | distinct loads | whole compact translation, `main` (`b49be183`) | this PR | DXIL | |---:|---:|---:|---| | 16 | 161.4 ms | 47.0 ms | identical (7,092 B) | | 128 | 869.4 ms | 51.1 ms | identical (27,596 B) | | 256 | 1,675.1 ms | 55.4 ms | identical (49,900 B) | `reload::analyze` alone takes 114 / 816 / 1,614 ms on these programs, the difference between the two columns. Full numbers are in https://git.gtahub.st/github/xcl-dev--xcl/issues/2746. - The smoke title translates two compute shaders in the compact form (14,377 and 13,890 blocks), in both runs. **Regression run** ``` xcl-smoke v1 commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 gpu: NVIDIA GeForce RTX 2070 SUPER title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 978 (PresentX 978) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15900 MB ``` ``` xcl-smoke v1 commit: f276e58d0fd307e0654aae45fe664eee956f0818 gpu: NVIDIA GeForce RTX 2070 SUPER title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1414 (PresentX 1415) presents per 2 s (last 3): 58 60 22 device removals: 0 crashes: 0 peak commit: 17230 MB ``` The frame counts differ, but the runs also differ in timing: according to the log timestamps, the main run reached the two compact shaders at about 43 s and this PR's run at about 17 s. I did not look into why, and I do not attribute the frame difference to this change. **Not tested** - No new unit test: the change affects only time spent, and its output is byte-identical, so no assertion can fail without it. The plain path's reload reuse is still covered by `reload::tests::the_translator_emits_a_repeated_load_once`. - Translation time of the title's two compact shaders was not measured on its own (the log has no per-translation timing). - Wave64 GPUs (AMD), and the 25 tests skipped on this adapter. **AI use** - Claude Code with Claude Opus 5.5: wrote the change and the probe, ran the tests, probe and smoke runs on the hardware above, and wrote this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_015csBcd63KUE2T1kW2P15nC
The direct DXIL backend ran reload::analyze for every compute and kernel
entry. Only the plain block loop reads its result, and that loop runs only
when there is no compact plan. Compact emission lowers its representative
blocks without it, so on that path the analysis (a fixed-point pass over the
whole CFG) was discarded. The call is now guarded with plan.is_none().

Measured on synthetic wave32 kernels (28,673 instructions, 8,193 blocks,
selected for the compact form automatically). Ryzen 5 3600XT, release,
medians of 5. Whole compact translation for 16 / 128 / 256 distinct load
addresses: 161 / 869 / 1,675 ms before, 47 / 51 / 55 ms after. The DXIL
output is byte-identical.

Fixes #2746

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015csBcd63KUE2T1kW2P15nC
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:34:47 +00:00
Author
Owner

@⁠MatyEjsr on GitHub · 2026-11-26 12:17 UTC · original · edited 2026-11-26 12:30 UTC

Independent verification of PR #2766 at exact head f276e58d0fd307e0654aae45fe664eee956f0818 (cleanly based on current main b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7, mergeable with no conflicts) on Windows 11 / NVIDIA RTX 3090, including direct DXIL translation timings and byte-identity checks on real retail compact compute shaders.

Code check

  • Audited all reload references across crates/xcl/src/gpu/dxil/: reloads in kernel.rs is read only inside for &b in cfg.rpo.iter().filter(|_| plan.is_none()), while compact::emit and compact::emit_with_nest leave lw.reload at None. Guarding reload::analyze(&cfg) with plan.is_none() eliminates dead CFG work on compact emission with zero semantic change.

Tested

  • OS / hardware: Windows 11 Pro for Workstations build 26200 (Developer Mode enabled), AMD Ryzen 7 7800X3D, 31.4 GB RAM, NVIDIA GeForce RTX 3090 (24 GB, driver 32.0.16.1742 / 617.42, wave32), rustc 1.100.0 (0ef1bc386 2026-11-09), DXC 1.9.2602.17.
  • cargo test --workspace -j 8 -- --test-threads=8 (debug): 1435 passed, 0 failed, 47 ignored.
    • SKIPPED (28): 21 no wave64 (dispatch_chain_native_wave64_builds_whole, gpu::recomp::lower / lower_dxil / tests wave64 variants), 3 per-lane f16/f32 refused for #1426, 2 no d3d12SDKLayers.dll (e2e.rs), 1 no heap windows (gpu_compute_e2e::heap_window_out_of_memory_falls_back_to_the_switch_form), 1 no D3D12 debug layer (texture_states::uploads_start_from_each_subresources_state).
  • Targeted debug checks (--test-threads=1):
    • cargo test -p xcl --lib gpu::dxil::reload::tests: 6 passed, 0 failed, 0 ignored, 0 SKIPPED (including the_translator_emits_a_repeated_load_once).
    • cargo test -p xcl --lib gpu::dxil::compact: 13 passed, 0 failed, 0 ignored, 0 SKIPPED.
    • XCL_DIRECT_DXIL=1 and XCL_DIRECT_DXIL=all cargo test -p xcl --test gpu_compute_e2e: 7 passed, 0 failed, 0 ignored, 1 SKIPPED (no heap windows) in both modes.
  • Retail shader corpus byte-identity & compact-form translation timings (main b49be183 vs PR #2766 f276e58d, release builds, --direct --validate):
    • Seeded 256-record sample (--sample 256 --seed 1 --validate --threads 8, default 16384 B cap; 41 over cap skipped): 215/215 translated and validated, 215/215 .direct.dxil outputs 100% byte-identical (0 diffs).
    • Real retail compact-emitted compute shaders (5 interleaved pairs per hash, --threads 1):
      container hash compact plan guest / DXIL bytes DXIL SHA-256 (first 16) main b49be183 median PR #2766 f276e58d median speedup
      95cc13288a27a96e 13,890 blocks, 2,643 kinds 333,596 B / 1,232,976 B 1ea6ec47667ec444 (identical) 675.15 ms 232.41 ms 2.91x (-442.74 ms)
      56c0cd3b82a00c6e 14,377 blocks, 617 kinds 488,744 B / 482,152 B 3bb11a22d84eb633 (identical) 337.87 ms 157.07 ms 2.15x (-180.80 ms)

Regression run

  • 60 s retail smoke runs (release, same title c1cc91a4, shared DXIL cache):

main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 3090
title: c1cc91a4
seconds: 60
exit: 0x0
frames shown: 1518 (PresentX 1518)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14104 MB

PR #2766 head:

xcl-smoke v1
commit: f276e58d0fd307e0654aae45fe664eee956f0818
gpu: NVIDIA GeForce RTX 3090
title: c1cc91a4
seconds: 60
exit: 0x0
frames shown: 1540 (PresentX 1540)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13976 MB

Not tested

  • AMD / native wave64 GPUs, Intel GPUs, Linux / Wine, and the 28 tests skipped on this host (wave64, #1426 refused f16/f32 per-lane, missing D3D12 debug layer, and XCL_HEAP_WINDOWS=1).

AI use

  • Antigravity (agy) with gemini-pro-orchestrator-argon (audited by gemini-pro-orchestrator-argon): audited the diff, ran the workspace/targeted tests, executed the retail shader benchmarks and smoke run on the hardware above, and drafted/audited this report.
**@⁠MatyEjsr** on GitHub · 2026-11-26 12:17 UTC · [original](https://github.com/xcl-dev/xcl/pull/2766#issuecomment-7191823437) · edited 2026-11-26 12:30 UTC Independent verification of PR #2766 at exact head `f276e58d0fd307e0654aae45fe664eee956f0818` (cleanly based on current `main` `b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7`, mergeable with no conflicts) on Windows 11 / NVIDIA RTX 3090, including direct DXIL translation timings and byte-identity checks on real retail compact compute shaders. **Code check** - Audited all `reload` references across `crates/xcl/src/gpu/dxil/`: `reloads` in `kernel.rs` is read only inside `for &b in cfg.rpo.iter().filter(|_| plan.is_none())`, while `compact::emit` and `compact::emit_with_nest` leave `lw.reload` at `None`. Guarding `reload::analyze(&cfg)` with `plan.is_none()` eliminates dead CFG work on compact emission with zero semantic change. **Tested** - OS / hardware: Windows 11 Pro for Workstations build 26200 (Developer Mode enabled), AMD Ryzen 7 7800X3D, 31.4 GB RAM, NVIDIA GeForce RTX 3090 (24 GB, driver 32.0.16.1742 / 617.42, wave32), `rustc 1.100.0` (`0ef1bc386 2026-11-09`), DXC `1.9.2602.17`. - `cargo test --workspace -j 8 -- --test-threads=8` (debug): **1435 passed, 0 failed, 47 ignored**. - `SKIPPED` (28): 21 `no wave64` (`dispatch_chain_native_wave64_builds_whole`, `gpu::recomp::lower` / `lower_dxil` / `tests` wave64 variants), 3 per-lane `f16`/`f32` refused for `#1426`, 2 `no d3d12SDKLayers.dll` (`e2e.rs`), 1 `no heap windows` (`gpu_compute_e2e::heap_window_out_of_memory_falls_back_to_the_switch_form`), 1 `no D3D12 debug layer` (`texture_states::uploads_start_from_each_subresources_state`). - Targeted debug checks (`--test-threads=1`): - `cargo test -p xcl --lib gpu::dxil::reload::tests`: **6 passed, 0 failed, 0 ignored**, 0 `SKIPPED` (including `the_translator_emits_a_repeated_load_once`). - `cargo test -p xcl --lib gpu::dxil::compact`: **13 passed, 0 failed, 0 ignored**, 0 `SKIPPED`. - `XCL_DIRECT_DXIL=1` and `XCL_DIRECT_DXIL=all` `cargo test -p xcl --test gpu_compute_e2e`: **7 passed, 0 failed, 0 ignored**, 1 `SKIPPED` (`no heap windows`) in both modes. - Retail shader corpus byte-identity & compact-form translation timings (`main` `b49be183` vs PR #2766 `f276e58d`, release builds, `--direct --validate`): - Seeded 256-record sample (`--sample 256 --seed 1 --validate --threads 8`, default 16384 B cap; 41 over cap skipped): **215/215** translated and validated, **215/215** `.direct.dxil` outputs **100% byte-identical** (`0` diffs). - Real retail compact-emitted compute shaders (5 interleaved pairs per hash, `--threads 1`): | container hash | compact plan | guest / DXIL bytes | DXIL SHA-256 (first 16) | `main` `b49be183` median | PR #2766 `f276e58d` median | speedup | |---|---|---|---|---:|---:|---:| | `95cc13288a27a96e` | 13,890 blocks, 2,643 kinds | 333,596 B / 1,232,976 B | `1ea6ec47667ec444` (identical) | 675.15 ms | 232.41 ms | **2.91x** (-442.74 ms) | | `56c0cd3b82a00c6e` | 14,377 blocks, 617 kinds | 488,744 B / 482,152 B | `3bb11a22d84eb633` (identical) | 337.87 ms | 157.07 ms | **2.15x** (-180.80 ms) | **Regression run** - 60 s retail smoke runs (release, same title `c1cc91a4`, shared DXIL cache): `main`: ``` xcl-smoke v1 commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 gpu: NVIDIA GeForce RTX 3090 title: c1cc91a4 seconds: 60 exit: 0x0 frames shown: 1518 (PresentX 1518) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14104 MB ``` PR #2766 head: ``` xcl-smoke v1 commit: f276e58d0fd307e0654aae45fe664eee956f0818 gpu: NVIDIA GeForce RTX 3090 title: c1cc91a4 seconds: 60 exit: 0x0 frames shown: 1540 (PresentX 1540) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 13976 MB ``` **Not tested** - AMD / native wave64 GPUs, Intel GPUs, Linux / Wine, and the 28 tests skipped on this host (wave64, `#1426` refused f16/f32 per-lane, missing D3D12 debug layer, and `XCL_HEAP_WINDOWS=1`). **AI use** - Antigravity (agy) with gemini-pro-orchestrator-argon (audited by gemini-pro-orchestrator-argon): audited the diff, ran the workspace/targeted tests, executed the retail shader benchmarks and smoke run on the hardware above, and drafted/audited this report.
Author
Owner

@⁠thehollowedone on GitHub · 2026-11-26 13:40 UTC · original

Independent Windows/NVIDIA check of #2766 head f276e58, based on main b49be183. I tested a clean detached checkout of the exact head.

Source check: the changed reload::analyze result is read by the plain block loop, which executes only when plan.is_none(). Compact emission runs on Some(plan), and its lowering does not set lw.reload. The guard leaves the plain path's analysis in place and removes work the compact path does not consume.

Tested: Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti 12 GiB (NVIDIA 621.35), rustc 1.99.1 MSVC, DXC 1.8.2502.11; XCL_ADAPTER=3080, writable local XCL_DXIL_CACHE.

  • cargo build --offline --locked --workspace: passed.
  • cargo test --offline --locked -p xcl --lib gpu::dxil::reload::tests -- --nocapture --test-threads=1: 6 passed, 0 failed, 0 ignored.
  • cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4: 1,435 passed, 0 failed, 47 ignored across 37 targets. There were 25 GPU SKIPPED notices (21 no wave64, three refused per-lane cases, one no heap windows); those are not GPU coverage. The suite log identifies the real RTX 3080 Ti backend.

Not tested: independent translation timing or byte-for-byte output comparison for a compact shader, a retail title smoke run, AMD wave64, and the skipped cases. This report verifies this revision's build and regression suite; it does not independently establish the reported translation speedup.

AI use: Codex (GPT-6.2 Sol) checked the source path, ran the tests, and drafted this report.

**@⁠thehollowedone** on GitHub · 2026-11-26 13:40 UTC · [original](https://github.com/xcl-dev/xcl/pull/2766#issuecomment-7193679274) Independent Windows/NVIDIA check of [#2766 head `f276e58`](https://github.com/xcl-dev/xcl/commit/f276e58d0fd307e0654aae45fe664eee956f0818), based on [`main` `b49be183`](https://github.com/xcl-dev/xcl/commit/b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7). I tested a clean detached checkout of the exact head. **Source check:** the changed `reload::analyze` result is read by [the plain block loop](https://github.com/xcl-dev/xcl/blob/f276e58d0fd307e0654aae45fe664eee956f0818/crates/xcl/src/gpu/dxil/kernel.rs#L346-L375), which executes only when `plan.is_none()`. [Compact emission](https://github.com/xcl-dev/xcl/blob/f276e58d0fd307e0654aae45fe664eee956f0818/crates/xcl/src/gpu/dxil/compact.rs#L214-L219) runs on `Some(plan)`, and its lowering does not set `lw.reload`. The guard leaves the plain path's analysis in place and removes work the compact path does not consume. **Tested:** Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti 12 GiB (NVIDIA 621.35), rustc 1.99.1 MSVC, DXC 1.8.2502.11; `XCL_ADAPTER=3080`, writable local `XCL_DXIL_CACHE`. - `cargo build --offline --locked --workspace`: passed. - `cargo test --offline --locked -p xcl --lib gpu::dxil::reload::tests -- --nocapture --test-threads=1`: **6 passed, 0 failed, 0 ignored**. - `cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4`: **1,435 passed, 0 failed, 47 ignored** across 37 targets. There were 25 GPU `SKIPPED` notices (21 no wave64, three refused per-lane cases, one no heap windows); those are not GPU coverage. The suite log identifies the real RTX 3080 Ti backend. **Not tested:** independent translation timing or byte-for-byte output comparison for a compact shader, a retail title smoke run, AMD wave64, and the skipped cases. This report verifies this revision's build and regression suite; it does not independently establish the reported translation speedup. AI use: Codex (GPT-6.2 Sol) checked the source path, ran the tests, and drafted this report.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2766/head:github-bot/gh-2766'
git switch 'github-bot/gh-2766'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2766'
git switch 'github-bot/gh-2766'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2766'
git switch 'github-bot/gh-2766'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2766'
git switch 'main'
git merge --squash 'github-bot/gh-2766'
git switch 'main'
git merge --ff-only 'github-bot/gh-2766'
git switch 'main'
git merge 'github-bot/gh-2766'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.