Recompiler: outline repeated direct-DXIL helpers into internal functions #3654

Closed
Kalmarv wants to merge 1 commit from upstream-pr/3654 into main
Kalmarv commented 2026-12-02 04:02:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T04:02:38Z.


What is in it

Outlines repeated direct-DXIL helper sequences into shared internal LLVM functions with inherited BLOCKINFO function abbreviations, rebased directly onto main (5eaadb54c) on top of #3655's HelperBody representation (+968/-150 across 10 files in crates/xcl/src/gpu/dxil/: +547/-143 production code and +421/-7 unit/DXC-validation tests). This PR is now independent of #3645 (no longer stacked on it).

  • Shared BLOCKINFO function abbreviations and internal helper builders (module.rs, bitreader_tests.rs):
    • Reuses #3655's existing HelperBody / FuncDecl.helper_body representation (no duplicate struct or emission path).
    • Emits BLOCK_BLOCKINFO / BLOCKINFO_CODE_SETBID function-block abbreviations once per module so main and every internal helper inherit the same abbreviations; updates the bitreader test helper to decode inherited BLOCKINFO abbreviations.
    • Adds Op::CallOutput (reads a private alloca slot written by a multi-word helper call) and internal helper builders for heap loads (xcl.sbuf.word, xcl.sbuf.word2, xcl.sbuf.word4, xcl.raw.word4), dynamic format decode (xcl.fmt.decode), legacy multiply (xcl.mul.legacy), word-result fmad (xcl.fmad.words), and carried flat read windows (xcl.read.carry).
  • Lowering integration and opt-out switch (kernel.rs, lower.rs, lower_mem.rs, lower_window.rs, prelude.rs, shader.rs):
    • Routes repeated heap-window scalar buffer loads, wide raw heap loads, dynamic format decodes, v_mul_legacy_f32, non-compute/compute word-result fmad, and carried flat read windows through the shared internal helpers.
    • Leaves fmt_encode, scalar_flat_read, and f16 RNE rounding inline (dropping the overlapping #3650 hunks and xcl.f16.rne — which also resolves the RTX 2070 SUPER gpu_s_round_mode_controls_f16_rounding_across_modes driver failure — as well as the unrelated ballot_ps_quad/waterfall hunks).
    • Adds XCL_DXIL_OUTLINE=0 (kernel::outline_enabled()) to keep all outlined helpers inline and appends xcl-dxil-outline-0 to the translator cache tag.
  • Optimizer and dispatch-splitter accounting (module/opt.rs, module/split.rs):
    • Handles Op::CallOutput in operand traversal/rewriting and DCE, marks ReadNone helper bodies lane_local, and includes all four heap-load helpers (SCALAR_HEAP_WORD, SCALAR_HEAP_PAIR, SCALAR_HEAP_QUAD, RAW_HEAP_QUAD) in both DCE removable and the flagged raw-load preservation guard.
    • Updates infer_piece_features to infer Feature::ResourceHeapIndexing for all four heap-load helpers and updates dispatch_block_cost to charge every f.helper_body against piece instruction budgets.
  • Tests (module.rs, module/opt.rs, module/split.rs, lower_mem.rs, bitreader_tests.rs):
    • Adds unit and DXC-validation tests covering BLOCKINFO abbreviation inheritance, xcl.fmad.words, xcl.read.carry, xcl.mul.legacy, xcl.fmt.decode, xcl.sbuf.word* / xcl.raw.word4, SCALAR_HEAP_WORD DCE + flag preservation, split-piece feature inference and helper-body budget accounting, and XCL_DXIL_OUTLINE=0 inline opt-out.
  • Why this is kept as one PR: The non-test diff is +547/-143 (with +421/-7 in tests). The BLOCKINFO abbreviations, Op::CallOutput / helper builders, lowering call sites, DCE/split accounting, and XCL_DXIL_OUTLINE=0 opt-out form one cohesive outlining change.

Tested

  • Hardware & toolchain: NVIDIA GeForce RTX 5070 Ti (driver 610.74), AMD Ryzen 9 9950X 16-Core, Windows 11 Pro 26200, rustc 1.99.0 (b940084d7 2026-09-28), DXC 1.9.2609.5 (debug + release).
  • cargo build --release -p xcl: clean (39 warnings; 0 new warnings vs main 5eaadb54c).
  • scripts/test.ps1 (cargo build --workspace, cargo bench -p xcl --bench '*' -- --test, cargo test --workspace -- --test-threads=4, with XCL_DXC_DIR set to DXC 1.9.2609.5): 2988 passed, 0 failed, 52 ignored across all 43 test targets (24 SKIPPED GPU tests on this adapter: 22 no wave64, 2 no heap windows; 0 DXC skips).
  • gpu::recomp::tests::gpu_s_round_mode_controls_f16_rounding_across_modes, scalar_heap_word_is_dce_removable_and_preserves_raw_load_flag, piece_budget_counts_every_outlined_helper_body, piece_feature_inference_marks_resource_heap_indexing_for_all_heap_load_helpers, and dxil_outline_opt_out_keeps_helpers_inline all passed with DXC 1.9.2609.5.

Regression run

Regression check only (both runs warm on the same title after an initial cache-warming run for the PR head, since changing crates/xcl/src/gpu/dxil/*.rs and emitted bitcode bytes busts the translated and driver shader caches on the first cold run, which recorded 1004 frames with 0 removals / 0 crashes). No frame-rate or memory speedup is claimed from the smoke delta.

Baseline (main):

xcl-smoke v1
commit: 5eaadb54c14e0fc29597b2a1689d7dbd83491303
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1640 (PresentX 1640)
presents per 2 s (last 3): 60 61 62
device removals: 0
crashes: 0
peak commit: 17384 MB

PR head (warm):

xcl-smoke v1
commit: 29440ec740c65458b9421a107d78aac9a1a8cdbd
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1694 (PresentX 1694)
presents per 2 s (last 3): 61 61 60
device removals: 0
crashes: 0
peak commit: 15177 MB

Not tested

  • AMD and Intel GPUs/drivers (including native wave64 hardware paths; 22 wave64 GPU tests skipped on RTX 5070 Ti).
  • Direct re-verification on RTX 2070 SUPER / driver 621.01 (though xcl.f16.rne has been removed and gpu_s_round_mode_controls_f16_rounding_across_modes passes on RTX 5070 Ti).
  • Opt-in XCL_HEAP_WINDOWS=1 GPU tests (2 skipped under default scripts/test.ps1).
  • Offline corpus bitcode-size and compile-time benchmarks were not re-measured on this rebased commit 29440ec74.

AI use

  • Codex (GPT-6) wrote the initial direct-DXIL helper-outlining changes.
  • Antigravity (Gemini 4 Neon) rebased the change directly onto main (5eaadb54c) atop #3655's HelperBody, dropped the #3650-overlapping and unrelated hunks (including xcl.f16.rne), addressed the opt.rs / split.rs / XCL_DXIL_OUTLINE=0 review findings and added unit/DXC-validation tests, ran cargo build --release -p xcl, scripts/test.ps1, and the 60 s smoke pair, and drafted this description.
<!-- greyfinch-sync:ivall/xcl:issue:5599581878 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3654). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T04:02:38Z. --- **What is in it** Outlines repeated direct-DXIL helper sequences into shared internal LLVM functions with inherited `BLOCKINFO` function abbreviations, rebased directly onto `main` (`5eaadb54c`) on top of `#3655`'s `HelperBody` representation (`+968/-150` across 10 files in `crates/xcl/src/gpu/dxil/`: `+547/-143` production code and `+421/-7` unit/DXC-validation tests). This PR is now independent of `#3645` (no longer stacked on it). - **Shared `BLOCKINFO` function abbreviations and internal helper builders (`module.rs`, `bitreader_tests.rs`):** - Reuses `#3655`'s existing `HelperBody` / `FuncDecl.helper_body` representation (no duplicate struct or emission path). - Emits `BLOCK_BLOCKINFO` / `BLOCKINFO_CODE_SETBID` function-block abbreviations once per module so `main` and every internal helper inherit the same abbreviations; updates the bitreader test helper to decode inherited `BLOCKINFO` abbreviations. - Adds `Op::CallOutput` (reads a private `alloca` slot written by a multi-word helper call) and internal helper builders for heap loads (`xcl.sbuf.word`, `xcl.sbuf.word2`, `xcl.sbuf.word4`, `xcl.raw.word4`), dynamic format decode (`xcl.fmt.decode`), legacy multiply (`xcl.mul.legacy`), word-result `fmad` (`xcl.fmad.words`), and carried flat read windows (`xcl.read.carry`). - **Lowering integration and opt-out switch (`kernel.rs`, `lower.rs`, `lower_mem.rs`, `lower_window.rs`, `prelude.rs`, `shader.rs`):** - Routes repeated heap-window scalar buffer loads, wide raw heap loads, dynamic format decodes, `v_mul_legacy_f32`, non-compute/compute word-result `fmad`, and carried flat read windows through the shared internal helpers. - Leaves `fmt_encode`, `scalar_flat_read`, and `f16` RNE rounding inline (dropping the overlapping `#3650` hunks and `xcl.f16.rne` — which also resolves the RTX 2070 SUPER `gpu_s_round_mode_controls_f16_rounding_across_modes` driver failure — as well as the unrelated `ballot_ps_quad`/`waterfall` hunks). - Adds `XCL_DXIL_OUTLINE=0` (`kernel::outline_enabled()`) to keep all outlined helpers inline and appends `xcl-dxil-outline-0` to the translator cache tag. - **Optimizer and dispatch-splitter accounting (`module/opt.rs`, `module/split.rs`):** - Handles `Op::CallOutput` in operand traversal/rewriting and DCE, marks `ReadNone` helper bodies `lane_local`, and includes all four heap-load helpers (`SCALAR_HEAP_WORD`, `SCALAR_HEAP_PAIR`, `SCALAR_HEAP_QUAD`, `RAW_HEAP_QUAD`) in both DCE `removable` and the `flagged` raw-load preservation guard. - Updates `infer_piece_features` to infer `Feature::ResourceHeapIndexing` for all four heap-load helpers and updates `dispatch_block_cost` to charge every `f.helper_body` against piece instruction budgets. - **Tests (`module.rs`, `module/opt.rs`, `module/split.rs`, `lower_mem.rs`, `bitreader_tests.rs`):** - Adds unit and DXC-validation tests covering `BLOCKINFO` abbreviation inheritance, `xcl.fmad.words`, `xcl.read.carry`, `xcl.mul.legacy`, `xcl.fmt.decode`, `xcl.sbuf.word*` / `xcl.raw.word4`, `SCALAR_HEAP_WORD` DCE + flag preservation, split-piece feature inference and helper-body budget accounting, and `XCL_DXIL_OUTLINE=0` inline opt-out. - **Why this is kept as one PR:** The non-test diff is `+547/-143` (with `+421/-7` in tests). The `BLOCKINFO` abbreviations, `Op::CallOutput` / helper builders, lowering call sites, DCE/split accounting, and `XCL_DXIL_OUTLINE=0` opt-out form one cohesive outlining change. **Tested** - Hardware & toolchain: NVIDIA GeForce RTX 5070 Ti (driver 610.74), AMD Ryzen 9 9950X 16-Core, Windows 11 Pro 26200, `rustc 1.99.0 (b940084d7 2026-09-28)`, DXC `1.9.2609.5` (debug + release). - `cargo build --release -p xcl`: clean (39 warnings; 0 new warnings vs `main` `5eaadb54c`). - `scripts/test.ps1` (`cargo build --workspace`, `cargo bench -p xcl --bench '*' -- --test`, `cargo test --workspace -- --test-threads=4`, with `XCL_DXC_DIR` set to DXC `1.9.2609.5`): **2988 passed, 0 failed, 52 ignored** across all 43 test targets (24 `SKIPPED` GPU tests on this adapter: 22 `no wave64`, 2 `no heap windows`; 0 DXC skips). - `gpu::recomp::tests::gpu_s_round_mode_controls_f16_rounding_across_modes`, `scalar_heap_word_is_dce_removable_and_preserves_raw_load_flag`, `piece_budget_counts_every_outlined_helper_body`, `piece_feature_inference_marks_resource_heap_indexing_for_all_heap_load_helpers`, and `dxil_outline_opt_out_keeps_helpers_inline` all passed with DXC `1.9.2609.5`. **Regression run** Regression check only (both runs warm on the same title after an initial cache-warming run for the PR head, since changing `crates/xcl/src/gpu/dxil/*.rs` and emitted bitcode bytes busts the translated and driver shader caches on the first cold run, which recorded 1004 frames with 0 removals / 0 crashes). No frame-rate or memory speedup is claimed from the smoke delta. Baseline (`main`): ``` xcl-smoke v1 commit: 5eaadb54c14e0fc29597b2a1689d7dbd83491303 gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 60 exit: 0x0 frames shown: 1640 (PresentX 1640) presents per 2 s (last 3): 60 61 62 device removals: 0 crashes: 0 peak commit: 17384 MB ``` PR head (warm): ``` xcl-smoke v1 commit: 29440ec740c65458b9421a107d78aac9a1a8cdbd gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 60 exit: 0x0 frames shown: 1694 (PresentX 1694) presents per 2 s (last 3): 61 61 60 device removals: 0 crashes: 0 peak commit: 15177 MB ``` **Not tested** - AMD and Intel GPUs/drivers (including native wave64 hardware paths; 22 wave64 GPU tests skipped on RTX 5070 Ti). - Direct re-verification on RTX 2070 SUPER / driver 621.01 (though `xcl.f16.rne` has been removed and `gpu_s_round_mode_controls_f16_rounding_across_modes` passes on RTX 5070 Ti). - Opt-in `XCL_HEAP_WINDOWS=1` GPU tests (2 skipped under default `scripts/test.ps1`). - Offline corpus bitcode-size and compile-time benchmarks were not re-measured on this rebased commit `29440ec74`. **AI use** - Codex (`GPT-6`) wrote the initial direct-DXIL helper-outlining changes. - Antigravity (`Gemini 4 Neon`) rebased the change directly onto `main` (`5eaadb54c`) atop `#3655`'s `HelperBody`, dropped the `#3650`-overlapping and unrelated hunks (including `xcl.f16.rne`), addressed the `opt.rs` / `split.rs` / `XCL_DXIL_OUTLINE=0` review findings and added unit/DXC-validation tests, ran `cargo build --release -p xcl`, `scripts/test.ps1`, and the 60 s smoke pair, and drafted this description.
Foniass commented 2026-12-02 08:45:19 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T08:45:19Z.


Review (head 03d8adeb, diff read, not a merge-check):

  • Too big, and it overlaps two other open PRs. This PR's own commit is +992/-180 on top of #3645. That is over the ~800-line limit, and the description does not say why it cannot be split. Part of it is the same code as other PRs. The HelperBody setup in module.rs (~96, ~1430, ~1595, plus the Value::Func work-list in liveness) is nearly line for line the same as #3655's commit b995046b6, down to the comment "The entry is declared when the Shader is created, before any helper". The xcl.f16.rne body (module.rs ~845) is the same RNE sequence that #3650 puts inline in f32_to_f16_rne. #3650 also reworks the dynamic fmt_pack/fmt_encode path and the carried flat-read window, as this PR does with xcl.fmt.encode and xcl.read.carry. Suggested split: (1) the helper infrastructure as one PR that both this and #3655 stack on, (2) the arithmetic helpers, (3) the heap-load helpers, (4) the format helpers. Each should leave out what #3650 already covers.
  • Unrelated changes are bundled in. These change no outlining: the PS quad compare now masks by the EXEC word (lower_valu.rs ~1345, lanes.rs ~879), scalar liveness in waterfall.rs ~166/~330 is now computed lazily, and f32_to_f16_rne swaps the old f32_to_f16_rm(f, 0) for a different algorithm (lower_wide.rs ~708). By reading, the quad change and the new RNE sequence look equivalent to the old code, but each belongs in its own PR.
  • Split budget misses two helpers. dispatch_block_cost (module/split.rs ~608) adds body sizes for xcl.sbuf.word, xcl.fmt.encode and xcl.read.carry only. xcl.f16.rne (21-instruction body; the old inline conversion was about 60) and xcl.mul.legacy (8) are not gated to whole entries, so split compute uses them too. Each call counts as one instruction. A piece heavy in v_cvt_f16_f32 or v_mul_legacy_f32 can then be several times over XCL_DIRECT_SPLIT_INSTRUCTIONS once the driver inlines the helper. This contradicts the description's claim that split boundaries stay within budget, and the test (~768) covers only xcl.sbuf.word.
  • Riskiest for drivers, and on by default. Non-inlined define internal functions with arguments in non-library cs/ps DXIL are something DXC never emits. Here they include createHandleFromHeap/annotateHandle plus pointer out-arguments to entry allocas (xcl.sbuf.word2/4, xcl.raw.word4, lower_mem.rs ~1289-1360). The evidence is the DXC validator and NVIDIA only. The maintainer's batch runs on AMD RDNA4, whose compiler this codebase already notes as sensitive (opt.rs ~730, shader.rs llvm.ident). There is no switch to turn outlining off. Please add an AMD run or an opt-out. Also, the smoke run shows 12% fewer frames than main (1215 vs 1387, still over the 80% gate), which the description does not explain.
  • Merge hazard with #3664. This PR widens the DCE raw-load guard flagged (opt.rs ~1473) to the heap-load helpers. #3664 moves that block into eliminate_dead. Whichever lands second must keep the helper names there, or a shader whose only raw loads are dead helper calls loses the load but keeps RawAndStructuredBuffers.

Fine: function records mark helpers internal and non-proto. Bodies follow the entry in declaration order, as the LLVM 3.7 reader expects. BLOCKINFO abbreviations are defined before any local ones, so their IDs match. CallOutput keeps the call live and is neither CSE'd nor forwarded. Live types skip entry-only lookups for helper-local operands. Feature scans and uses_fmad know the helper names. The helpers in this PR contain no wave, quad, derivative or barrier ops, so convergence and helper-lane behaviour inside them is unchanged.

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

<!-- greyfinch-sync:ivall/xcl:comment:7339882618 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3654#issuecomment-7339882618). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T08:45:19Z. --- Review (head 03d8adeb, diff read, not a merge-check): - **Too big, and it overlaps two other open PRs.** This PR's own commit is +992/-180 on top of #3645. That is over the ~800-line limit, and the description does not say why it cannot be split. Part of it is the same code as other PRs. The `HelperBody` setup in `module.rs` (~96, ~1430, ~1595, plus the `Value::Func` work-list in liveness) is nearly line for line the same as #3655's commit b995046b6, down to the comment "The entry is declared when the Shader is created, before any helper". The `xcl.f16.rne` body (`module.rs` ~845) is the same RNE sequence that #3650 puts inline in `f32_to_f16_rne`. #3650 also reworks the dynamic `fmt_pack`/`fmt_encode` path and the carried flat-read window, as this PR does with `xcl.fmt.encode` and `xcl.read.carry`. Suggested split: (1) the helper infrastructure as one PR that both this and #3655 stack on, (2) the arithmetic helpers, (3) the heap-load helpers, (4) the format helpers. Each should leave out what #3650 already covers. - **Unrelated changes are bundled in.** These change no outlining: the PS quad compare now masks by the EXEC word (`lower_valu.rs` ~1345, `lanes.rs` ~879), scalar liveness in `waterfall.rs` ~166/~330 is now computed lazily, and `f32_to_f16_rne` swaps the old `f32_to_f16_rm(f, 0)` for a different algorithm (`lower_wide.rs` ~708). By reading, the quad change and the new RNE sequence look equivalent to the old code, but each belongs in its own PR. - **Split budget misses two helpers.** `dispatch_block_cost` (`module/split.rs` ~608) adds body sizes for `xcl.sbuf.word`, `xcl.fmt.encode` and `xcl.read.carry` only. `xcl.f16.rne` (21-instruction body; the old inline conversion was about 60) and `xcl.mul.legacy` (8) are not gated to whole entries, so split compute uses them too. Each call counts as one instruction. A piece heavy in `v_cvt_f16_f32` or `v_mul_legacy_f32` can then be several times over `XCL_DIRECT_SPLIT_INSTRUCTIONS` once the driver inlines the helper. This contradicts the description's claim that split boundaries stay within budget, and the test (~768) covers only `xcl.sbuf.word`. - **Riskiest for drivers, and on by default.** Non-inlined `define internal` functions with arguments in non-library cs/ps DXIL are something DXC never emits. Here they include `createHandleFromHeap`/`annotateHandle` plus pointer out-arguments to entry `alloca`s (`xcl.sbuf.word2/4`, `xcl.raw.word4`, `lower_mem.rs` ~1289-1360). The evidence is the DXC validator and NVIDIA only. The maintainer's batch runs on AMD RDNA4, whose compiler this codebase already notes as sensitive (`opt.rs` ~730, `shader.rs` llvm.ident). There is no switch to turn outlining off. Please add an AMD run or an opt-out. Also, the smoke run shows 12% fewer frames than main (1215 vs 1387, still over the 80% gate), which the description does not explain. - **Merge hazard with #3664.** This PR widens the DCE raw-load guard `flagged` (`opt.rs` ~1473) to the heap-load helpers. #3664 moves that block into `eliminate_dead`. Whichever lands second must keep the helper names there, or a shader whose only raw loads are dead helper calls loses the load but keeps `RawAndStructuredBuffers`. Fine: function records mark helpers internal and non-proto. Bodies follow the entry in declaration order, as the LLVM 3.7 reader expects. BLOCKINFO abbreviations are defined before any local ones, so their IDs match. `CallOutput` keeps the call live and is neither CSE'd nor forwarded. Live types skip entry-only lookups for helper-local operands. Feature scans and `uses_fmad` know the helper names. The helpers in this PR contain no wave, quad, derivative or barrier ops, so convergence and helper-lane behaviour inside them is unchanged. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Decodere commented 2026-12-02 08:56:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Decodere on 2026-12-02T08:56:50Z.


Diff review (head 03d8adeb8, read-only code review — not a test report):

Clean BLOCKINFO shared-abbreviation encoding (crates/xcl/src/gpu/dxil/module.rs:1572-1581), solid CallOutput non-CSE/non-forwarding design (opt.rs:523, :1555), and Value::Func work-list propagation for helper liveness (module.rs:1633-1666). Reading the full diff (+1677/-334 across 17 files) turned up 3 concrete issues worth addressing before merge:

  1. SCALAR_HEAP_WORD (xcl.sbuf.word) is omitted from opt.rs removable and the flagged raw-load guard (crates/xcl/src/gpu/dxil/module/opt.rs:526-534, :1473; crates/xcl/src/gpu/dxil/module.rs:81, :633-644):
    finish_heap_load marks 1-word scalar loads FnAttrs::ReadOnly (module.rs:637-638), whereas multi-word loads (width > 1) use FnAttrs::NoUnwind (module.rs:641). In removable (opt.rs:528-533), helper calls are only removable when d.attrs == FnAttrs::ReadNone or d.name matches SCALAR_HEAP_PAIR | SCALAR_HEAP_QUAD | RAW_HEAP_QUAD, and the ReadOnly fallback requires a "dx.op." prefix — so dead xcl.sbuf.word calls are never dead-code eliminated. flagged (opt.rs:1473) similarly omits SCALAR_HEAP_WORD. Adding SCALAR_HEAP_WORD to both removable and flagged enables DCE of dead 1-word outlined loads while still preserving RawAndStructuredBuffers validity when every raw load is dead.

  2. split.rs feature inference and piece-budget accounting miss several outlined helpers (crates/xcl/src/gpu/dxil/module/split.rs:298-309, :608-624):

    • split.rs:301-302 checks only SCALAR_HEAP_WORD for Feature::ResourceHeapIndexing, omitting SCALAR_HEAP_PAIR, SCALAR_HEAP_QUAD, and RAW_HEAP_QUAD (implicitly relying on whole_entry_loads preventing them in split pieces).
    • dispatch_block_cost (split.rs:608-624) adds helper body instruction counts only for SCALAR_HEAP_WORD, FORMAT_ENCODER, and CARRIED_READ_WINDOW, omitting xcl.f16.rne (module.rs:845, 21 instructions) and xcl.mul.legacy (module.rs:811-812, 8 instructions), both of which are emitted in split compute shaders (lower_wide.rs:709-710, prelude.rs:233). Pieces heavy in half-conversion or legacy multiply count each call as 1 instruction instead of the inlined body size.
  3. Stacking, overlap with #3645 / #3650 / #3655, and default-ON driver risk:

    • Commit bc4792159 (+685/-154) embeds open PR #3645 verbatim; commit 03d8adeb8 (+992/-180) also duplicates #3650's RNE half-conversion logic as xcl.f16.rne (module.rs:845), introduces a competing struct HelperBody (module.rs:96-101) that conflicts with #3655, and bundles unrelated ballot_ps_quad EXEC masking (lower_valu.rs:1345, lanes.rs:879) and lazy scalar_live_in (waterfall.rs:166, :330).
    • Rebasing after #3645 and #3650, splitting shared HelperBody infrastructure (shared with #3655) from the individual outlining passes, and adding an opt-out or AMD validation for default-ON define internal helpers with alloca out-pointers will keep review and bisecting clean.

AI use: Antigravity (Gemini 4 Neon) audited the full diff against main and drafted this review.

<!-- greyfinch-sync:ivall/xcl:comment:7340146999 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3654#issuecomment-7340146999). Originally posted by [Decodere](https://github.com/Decodere) on 2026-12-02T08:56:50Z. --- Diff review (head `03d8adeb8`, read-only code review — not a test report): Clean `BLOCKINFO` shared-abbreviation encoding (`crates/xcl/src/gpu/dxil/module.rs:1572-1581`), solid `CallOutput` non-CSE/non-forwarding design (`opt.rs:523`, `:1555`), and `Value::Func` work-list propagation for helper liveness (`module.rs:1633-1666`). Reading the full diff (`+1677/-334` across 17 files) turned up 3 concrete issues worth addressing before merge: 1. **`SCALAR_HEAP_WORD` (`xcl.sbuf.word`) is omitted from `opt.rs` `removable` and the `flagged` raw-load guard** (`crates/xcl/src/gpu/dxil/module/opt.rs:526-534`, `:1473`; `crates/xcl/src/gpu/dxil/module.rs:81`, `:633-644`): `finish_heap_load` marks 1-word scalar loads `FnAttrs::ReadOnly` (`module.rs:637-638`), whereas multi-word loads (`width > 1`) use `FnAttrs::NoUnwind` (`module.rs:641`). In `removable` (`opt.rs:528-533`), helper calls are only removable when `d.attrs == FnAttrs::ReadNone` or `d.name` matches `SCALAR_HEAP_PAIR | SCALAR_HEAP_QUAD | RAW_HEAP_QUAD`, and the `ReadOnly` fallback requires a `"dx.op."` prefix — so dead `xcl.sbuf.word` calls are never dead-code eliminated. `flagged` (`opt.rs:1473`) similarly omits `SCALAR_HEAP_WORD`. Adding `SCALAR_HEAP_WORD` to both `removable` and `flagged` enables DCE of dead 1-word outlined loads while still preserving `RawAndStructuredBuffers` validity when every raw load is dead. 2. **`split.rs` feature inference and piece-budget accounting miss several outlined helpers** (`crates/xcl/src/gpu/dxil/module/split.rs:298-309`, `:608-624`): - `split.rs:301-302` checks only `SCALAR_HEAP_WORD` for `Feature::ResourceHeapIndexing`, omitting `SCALAR_HEAP_PAIR`, `SCALAR_HEAP_QUAD`, and `RAW_HEAP_QUAD` (implicitly relying on `whole_entry_loads` preventing them in split pieces). - `dispatch_block_cost` (`split.rs:608-624`) adds helper body instruction counts only for `SCALAR_HEAP_WORD`, `FORMAT_ENCODER`, and `CARRIED_READ_WINDOW`, omitting `xcl.f16.rne` (`module.rs:845`, 21 instructions) and `xcl.mul.legacy` (`module.rs:811-812`, 8 instructions), both of which are emitted in split compute shaders (`lower_wide.rs:709-710`, `prelude.rs:233`). Pieces heavy in half-conversion or legacy multiply count each call as 1 instruction instead of the inlined body size. 3. **Stacking, overlap with `#3645` / `#3650` / `#3655`, and default-ON driver risk**: - Commit `bc4792159` (`+685/-154`) embeds open PR `#3645` verbatim; commit `03d8adeb8` (`+992/-180`) also duplicates `#3650`'s RNE half-conversion logic as `xcl.f16.rne` (`module.rs:845`), introduces a competing `struct HelperBody` (`module.rs:96-101`) that conflicts with `#3655`, and bundles unrelated `ballot_ps_quad` EXEC masking (`lower_valu.rs:1345`, `lanes.rs:879`) and lazy `scalar_live_in` (`waterfall.rs:166`, `:330`). - Rebasing after `#3645` and `#3650`, splitting shared `HelperBody` infrastructure (shared with `#3655`) from the individual outlining passes, and adding an opt-out or AMD validation for default-ON `define internal` helpers with `alloca` out-pointers will keep review and bisecting clean. AI use: Antigravity (Gemini 4 Neon) audited the full diff against `main` and drafted this review.
Foniass commented 2026-12-02 10:57:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T10:57:56Z.


merge-check
base: 1c8b551475
head: 03d8adeb89
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2930 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/3654#issuecomment-7339882618 and its findings stand. Most serious: its own commit is +992/-180 with no split, the split budget misses two new helpers, and outlining is on by default with no AMD run.
performance: 60 s smoke of a retail title, main 1c8b5514 vs this merge (03d8adeb): 1652 -> 1434 frames shown (86 %; last presents per 2 s: 60 60 60), peak commit 18228 -> 16099 MB, 0 device removals, 0 crashes. This run is lower than most today: the PC was in use at the time (a browser and Discord running), and main's own runs on this machine today ranged from 1370 to 1652 frames, so the difference isn't clearly from this PR.
verdict: not yet: its own commit is +992/-180 with no split, the split budget misses two new helpers, and outlining is on by default with no AMD run (see the review)
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:7343232629 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3654#issuecomment-7343232629). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T10:57:56Z. --- merge-check base: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f head: 03d8adeb89ab1492a718ff3bc07f3bf86355cbd3 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2930 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/3654#issuecomment-7339882618 and its findings stand. Most serious: its own commit is +992/-180 with no split, the split budget misses two new helpers, and outlining is on by default with no AMD run. performance: 60 s smoke of a retail title, main 1c8b5514 vs this merge (03d8adeb): 1652 -> 1434 frames shown (86 %; last presents per 2 s: 60 60 60), peak commit 18228 -> 16099 MB, 0 device removals, 0 crashes. This run is lower than most today: the PC was in use at the time (a browser and Discord running), and main's own runs on this machine today ranged from 1370 to 1652 frames, so the difference isn't clearly from this PR. verdict: not yet: its own commit is +992/-180 with no split, the split budget misses two new helpers, and outlining is on by default with no AMD run (see the review) 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.
Royalflamejlh commented 2026-12-02 14:33:19 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T14:33:19Z.


With this PR in, main's gpu_s_round_mode_controls_f16_rounding_across_modes fails on native Windows with an NVIDIA card: RTX 2070 SUPER 8 GB (driver 621.01), Windows 11 26200, debug, 1 run each. v_mul_f16 under round-toward-zero gets the result of the v_pk_mul_f16 high half next to it (0xFBFF where 0x7BFF is expected).

This was found on our integration branch, which carries this PR at 44e1860a, not on main plus this PR alone. A first-parent bisect there passes at the commit before the merge (11d46940) and fails at the merge.

The translated module looks right: disassembled, each xcl.f16.rne call takes its own product. With the f32→f16 round-to-nearest-even inline again (as #3650 writes it) and the other helpers still outlined, the test passes on the same PC. So it looks like the driver mixing up two calls of the outlined helper. That is a guess from the symptom, not shown.

Not tested: main + this PR alone; AMD; other NVIDIA drivers.

AI use: Claude Code (Claude Opus 5.5) ran the bisect and wrote this comment.

<!-- greyfinch-sync:ivall/xcl:comment:7348744947 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3654#issuecomment-7348744947). Originally posted by [Royalflamejlh](https://github.com/Royalflamejlh) on 2026-12-02T14:33:19Z. --- With this PR in, `main`'s `gpu_s_round_mode_controls_f16_rounding_across_modes` fails on native Windows with an NVIDIA card: RTX 2070 SUPER 8 GB (driver 621.01), Windows 11 26200, debug, 1 run each. `v_mul_f16` under round-toward-zero gets the result of the `v_pk_mul_f16` high half next to it (`0xFBFF` where `0x7BFF` is expected). This was found on our integration branch, which carries this PR at `44e1860a`, not on `main` plus this PR alone. A first-parent bisect there passes at the commit before the merge (`11d46940`) and fails at the merge. The translated module looks right: disassembled, each `xcl.f16.rne` call takes its own product. With the f32→f16 round-to-nearest-even inline again (as #3650 writes it) and the other helpers still outlined, the test passes on the same PC. So it looks like the driver mixing up two calls of the outlined helper. That is a guess from the symptom, not shown. Not tested: `main` + this PR alone; AMD; other NVIDIA drivers. AI use: Claude Code (Claude Opus 5.5) ran the bisect and wrote this comment.
Kalmarv commented 2026-12-02 15:46:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T15:46:56Z.


Rebased #3654 directly onto main (5eaadb54c) as 29440ec74 (no longer stacked on #3645, and reusing #3655's HelperBody directly) and addressed all points from @Foniass, @Decodere, and @Royalflamejlh:

  • Dropped overlapping and unrelated hunks (+2437/-482 across 15 files -> +968/-150 across 10 files; +547/-143 production, +421/-7 tests):
    • Dropped xcl.f16.rne, fmt_encode, and scalar_flat_read edits so there is no overlap with #3650 (instead shared_scalar_words temporarily binds uma_base_val to the helper's base argument).
    • Dropping xcl.f16.rne also addresses @Royalflamejlh's RTX 2070 SUPER report on gpu_s_round_mode_controls_f16_rounding_across_modes, which passes in scripts/test.ps1 here (not yet re-verified on RTX 2070 SUPER / driver 621.01).
    • Dropped the unrelated ballot_ps_quad / waterfall hunks (core_tests.rs, lanes.rs, lower_valu.rs, lower_wide.rs, waterfall.rs now have zero diff).
  • opt.rs DCE & raw-load flag guard (@Foniass): Added SCALAR_HEAP_WORD alongside SCALAR_HEAP_PAIR, SCALAR_HEAP_QUAD, and RAW_HEAP_QUAD in both removable and flagged, covered by scalar_heap_word_is_dce_removable_and_preserves_raw_load_flag (validated with DXC 1.9.2609.5).
  • split.rs feature inference & piece budgets (@Foniass): Updated infer_piece_features to infer Feature::ResourceHeapIndexing for all four heap-load helpers and updated dispatch_block_cost to charge every f.helper_body (including #3655's helpers and xcl.mul.legacy) against piece budgets, covered by piece_feature_inference_marks_resource_heap_indexing_for_all_heap_load_helpers and piece_budget_counts_every_outlined_helper_body.
  • Opt-out switch (@Decodere): Added XCL_DXIL_OUTLINE=0 (kernel::outline_enabled(), cache tag xcl-dxil-outline-0) to keep all outlined helpers inline, covered by dxil_outline_opt_out_keeps_helpers_inline.
  • Verification on 29440ec74 (RTX 5070 Ti, driver 610.74, DXC 1.9.2609.5):
    • cargo build --release -p xcl: clean, 39 warnings (0 new vs main 5eaadb54c).
    • scripts/test.ps1: 2988 passed, 0 failed, 52 ignored across 43 test targets (24 SKIPPED GPU tests: 22 no wave64, 2 no heap windows; 0 DXC skips; gpu_s_round_mode_controls_f16_rounding_across_modes passed; cargo bench -p xcl --bench '*' -- --test passed).
    • 60 s scripts/smoke.ps1 regression check (title: ea3b5e4d): main 5eaadb54c 1640 frames (0 removals, 0 crashes, 17384 MB peak commit) vs 29440ec74 warm 1694 frames (0 removals, 0 crashes, 15177 MB peak commit; initial cold-cache compile run was 1004 frames, 0 removals, 0 crashes). Updated the PR description with both xcl-smoke v1 blocks and regression-only framing (AMD/Intel and RTX 2070 SUPER still untested).

(Updated by Antigravity, Gemini 4 Neon, building on Codex, GPT-6's initial changes.)

<!-- greyfinch-sync:ivall/xcl:comment:7350908567 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3654#issuecomment-7350908567). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T15:46:56Z. --- Rebased `#3654` directly onto `main` (`5eaadb54c`) as `29440ec74` (no longer stacked on `#3645`, and reusing `#3655`'s `HelperBody` directly) and addressed all points from `@Foniass`, `@Decodere`, and `@Royalflamejlh`: - **Dropped overlapping and unrelated hunks (`+2437/-482` across 15 files -> `+968/-150` across 10 files; `+547/-143` production, `+421/-7` tests):** - Dropped `xcl.f16.rne`, `fmt_encode`, and `scalar_flat_read` edits so there is no overlap with `#3650` (instead `shared_scalar_words` temporarily binds `uma_base_val` to the helper's `base` argument). - Dropping `xcl.f16.rne` also addresses `@Royalflamejlh`'s RTX 2070 SUPER report on `gpu_s_round_mode_controls_f16_rounding_across_modes`, which passes in `scripts/test.ps1` here (not yet re-verified on RTX 2070 SUPER / driver 621.01). - Dropped the unrelated `ballot_ps_quad` / `waterfall` hunks (`core_tests.rs`, `lanes.rs`, `lower_valu.rs`, `lower_wide.rs`, `waterfall.rs` now have zero diff). - **`opt.rs` DCE & raw-load flag guard (`@Foniass`):** Added `SCALAR_HEAP_WORD` alongside `SCALAR_HEAP_PAIR`, `SCALAR_HEAP_QUAD`, and `RAW_HEAP_QUAD` in both `removable` and `flagged`, covered by `scalar_heap_word_is_dce_removable_and_preserves_raw_load_flag` (validated with DXC `1.9.2609.5`). - **`split.rs` feature inference & piece budgets (`@Foniass`):** Updated `infer_piece_features` to infer `Feature::ResourceHeapIndexing` for all four heap-load helpers and updated `dispatch_block_cost` to charge every `f.helper_body` (including `#3655`'s helpers and `xcl.mul.legacy`) against piece budgets, covered by `piece_feature_inference_marks_resource_heap_indexing_for_all_heap_load_helpers` and `piece_budget_counts_every_outlined_helper_body`. - **Opt-out switch (`@Decodere`):** Added `XCL_DXIL_OUTLINE=0` (`kernel::outline_enabled()`, cache tag `xcl-dxil-outline-0`) to keep all outlined helpers inline, covered by `dxil_outline_opt_out_keeps_helpers_inline`. - **Verification on `29440ec74` (RTX 5070 Ti, driver 610.74, DXC `1.9.2609.5`):** - `cargo build --release -p xcl`: clean, 39 warnings (0 new vs `main` `5eaadb54c`). - `scripts/test.ps1`: **2988 passed, 0 failed, 52 ignored** across 43 test targets (24 `SKIPPED` GPU tests: 22 `no wave64`, 2 `no heap windows`; 0 DXC skips; `gpu_s_round_mode_controls_f16_rounding_across_modes` passed; `cargo bench -p xcl --bench '*' -- --test` passed). - 60 s `scripts/smoke.ps1` regression check (`title: ea3b5e4d`): `main` `5eaadb54c` 1640 frames (0 removals, 0 crashes, 17384 MB peak commit) vs `29440ec74` warm 1694 frames (0 removals, 0 crashes, 15177 MB peak commit; initial cold-cache compile run was 1004 frames, 0 removals, 0 crashes). Updated the PR description with both `xcl-smoke v1` blocks and regression-only framing (AMD/Intel and RTX 2070 SUPER still untested). *(Updated by Antigravity, Gemini 4 Neon, building on Codex, GPT-6's initial changes.)*
Kalmarv commented 2026-12-02 16:26:57 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T16:26:57Z.


Moving to Draft until we verify compatibility with AMD (amdxc64.dll, #3694) and Linux vkd3d-proton (dxil-spirv, #3707).

In #3707, @lucsoft found that dxil-spirv aborts (std::terminate()) on internal DXIL functions that take pointer parameters (Cannot reliably convert LLVM pointer type), and #3694 shows AMD's Windows compiler crashing (0xc0000409 / 0x887A0005) on #3655's internal @xcl.spin.wait / @xcl.barrier.arrive helpers. This PR's xcl.sbuf.word2, xcl.sbuf.word4, and xcl.raw.word4 helpers currently pass private alloca i32* output pointers and emit internal DXIL functions as well, so it should not merge until we test whether value-only internal helpers (without pointer parameters) are accepted by both amdxc64.dll and dxil-spirv — or drop internal functions if not.

AI use: Antigravity (Gemini 4 Neon) cross-checked #3654 against #3694 and #3707 and drafted this note.

<!-- greyfinch-sync:ivall/xcl:comment:7351962230 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3654#issuecomment-7351962230). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T16:26:57Z. --- Moving to Draft until we verify compatibility with AMD (`amdxc64.dll`, #3694) and Linux `vkd3d-proton` (`dxil-spirv`, #3707). In #3707, @lucsoft found that `dxil-spirv` aborts (`std::terminate()`) on internal DXIL functions that take pointer parameters (`Cannot reliably convert LLVM pointer type`), and #3694 shows AMD's Windows compiler crashing (`0xc0000409` / `0x887A0005`) on #3655's internal `@xcl.spin.wait` / `@xcl.barrier.arrive` helpers. This PR's `xcl.sbuf.word2`, `xcl.sbuf.word4`, and `xcl.raw.word4` helpers currently pass private `alloca` `i32*` output pointers and emit internal DXIL functions as well, so it should not merge until we test whether value-only internal helpers (without pointer parameters) are accepted by both `amdxc64.dll` and `dxil-spirv` — or drop internal functions if not. AI use: Antigravity (Gemini 4 Neon) cross-checked #3654 against #3694 and #3707 and drafted this note.
Foniass commented 2026-12-03 03:43:12 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T03:43:12Z.


merge-check
base: 078358a058
head: 29440ec740
merge: clean
build: ok
tests: 3020 passed, 0 failed, 52 ignored; 28 skipped, the same as on main
review: 1 high, 4 medium (below)
performance: 60 s smoke run: 1669 → 1538 frames (92 % of main), peak commit 17577 → 15608 MB, no device removal, no crash
title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 24 s there, 0 device removals, 0 crashes, 9.2 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: 1 blocking finding (critical or high, below)
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: Moves repeated direct-DXIL sequences (heap scalar/raw loads, format decode, v_mul_legacy, word fmad, carried read window) into internal DXIL functions with shared BLOCKINFO abbreviations; on by default, with an XCL_DXIL_OUTLINE=0 opt-out. It now reuses #3655's HelperBody, drops the overlaps with #3650 and the unrelated hunks, and counts every helper in the split budget. It is blocked because it adds internal functions with pointer parameters on the default path, the construct #3707 removes because dxil-spirv aborts on it; it also conflicts with #3707 in code and in intent.

High

  1. Internal functions with pointer parameters, on by default. xcl.sbuf.word2, xcl.sbuf.word4 and xcl.raw.word4 take i32* output pointers (module.rs finish_heap_load ~728), and every outlined helper is a define internal function in a non-library shader, which DXC never emits. #3707 shows that vkd3d-proton's dxil-spirv calls std::terminate on a pointer-typed function parameter. #3694, with Chrysana's run on #3707, shows AMD's compiler crashing on #3655's helper functions until they are inlined. Only an RTX 5070 Ti was tested. Make outlining opt-in (XCL_DXIL_OUTLINE=1) until there are AMD and Wine runs, or drop the helpers that take pointers.

Medium

  1. Conflicts with #3707. git merge-tree shows a textual conflict in module.rs, and #3707's inline_helpers writes every helper_body back into the entry when the bitcode is written, which would undo all of this PR's outlining (and has to handle Op::CallOutput's call operand). Agree with #3707's author which approach lands.
  2. Size over the limit. One commit of +968/-150 (~1,118 lines). The description gives a reason (one cohesive change), but it splits cleanly: the BLOCKINFO, CallOutput and helper builders; the arithmetic helpers (mul.legacy, fmad.words); the heap-load helpers; then the format decoder and read.carry.
  3. No AMD measurement for a default-on change. Every f32 fmad in VS/PS/MS becomes a call to xcl.fmad.words (lower.rs ~752), and every v_mul_legacy_f32 a call to xcl.mul.legacy (prelude.rs ~233), with no minimum count. Frame time on RDNA, where the maintainer's batch runs, is unmeasured.
  4. Merge hazard with #3664 still open. #3664 (open) moves the raw-load guard into eliminate_dead, and this PR extends flagged (opt.rs ~1478) to the four heap-load helpers. Whichever lands second must keep the helper names there; otherwise a shader whose only raw loads are dead helper calls loses the load that keeps its RawAndStructuredBuffers flag valid.
Checked and fine
  • Earlier finding fixed: the HelperBody setup is no longer duplicated from #3655 (it reuses FuncDecl.helper_body), and xcl.f16.rne, fmt_encode and the quad/waterfall/RNE hunks are gone
  • Earlier finding fixed: dispatch_block_cost counts every helper_body (split.rs ~727), and a test covers xcl.sbuf.word plus xcl.mul.legacy
  • Earlier finding fixed: XCL_DXIL_OUTLINE=0 keeps every helper inline and is part of the translator cache tag (kernel.rs ~113-136)
  • CallOutput operands are visited and rewritten, CallOutput is neither CSE'd nor forwarded, and the output allocas escape, so opt_local_allocas leaves them alone (opt.rs ~889)
  • Multi-word helpers are only used in whole-entry programs (whole_entry_loads), and the body builders swap uma_base_val and refuse rodata, so no entry value leaks into a helper body
How this was tested
  • Merged onto main 078358a0, 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 078358a0 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:7366862479 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3654#issuecomment-7366862479). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T03:43:12Z. --- merge-check base: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a head: 29440ec740c65458b9421a107d78aac9a1a8cdbd merge: clean build: ok tests: 3020 passed, 0 failed, 52 ignored; 28 skipped, the same as on main review: 1 high, 4 medium (below) performance: 60 s smoke run: 1669 → 1538 frames (92 % of main), peak commit 17577 → 15608 MB, no device removal, no crash title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 24 s there, 0 device removals, 0 crashes, 9.2 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: 1 blocking finding (critical or high, below) 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:** Moves repeated direct-DXIL sequences (heap scalar/raw loads, format decode, v_mul_legacy, word fmad, carried read window) into internal DXIL functions with shared BLOCKINFO abbreviations; on by default, with an XCL_DXIL_OUTLINE=0 opt-out. It now reuses #3655's HelperBody, drops the overlaps with #3650 and the unrelated hunks, and counts every helper in the split budget. It is blocked because it adds internal functions with pointer parameters on the default path, the construct #3707 removes because dxil-spirv aborts on it; it also conflicts with #3707 in code and in intent. #### High 1. **Internal functions with pointer parameters, on by default.** xcl.sbuf.word2, xcl.sbuf.word4 and xcl.raw.word4 take i32* output pointers (module.rs finish_heap_load ~728), and every outlined helper is a define internal function in a non-library shader, which DXC never emits. #3707 shows that vkd3d-proton's dxil-spirv calls std::terminate on a pointer-typed function parameter. #3694, with Chrysana's run on #3707, shows AMD's compiler crashing on #3655's helper functions until they are inlined. Only an RTX 5070 Ti was tested. Make outlining opt-in (XCL_DXIL_OUTLINE=1) until there are AMD and Wine runs, or drop the helpers that take pointers. #### Medium 2. **Conflicts with #3707.** git merge-tree shows a textual conflict in module.rs, and #3707's inline_helpers writes every helper_body back into the entry when the bitcode is written, which would undo all of this PR's outlining (and has to handle Op::CallOutput's call operand). Agree with #3707's author which approach lands. 3. **Size over the limit.** One commit of +968/-150 (~1,118 lines). The description gives a reason (one cohesive change), but it splits cleanly: the BLOCKINFO, CallOutput and helper builders; the arithmetic helpers (mul.legacy, fmad.words); the heap-load helpers; then the format decoder and read.carry. 4. **No AMD measurement for a default-on change.** Every f32 fmad in VS/PS/MS becomes a call to xcl.fmad.words (lower.rs ~752), and every v_mul_legacy_f32 a call to xcl.mul.legacy (prelude.rs ~233), with no minimum count. Frame time on RDNA, where the maintainer's batch runs, is unmeasured. 5. **Merge hazard with #3664 still open.** #3664 (open) moves the raw-load guard into eliminate_dead, and this PR extends flagged (opt.rs ~1478) to the four heap-load helpers. Whichever lands second must keep the helper names there; otherwise a shader whose only raw loads are dead helper calls loses the load that keeps its RawAndStructuredBuffers flag valid. <details><summary>Checked and fine</summary> - Earlier finding fixed: the HelperBody setup is no longer duplicated from #3655 (it reuses FuncDecl.helper_body), and xcl.f16.rne, fmt_encode and the quad/waterfall/RNE hunks are gone - Earlier finding fixed: dispatch_block_cost counts every helper_body (split.rs ~727), and a test covers xcl.sbuf.word plus xcl.mul.legacy - Earlier finding fixed: XCL_DXIL_OUTLINE=0 keeps every helper inline and is part of the translator cache tag (kernel.rs ~113-136) - CallOutput operands are visited and rewritten, CallOutput is neither CSE'd nor forwarded, and the output allocas escape, so opt_local_allocas leaves them alone (opt.rs ~889) - Multi-word helpers are only used in whole-entry programs (whole_entry_loads), and the body builders swap uma_base_val and refuse rodata, so no entry value leaks into a helper body </details> <details><summary>How this was tested</summary> - Merged onto main `078358a0`, 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 `078358a0` 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>
Kalmarv commented 2026-12-03 13:01:13 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-03T13:01:13Z.


Closing this PR as superseded by #3707 (a815de932), which established the single-function non-library DXIL invariant via Module::inline_helpers() for AMD amdxc64.dll (#3694) and Linux vkd3d-proton (dxil-spirv) compatibility.

Emitting internal DXIL helper functions (including pointer out-parameters) into non-library shaders conflicts with that invariant, while running inline_helpers() erases the outlined functions. Thanks to @Foniass, @Decodere, @Royalflamejlh, and @lucsoft for the reviews and cross-driver testing.

<!-- greyfinch-sync:ivall/xcl:comment:7379192117 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3654#issuecomment-7379192117). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-03T13:01:13Z. --- Closing this PR as superseded by #3707 (`a815de932`), which established the single-function non-library DXIL invariant via `Module::inline_helpers()` for AMD `amdxc64.dll` (#3694) and Linux `vkd3d-proton` (`dxil-spirv`) compatibility. Emitting internal DXIL helper functions (including pointer out-parameters) into non-library shaders conflicts with that invariant, while running `inline_helpers()` erases the outlined functions. Thanks to `@Foniass`, `@Decodere`, `@Royalflamejlh`, and `@lucsoft` for the reviews and cross-driver testing.

Pull request closed

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!3654
No description provided.