Recompiler: keep the raw-load shader flag guard in the DCE after block merging #3664

Open
Prime1997 wants to merge 1 commit from upstream-pr/3664 into main
Prime1997 commented 2026-12-02 05:54:00 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Prime1997 on 2026-12-02T05:54:00Z.


Requested by Prime

#3503 made the optimizer's dead-code elimination keep one raw buffer load when every raw load in a shader is dead. The RawAndStructuredBuffers shader flag is set while the module is built, so a shader that loses all its raw loads no longer matches its flags. But Module::optimize runs a second DCE after simplify_cfg merges blocks, and that one had no such guard: it dropped the very load the first DCE had kept. Both DCEs now go through one Module::eliminate_dead, which applies the guard, so the load survives block merging too.

Related: #3503 added the guard to the first DCE; this adds it to the second. #3646 (open) also changes Module::optimize in opt.rs for speed; the two may conflict in text, not in behaviour.

What is in it

  • crates/xcl/src/gpu/dxil/module/opt.rs: the two DCE loops in Module::optimize become one Module::eliminate_dead, with the raw-load guard in both; a switch for the second one; a unit test that a dead raw load survives the DCE after block merging.
  • crates/xcl/src/gpu/recomp/pso.rs, crates/xcl/src/shaders.rs: the new switch bypasses the translated shader caches and is part of the warm pipeline settings key, like XCL_DXIL_NO_OPT.

Tested

  • RTX 3060 Ti 8 GB, Windows 11, release build: the optimizer change has been in our test builds since 30 Nov (no measured before/after on its own); the cache-key part is new on this branch.
  • This branch (on main 1c8b5514): cargo check -p xcl --lib --tests --target x86_64-pc-windows-gnu passes. The test suite was not run on this exact branch.

Regression run

  • Not run yet: testers welcome.

Not tested

  • The suite and scripts/smoke.ps1 on this branch; AMD.
  • The new test a_dead_raw_buffer_load_survives_the_dce_after_block_merging was not run on this branch.

Switches

  • XCL_DXIL_MERGE_DCE_RAW_GUARD (default on): =0 leaves the guard out of the DCE after block merging, as before this change. While it is set (to any value), the shader caches are bypassed, as with XCL_DXIL_NO_OPT.

