Recompiler: direct DXIL optimizer runs to a fixed point with new passes #3269

Merged
Foniass merged 1 commit from upstream-pr/3269 into main 2026-11-30 04:03:20 +00:00
Foniass commented 2026-11-29 02:29:16 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-11-29T02:29:16Z.


#3266 and #3268 are merged; this PR is now one commit (a899ec90) on main 5b0d5fa3. It includes #3268's review fixes (the fold's phi edges, the 64-bit cmpxchg flag), which are on main.

Rebased for a test on newer main: main's lanes::ps_ballot_tests::direct_ps_mask_and_scc_counts_live_lanes_only (de915b5a) split a block with a dead s_add, so that block-local CSE kept two identical waveActiveBallot(true) calls apart. This PR's fixed-point loop runs CSE again after simplify_cfg has merged that block away, and folds them. That fold is correct (one block, no discard between), but the test then counts 1 ballot instead of 2 (the CI failure on 568e9380). The test now exports the skipped s14, so its split stays; that is the only change to it.

The IR part of amd-dev's direct DXIL size work (f089a9df, "shrink emitted shaders 4.5x-5.4x"); the bitcode part is #3250 and the compact-form part is #3261. optimize() now repeats its passes, up to 4 times, while one of them still changes the function. It gains:

  • scalar-alloca store-to-load forwarding and dead-store elimination (mostly the compact form's register slots)
  • entry-block hoisting of repeated constant-argument ReadNone intrinsics (createHandleFromHeap unshared, annotateHandle / getDimensions block-local)
  • branch facts in the dominator-tree CSE
  • chained-select collapse and removal of redundant adjacent barriers
  • in the lowering: constant EXEC lane-bit folds, single-instruction IEEE f32 compares, and constant fast paths for XCL_RDNA_FLOAT's FRC and legacy mul / fma

XCL_DXIL_NO_OPT gains alloca, facts, hoist and barrier.

What is in it

  • crates/xcl/src/gpu/dxil/module/opt.rs: the passes, optimize() rebuilt as the fixed-point loop, layout_positions, three new tests (local_alloca_store_load_forwarding_and_dse, hoist_entry_readnone_and_keep_heap_handles_unshared, redundant_barriers_eliminated_within_block)
  • crates/xcl/src/gpu/dxil/lanes.rs, prelude.rs, lower_valu.rs, module.rs (const_f32); lanes.rs also has the test change above
  • port to main: the loop keeps main's fold_guarded_selects, the trivial-phi pass after simplify_cfg, and main's back-edge check in every trivial-phi pass. The original commit's XCL_HEAP_WINDOWS default flip is left out (two NVIDIA setups failed with heap windows on, per the amd-dev port).

NVIDIA fix in this port: with XCL_RDNA_FLOAT (on by default) the original commit lowers v_fract_f32 to a bare native Frc. On NVIDIA Frc of a tiny negative input returns 1.0, which RDNA never does (it clamps to 0x3F7FFFFF): gpu_fract_f32_edges and f32_programs_on_the_gpu failed every run. The port keeps the native Frc and its result keeps the old clamp. The original was only run on AMD.

Why it needs #3266, and size
Without #3266's live double-ext scan, the new passes remove f64 ops but DoubleExtensions stays declared, and the validator rejects the module (fuzz_validate_and_gpu_0, seed 33). With it, the fuzz tests pass. The change is 886 + 245 lines: the new passes share the rewritten optimize() loop. It could be split into the loop plus one PR per pass if a reviewer prefers.

#3265 (merged): amd-dev's f089a9df also changed #3265's test raw_buffer_oob_check_guards_32bit_wraparound (the atomic's OFFSET from 16 to 20). On main, which has #3265, the test passes unchanged with this PR.

Tested

  • RTX 5070 Ti (driver 32.0.16.2114), AMD Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), debug tests, release smoke
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on a899ec90 (rebased onto main 5b0d5fa3): 2779 passed, 0 failed, 49 ignored. SKIPPED GPU tests: 45 distinct notices, almost all no wave64.
  • Retail title: 60 s smoke run below. The PR's run used -StartupTimeoutSeconds 3600 for the cold pipeline rebuild new DXIL needs.

Regression run

main:

xcl-smoke v1
commit: 3b6a91ed096d6d6e0fee52cfb86dc0a7d7c8c1b0
gpu: NVIDIA GeForce RTX 5070 Ti
title: 3cb1d8e0
seconds: 60
exit: 0x0
frames shown: 1193 (PresentX 1193)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15684 MB

this PR:

xcl-smoke v1
commit: a899ec90b55f1c0d9a8f3db853b67be3ba28d647
gpu: NVIDIA GeForce RTX 5070 Ti
title: 3cb1d8e0
seconds: 60
exit: 0x0
frames shown: 1581 (PresentX 1581)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15612 MB

Not tested

  • the DXIL size / driver compile time effect on main (not measured), AMD GPUs, whether the image looks the same, other titles

