dxil: fold constant CFG terminators after CSE #1818

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

@⁠mokkamokacaffe on GitHub · 2026-11-24 21:11 UTC · original
mokkamokacaffe:codex/dxil-fold-constant-cfg → main · +435 −67 · 3 files · 1 commits · open

Part of #1269.

Direct-DXIL branch conditions can become constants after CSE, or be known from the control-flow edge that reaches a block. The optimizer previously retained both CFG arms, keeping dead blocks, terminators and PHI inputs in the emitted DXIL. This pass folds those branches conservatively, cleans the resulting graph, and recomputes type-derived shader flags from the surviving instructions.

What is in it

  • crates/xcl/src/gpu/dxil/module/opt.rs: fold constant CondBr and Switch terminators after CSE.
  • Propagate only branch/switch selector values proven on incoming edges; intersect facts at joins so contradictory paths are discarded.
  • Recompute reachability and predecessor edges, remove obsolete PHI inputs, and rerun trivial-PHI simplification while preserving loop backedges.
  • Add cfg to XCL_DXIL_NO_OPT for independent bisection.
  • crates/xcl/src/gpu/dxil/module.rs: compute double-extension use from surviving instructions after CFG cleanup, including live Fma calls.
  • crates/xcl/src/gpu/dxil/shader.rs: recompute Int64Ops, Doubles, and DoubleExtensions after optimization so removed wide operations cannot leave stale metadata.
  • Add focused tests for constants, dominated branches and switches, reconvergence, loop-carried PHIs, stale type-feature flags, and live FMA feature inference.

Tested

  • Rebased head 673ab90c82584abfdd5e65bf61e199c373f5752d: cargo check -p xcl --tests --target x86_64-pc-windows-msvc passed in a Linux cross-check environment using a local lib.exe-compatible archive wrapper. This was compile-only; Windows test binaries were not executed.
  • git diff --check: passed on 673ab90c82584abfdd5e65bf61e199c373f5752d.
  • Historical predecessor 0561b6b, Windows 11 / NVIDIA RTX 3060: cargo test --workspace -- --test-threads=4 reported 1186 passed, 2 failed and 26 ignored before the lib test binary stopped. The two failures were fuzz_validate_and_gpu_1 seed 884 and fuzz_validate_and_gpu_2 seed 1417: declared flags 1048592, actual 16, exposing a stale Int64Ops bit after CFG folding. Current head 673ab90 adds the metadata fix and focused regression coverage; the exact fuzz seeds still require a Windows/GPU rerun.
  • Historical standalone optimizer harness on the predecessor: 16 passed, 0 failed, 0 ignored, including the focused CFG tests.

Regression run

The following paired retail smoke passed on predecessor 0561b6b. It is retained as historical evidence but no longer satisfies the exact-head requirement after the rebase and shader-flag fix. A new PR-head run on 673ab90c82584abfdd5e65bf61e199c373f5752d is pending.

main:

xcl-smoke v1
commit: 1a0bbe3a2ba91ea8f5b6fc29130a053868d3c9e6
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1628 (PresentX 1628)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14561 MB

PR predecessor:

xcl-smoke v1
commit: 0561b6b055371015409b25785fa03852bbb310c5
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1631 (PresentX 1631)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14591 MB

The predecessor produced 100.2% of main frames and 100.2% of main peak commit, with no crash or device removal. It does not validate the new head.

Not tested

  • The exact Windows/GPU fuzz reproductions for seeds 884 and 1417 on 673ab90.
  • The full Windows workspace suite on the current head.
  • A new exact-head paired retail-title smoke run.
  • AMD and NVIDIA shader-pack translation or cold PSO measurements on the current head.

AI use

  • OpenAI Codex (GPT-5) implemented the original path-fact pass and focused CFG tests.
  • OpenAI Codex (GPT-6.2 Astra Ultra) rebased the change onto current main, preserved the newer optimizer work, diagnosed the stale shader-feature metadata from the independent fuzz report, implemented the type-feature reconciliation and tests, ran the Windows-target compile check, and drafted this updated description.
  • A GPL-3.0 project's reported behavior was considered as evidence only; no code was copied or adapted.