AI use

  • Claude Code wrote the change and this description.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5600745130 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3664). Originally posted by [Prime1997](https://github.com/Prime1997) on 2026-12-02T05:54:00Z. --- <!-- claude-projects-attribution: {"github_login":"Prime1997"} --> _Requested by **Prime**_ #3503 made the optimizer's dead-code elimination keep one raw buffer load when every raw load in a shader is dead. The RawAndStructuredBuffers shader flag is set while the module is built, so a shader that loses all its raw loads no longer matches its flags. But `Module::optimize` runs a second DCE after `simplify_cfg` merges blocks, and that one had no such guard: it dropped the very load the first DCE had kept. Both DCEs now go through one `Module::eliminate_dead`, which applies the guard, so the load survives block merging too. Related: #3503 added the guard to the first DCE; this adds it to the second. #3646 (open) also changes `Module::optimize` in `opt.rs` for speed; the two may conflict in text, not in behaviour. **What is in it** - `crates/xcl/src/gpu/dxil/module/opt.rs`: the two DCE loops in `Module::optimize` become one `Module::eliminate_dead`, with the raw-load guard in both; a switch for the second one; a unit test that a dead raw load survives the DCE after block merging. - `crates/xcl/src/gpu/recomp/pso.rs`, `crates/xcl/src/shaders.rs`: the new switch bypasses the translated shader caches and is part of the warm pipeline settings key, like `XCL_DXIL_NO_OPT`. **Tested** - RTX 3060 Ti 8 GB, Windows 11, release build: the optimizer change has been in our test builds since 30 Nov (no measured before/after on its own); the cache-key part is new on this branch. - This branch (on main 1c8b5514): `cargo check -p xcl --lib --tests --target x86_64-pc-windows-gnu` passes. The test suite was not run on this exact branch. **Regression run** - Not run yet: testers welcome. **Not tested** - The suite and `scripts/smoke.ps1` on this branch; AMD. - The new test `a_dead_raw_buffer_load_survives_the_dce_after_block_merging` was not run on this branch. **Switches** - `XCL_DXIL_MERGE_DCE_RAW_GUARD` (default on): `=0` leaves the guard out of the DCE after block merging, as before this change. While it is set (to any value), the shader caches are bypassed, as with `XCL_DXIL_NO_OPT`. **AI use** - Claude Code wrote the change and this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Foniass commented 2026-12-02 09:13:32 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T09:13:32Z.


Review (head cc6b6d1a, diff read, not a merge-check; checks red):

  • PR description check refuses it. PR checks reports that Regression run has no xcl-smoke block made on head cc6b6d1a90 and none made on a commit of main. The description also says the suite and the new test were not run on this branch, and the only test listed is cargo check with x86_64-pc-windows-gnu. CONTRIBUTING requires the whole suite on a GPU with counts. Build and test (Windows, no GPU) is red too, but it looks unrelated: the lib test process aborts (exit code 130088963) right after hle::d3d12x::uma_driver logs "coherent window could not be restored". The new test shows ... ok in that log. A rerun should tell.
  • The switch only brings the bug back and pulls in two files. XCL_DXIL_MERGE_DCE_RAW_GUARD=0 (opt.rs ~1937) restores the old behaviour, which drops the raw load the first DCE kept. That switch is the only reason for the pso.rs ~1183 and shaders.rs ~36 changes, and for the textual conflict with #3669 in shaders.rs. Any value disables the shader caches, including =1, which is the same as the default. CONTRIBUTING puts env-var switches in their own PR. Without the switch this is a ~90-line change to opt.rs alone.
  • The consequence is not shown. The description says the flags "no longer match", but there is no shader, validator message or device error where this happened ("no measured before/after on its own"). The unit test counts calls and does not validate a module. By reading, the bug is real: on main the DCE after simplify_cfg treats every rawBufferLoad as removable and has no guard. It drops the load (and its handle chain) that #3503's guard kept, and the next iteration finds no raw load left to keep.
  • Conflicts with #3654. #3654 widens the same flagged closure to SCALAR_HEAP_PAIR | SCALAR_HEAP_QUAD | RAW_HEAP_QUAD. Whichever PR lands second has to move that predicate into eliminate_dead (opt.rs ~1517). If it doesn't, the outlined helpers lose the guard in one of the two DCEs.

Fine: by reading, eliminate_dead keeps main's behaviour for both DCE passes: the same roots, keep_all stands in for skip("dce"), the second pass has the same !removable roots, and live is now sized for each call. The new test fails on main for merge=true (the second DCE drops both the raw load and its dx.op.unary operand) and passes with the fix. No cache version bump is needed: module/opt.rs is under src/gpu/dxil, which XCL_DIRECT_DXIL_SOURCE_ID hashes (build.rs ~141).

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7340565755 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3664#issuecomment-7340565755). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T09:13:32Z. --- Review (head cc6b6d1a, diff read, not a merge-check; checks red): - **PR description check refuses it.** `PR checks` reports that **Regression run** has no `xcl-smoke` block made on head cc6b6d1a90db and none made on a commit of main. The description also says the suite and the new test were not run on this branch, and the only test listed is `cargo check` with `x86_64-pc-windows-gnu`. CONTRIBUTING requires the whole suite on a GPU with counts. `Build and test (Windows, no GPU)` is red too, but it looks unrelated: the lib test process aborts (exit code 130088963) right after `hle::d3d12x::uma_driver` logs "coherent window could not be restored". The new test shows `... ok` in that log. A rerun should tell. - **The switch only brings the bug back and pulls in two files.** `XCL_DXIL_MERGE_DCE_RAW_GUARD=0` (`opt.rs ~1937`) restores the old behaviour, which drops the raw load the first DCE kept. That switch is the only reason for the `pso.rs ~1183` and `shaders.rs ~36` changes, and for the textual conflict with #3669 in `shaders.rs`. Any value disables the shader caches, including `=1`, which is the same as the default. CONTRIBUTING puts env-var switches in their own PR. Without the switch this is a ~90-line change to `opt.rs` alone. - **The consequence is not shown.** The description says the flags "no longer match", but there is no shader, validator message or device error where this happened ("no measured before/after on its own"). The unit test counts calls and does not validate a module. By reading, the bug is real: on main the DCE after `simplify_cfg` treats every `rawBufferLoad` as removable and has no guard. It drops the load (and its handle chain) that #3503's guard kept, and the next iteration finds no raw load left to keep. - **Conflicts with #3654.** #3654 widens the same `flagged` closure to `SCALAR_HEAP_PAIR | SCALAR_HEAP_QUAD | RAW_HEAP_QUAD`. Whichever PR lands second has to move that predicate into `eliminate_dead` (`opt.rs ~1517`). If it doesn't, the outlined helpers lose the guard in one of the two DCEs. Fine: by reading, `eliminate_dead` keeps main's behaviour for both DCE passes: the same roots, `keep_all` stands in for `skip("dce")`, the second pass has the same `!removable` roots, and `live` is now sized for each call. The new test fails on main for `merge=true` (the second DCE drops both the raw load and its `dx.op.unary` operand) and passes with the fix. No cache version bump is needed: `module/opt.rs` is under `src/gpu/dxil`, which `XCL_DIRECT_DXIL_SOURCE_ID` hashes (`build.rs ~141`). AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Foniass commented 2026-12-02 11:33:33 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T11:33:33Z.


Test report (not a merge-check: PR description red)
base: 1c8b551475
head: cc6b6d1a90
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2910 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read by one reviewer at this same head; the review is at https://github.com/xcl-dev/xcl/pull/3664#issuecomment-7340565755 and its findings stand. Most serious: the fix is correct by reading; the description lacks the suite run and smoke blocks.
performance: 60 s smoke of a retail title, main 1c8b5514 vs this merge (cc6b6d1a): 1652 -> 1693 frames shown (102 %; last presents per 2 s: 61 60 60), peak commit 18228 -> 18028 MB, 0 device removals, 0 crashes.
assessment: merges, builds and passes the whole suite on current main, and the smoke run is clean; the review found no blocking problem, and the description still needs its suite counts and smoke blocks
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7344086773 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3664#issuecomment-7344086773). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T11:33:33Z. --- Test report (not a merge-check: `PR description` red) base: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f head: cc6b6d1a90dbcc1d3f3e6d78382b644b1bda7c7c merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2910 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none review: read by one reviewer at this same head; the review is at https://github.com/xcl-dev/xcl/pull/3664#issuecomment-7340565755 and its findings stand. Most serious: the fix is correct by reading; the description lacks the suite run and smoke blocks. performance: 60 s smoke of a retail title, main 1c8b5514 vs this merge (cc6b6d1a): 1652 -> 1693 frames shown (102 %; last presents per 2 s: 61 60 60), peak commit 18228 -> 18028 MB, 0 device removals, 0 crashes. assessment: merges, builds and passes the whole suite on current main, and the smoke run is clean; the review found no blocking problem, and the description still needs its suite counts and smoke blocks hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 AI-written and posted by Foniass without a human check of each point.
Edgaras0404 commented 2026-12-02 16:01:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Edgaras0404 on 2026-12-02T16:01:58Z.


test report (not a merge-check; requested AMD test of #3664)

base: df0cfef638
head: cc6b6d1a90
merge: clean
build: cargo build --workspace -> ok; cargo build --release -p xcl -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> the -p xcl --lib binary aborted at exit 0x80004005 with no test result: line: 1383 ok, 4 failed, 25 ignored observed of 2,795 lib tests (the rest did not run); the 43 non-lib result lines: 147 passed, 2 failed, 20 ignored. SKIPPED 2 among the tests that ran, both no heap windows (hle::d3d12x::bind::tests::two_pass_binds_set_the_shared_view_heap, heap_window_out_of_memory_falls_back_to_the_switch_form). Failing: gpu::dxil::compact_tests::gpu_compact_form_with_micro_blocks_and_literal_table_runs_as_the_plain_form (compact_tests.rs:184, left (50, 0, 1, 5) vs right (50, 10045, 1, 5)), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu, gpu::recomp::tests::gpu_f32_compares_with_nan, gpu::recomp::tests::gpu_float_compares_random (all three fail in the base lib run too), and gpu_two_pass_cache_e2e::two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs (merge full run: child at gpu_two_pass_cache_e2e.rs:472, parent at :584; base alone fails at :584, left: 1, right: 0). The base lib run has the same abort (exit 0x80004005; 1382 ok, 4 failed, 25 ignored) and the same four failures, so the PR adds no failure; its new test gpu::dxil::module::opt::tests::a_dead_raw_buffer_load_survives_the_dce_after_block_merging passes. With XCL_DXIL_MERGE_DCE_RAW_GUARD=0 that test fails for merge=true (left: 0, right: 1), so it covers the fix.
review: most serious first: (1) the code fix is correct by reading: both DCEs now call Module::eliminate_dead; the second gets the same raw-load guard, order is refreshed after simplify_cfg (opt.rs:1455), repl2 is sized for the whole instruction list, and the first call keeps the skip("dce")/keep-all behaviour. The new test passes with the guard on and fails with it off, so it is a real regression test. (2) XCL_DXIL_MERGE_DCE_RAW_GUARD is scope for its own PR: =0 only restores the bug, while any value (including =1) bypasses the translated shader caches and changes the warm-pipeline settings key, and CONTRIBUTING asks for env switches separately; the fix itself is a ~90-line opt.rs change. (3) overlap, not duplicate: #3654 changes the same flagged predicate in opt.rs (the earlier review says it widens it to the scalar-heap pairs/quads), and #3646 also edits Module::optimize; whichever lands second needs the predicate moved into eliminate_dead. #3503 is the merged predecessor that added the first guard. No duplicate found in open/merged PRs or #1607. (4) the description has no suite counts and no xcl-smoke blocks, so PR description is red; Build and test is red; the linked review reports the new test logs ok in that run, so it is not the new test.
performance: 60 s retail smoke: base df0cfef6 1619 frames / 16,223 MB peak, merge 15614e38 1618 / 17,816 (99.9% frames, 109.8% peak; thresholds 80%/125%), 0 device removals and 0 crashes on both, exit 0x0 both; presents per 2 s last 3: base 60 60 61, merge 61 60 60.
verdict: not yet: the PR description check is red (no suite counts or xcl-smoke block) and the new switch is scope for its own PR; the code, tests and manual 60 s smoke are clean on AMD, so those are the only blockers.
hardware / tool and model: AMD Radeon RX 6700 XT 12 GB (RDNA2), driver 32.0.21045.29003; AMD Ryzen 5 5600X; Windows 10 build 19045 / OpenCode, DeepSeek V4.1 Flash 1017

<!-- greyfinch-sync:ivall/xcl:comment:7351335195 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3664#issuecomment-7351335195). Originally posted by [Edgaras0404](https://github.com/Edgaras0404) on 2026-12-02T16:01:58Z. --- test report (not a merge-check; requested AMD test of #3664) base: df0cfef638306f325b208e5adae18d35ab4bf4ed head: cc6b6d1a90dbcc1d3f3e6d78382b644b1bda7c7c merge: clean build: cargo build --workspace -> ok; cargo build --release -p xcl -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> the `-p xcl --lib` binary aborted at exit 0x80004005 with no `test result:` line: 1383 ok, 4 failed, 25 ignored observed of 2,795 lib tests (the rest did not run); the 43 non-lib result lines: 147 passed, 2 failed, 20 ignored. SKIPPED 2 among the tests that ran, both `no heap windows` (`hle::d3d12x::bind::tests::two_pass_binds_set_the_shared_view_heap`, `heap_window_out_of_memory_falls_back_to_the_switch_form`). Failing: `gpu::dxil::compact_tests::gpu_compact_form_with_micro_blocks_and_literal_table_runs_as_the_plain_form` (`compact_tests.rs:184`, `left (50, 0, 1, 5)` vs `right (50, 10045, 1, 5)`), `gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu`, `gpu::recomp::tests::gpu_f32_compares_with_nan`, `gpu::recomp::tests::gpu_float_compares_random` (all three fail in the base lib run too), and `gpu_two_pass_cache_e2e::two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs` (merge full run: child at `gpu_two_pass_cache_e2e.rs:472`, parent at `:584`; base alone fails at `:584`, `left: 1, right: 0`). The base lib run has the same abort (exit 0x80004005; 1382 ok, 4 failed, 25 ignored) and the same four failures, so the PR adds no failure; its new test `gpu::dxil::module::opt::tests::a_dead_raw_buffer_load_survives_the_dce_after_block_merging` passes. With `XCL_DXIL_MERGE_DCE_RAW_GUARD=0` that test fails for `merge=true` (`left: 0, right: 1`), so it covers the fix. review: most serious first: (1) the code fix is correct by reading: both DCEs now call `Module::eliminate_dead`; the second gets the same raw-load guard, `order` is refreshed after `simplify_cfg` (`opt.rs:1455`), `repl2` is sized for the whole instruction list, and the first call keeps the `skip("dce")`/keep-all behaviour. The new test passes with the guard on and fails with it off, so it is a real regression test. (2) `XCL_DXIL_MERGE_DCE_RAW_GUARD` is scope for its own PR: `=0` only restores the bug, while any value (including `=1`) bypasses the translated shader caches and changes the warm-pipeline settings key, and CONTRIBUTING asks for env switches separately; the fix itself is a ~90-line `opt.rs` change. (3) overlap, not duplicate: #3654 changes the same `flagged` predicate in `opt.rs` (the earlier review says it widens it to the scalar-heap pairs/quads), and #3646 also edits `Module::optimize`; whichever lands second needs the predicate moved into `eliminate_dead`. #3503 is the merged predecessor that added the first guard. No duplicate found in open/merged PRs or #1607. (4) the description has no suite counts and no `xcl-smoke` blocks, so `PR description` is red; `Build and test` is red; the linked review reports the new test logs `ok` in that run, so it is not the new test. performance: 60 s retail smoke: base `df0cfef6` 1619 frames / 16,223 MB peak, merge `15614e38` 1618 / 17,816 (99.9% frames, 109.8% peak; thresholds 80%/125%), 0 device removals and 0 crashes on both, exit 0x0 both; presents per 2 s last 3: base 60 60 61, merge 61 60 60. verdict: not yet: the `PR description` check is red (no suite counts or `xcl-smoke` block) and the new switch is scope for its own PR; the code, tests and manual 60 s smoke are clean on AMD, so those are the only blockers. hardware / tool and model: AMD Radeon RX 6700 XT 12 GB (RDNA2), driver 32.0.21045.29003; AMD Ryzen 5 5600X; Windows 10 build 19045 / OpenCode, DeepSeek V4.1 Flash 1017
bmjask commented 2026-12-02 20:05:12 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T20:05:12Z.

Review: COMMENTED


Review of cc6b6d1a: 1 finding(s) (1 medium), most severe first.

  1. Medium crates/xcl/src/gpu/dxil/module/opt.rs:1392: see below.

On lines outside the diff:

  1. Medium crates/xcl/src/gpu/dxil/module/opt.rs:1392: The raw-load guard only sees blocks that are still reachable when eliminate_dead runs, but constant branch folding (and the unreachable-block sweep at line 1153) empties blocks with self.blocks[b].clear() before any DCE, so raw loads that existed only in a folded-away branch are dropped with no guard. Take a shader whose only raw-buffer access is a rawBufferLoad inside if (CONST_FALSE): the CondBr folds to Br, the block becomes unreachable and is cleared, eliminate_dead finds no reachable rawBufferLoad, and the emitted DXIL still declares RawAndStructuredBuffers with no raw load left, the mismatch this PR is meant to prevent. Working out the flag from the final optimized code (on the writer side) instead of protecting loads in each DCE would cover every path.

These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.

<!-- greyfinch-sync:ivall/xcl:review:6158026670 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3664#pullrequestreview-6158026670). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T20:05:12Z. **Review:** COMMENTED --- Review of `cc6b6d1a`: 1 finding(s) (1 medium), most severe first. 1. **Medium** `crates/xcl/src/gpu/dxil/module/opt.rs:1392`: see below. **On lines outside the diff:** 1. **Medium** `crates/xcl/src/gpu/dxil/module/opt.rs:1392`: The raw-load guard only sees blocks that are still reachable when `eliminate_dead` runs, but constant branch folding (and the unreachable-block sweep at line 1153) empties blocks with `self.blocks[b].clear()` before any DCE, so raw loads that existed only in a folded-away branch are dropped with no guard. Take a shader whose only raw-buffer access is a `rawBufferLoad` inside `if (CONST_FALSE)`: the CondBr folds to Br, the block becomes unreachable and is cleared, `eliminate_dead` finds no reachable rawBufferLoad, and the emitted DXIL still declares RawAndStructuredBuffers with no raw load left, the mismatch this PR is meant to prevent. Working out the flag from the final optimized code (on the writer side) instead of protecting loads in each DCE would cover every path. --- _These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it._
Foniass commented 2026-12-03 14:50:20 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T14:50:20Z.


merge-check
base: 16c2fd082a
head: cc6b6d1a90
merge: clean
build: ok
tests: 3013 passed, 0 failed, 56 ignored; 28 skipped, the same as on main
review: 4 medium, 1 nit (below)
performance: 60 s smoke run: 1683 → 1659 frames (98 % of main), peak commit 18505 → 17233 MB, no device removal, no crash
title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 226 s there, 0 device removals, 0 crashes, 3.4 presents/s; run with XCL_SKIP_CS=95cc13288a27a96e (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590)
verdict: not yet: PR description is red; otherwise no blocking finding, the suite passes and the smoke run is clean
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5


In short: Both DCE passes in Module::optimize now go through one eliminate_dead, so the raw-load guard from #3503 also runs after simplify_cfg merges blocks; a switch turns that off. The head has not changed since my earlier review: the fix is correct by reading, and the new test fails without the guard (an AMD tester confirmed it with the switch at 0). Nothing in the code blocks it; the switch belongs in another PR.

Medium

  1. The switch only brings the bug back. Still open from my earlier review. XCL_DXIL_MERGE_DCE_RAW_GUARD=0 (opt.rs ~1937) restores dropping the load the first DCE kept. The switch is the only reason for the pso.rs ~1183 and shaders.rs ~36 changes. Any value, including =1 (the default behaviour), bypasses the shader caches. CONTRIBUTING puts env-var switches in a PR of their own; without it the fix is about 90 lines in opt.rs alone.
  2. The consequence is not shown. Still open. No shader, validator message or device error is given where the mismatch happened ("no measured before/after"). The unit test counts calls and does not validate a module.
  3. Conflicts with #3654. Still open; #3654 is still open. It widens the same flagged predicate to SCALAR_HEAP_PAIR | SCALAR_HEAP_QUAD | RAW_HEAP_QUAD. Whichever lands second has to move that predicate into eliminate_dead (opt.rs ~1517), or the outlined helpers lose the guard in one of the two DCEs. #3646 also edits Module::optimize; that conflict is only textual.
  4. Description gaps. Still open. No suite counts and no xcl-smoke blocks (Tested has only cargo check for the gnu target). AI use does not name the model.

Nit

  1. The guard misses raw loads removed by branch folding. Raised in a later review on the PR, and present since #3503. Blocks cleared by constant branch folding or the unreachable-block sweep (opt.rs ~1153) lose their raw loads before any DCE, so the flag can still mismatch. Working out the flag from the final code would cover every path. That is not for this PR.
Checked and fine
  • eliminate_dead keeps main's behaviour for both passes: same roots, keep_all stands in for skip("dce"), live sized per call
  • The new test fails on main for merge=true (both the raw load and its dx.op.unary operand are dropped) and passes with the fix
  • No cache version bump is needed: module/opt.rs is under src/gpu/dxil, which XCL_DIRECT_DXIL_SOURCE_ID hashes (build.rs ~141)
How this was tested
  • Merged onto main 16c2fd08, then cargo build --workspace and cargo test --workspace --no-fail-fast -- --test-threads=4.
  • The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar).
  • scripts/smoke.ps1: 60 s of a retail title on main 16c2fd08 and on this merge; presents per 2 s at the end: 60 60 60.
  • Title run: the release build of this merge launched the retail title with XCL_RUN_SECONDS=300 and scripted A presses counted from the first frame (XCL_PRESS_BASE=frame, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7382118812 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3664#issuecomment-7382118812). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T14:50:20Z. --- merge-check base: 16c2fd082ae2e96967a2ab553bc2e1032e491f70 head: cc6b6d1a90dbcc1d3f3e6d78382b644b1bda7c7c merge: clean build: ok tests: 3013 passed, 0 failed, 56 ignored; 28 skipped, the same as on main review: 4 medium, 1 nit (below) performance: 60 s smoke run: 1683 → 1659 frames (98 % of main), peak commit 18505 → 17233 MB, no device removal, no crash title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 226 s there, 0 device removals, 0 crashes, 3.4 presents/s; run with `XCL_SKIP_CS=95cc13288a27a96e` (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590) verdict: not yet: `PR description` is red; otherwise no blocking finding, the suite passes and the smoke run is clean hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 --- **In short:** Both DCE passes in Module::optimize now go through one eliminate_dead, so the raw-load guard from #3503 also runs after simplify_cfg merges blocks; a switch turns that off. The head has not changed since my earlier review: the fix is correct by reading, and the new test fails without the guard (an AMD tester confirmed it with the switch at 0). Nothing in the code blocks it; the switch belongs in another PR. #### Medium 1. **The switch only brings the bug back.** Still open from my earlier review. XCL_DXIL_MERGE_DCE_RAW_GUARD=0 (opt.rs ~1937) restores dropping the load the first DCE kept. The switch is the only reason for the pso.rs ~1183 and shaders.rs ~36 changes. Any value, including =1 (the default behaviour), bypasses the shader caches. CONTRIBUTING puts env-var switches in a PR of their own; without it the fix is about 90 lines in opt.rs alone. 2. **The consequence is not shown.** Still open. No shader, validator message or device error is given where the mismatch happened ("no measured before/after"). The unit test counts calls and does not validate a module. 3. **Conflicts with #3654.** Still open; #3654 is still open. It widens the same flagged predicate to SCALAR_HEAP_PAIR | SCALAR_HEAP_QUAD | RAW_HEAP_QUAD. Whichever lands second has to move that predicate into eliminate_dead (opt.rs ~1517), or the outlined helpers lose the guard in one of the two DCEs. #3646 also edits Module::optimize; that conflict is only textual. 4. **Description gaps.** Still open. No suite counts and no xcl-smoke blocks (Tested has only cargo check for the gnu target). AI use does not name the model. #### Nit 5. **The guard misses raw loads removed by branch folding.** Raised in a later review on the PR, and present since #3503. Blocks cleared by constant branch folding or the unreachable-block sweep (opt.rs ~1153) lose their raw loads before any DCE, so the flag can still mismatch. Working out the flag from the final code would cover every path. That is not for this PR. <details><summary>Checked and fine</summary> - eliminate_dead keeps main's behaviour for both passes: same roots, keep_all stands in for skip("dce"), live sized per call - The new test fails on main for merge=true (both the raw load and its dx.op.unary operand are dropped) and passes with the fix - No cache version bump is needed: module/opt.rs is under src/gpu/dxil, which XCL_DIRECT_DXIL_SOURCE_ID hashes (build.rs ~141) </details> <details><summary>How this was tested</summary> - Merged onto main `16c2fd08`, then `cargo build --workspace` and `cargo test --workspace --no-fail-fast -- --test-threads=4`. - The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar). - `scripts/smoke.ps1`: 60 s of a retail title on main `16c2fd08` and on this merge; presents per 2 s at the end: 60 60 60. - Title run: the release build of this merge launched the retail title with `XCL_RUN_SECONDS=300` and scripted A presses counted from the first frame (`XCL_PRESS_BASE=frame`, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3664:upstream-pr/3664'
git switch 'upstream-pr/3664'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3664'
git switch 'upstream-pr/3664'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3664'
git switch 'upstream-pr/3664'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3664'
git switch 'main'
git merge --squash 'upstream-pr/3664'
git switch 'main'
git merge --ff-only 'upstream-pr/3664'
git switch 'main'
git merge 'upstream-pr/3664'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!3664
No description provided.