AI use

  • Claude Code with Claude Opus 5.5: ported the IR part of f089a9df, merged its optimize() with main's, found the dependency on #3266 (seed 33), adapted main's ballot test, ran the tests and the smoke run above, wrote this description.
  • Original code: amd-dev f089a9df (raylitebull, from 46aecbf7, written with Antigravity (Gemini 4 Neon High)).

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5546821553 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3269). Originally posted by [Foniass](https://github.com/Foniass) on 2026-11-29T02:29:16Z. --- #3266 and #3268 are merged; this PR is now one commit (`a899ec90`) on main `5b0d5fa3`. It includes #3268's review fixes (the fold's phi edges, the 64-bit `cmpxchg` flag), which are on main. **Rebased for a test on newer main:** main's `lanes::ps_ballot_tests::direct_ps_mask_and_scc_counts_live_lanes_only` (de915b5a) split a block with a dead `s_add`, so that block-local CSE kept two identical `waveActiveBallot(true)` calls apart. This PR's fixed-point loop runs CSE again after `simplify_cfg` has merged that block away, and folds them. That fold is correct (one block, no discard between), but the test then counts 1 ballot instead of 2 (the CI failure on `568e9380`). The test now exports the skipped `s14`, so its split stays; that is the only change to it. The IR part of amd-dev's direct DXIL size work (`f089a9df`, "shrink emitted shaders 4.5x-5.4x"); the bitcode part is #3250 and the compact-form part is #3261. `optimize()` now repeats its passes, up to 4 times, while one of them still changes the function. It gains: - scalar-alloca store-to-load forwarding and dead-store elimination (mostly the compact form's register slots) - entry-block hoisting of repeated constant-argument ReadNone intrinsics (`createHandleFromHeap` unshared, `annotateHandle` / `getDimensions` block-local) - branch facts in the dominator-tree CSE - chained-select collapse and removal of redundant adjacent barriers - in the lowering: constant EXEC lane-bit folds, single-instruction IEEE f32 compares, and constant fast paths for `XCL_RDNA_FLOAT`'s FRC and legacy mul / fma `XCL_DXIL_NO_OPT` gains `alloca`, `facts`, `hoist` and `barrier`. **What is in it** - `crates/xcl/src/gpu/dxil/module/opt.rs`: the passes, `optimize()` rebuilt as the fixed-point loop, `layout_positions`, three new tests (`local_alloca_store_load_forwarding_and_dse`, `hoist_entry_readnone_and_keep_heap_handles_unshared`, `redundant_barriers_eliminated_within_block`) - `crates/xcl/src/gpu/dxil/lanes.rs`, `prelude.rs`, `lower_valu.rs`, `module.rs` (`const_f32`); `lanes.rs` also has the test change above - port to main: the loop keeps main's `fold_guarded_selects`, the trivial-phi pass after `simplify_cfg`, and main's back-edge check in every trivial-phi pass. The original commit's `XCL_HEAP_WINDOWS` default flip is left out (two NVIDIA setups failed with heap windows on, per the amd-dev port). **NVIDIA fix in this port:** with `XCL_RDNA_FLOAT` (on by default) the original commit lowers `v_fract_f32` to a bare native `Frc`. On NVIDIA `Frc` of a tiny negative input returns 1.0, which RDNA never does (it clamps to `0x3F7FFFFF`): `gpu_fract_f32_edges` and `f32_programs_on_the_gpu` failed every run. The port keeps the native `Frc` and its result keeps the old clamp. The original was only run on AMD. **Why it needs #3266, and size** Without #3266's live double-ext scan, the new passes remove f64 ops but `DoubleExtensions` stays declared, and the validator rejects the module (`fuzz_validate_and_gpu_0`, seed 33). With it, the fuzz tests pass. The change is 886 + 245 lines: the new passes share the rewritten `optimize()` loop. It could be split into the loop plus one PR per pass if a reviewer prefers. **#3265 (merged):** amd-dev's `f089a9df` also changed #3265's test `raw_buffer_oob_check_guards_32bit_wraparound` (the atomic's `OFFSET` from 16 to 20). On main, which has #3265, the test passes unchanged with this PR. **Tested** - RTX 5070 Ti (driver 32.0.16.2114), AMD Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), debug tests, release smoke - `cargo test --workspace --no-fail-fast -- --test-threads=4` on a899ec90 (rebased onto main 5b0d5fa3): 2779 passed, 0 failed, 49 ignored. SKIPPED GPU tests: 45 distinct notices, almost all `no wave64`. - Retail title: 60 s smoke run below. The PR's run used `-StartupTimeoutSeconds 3600` for the cold pipeline rebuild new DXIL needs. **Regression run** main: ``` xcl-smoke v1 commit: 3b6a91ed096d6d6e0fee52cfb86dc0a7d7c8c1b0 gpu: NVIDIA GeForce RTX 5070 Ti title: 3cb1d8e0 seconds: 60 exit: 0x0 frames shown: 1193 (PresentX 1193) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15684 MB ``` this PR: ``` xcl-smoke v1 commit: a899ec90b55f1c0d9a8f3db853b67be3ba28d647 gpu: NVIDIA GeForce RTX 5070 Ti title: 3cb1d8e0 seconds: 60 exit: 0x0 frames shown: 1581 (PresentX 1581) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15612 MB ``` **Not tested** - the DXIL size / driver compile time effect on main (not measured), AMD GPUs, whether the image looks the same, other titles **AI use** - Claude Code with Claude Opus 5.5: ported the IR part of `f089a9df`, merged its `optimize()` with main's, found the dependency on #3266 (seed 33), adapted main's ballot test, ran the tests and the smoke run above, wrote this description. - Original code: amd-dev `f089a9df` (raylitebull, from `46aecbf7`, written with Antigravity (Gemini 4 Neon High)). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Kalmarv commented 2026-11-29 03:23:09 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T03:23:09Z.


merge-check
base: fa204595a4
head: b97cdff57c
merge: clean onto main (stacked on #3266 + #3268) and with the full 8-PR stack.
build: cargo build --workspace -> ok; cargo build --release -p xcl -> ok.
tests: In the clean 8-PR stack on main fa204595 with DXC 1.9.2609.5 and default env: cargo test -p xcl --lib --no-fail-fast -- --test-threads=4 -> 2483 passed, 3 failed, 29 ignored; failing: gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 rounding, wave32: lane 0 v9: 0x3f800000 against 0x3f7fffff), gpu::recomp::tests::gpu_fract_f32_edges (lane 6: fract(-0.000000029802322) below 1.0: left 1065353216 right 1065353215), and hle::kernelx::tests::a_page_whose_move_fails_stays_mapped_where_it_was (parallel flake). Re-running all 3 with XCL_RDNA_FLOAT=0 passed (3 passed; 0 failed in 0.90 s), and the 7-PR stack without #3269 passed all 2620 workspace tests with default env. 150 s xcl-smoke (ea3b5e4d, XCL_PREPARE=0, RTX 5070 Ti) on the combined 8-PR stack: exit: 0x0, 2096 frames shown, 0 device removals, 0 crashes, 0 display System events, 32049 MB peak commit.
review: finding in crates/xcl/src/gpu/dxil/prelude.rs: rdna_float_enabled() (XCL_RDNA_FLOAT) defaults to true, which lowers fract_f to a single dx.op.unary(Frc). On NVIDIA RTX 5070 Ti, dx.op.unary(Frc) returns 1.0f (0x3f800000) instead of 0x3f7fffff for fract(-2^-25), failing both f32_programs_on_the_gpu and gpu_fract_f32_edges. Either keep fract_f's < 1.0 clamp (defaulting XCL_RDNA_FLOAT off on non-RDNA / by default) or drop the Frc shortcut from default lowering.
performance: positive IR shrink from the optimizer passes when XCL_RDNA_FLOAT=0 (8-PR smoke 2096 frames, 32049 MB peak commit), but default-on Frc breaks f32 v_fract_f32 precision on NVIDIA.
verdict: not yet: XCL_RDNA_FLOAT defaults to on in prelude.rs, breaking fract_f on NVIDIA RTX 5070 Ti (f32_programs_on_the_gpu and gpu_fract_f32_edges fail with 0x3f800000 vs 0x3f7fffff; both pass with XCL_RDNA_FLOAT=0).
hardware / tool and model: NVIDIA GeForce RTX 5070 Ti 16 GB (wave32 only), Windows 11, DXC 1.9.2609.5 via XCL_DXC_DIR; Antigravity (Gemini 3.5 Pro) ran the merges, builds, workspace test suites, 150 s title smokes, diff reviews, and drafted this check.

<!-- greyfinch-sync:ivall/xcl:comment:7250015553 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3269#issuecomment-7250015553). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-11-29T03:23:09Z. --- merge-check base: fa204595a488c60c6c5f905244f0172072c9c2a9 head: b97cdff57c05f005a3e04aa6054642eb5b8e5012 merge: clean onto main (stacked on #3266 + #3268) and with the full 8-PR stack. build: cargo build --workspace -> ok; cargo build --release -p xcl -> ok. tests: In the clean 8-PR stack on main `fa204595` with DXC 1.9.2609.5 and default env: `cargo test -p xcl --lib --no-fail-fast -- --test-threads=4` -> 2483 passed, 3 failed, 29 ignored; failing: `gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu` (`f32 rounding, wave32: lane 0 v9: 0x3f800000 against 0x3f7fffff`), `gpu::recomp::tests::gpu_fract_f32_edges` (`lane 6: fract(-0.000000029802322) below 1.0: left 1065353216 right 1065353215`), and `hle::kernelx::tests::a_page_whose_move_fails_stays_mapped_where_it_was` (parallel flake). Re-running all 3 with `XCL_RDNA_FLOAT=0` passed (`3 passed; 0 failed` in 0.90 s), and the 7-PR stack without #3269 passed all 2620 workspace tests with default env. 150 s `xcl-smoke` (`ea3b5e4d`, `XCL_PREPARE=0`, RTX 5070 Ti) on the combined 8-PR stack: `exit: 0x0`, `2096` frames shown, `0` device removals, `0` crashes, `0` display System events, `32049 MB` peak commit. review: finding in `crates/xcl/src/gpu/dxil/prelude.rs`: `rdna_float_enabled()` (`XCL_RDNA_FLOAT`) defaults to `true`, which lowers `fract_f` to a single `dx.op.unary(Frc)`. On NVIDIA RTX 5070 Ti, `dx.op.unary(Frc)` returns `1.0f` (`0x3f800000`) instead of `0x3f7fffff` for `fract(-2^-25)`, failing both `f32_programs_on_the_gpu` and `gpu_fract_f32_edges`. Either keep `fract_f`'s `< 1.0` clamp (defaulting `XCL_RDNA_FLOAT` off on non-RDNA / by default) or drop the `Frc` shortcut from default lowering. performance: positive IR shrink from the optimizer passes when `XCL_RDNA_FLOAT=0` (8-PR smoke 2096 frames, 32049 MB peak commit), but default-on `Frc` breaks f32 `v_fract_f32` precision on NVIDIA. verdict: not yet: `XCL_RDNA_FLOAT` defaults to on in `prelude.rs`, breaking `fract_f` on NVIDIA RTX 5070 Ti (`f32_programs_on_the_gpu` and `gpu_fract_f32_edges` fail with `0x3f800000` vs `0x3f7fffff`; both pass with `XCL_RDNA_FLOAT=0`). hardware / tool and model: NVIDIA GeForce RTX 5070 Ti 16 GB (wave32 only), Windows 11, DXC 1.9.2609.5 via XCL_DXC_DIR; Antigravity (Gemini 3.5 Pro) ran the merges, builds, workspace test suites, 150 s title smokes, diff reviews, and drafted this check.
Kalmarv commented 2026-11-29 06:39:32 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T06:39:32Z.


merge-check
base: fa204595
head: 4a8217a7
verdict: safe to merge

Re-verified updated head 4a8217a7 (fast-forward onto origin/main fa204595, NVIDIA GeForce RTX 5070 Ti, DXC 1.9.2609.5, default XCL_RDNA_FLOAT enabled):

  • gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: 1 passed, 0 failed (0.69 s) — the 0x3F7FFFFF clamp on native Frc fixes the previous NVIDIA failure.
  • gpu::recomp::tests::gpu_fract_f32_edges: 1 passed, 0 failed (0.36 s).
  • gpu::dxil::: 241 passed, 0 failed, 3 ignored (8.10 s, including fuzz_validate_and_gpu_0..3).
  • xcl --lib: 2477 passed, 0 failed, 29 ignored (5 parallel-contention tests re-verified 5/5 with --test-threads=1; 2 known main #3187 uma_driver mixed-window tests skipped).
<!-- greyfinch-sync:ivall/xcl:comment:7251989062 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3269#issuecomment-7251989062). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-11-29T06:39:32Z. --- merge-check base: fa204595 head: 4a8217a7 verdict: safe to merge Re-verified updated head `4a8217a7` (fast-forward onto `origin/main` `fa204595`, NVIDIA GeForce RTX 5070 Ti, DXC 1.9.2609.5, default `XCL_RDNA_FLOAT` enabled): - `gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu`: 1 passed, 0 failed (0.69 s) — the `0x3F7FFFFF` clamp on native `Frc` fixes the previous NVIDIA failure. - `gpu::recomp::tests::gpu_fract_f32_edges`: 1 passed, 0 failed (0.36 s). - `gpu::dxil::`: 241 passed, 0 failed, 3 ignored (8.10 s, including `fuzz_validate_and_gpu_0..3`). - `xcl --lib`: 2477 passed, 0 failed, 29 ignored (5 parallel-contention tests re-verified 5/5 with `--test-threads=1`; 2 known `main` `#3187` `uma_driver` mixed-window tests skipped).
KOLESNiii commented 2026-11-29 19:32:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-29T19:32:43Z.


Test report: cold driver compile time with this stack on an RTX 2070 SUPER (Turing, 8 GB). One run per record, so read it as a direction.

I merged both of Foniass's stacks onto main 0fe06eb0 (#3250 → #3261 → #3263 and this PR's #3266 → #3268 → #3269; they merge without conflicts) and compared that build with main. The numbers are for both stacks together: I did not measure them separately.

Setup

  • RTX 2070 SUPER 8 GB (driver 621.40, 32-lane waves), Ryzen 5 3600XT, Windows 11 26300, release builds, Rust 1.100.1 (merged head 477e2b69).
  • xcl shaders <retail game's shaders.rpf> --measure-pso <record> --repeat 1: the driver's shader caches are turned off (ShaderCacheControl, Developer Mode), so every build is cold. One compile at a time, through a local exclusive queue.

Results (DXIL bytes, cold CreateComputePipelineState s)

record main both stacks both stacks + XCL_HEAP_WINDOWS=1 XCL_HEAP_FLAT=1
95cc13288a27a96e 1,221,312 B, 34.1 s 252,036 B, 6.6 s 228,824 B, 5.6 s
2e1d03fbed9d95eb 1,387,508 B, 33.9 s 948,960 B, 33.1 s 730,648 B, 21.1 s
958400d2caf07244 618,416 B, 14.5 s 260,476 B, 7.2 s 252,436 B, 7.9 s
56c0cd3b82a00c6e 682,480 B, 18.1 s 298,888 B, 10.0 s 286,604 B, 10.2 s
1d4ecf4cb407d4fe 506,032 B, 8.8 s 346,680 B, 8.6 s 278,744 B, 5.0 s
total 109.5 s 65.5 s (−40 %) 49.8 s (−55 %)
  • The biggest gain is on 95cc…, the program #3261 names: 4.8× less DXIL and 5.1× faster to build cold here. 958400d2… and 56c0cd3b…: about half. The plain-form programs (2e1d…, 1d4e…) shrink 27–32 % but build barely faster; heap windows help those instead, so the two are complementary.
  • Every build succeeded on this 8 GB card (no E_OUTOFMEMORY).

Not tested: the stacks separately; the suite and a title run of the merged build (only pipeline builds); whether the image is the same; AMD.

AI use: Claude Code (Claude Opus 5.5) merged and built the stacks, ran the queued job and wrote this report.

Context: why DXIL size matters for cold compilation. On this title, compute programs whose whole DXIL is 512 KiB or larger are 27 % of the 2,730 compute programs but about 95 % of a cold full preparation's compute driver work (driver time weighted as size^1.6, fitted to 1,340 cold compiles on this card). So size reductions count almost only on those programs. Breakdown by size band: https://github.com/xcl-dev/xcl/issues/2088#issuecomment-7262349510

<!-- greyfinch-sync:ivall/xcl:comment:7261363747 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3269#issuecomment-7261363747). Originally posted by [KOLESNiii](https://github.com/KOLESNiii) on 2026-11-29T19:32:43Z. --- **Test report: cold driver compile time with this stack on an RTX 2070 SUPER (Turing, 8 GB).** One run per record, so read it as a direction. I merged both of Foniass's stacks onto `main` 0fe06eb0 (#3250 → #3261 → #3263 and this PR's #3266 → #3268 → #3269; they merge without conflicts) and compared that build with `main`. The numbers are for **both stacks together**: I did not measure them separately. **Setup** - RTX 2070 SUPER 8 GB (driver 621.40, 32-lane waves), Ryzen 5 3600XT, Windows 11 26300, release builds, Rust 1.100.1 (merged head 477e2b69). - `xcl shaders <retail game's shaders.rpf> --measure-pso <record> --repeat 1`: the driver's shader caches are turned off (`ShaderCacheControl`, Developer Mode), so every build is cold. One compile at a time, through a local exclusive queue. **Results** (DXIL bytes, cold `CreateComputePipelineState` s) | record | `main` | both stacks | both stacks + `XCL_HEAP_WINDOWS=1 XCL_HEAP_FLAT=1` | |---|---|---|---| | `95cc13288a27a96e` | 1,221,312 B, 34.1 s | 252,036 B, 6.6 s | 228,824 B, 5.6 s | | `2e1d03fbed9d95eb` | 1,387,508 B, 33.9 s | 948,960 B, 33.1 s | 730,648 B, 21.1 s | | `958400d2caf07244` | 618,416 B, 14.5 s | 260,476 B, 7.2 s | 252,436 B, 7.9 s | | `56c0cd3b82a00c6e` | 682,480 B, 18.1 s | 298,888 B, 10.0 s | 286,604 B, 10.2 s | | `1d4ecf4cb407d4fe` | 506,032 B, 8.8 s | 346,680 B, 8.6 s | 278,744 B, 5.0 s | | **total** | **109.5 s** | **65.5 s (−40 %)** | **49.8 s (−55 %)** | - The biggest gain is on `95cc…`, the program #3261 names: 4.8× less DXIL and 5.1× faster to build cold here. `958400d2…` and `56c0cd3b…`: about half. The plain-form programs (`2e1d…`, `1d4e…`) shrink 27–32 % but build barely faster; heap windows help those instead, so the two are complementary. - Every build succeeded on this 8 GB card (no `E_OUTOFMEMORY`). **Not tested:** the stacks separately; the suite and a title run of the merged build (only pipeline builds); whether the image is the same; AMD. AI use: Claude Code (Claude Opus 5.5) merged and built the stacks, ran the queued job and wrote this report. **Context: why DXIL size matters for cold compilation.** On this title, compute programs whose whole DXIL is 512 KiB or larger are 27 % of the 2,730 compute programs but about 95 % of a cold full preparation's compute driver work (driver time weighted as size^1.6, fitted to 1,340 cold compiles on this card). So size reductions count almost only on those programs. Breakdown by size band: https://github.com/xcl-dev/xcl/issues/2088#issuecomment-7262349510
KOLESNiii commented 2026-11-29 21:42:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-29T21:42:55Z.


Test report: full startup shader preparation, cold cache, with #3442 + the #3263 stack + the #3269 stack together

One run of a build that combines these three PRs. It shows what they do together; it does not say how much each one contributes.

Build: a96b183c, local merge of 4465c886 (main 3b6a91ed + #3318 #3321 #3323 #3325 #3328 #3330 #3332 #3336 #3364 #3377 + #3241 + #3242) with:

cargo build --release -p xcl. Also set: XCL_HEAP_WINDOWS=1 XCL_HEAP_FLAT=1 (stands in for #2428, which does not merge onto this set).

This PR in the build: the whole stack, #3266 a343eafc, #3268 527a8b26, #3269 4a8217a7 (the head is now e01151a2, which differs).

Run: retail game, XCL_PREPARE_ALL=1 (all 26,503 records), XCL_RUN_SECONDS=180 (ends 180 s after the title starts), XCL_ACTIVITY=1. Cold XCL cache: XCL_DXIL_CACHE pointed at a new, empty folder, so no translation, DXC output or driver blob was reused.

Compared with: the same retail game and settings on 4465c886 alone (the base above, without the three PRs and without the heap switches), run earlier today with a warm cache: it started with 48,305 translations, 44,556 DXIL files and 13,051 driver blobs, and reused about half of its driver blobs.

base 4465c886, warm cache + #3442 + #3263 stack + #3269 stack, cold cache
translation + DXC (26,503 records) 1,353 s 1,619 s
driver compute pipelines 10,868 s 3,413 s
graphics pipelines 374 in ~80 s 391 in 100 s
title first presents 12,326 s (3 h 25 min) 5,141 s (1 h 26 min)
driver blobs made 12,304 new (25,355 in cache) 3,277
failed / fallback pipelines, crash 0 / 0 / none 0 / 0 / none
frames in the 180 s of play 5,104 3,818
  • Preparation finished 2.4× sooner even though the base was given the warm cache. Nearly all of the saving is in the driver's compute pipelines (3.2× shorter), the long tail where the very large compute programs are compiled.
  • The run made far fewer distinct driver pipelines (3,277 blobs against 25,355), which fits shorter, more compact programs reaching the driver.
  • Frames in play were 25 % lower (3,818 against 5,104). One 180 s run per side, with different builds, the heap switches on and the game possibly at a different point, so this is not a measured regression, but it needs a matched check (smoke on main and on this PR's head) before anyone reads the preparation result as free.

Not tested / limits

  • Each PR on its own; the share of #3442 against the two stacks is unknown.
  • The commits tested are not all current heads: #3263's head is the one tested; #3442 (now 30122062) and #3269 (now e01151a2, with #3268 now 64f666c0) have changed since, so this report is for the commits listed above.
  • NVIDIA's own shader cache was left on for the cold run (the base run had it on too).
  • One run per side; RTX 2070 SUPER only (wave32). Not tested on AMD.

Hardware: NVIDIA GeForce RTX 2070 SUPER 8 GB (driver 621.40), AMD Ryzen 5 3600XT, 32 GB, Windows 11 Home build 26300, rustc 1.100.1.

Tool and model: Claude Code (Claude Opus 5.5): two sessions on this machine ran the queued runs; this one extracted the numbers from their logs and wrote this report.

<!-- greyfinch-sync:ivall/xcl:comment:7263092641 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3269#issuecomment-7263092641). Originally posted by [KOLESNiii](https://github.com/KOLESNiii) on 2026-11-29T21:42:55Z. --- **Test report: full startup shader preparation, cold cache, with #3442 + the #3263 stack + the #3269 stack together** One run of a build that combines these three PRs. It shows what they do **together**; it does not say how much each one contributes. **Build:** `a96b183c`, local merge of 4465c886 (main 3b6a91ed + #3318 #3321 #3323 #3325 #3328 #3330 #3332 #3336 #3364 #3377 + #3241 + #3242) with: - #3442 as `4511c6e5`; - #3263 stack (#3250 `e13ccd7f`, #3261 `16f2f5c1`, #3263 `e618b742`); - #3269 stack (#3266 `a343eafc`, #3268 `527a8b26`, #3269 `4a8217a7`). `cargo build --release -p xcl`. Also set: `XCL_HEAP_WINDOWS=1 XCL_HEAP_FLAT=1` (stands in for #2428, which does not merge onto this set). **This PR in the build:** the whole stack, #3266 `a343eafc`, #3268 `527a8b26`, #3269 `4a8217a7` (the head is now `e01151a2`, which differs). **Run:** retail game, `XCL_PREPARE_ALL=1` (all 26,503 records), `XCL_RUN_SECONDS=180` (ends 180 s after the title starts), `XCL_ACTIVITY=1`. **Cold XCL cache:** `XCL_DXIL_CACHE` pointed at a new, empty folder, so no translation, DXC output or driver blob was reused. **Compared with:** the same retail game and settings on 4465c886 alone (the base above, without the three PRs and without the heap switches), run earlier today with a **warm** cache: it started with 48,305 translations, 44,556 DXIL files and 13,051 driver blobs, and reused about half of its driver blobs. | | base 4465c886, warm cache | + #3442 + #3263 stack + #3269 stack, **cold** cache | |---|---|---| | translation + DXC (26,503 records) | 1,353 s | 1,619 s | | driver compute pipelines | 10,868 s | **3,413 s** | | graphics pipelines | 374 in ~80 s | 391 in 100 s | | title first presents | 12,326 s (3 h 25 min) | **5,141 s (1 h 26 min)** | | driver blobs made | 12,304 new (25,355 in cache) | 3,277 | | failed / fallback pipelines, crash | 0 / 0 / none | 0 / 0 / none | | frames in the 180 s of play | 5,104 | 3,818 | - Preparation finished **2.4× sooner even though the base was given the warm cache.** Nearly all of the saving is in the driver's compute pipelines (3.2× shorter), the long tail where the very large compute programs are compiled. - The run made far fewer distinct driver pipelines (3,277 blobs against 25,355), which fits shorter, more compact programs reaching the driver. - **Frames in play were 25 % lower** (3,818 against 5,104). One 180 s run per side, with different builds, the heap switches on and the game possibly at a different point, so this is not a measured regression, but it needs a matched check (smoke on main and on this PR's head) before anyone reads the preparation result as free. **Not tested / limits** - Each PR on its own; the share of #3442 against the two stacks is unknown. - The commits tested are not all current heads: #3263's head is the one tested; #3442 (now `30122062`) and #3269 (now `e01151a2`, with #3268 now `64f666c0`) have changed since, so this report is for the commits listed above. - NVIDIA's own shader cache was left on for the cold run (the base run had it on too). - One run per side; RTX 2070 SUPER only (wave32). Not tested on AMD. **Hardware:** NVIDIA GeForce RTX 2070 SUPER 8 GB (driver 621.40), AMD Ryzen 5 3600XT, 32 GB, Windows 11 Home build 26300, rustc 1.100.1. **Tool and model:** Claude Code (Claude Opus 5.5): two sessions on this machine ran the queued runs; this one extracted the numbers from their logs and wrote this report.
KOLESNiii commented 2026-11-29 22:39:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-29T22:39:26Z.

Review: COMMENTED


Static review of e01151a2 for the stack in the #3041 comparison.

Legacy floating-point fast paths can change signed-zero results. One known finite nonzero operand removes both zero checks. For instance, multiplying literal -1.0 by runtime +0.0 can yield -0.0, where the prior legacy lowering returned +0.0. The FMA fast path can similarly bypass returning the exact addend when the runtime operand is zero. Keep the check for any operand that can still be zero. Float fast paths

The scalar alloca pass can also delete an initializing store if its only load uses a trivial pointer PHI. The load is still keyed by the PHI when liveness is counted. Later operand rewriting exposes a load from the now-uninitialized alloca. I found no current shader-lowering caller that constructs this IR pattern. Store elimination

Both findings apply to 4a8217a7 in the measured stack and were checked in e01151a2.

Review assisted by Codex (GPT-6, exact variant unavailable). No new build or GPU run for this review.

<!-- greyfinch-sync:ivall/xcl:review:6105175353 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3269#pullrequestreview-6105175353). Originally posted by [KOLESNiii](https://github.com/KOLESNiii) on 2026-11-29T22:39:26Z. **Review:** COMMENTED --- Static review of `e01151a2` for the stack in the [#3041 comparison](https://github.com/xcl-dev/xcl/issues/3041#issuecomment-7263214809). **Legacy floating-point fast paths can change signed-zero results.** One known finite nonzero operand removes both zero checks. For instance, multiplying literal `-1.0` by runtime `+0.0` can yield `-0.0`, where the prior legacy lowering returned `+0.0`. The FMA fast path can similarly bypass returning the exact addend when the runtime operand is zero. Keep the check for any operand that can still be zero. [Float fast paths](https://github.com/xcl-dev/xcl/blob/e01151a2/crates/xcl/src/gpu/dxil/prelude.rs#L222-L265) The scalar alloca pass can also delete an initializing store if its only load uses a trivial pointer PHI. The load is still keyed by the PHI when liveness is counted. Later operand rewriting exposes a load from the now-uninitialized alloca. I found no current shader-lowering caller that constructs this IR pattern. [Store elimination](https://github.com/xcl-dev/xcl/blob/e01151a2/crates/xcl/src/gpu/dxil/module/opt.rs#L917-L967) Both findings apply to `4a8217a7` in the measured stack and were checked in `e01151a2`. Review assisted by Codex (GPT-6, exact variant unavailable). No new build or GPU run for this review.
jsalzy commented 2026-11-30 03:38:17 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by jsalzy on 2026-11-30T03:38:17Z.


merge-check claim
head: a899ec90b5

<!-- greyfinch-sync:ivall/xcl:comment:7268065405 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3269#issuecomment-7268065405). Originally posted by [jsalzy](https://github.com/jsalzy) on 2026-11-30T03:38:17Z. --- merge-check claim head: a899ec90b55f1c0d9a8f3db853b67be3ba28d647
jsalzy commented 2026-11-30 03:54:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by jsalzy on 2026-11-30T03:54:56Z.


merge-check
base: f97120dc19
head: a899ec90b5
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2843 passed, 1 failed, 51 ignored; SKIPPED: 25 (22 no wave64 on this GPU; 2 no heap windows (opt-in XCL_HEAP_WINDOWS=1); 1 driver cache cannot be disabled without Windows Developer Mode); failing: two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs (gpu_two_pass_cache_e2e.rs:584 "releasing the title PSOs releases their two-pass state", left 1, right 0, in its warm child run; cargo also prints the child's result, so its total reads 2 failed), passes on base this time but is unstable on this machine: the same assertion failed in 4 of 17 suite runs tonight, twice on main alone. Main alone at f97120d: 2841 passed, 0 failed, 51 ignored. The PR's three new tests pass, and so do f32_programs_on_the_gpu (wave32 parts; wave64 skipped) and gpu_fract_f32_edges on this NVIDIA card, the two the first check saw fail on an RTX 5070 Ti at b97cdff.
review: one finding, then the rest reads right. (1) XCL_RDNA_FLOAT (default on) gives mul_legacy and fma_legacy a fast path that returns a plain fmul / fmad as soon as ONE operand is a finite non-zero constant, dropping the == 0 test of the other operand. That test is not redundant: mul_legacy(-2.0, x) with x = +0.0 gives +0.0 on main and -0.0 with the fast path; fma_legacy(2.0, x, -0.0) with x = 0 gives -0.0 on main and +0.0; and a subnormal constant (x != 0.0 in Rust) is taken as non-zero although the GPU flushes it to zero. No test covers a one-constant legacy multiply with a zero operand. #2262 (older, open) changes the same functions but keeps the compare for the unknown operand and excludes subnormals; the two conflict in prelude.rs. (2) The rest, whole diff read: the passes repeat up to 4 times while one still changes the function; scalar-alloca forwarding and dead-store removal only touch non-escaping single-element allocas and stay inside a block; branch facts go only into a block whose single predecessor branches on the condition and stay within its dominator subtree; the entry hoist takes only groupId / threadId / flattenedThreadIdInGroup / createHandleFromBinding with entry-available arguments and leaves heap handles, annotateHandle and getDimensions in their blocks (minor: the doc comments of hoist_entry_readnone still say it hoists createHandleFromHeap / annotateHandle); a barrier is dropped only when an equal or stronger one precedes it in the block with no store, atomic, non-constant load or non-ReadNone call between; CSE's block-local table is cleared after dx.op.discard. f32 compares become single ordered / unordered fcmp (mapping checked: nlt -> UGE, nge -> ULT, nlg -> UEQ, lg -> ONE). #1860 (open) also edits opt.rs's CFG clean-up; not a duplicate.
performance: every pass removes or merges instructions, so the DXIL gets smaller; translation time can rise (up to 4 optimizer rounds per program), not measured here.
verdict: not yet: in the XCL_RDNA_FLOAT fast path of mul_legacy / fma_legacy, take plain fmul / fmad only when both operands are known non-zero normals (or keep the == 0 test of the unknown operand, as #2262 does), and settle the overlap with #2262.
hardware / tool and model: RTX 4070 SUPER 12 GB (621.24 / 32.0.16.2124), Ryzen 7 7800X3D, 32 GB, Windows 11 Pro 25H2 26200.9974, Rust 1.100.0, debug / Claude app (Claude Opus 5.5): merge, build and suite run on this PC with git and cargo only; diff review by Claude Opus 5.5.

<!-- greyfinch-sync:ivall/xcl:comment:7268304865 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3269#issuecomment-7268304865). Originally posted by [jsalzy](https://github.com/jsalzy) on 2026-11-30T03:54:56Z. --- merge-check base: f97120dc196ca05e7f47e919d3675f7d5a2b478a head: a899ec90b55f1c0d9a8f3db853b67be3ba28d647 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2843 passed, 1 failed, 51 ignored; SKIPPED: 25 (22 no wave64 on this GPU; 2 no heap windows (opt-in XCL_HEAP_WINDOWS=1); 1 driver cache cannot be disabled without Windows Developer Mode); failing: two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs (gpu_two_pass_cache_e2e.rs:584 "releasing the title PSOs releases their two-pass state", left 1, right 0, in its warm child run; cargo also prints the child's result, so its total reads 2 failed), passes on base this time but is unstable on this machine: the same assertion failed in 4 of 17 suite runs tonight, twice on main alone. Main alone at f97120d: 2841 passed, 0 failed, 51 ignored. The PR's three new tests pass, and so do f32_programs_on_the_gpu (wave32 parts; wave64 skipped) and gpu_fract_f32_edges on this NVIDIA card, the two the first check saw fail on an RTX 5070 Ti at b97cdff. review: one finding, then the rest reads right. (1) XCL_RDNA_FLOAT (default on) gives mul_legacy and fma_legacy a fast path that returns a plain fmul / fmad as soon as ONE operand is a finite non-zero constant, dropping the == 0 test of the other operand. That test is not redundant: mul_legacy(-2.0, x) with x = +0.0 gives +0.0 on main and -0.0 with the fast path; fma_legacy(2.0, x, -0.0) with x = 0 gives -0.0 on main and +0.0; and a subnormal constant (x != 0.0 in Rust) is taken as non-zero although the GPU flushes it to zero. No test covers a one-constant legacy multiply with a zero operand. #2262 (older, open) changes the same functions but keeps the compare for the unknown operand and excludes subnormals; the two conflict in prelude.rs. (2) The rest, whole diff read: the passes repeat up to 4 times while one still changes the function; scalar-alloca forwarding and dead-store removal only touch non-escaping single-element allocas and stay inside a block; branch facts go only into a block whose single predecessor branches on the condition and stay within its dominator subtree; the entry hoist takes only groupId / threadId / flattenedThreadIdInGroup / createHandleFromBinding with entry-available arguments and leaves heap handles, annotateHandle and getDimensions in their blocks (minor: the doc comments of hoist_entry_readnone still say it hoists createHandleFromHeap / annotateHandle); a barrier is dropped only when an equal or stronger one precedes it in the block with no store, atomic, non-constant load or non-ReadNone call between; CSE's block-local table is cleared after dx.op.discard. f32 compares become single ordered / unordered fcmp (mapping checked: nlt -> UGE, nge -> ULT, nlg -> UEQ, lg -> ONE). #1860 (open) also edits opt.rs's CFG clean-up; not a duplicate. performance: every pass removes or merges instructions, so the DXIL gets smaller; translation time can rise (up to 4 optimizer rounds per program), not measured here. verdict: not yet: in the XCL_RDNA_FLOAT fast path of mul_legacy / fma_legacy, take plain fmul / fmad only when both operands are known non-zero normals (or keep the == 0 test of the unknown operand, as #2262 does), and settle the overlap with #2262. hardware / tool and model: RTX 4070 SUPER 12 GB (621.24 / 32.0.16.2124), Ryzen 7 7800X3D, 32 GB, Windows 11 Pro 25H2 26200.9974, Rust 1.100.0, debug / Claude app (Claude Opus 5.5): merge, build and suite run on this PC with git and cargo only; diff review by Claude Opus 5.5.
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!3269
No description provided.