**@⁠mokkamokacaffe** on GitHub · 2026-11-24 21:11 UTC · [original](https://github.com/xcl-dev/xcl/pull/1818) `mokkamokacaffe:codex/dxil-fold-constant-cfg` → `main` · +435 −67 · 3 files · 1 commits · open Part of #1269. Direct-DXIL branch conditions can become constants after CSE, or be known from the control-flow edge that reaches a block. The optimizer previously retained both CFG arms, keeping dead blocks, terminators and PHI inputs in the emitted DXIL. This pass folds those branches conservatively, cleans the resulting graph, and recomputes type-derived shader flags from the surviving instructions. **What is in it** - `crates/xcl/src/gpu/dxil/module/opt.rs`: fold constant `CondBr` and `Switch` terminators after CSE. - Propagate only branch/switch selector values proven on incoming edges; intersect facts at joins so contradictory paths are discarded. - Recompute reachability and predecessor edges, remove obsolete PHI inputs, and rerun trivial-PHI simplification while preserving loop backedges. - Add `cfg` to `XCL_DXIL_NO_OPT` for independent bisection. - `crates/xcl/src/gpu/dxil/module.rs`: compute double-extension use from surviving instructions after CFG cleanup, including live `Fma` calls. - `crates/xcl/src/gpu/dxil/shader.rs`: recompute `Int64Ops`, `Doubles`, and `DoubleExtensions` after optimization so removed wide operations cannot leave stale metadata. - Add focused tests for constants, dominated branches and switches, reconvergence, loop-carried PHIs, stale type-feature flags, and live FMA feature inference. **Tested** - Rebased head `673ab90c82584abfdd5e65bf61e199c373f5752d`: `cargo check -p xcl --tests --target x86_64-pc-windows-msvc` passed in a Linux cross-check environment using a local `lib.exe`-compatible archive wrapper. This was compile-only; Windows test binaries were not executed. - `git diff --check`: passed on `673ab90c82584abfdd5e65bf61e199c373f5752d`. - Historical predecessor `0561b6b`, Windows 11 / NVIDIA RTX 3060: `cargo test --workspace -- --test-threads=4` reported 1186 passed, 2 failed and 26 ignored before the lib test binary stopped. The two failures were `fuzz_validate_and_gpu_1` seed 884 and `fuzz_validate_and_gpu_2` seed 1417: declared flags `1048592`, actual `16`, exposing a stale `Int64Ops` bit after CFG folding. Current head `673ab90` adds the metadata fix and focused regression coverage; the exact fuzz seeds still require a Windows/GPU rerun. - Historical standalone optimizer harness on the predecessor: 16 passed, 0 failed, 0 ignored, including the focused CFG tests. **Regression run** The following paired retail smoke passed on predecessor `0561b6b`. It is retained as historical evidence but no longer satisfies the exact-head requirement after the rebase and shader-flag fix. A new PR-head run on `673ab90c82584abfdd5e65bf61e199c373f5752d` is pending. main: ```xcl-smoke xcl-smoke v1 commit: 1a0bbe3a2ba91ea8f5b6fc29130a053868d3c9e6 gpu: AMD Radeon RX 9070 title: 34df7c50 seconds: 60 exit: 0x0 frames shown: 1628 (PresentX 1628) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14561 MB ``` PR predecessor: ```xcl-smoke xcl-smoke v1 commit: 0561b6b055371015409b25785fa03852bbb310c5 gpu: AMD Radeon RX 9070 title: 34df7c50 seconds: 60 exit: 0x0 frames shown: 1631 (PresentX 1631) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14591 MB ``` The predecessor produced 100.2% of main frames and 100.2% of main peak commit, with no crash or device removal. It does not validate the new head. **Not tested** - The exact Windows/GPU fuzz reproductions for seeds 884 and 1417 on `673ab90`. - The full Windows workspace suite on the current head. - A new exact-head paired retail-title smoke run. - AMD and NVIDIA shader-pack translation or cold PSO measurements on the current head. **AI use** - OpenAI Codex (GPT-5) implemented the original path-fact pass and focused CFG tests. - OpenAI Codex (GPT-6.2 Astra Ultra) rebased the change onto current `main`, preserved the newer optimizer work, diagnosed the stale shader-feature metadata from the independent fuzz report, implemented the type-feature reconciliation and tests, ran the Windows-target compile check, and drafted this updated description. - A GPL-3.0 project's reported behavior was considered as evidence only; no code was copied or adapted.
Fold branch and switch terminators both after ordinary constant simplification and when every incoming control-flow edge proves the selector value. Facts are intersected at joins and bounded to branch selectors, so contradictory paths do not leak through reconvergence.

Assisted-by: OpenAI Codex (GPT-5)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:06:17 +00:00
Author
Owner

@⁠Anon64 on GitHub · 2026-11-24 21:26 UTC · original

Regression run for this PR: head 365148b, based on main ea683a0. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release, XCL_NETWORK=0, A pressed every 4 s from 20 s, scripts/smoke.ps1 on a retail title for 60 s, back to back with the main run.

Default settings (the pair for Regression run):

main ea683a0:

xcl-smoke v1
commit: ea683a007da7f0319bbaf680a37717a582445ac3
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1488 (PresentX 1488)
presents per 2 s (last 3): 26 4 2
device removals: 0
crashes: 0
peak commit: 23201 MB

this PR:

xcl-smoke v1
commit: 365148bcc935ef04aeb9608debe0d72ba7db866f
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1602 (PresentX 1602)
presents per 2 s (last 3): 49 55 33
device removals: 0
crashes: 0
peak commit: 20875 MB

No device removals or crashes; 108 % of main's frames, 90 % of its peak commit. With default settings the direct path is off, so these runs do not reach this PR's code.

With XCL_DIRECT_DXIL=1, so that the changed pass runs:

run frames crashes peak commit
main ea683a0 1455 0 24.6 GB
this PR, run 1 – 1 15.7 GB
this PR, run 2 1474 0 24.7 GB
this PR, run 3 1468 0 24.5 GB

Run 1 crashed at 36.7 s with an access violation in VCRUNTIME140.dll, reading unmapped memory on a texture-detile thread: gpu::tiling::Chain::detile_level (tiling.rs:438) ← title_textures::subresources (title_textures.rs:1182). I don't think it comes from this PR: the stack is in texture upload, not in the DXIL optimiser, and two reruns of the same build were clean. It looks more like the race in #1359. I'm noting it here because it happened in a run of this PR's head.

Not tested: the whole suite; a world-loading run with the direct path.

Written with Claude Code (Claude Opus 5.5) from runs on this machine.

**@⁠Anon64** on GitHub · 2026-11-24 21:26 UTC · [original](https://github.com/xcl-dev/xcl/pull/1818#issuecomment-7144937889) Regression run for this PR: head `365148b`, based on `main` `ea683a0`. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release, `XCL_NETWORK=0`, A pressed every 4 s from 20 s, `scripts/smoke.ps1` on a retail title for 60 s, back to back with the `main` run. **Default settings** (the pair for **Regression run**): main `ea683a0`: ``` xcl-smoke v1 commit: ea683a007da7f0319bbaf680a37717a582445ac3 gpu: NVIDIA GeForce RTX 3060 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1488 (PresentX 1488) presents per 2 s (last 3): 26 4 2 device removals: 0 crashes: 0 peak commit: 23201 MB ``` this PR: ``` xcl-smoke v1 commit: 365148bcc935ef04aeb9608debe0d72ba7db866f gpu: NVIDIA GeForce RTX 3060 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1602 (PresentX 1602) presents per 2 s (last 3): 49 55 33 device removals: 0 crashes: 0 peak commit: 20875 MB ``` No device removals or crashes; 108 % of main's frames, 90 % of its peak commit. With default settings the direct path is off, so these runs do not reach this PR's code. **With `XCL_DIRECT_DXIL=1`**, so that the changed pass runs: | run | frames | crashes | peak commit | |---|---|---|---| | `main` `ea683a0` | 1455 | 0 | 24.6 GB | | this PR, run 1 | – | 1 | 15.7 GB | | this PR, run 2 | 1474 | 0 | 24.7 GB | | this PR, run 3 | 1468 | 0 | 24.5 GB | Run 1 crashed at 36.7 s with an access violation in `VCRUNTIME140.dll`, reading unmapped memory on a texture-detile thread: `gpu::tiling::Chain::detile_level` (tiling.rs:438) ← `title_textures::subresources` (title_textures.rs:1182). I don't think it comes from this PR: the stack is in texture upload, not in the DXIL optimiser, and two reruns of the same build were clean. It looks more like the race in #1359. I'm noting it here because it happened in a run of this PR's head. **Not tested:** the whole suite; a world-loading run with the direct path. Written with Claude Code (Claude Opus 5.5) from runs on this machine.
Author
Owner

@⁠minimalhipster990 on GitHub · 2026-11-24 21:32 UTC · original

RTX 4090 — direct DXIL and GPU readback

For #1269, we tested the same retail compute shader and readback fixtures used in the RTX 4090 test of #1800. On CS_LaserLightShadowRaytracing, the new control-flow pass removed both constant conditional branches and 41 PHI instructions. The validated DXIL container shrank by 576 bytes (2.11%). Disabling only the new pass reproduced the parent's container byte for byte. All three configurations passed the GPU readback checks. Across 12 matched rounds per condition, we observed no consistent reduction in translation or driver time on this shader.

What changed in the compiled shader

Direct DXIL output Parent PR enabled PR with cfg disabled
Validated container, bytes 27,312 26,736 27,312
Basic blocks in the compute entry 119 119 119
Conditional branches 59 57 59
Conditional branches with a literal condition 2 0 2
Unconditional branches 59 61 59
PHI instructions 362 321 362

These counts come from the Windows SDK disassembly of the final containers. Both constant branches became unconditional. The entry had 119 basic blocks and zero switches in all three configurations. The parent and disabled containers shared SHA-256 97da0d91b8994f85a62ab78625be8e07d6fbe8b33dd39577b8ebdc27472e1977. With the pass enabled, the digest was de665670b8e83bbc1361b9d18ca8dbbf5346e2f532fb8df4493a971ec4d04bc9.

Translation and driver timings

Milliseconds of CPU wall time, median [minimum–maximum] across 12 trials per configuration.

Measurement Parent PR enabled PR with cfg disabled
Direct DXIL translation, fixed executable paths 5.054 [4.847–5.450] 5.069 [4.880–5.532] 5.129 [4.783–5.828]
Driver PSO creation, fixed paths after warm-up 0.555 [0.542–0.589] 0.561 [0.550–0.813] 0.567 [0.546–0.768]
Direct DXIL translation, fresh path per trial 5.309 [5.015–5.484] 5.329 [5.148–5.970] 5.194 [5.053–5.576]
Driver PSO creation, fresh path per trial 144.046 [142.445–153.179] 144.630 [141.881–146.185] 143.863 [142.506–151.147]

With a fresh executable path, the enabled PR's driver median was 0.584 ms higher than the parent's. The PR was faster in six of the 12 matched rounds. All three ranges overlap.

  • Trials. Each sample ran in a fresh process. Each series used all six possible orders twice. The fixed-path series excluded one warm-up per variant. Each fresh-path invocation used a copy of its build executable in a separate directory. The enabled and disabled PR arms used the same binary. In total there were 72 measured invocations and three warm-ups.
  • DXIL timer. Timed the release-build kernel::translate_compute call using direct DXIL, wave32 and one memory window. Archive I/O, shader selection, validation, device setup and dispatch were outside the timer. Every timed container passed explicit validation and reproduced its configuration's reference FNV-1a-64 digest.
  • Driver timer. Timed the synchronous ID3D12Device::CreateComputePipelineState call after device and root-signature creation. The application supplied no cached PSO blob. Disabling the implicit driver cache returned 0x887A002D in every timed process. Fresh paths consistently reproduced long first-use PSO creation times. The cache state inside the driver was unobservable, so fully cold compiler cost remains unverified. These CPU timings do not measure dispatch or frame time.

GPU correctness

Full shader. Each configuration dispatched the original shader with a zero activity mask, an active mask and empty root, and an active mask and box32 root containing four invalid children. All 32 output words held the expected miss value 0x7f7fffff after each dispatch. Comparing the entire 20 KiB buffer against expectations gave zero differing words across nine full-shader checks. A separate coverage probe after the first BVH site preserved all 32 sentinels in the empty-box case and allowed all 32 writes in the two controls for every configuration.

Instruction readback. Both original 20-byte image_bvh_intersect_ray instructions, at 0x01C8 and 0x0880, were replayed with their original register operands. Four-child box32 and box16 cases covered sorting on and off, hits, distance clipping, grazing rays and misses. All 1,024 output words per configuration matched the geometric expectations and a separate HLSL + DXC GPU run bit for bit. Readbacks also matched across configurations. The second BVH site has instruction-replay coverage only. Full-shader tests used controlled inputs, and gameplay rendering was outside this benchmark.

Reproduction details

  • Revisions. Immediate parent ea683a007da7f0319bbaf680a37717a582445ac3 and PR head 365148b. Separate target directories, locked dependencies, release profile and identical measurement code. XCL_DXIL_NO_OPT was unset for the parent and enabled PR. The third configuration set only XCL_DXIL_NO_OPT=cfg.
  • Input. deferred_tiled:CS_LaserLightShadowRaytracing_c3ab3042_Wrapped, inflated-record FNV-1a-64 7118f495493c73af, 3,332 program bytes, 642 decoded instructions and 32 × 1 × 1 threads.
  • System. NVIDIA GeForce RTX 4090, driver 621.24, AMD Ryzen 7 5800X3D, Windows 11 build 26300.10075, Rust 1.99.1, Windows SDK 10.0.26100.0, DXC and DXIL validator 1.9.2602.17. Tested on 24 November 2026.
  • Focused tests. The PR's three optimizer tests passed on Windows in release mode, covering constant conditional branches, constant switches and preservation of a loop-carried PHI edge. The filter excluded 864 other tests.

AI disclosure. Codex prepared the harness, ran the tests and drafted this report.

**@⁠minimalhipster990** on GitHub · 2026-11-24 21:32 UTC · [original](https://github.com/xcl-dev/xcl/pull/1818#issuecomment-7145075501) ## RTX 4090 — direct DXIL and GPU readback For #1269, we tested the same retail compute shader and readback fixtures used in the [RTX 4090 test of #1800](https://git.gtahub.st/github/xcl-dev--xcl/pulls/1800). On `CS_LaserLightShadowRaytracing`, the new control-flow pass removed both constant conditional branches and 41 PHI instructions. The validated DXIL container shrank by **576 bytes (2.11%)**. Disabling only the new pass reproduced the parent's container **byte for byte**. All three configurations passed the GPU readback checks. Across 12 matched rounds per condition, we observed **no consistent reduction in translation or driver time on this shader**. ### What changed in the compiled shader | Direct DXIL output | Parent | PR enabled | PR with `cfg` disabled | |---|---:|---:|---:| | Validated container, bytes | 27,312 | 26,736 | 27,312 | | Basic blocks in the compute entry | 119 | 119 | 119 | | Conditional branches | 59 | 57 | 59 | | Conditional branches with a literal condition | 2 | 0 | 2 | | Unconditional branches | 59 | 61 | 59 | | PHI instructions | 362 | 321 | 362 | These counts come from the Windows SDK disassembly of the final containers. Both constant branches became unconditional. The entry had 119 basic blocks and zero switches in all three configurations. The parent and disabled containers shared SHA-256 `97da0d91b8994f85a62ab78625be8e07d6fbe8b33dd39577b8ebdc27472e1977`. With the pass enabled, the digest was `de665670b8e83bbc1361b9d18ca8dbbf5346e2f532fb8df4493a971ec4d04bc9`. ### Translation and driver timings Milliseconds of CPU wall time, median [minimum–maximum] across 12 trials per configuration. | Measurement | Parent | PR enabled | PR with `cfg` disabled | |---|---:|---:|---:| | Direct DXIL translation, fixed executable paths | 5.054 [4.847–5.450] | 5.069 [4.880–5.532] | 5.129 [4.783–5.828] | | Driver PSO creation, fixed paths after warm-up | 0.555 [0.542–0.589] | 0.561 [0.550–0.813] | 0.567 [0.546–0.768] | | Direct DXIL translation, fresh path per trial | 5.309 [5.015–5.484] | 5.329 [5.148–5.970] | 5.194 [5.053–5.576] | | Driver PSO creation, fresh path per trial | 144.046 [142.445–153.179] | 144.630 [141.881–146.185] | 143.863 [142.506–151.147] | With a fresh executable path, the enabled PR's driver median was **0.584 ms higher than the parent's**. The PR was faster in six of the 12 matched rounds. All three ranges overlap. - **Trials.** Each sample ran in a fresh process. Each series used all six possible orders twice. The fixed-path series excluded one warm-up per variant. Each fresh-path invocation used a copy of its build executable in a separate directory. The enabled and disabled PR arms used the same binary. In total there were 72 measured invocations and three warm-ups. - **DXIL timer.** Timed the release-build `kernel::translate_compute` call using direct DXIL, wave32 and one memory window. Archive I/O, shader selection, validation, device setup and dispatch were outside the timer. Every timed container passed explicit validation and reproduced its configuration's reference FNV-1a-64 digest. - **Driver timer.** Timed the synchronous `ID3D12Device::CreateComputePipelineState` call after device and root-signature creation. The application supplied no cached PSO blob. Disabling the implicit driver cache returned `0x887A002D` in every timed process. Fresh paths consistently reproduced long first-use PSO creation times. The cache state inside the driver was unobservable, so fully cold compiler cost remains unverified. These CPU timings do not measure dispatch or frame time. ### GPU correctness **Full shader.** Each configuration dispatched the original shader with a zero activity mask, an active mask and empty root, and an active mask and box32 root containing four invalid children. All 32 output words held the expected miss value `0x7f7fffff` after each dispatch. Comparing the entire 20 KiB buffer against expectations gave **zero differing words across nine full-shader checks**. A separate coverage probe after the first BVH site preserved all 32 sentinels in the empty-box case and allowed all 32 writes in the two controls for every configuration. **Instruction readback.** Both original 20-byte `image_bvh_intersect_ray` instructions, at `0x01C8` and `0x0880`, were replayed with their original register operands. Four-child box32 and box16 cases covered sorting on and off, hits, distance clipping, grazing rays and misses. All **1,024 output words per configuration** matched the geometric expectations and a separate HLSL + DXC GPU run bit for bit. Readbacks also matched across configurations. The second BVH site has instruction-replay coverage only. Full-shader tests used controlled inputs, and gameplay rendering was outside this benchmark. ### Reproduction details - **Revisions.** Immediate parent `ea683a007da7f0319bbaf680a37717a582445ac3` and [PR head 365148b](https://github.com/xcl-dev/xcl/commit/365148bcc935ef04aeb9608debe0d72ba7db866f). Separate target directories, locked dependencies, release profile and identical measurement code. `XCL_DXIL_NO_OPT` was unset for the parent and enabled PR. The third configuration set only `XCL_DXIL_NO_OPT=cfg`. - **Input.** `deferred_tiled:CS_LaserLightShadowRaytracing_c3ab3042_Wrapped`, inflated-record FNV-1a-64 `7118f495493c73af`, 3,332 program bytes, 642 decoded instructions and 32 × 1 × 1 threads. - **System.** NVIDIA GeForce RTX 4090, driver 621.24, AMD Ryzen 7 5800X3D, Windows 11 build 26300.10075, Rust 1.99.1, Windows SDK 10.0.26100.0, DXC and DXIL validator 1.9.2602.17. Tested on 24 November 2026. - **Focused tests.** The PR's three optimizer tests passed on Windows in release mode, covering constant conditional branches, constant switches and preservation of a loop-carried PHI edge. The filter excluded 864 other tests. **AI disclosure.** Codex prepared the harness, ran the tests and drafted this report.
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-24 22:37 UTC · original · edited 2026-11-24 22:54 UTC

Full-suite run, since this PR has no test report yet. Tested exact head 365148b (on its base ea683a0).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu: 893 passed, 0 failed, 42 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: constant_conditional_removes_edge_and_trivial_phi, constant_switch_keeps_only_the_selected_predecessor, edge_trim_keeps_a_loop_phi_backedge.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 894 passed, 0 failed, 42 ignored. SKIPPED: heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • On NVIDIA, --skip leaves out five tests where this PR's base has them. They fail on main 689f2db too, not because of this PR: under XCL_REQUIRE_GPU=mesh, runner::skip_test turns their skips into failures. These are heap_window_out_of_memory_falls_back_to_the_switch_form (#1651) and the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests (follow-up on #1651). The AMD run does not set XCL_REQUIRE_GPU.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-24 22:37 UTC · [original](https://github.com/xcl-dev/xcl/pull/1818#issuecomment-7146447597) · edited 2026-11-24 22:54 UTC Full-suite run, since this PR has no test report yet. Tested exact head `365148b` (on its base `ea683a0`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu`: **893 passed, 0 failed, 42 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - The new tests ran and passed: `constant_conditional_removes_edge_and_trivial_phi`, `constant_switch_keeps_only_the_selected_predecessor`, `edge_trim_keeps_a_loop_phi_backedge`. - Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4`: **894 passed, 0 failed, 42 ignored**. SKIPPED: `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). - On NVIDIA, `--skip` leaves out five tests where this PR's base has them. They fail on main `689f2db` too, not because of this PR: under `XCL_REQUIRE_GPU=mesh`, `runner::skip_test` turns their skips into failures. These are `heap_window_out_of_memory_falls_back_to_the_switch_form` (#1651) and the four `gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu` tests ([follow-up on #1651](https://git.gtahub.st/github/xcl-dev--xcl/issues/1651)). The AMD run does not set `XCL_REQUIRE_GPU`. **Not tested** - a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Author
Owner

@⁠pvfreis on GitHub · 2026-11-24 23:34 UTC · original

7c44c94 (same tree as 1a52a27, which is what ran; on main 689f2db; sandbox, debug, RTX 3060): 976 passed, 3 failed, 45 ignored; 689f2db alone 974 / 1 / 45 (the same e2e). DoubleExtensions and the version point are settled. Two failures remain, the require case I had read but not run:

  • fuzz_validate_and_gpu_1 seed 884, _2 seed 1417: Flags declared=1048592, actual=16: bit 20, Int64Ops, set by Shader::require while building an i64 instruction in a block the fold then empties. _0 and _3 pass.

main is now 20cf130 (#1900, two MSAA files, none of yours); I have not run on it.

Run and written with Claude Code (Claude Opus 5.5), checked with Claude Fable 5.2; each point checked by a person before posting.

**@⁠pvfreis** on GitHub · 2026-11-24 23:34 UTC · [original](https://github.com/xcl-dev/xcl/pull/1818#issuecomment-7147561397) `7c44c94` (same tree as `1a52a27`, which is what ran; on `main` `689f2db`; sandbox, debug, RTX 3060): 976 passed, 3 failed, 45 ignored; `689f2db` alone 974 / 1 / 45 (the same e2e). `DoubleExtensions` and the version point are settled. Two failures remain, the `require` case I had read but not run: - `fuzz_validate_and_gpu_1` seed 884, `_2` seed 1417: `Flags declared=1048592, actual=16`: bit 20, `Int64Ops`, set by `Shader::require` while building an i64 instruction in a block the fold then empties. `_0` and `_3` pass. `main` is now `20cf130` (#1900, two MSAA files, none of yours); I have not run on it. Run and written with Claude Code (Claude Opus 5.5), checked with Claude Fable 5.2; each point checked by a person before posting.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 00:39 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 00:39 UTC · [original](https://github.com/xcl-dev/xcl/pull/1818#issuecomment-7148741219) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~23 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Author
Owner

@⁠ivall on GitHub · 2026-11-25 11:35 UTC · original

A measurement on whether this pass finds anything in the programs it is meant for. I did not run this head (it conflicts with main in opt.rs and kernel.rs); I put the same step into main 9633138 as a local prototype: after each optimize round, constant CondBr / Switch terminators folded, unreachable blocks dropped, up to 4 rounds. A second switch also used what a branch tells about its condition in the blocks below it.

record constant terminators, fold only fold + branch conditions known below the branch
95cc13288a27a96e 0 (23,516 blocks, 12,694 branches) 0, DXIL the same bytes (2,401,953 B file)
ef008c0f04b6261a 0 1, 957,141 → 957,101 B
742a41ceb422beb5 0 1, 962,829 → 962,797 B
33743bd6d1e45443 0 1, 872,249 → 872,229 B

So on these four there is nothing to fold in the per-instruction form. It may still help other programs: I did not run the whole pack. Before this is rebased, a count over the pack (how many programs change, and by how much) would show whether it is worth it.

AMD RDNA4, native wave64, XCL_DIRECT_DXIL=1, XCL_DIRECT_COMPACT=0, 4 memory windows, translation only.

AI use: Claude Code (Claude Opus 5.5) wrote the prototype, ran it and wrote this on the maintainer's behalf.

**@⁠ivall** on GitHub · 2026-11-25 11:35 UTC · [original](https://github.com/xcl-dev/xcl/pull/1818#issuecomment-7161246267) A measurement on whether this pass finds anything in the programs it is meant for. I did not run this head (it conflicts with `main` in `opt.rs` and `kernel.rs`); I put the same step into `main` `9633138` as a local prototype: after each `optimize` round, constant `CondBr` / `Switch` terminators folded, unreachable blocks dropped, up to 4 rounds. A second switch also used what a branch tells about its condition in the blocks below it. | record | constant terminators, fold only | fold + branch conditions known below the branch | |---|---|---| | `95cc13288a27a96e` | 0 (23,516 blocks, 12,694 branches) | 0, DXIL the same bytes (2,401,953 B file) | | `ef008c0f04b6261a` | 0 | 1, 957,141 → 957,101 B | | `742a41ceb422beb5` | 0 | 1, 962,829 → 962,797 B | | `33743bd6d1e45443` | 0 | 1, 872,249 → 872,229 B | So on these four there is nothing to fold in the per-instruction form. It may still help other programs: I did not run the whole pack. Before this is rebased, a count over the pack (how many programs change, and by how much) would show whether it is worth it. AMD RDNA4, native wave64, `XCL_DIRECT_DXIL=1`, `XCL_DIRECT_COMPACT=0`, 4 memory windows, translation only. AI use: Claude Code (Claude Opus 5.5) wrote the prototype, ran it and wrote this on the maintainer's behalf.
Author
Owner

@⁠Toons29 on GitHub · 2026-11-25 13:44 UTC · original

Regression run of 0561b6b0 on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 1a0bbe3a, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 1a0bbe3a2ba91ea8f5b6fc29130a053868d3c9e6
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1628 (PresentX 1628)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14561 MB
xcl-smoke v1
commit: 0561b6b055371015409b25785fa03852bbb310c5
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1631 (PresentX 1631)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14591 MB

Against the limits in CONTRIBUTING.md: 100 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; a script posted this right after the run, with both blocks exactly as printed.

**@⁠Toons29** on GitHub · 2026-11-25 13:44 UTC · [original](https://github.com/xcl-dev/xcl/pull/1818#issuecomment-7164223963) Regression run of `0561b6b0` on the retail title, for this PR's **Regression run** section. Both blocks are from `scripts/smoke.ps1` as printed, not edited: `main` on `1a0bbe3a`, this PR on its head commit with no uncommitted changes, same title and time. ``` xcl-smoke v1 commit: 1a0bbe3a2ba91ea8f5b6fc29130a053868d3c9e6 gpu: AMD Radeon RX 9070 title: 34df7c50 seconds: 60 exit: 0x0 frames shown: 1628 (PresentX 1628) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14561 MB ``` ``` xcl-smoke v1 commit: 0561b6b055371015409b25785fa03852bbb310c5 gpu: AMD Radeon RX 9070 title: 34df7c50 seconds: 60 exit: 0x0 frames shown: 1631 (PresentX 1631) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14591 MB ``` Against the limits in CONTRIBUTING.md: 100 % of `main`'s frames, 100 % of its peak commit, no crash, no device removal. AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, `cargo build --release -p xcl`, 60 s, `XCL_NETWORK=0`. This is a regression check only: it does not show whether the run reaches the code this PR changes. AI use: Claude Code (Claude Opus 5.5) built both trees and ran `scripts/smoke.ps1`; a script posted this right after the run, with both blocks exactly as printed.
Author
Owner

@⁠jennydeth on GitHub · 2026-11-25 14:13 UTC · original

Full Windows workspace run (listed under Not tested). Two fuzz tests fail on this head and pass on its base.

Setup: RTX 3060 12 GB (32-lane waves, driver 32.0.16.2101), Ryzen 5 5600X, 32 GB RAM, Windows 11 build 26300, Rust 1.100.0, DXC 1.9.2609.5 (validator from the same release), debug build. Head 0561b6b, base main 1a0bbe3.

Result: cargo test --workspace -- --test-threads=4: 1186 passed, 2 failed, 26 ignored (the lib binary stopped at the failures, so later binaries did not run).

gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (fuzz_tests.rs:1152)
seed 884: validator rejected the module:
error: Flags must match usage.
note: Flags declared=1048592, actual=16

gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_2
seed 1417: validator rejected the module:
error: Flags must match usage.
note: Flags declared=1048592, actual=16
Reproduced with cargo test -p xcl --lib -- fuzz_validate_and_gpu (same two seeds). The same filter on main 1a0bbe3: 4 passed, 0 failed. The module declares flag bit 0x100000 that its code no longer uses; my guess (not checked) is that the CFG folding removes the instruction that set it without recomputing the flags.

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report, checked by a person before posting

**@⁠jennydeth** on GitHub · 2026-11-25 14:13 UTC · [original](https://github.com/xcl-dev/xcl/pull/1818#issuecomment-7164956415) Full Windows workspace run (listed under Not tested). Two fuzz tests fail on this head and pass on its base. Setup: RTX 3060 12 GB (32-lane waves, driver 32.0.16.2101), Ryzen 5 5600X, 32 GB RAM, Windows 11 build 26300, Rust 1.100.0, DXC 1.9.2609.5 (validator from the same release), debug build. Head 0561b6b, base main 1a0bbe3. Result: cargo test --workspace -- --test-threads=4: 1186 passed, 2 failed, 26 ignored (the lib binary stopped at the failures, so later binaries did not run). gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (fuzz_tests.rs:1152) seed 884: validator rejected the module: error: Flags must match usage. note: Flags declared=1048592, actual=16 gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_2 seed 1417: validator rejected the module: error: Flags must match usage. note: Flags declared=1048592, actual=16 Reproduced with cargo test -p xcl --lib -- fuzz_validate_and_gpu (same two seeds). The same filter on main 1a0bbe3: 4 passed, 0 failed. The module declares flag bit 0x100000 that its code no longer uses; my guess (not checked) is that the CFG folding removes the instruction that set it without recomputing the flags. AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report, checked by a person before posting
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 06:19 UTC · original

Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current main on the new head — needs another rebase before it can be tested.

**@⁠DavidM1911** on GitHub · 2026-11-26 06:19 UTC · [original](https://github.com/xcl-dev/xcl/pull/1818#issuecomment-7184326263) Re-verification on RTX 3060 Ti (Windows 11): still a **merge conflict with current `main`** on the new head — needs another rebase before it can be tested.
Author
Owner

@⁠pvfreis on GitHub · 2026-11-24 22:48 UTC · original · reviewed

Review of 365148b merged onto main 689f2db (no conflict, tree 46747484).

  1. CONFIRMED (run): three fuzz tests fail on the merged tree and pass on main here (RTX 3060). fuzz_tests.rs came with #1679, after this head, so the runs on ea683a0 cannot see it.

    test (first failing seed) validator
    fuzz_validate_and_gpu_0 (33) error: Flags must match usage. / Flags declared=1572948, actual=1572884
    fuzz_validate_and_gpu_1 (641) Flags declared=84, actual=20
    fuzz_validate_and_gpu_2 (1103) Flags declared=80, actual=16

    These are validator rejections, separate from the GPU failures reported on main in #1679 (AMD, RTX 5060 Ti).

    The difference is always 64, bit 6, DoubleExtensions. uses_double_extensions (module.rs:1394 on the merged tree) scans all of self.insts, including the instructions of the blocks the new step empties (opt.rs:535); insts_use_type next to it scans self.blocks. A dropped int -> double cast therefore still declares the flag. Scanning the blocks there should clear the flag for these three seeds (not run) but not the general case. Read, not run: Shader::require only adds, and Lw::f64ty, Lw::i64, v_cvt_f64_i32 (lower_wide.rs:875), Shader::binary on i64/f64 and the wave ops call it while building, so a flag whose only user is in an emptied block stays declared (removable refuses those for this reason). One way is to derive the flags from the remaining blocks after optimize. Each test stops at its first bad seed, so rerun all four. The flag code is the same at ea683a0. The block scan is also proposed in #1894 (item 2) and made by the draft #1544; neither covers the require flags.

    cargo test --workspace --locked --offline --no-fail-fast -- --test-threads=4, debug, RTX 3060, DXC 1.9.2602.17, isolated session: main 974 passed, 1 failed, 45 ignored; merged 974 passed, 4 failed, 45 ignored. The shared failure is the e2e title test (no swap chain there). The three new tests pass; 22 identical SKIPPED lines.

  2. CONFIRMED (read): TRANSLATOR_VERSION needs a value above main's 7. main went to 7 in #1679 (kernel.rs:40), this PR also goes 6 -> 7, so the merge keeps 7 without a conflict. The comment above the constant says gpu/dxil is not in build.rs's source hash, so with the same DXC and backend a cache written by main at 7 would keep serving the unfolded containers. Only direct DXIL (XCL_DIRECT_DXIL) is affected.

Not tested: AMD, wave64, a title.

Review by Claude Code (Claude Opus 5.5), checked with Claude Fable 5.2; each point checked by a person before posting.

**@⁠pvfreis** on GitHub · 2026-11-24 22:48 UTC · [original](https://github.com/xcl-dev/xcl/pull/1818#pullrequestreview-6048611188) · **reviewed** Review of `365148b` merged onto `main` `689f2db` (no conflict, tree `46747484`). 1. **CONFIRMED (run): three fuzz tests fail on the merged tree and pass on `main` here (RTX 3060).** `fuzz_tests.rs` came with #1679, after this head, so the runs on `ea683a0` cannot see it. | test (first failing seed) | validator | |---|---| | `fuzz_validate_and_gpu_0` (33) | `error: Flags must match usage.` / `Flags declared=1572948, actual=1572884` | | `fuzz_validate_and_gpu_1` (641) | `Flags declared=84, actual=20` | | `fuzz_validate_and_gpu_2` (1103) | `Flags declared=80, actual=16` | These are validator rejections, separate from the GPU failures reported on `main` in #1679 (AMD, RTX 5060 Ti). The difference is always 64, bit 6, `DoubleExtensions`. `uses_double_extensions` (`module.rs:1394` on the merged tree) scans all of `self.insts`, including the instructions of the blocks the new step empties (`opt.rs:535`); `insts_use_type` next to it scans `self.blocks`. A dropped int -> double cast therefore still declares the flag. Scanning the blocks there should clear the flag for these three seeds (not run) but not the general case. Read, not run: `Shader::require` only adds, and `Lw::f64ty`, `Lw::i64`, `v_cvt_f64_i32` (`lower_wide.rs:875`), `Shader::binary` on i64/f64 and the wave ops call it while building, so a flag whose only user is in an emptied block stays declared (`removable` refuses those for this reason). One way is to derive the flags from the remaining blocks after `optimize`. Each test stops at its first bad seed, so rerun all four. The flag code is the same at `ea683a0`. The block scan is also proposed in #1894 (item 2) and made by the draft #1544; neither covers the `require` flags. `cargo test --workspace --locked --offline --no-fail-fast -- --test-threads=4`, debug, RTX 3060, DXC 1.9.2602.17, isolated session: `main` 974 passed, 1 failed, 45 ignored; merged 974 passed, 4 failed, 45 ignored. The shared failure is the e2e title test (no swap chain there). The three new tests pass; 22 identical SKIPPED lines. 2. **CONFIRMED (read): `TRANSLATOR_VERSION` needs a value above `main`'s 7.** `main` went to 7 in #1679 (`kernel.rs:40`), this PR also goes 6 -> 7, so the merge keeps 7 without a conflict. The comment above the constant says `gpu/dxil` is not in build.rs's source hash, so with the same DXC and backend a cache written by `main` at 7 would keep serving the unfolded containers. Only direct DXIL (`XCL_DIRECT_DXIL`) is affected. Not tested: AMD, wave64, a title. Review by Claude Code (Claude Opus 5.5), checked with Claude Fable 5.2; each point checked by a person before posting.
github-bot force-pushed github-bot/gh-1818 from 0561b6b055 to 673ab90c82 2026-11-26 11:34:54 +00:00 Compare
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/1818/head:github-bot/gh-1818'
git switch 'github-bot/gh-1818'

Merge

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