Recompiler: enforce LOOP_BUDGET at loop headers in per-lane lowering #2759

Open
Saksukella wants to merge 3 commits from upstream-pr/2769 into main
Saksukella commented 2026-11-26 11:33:33 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Saksukella on 2026-11-26T11:33:33Z.


Enforce LOOP_BUDGET at loop headers in the per-lane SSA lowering backend (XCL_PER_LANE=1), charging weighted loop_cost per header visit and keeping per-region budgets for kernel programs while keeping a single program-wide Var::Budget per lane for compute and graphics shaders. Exhausted lanes branch straight from the loop header to exit, matching direct-DXIL semantics and preventing runaway shaders from triggering Windows TDR (0x887a0006).

What is in it

  • crates/xcl/src/gpu/recomp/ssa.rs: add Var::Budget, Var::BudgetOwner, and Var::BudgetTotal.
  • crates/xcl/src/gpu/recomp/lower_dxil.rs: map Var::Budget, Var::BudgetOwner, and Var::BudgetTotal to i32 in DxilIr::ty() and handle them in DxilIr::escape().
  • crates/xcl/src/gpu/recomp/lower.rs: detect loop headers from reverse-postorder, split each loop header into a budget-check entry and continuation block, deduct weighted loop_cost (1 per 128 bytes of innermost loop code, clamped to 1..=256), apply per-region budgets (LOOP_BUDGET * 2 per region, LOOP_BUDGET * 4 total) for kernel programs only (keeping compute/graphics on a single program-wide budget to avoid the AMD compiler crash in #2874), and add regression tests (infinite_loop_exits_at_loop_budget, nested_loops_share_loop_budget_across_headers, long_loop_spends_its_code_size_per_header_visit, kernel_loop_after_a_full_spin_keeps_its_own_budget).

Tested

  • Hardware: AMD Radeon RX 9070 XT (driver 32.0.32029.2010), AMD Ryzen 9 7900X, 32 GB RAM, Windows 11 Pro (build 26200), rustc 1.100.0 (0ef1bc386 2026-11-09); debug (tests) and release (xcl.exe).
  • cargo test --lib -p xcl recomp::lower -- --test-threads=4: 64 passed, 0 failed, 0 ignored (2.49s), including infinite_loop_exits_at_loop_budget, nested_loops_share_loop_budget_across_headers, long_loop_spends_its_code_size_per_header_visit, and kernel_loop_after_a_full_spin_keeps_its_own_budget.
  • SKIPPED GPU sub-cases on this adapter: f16_programs_on_the_gpu (V_MUL_F16 / V_PK_MUL_F16 refused by per-lane form) and f32_programs_on_the_gpu (V_CVT_F16_F32 refused by per-lane form).
  • cargo check --workspace: passed.

Regression run

xcl-smoke v1
commit: 227d2cb388f103268dac7635ea720eb3e5352d4e
gpu: AMD Radeon RX 9070 XT
title: b8db18c2
seconds: 60
exit: 0x0
frames shown: 1674 (PresentX 1674)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17279 MB
xcl-smoke v1
commit: a68bf237e5d02a72df1f1311b40897c1aa432c57
gpu: AMD Radeon RX 9070 XT
title: b8db18c2
seconds: 60
exit: 0x0
frames shown: 1687 (PresentX 1687)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 18139 MB

Not tested

  • NVIDIA and Intel GPU adapters (tested on AMD Radeon RX 9070 XT only).
  • Full cargo test --workspace run (targeted recomp::lower suite + cargo check --workspace + 60s TitleID 7952987A smoke run were executed).

AI use

  • Assisted with code review feedback alignment, regression test authoring, and rebase verification; all diffs, tests, and hardware smoke runs were verified locally.
<!-- greyfinch-sync:ivall/xcl:issue:5509273440 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2769). Originally posted by [Saksukella](https://github.com/Saksukella) on 2026-11-26T11:33:33Z. --- Enforce `LOOP_BUDGET` at loop headers in the per-lane SSA lowering backend (`XCL_PER_LANE=1`), charging weighted `loop_cost` per header visit and keeping per-region budgets for kernel programs while keeping a single program-wide `Var::Budget` per lane for compute and graphics shaders. Exhausted lanes branch straight from the loop header to `exit`, matching direct-DXIL semantics and preventing runaway shaders from triggering Windows TDR (`0x887a0006`). **What is in it** - `crates/xcl/src/gpu/recomp/ssa.rs`: add `Var::Budget`, `Var::BudgetOwner`, and `Var::BudgetTotal`. - `crates/xcl/src/gpu/recomp/lower_dxil.rs`: map `Var::Budget`, `Var::BudgetOwner`, and `Var::BudgetTotal` to `i32` in `DxilIr::ty()` and handle them in `DxilIr::escape()`. - `crates/xcl/src/gpu/recomp/lower.rs`: detect loop headers from reverse-postorder, split each loop header into a budget-check entry and continuation block, deduct weighted `loop_cost` (`1` per `128` bytes of innermost loop code, clamped to `1..=256`), apply per-region budgets (`LOOP_BUDGET * 2` per region, `LOOP_BUDGET * 4` total) for kernel programs only (keeping compute/graphics on a single program-wide budget to avoid the AMD compiler crash in #2874), and add regression tests (`infinite_loop_exits_at_loop_budget`, `nested_loops_share_loop_budget_across_headers`, `long_loop_spends_its_code_size_per_header_visit`, `kernel_loop_after_a_full_spin_keeps_its_own_budget`). **Tested** - Hardware: AMD Radeon RX 9070 XT (driver `32.0.32029.2010`), AMD Ryzen 9 7900X, 32 GB RAM, Windows 11 Pro (build `26200`), `rustc 1.100.0 (0ef1bc386 2026-11-09)`; debug (tests) and release (`xcl.exe`). - `cargo test --lib -p xcl recomp::lower -- --test-threads=4`: 64 passed, 0 failed, 0 ignored (`2.49s`), including `infinite_loop_exits_at_loop_budget`, `nested_loops_share_loop_budget_across_headers`, `long_loop_spends_its_code_size_per_header_visit`, and `kernel_loop_after_a_full_spin_keeps_its_own_budget`. - `SKIPPED` GPU sub-cases on this adapter: `f16_programs_on_the_gpu` (`V_MUL_F16` / `V_PK_MUL_F16` refused by per-lane form) and `f32_programs_on_the_gpu` (`V_CVT_F16_F32` refused by per-lane form). - `cargo check --workspace`: passed. **Regression run** ``` xcl-smoke v1 commit: 227d2cb388f103268dac7635ea720eb3e5352d4e gpu: AMD Radeon RX 9070 XT title: b8db18c2 seconds: 60 exit: 0x0 frames shown: 1674 (PresentX 1674) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 17279 MB ``` ``` xcl-smoke v1 commit: a68bf237e5d02a72df1f1311b40897c1aa432c57 gpu: AMD Radeon RX 9070 XT title: b8db18c2 seconds: 60 exit: 0x0 frames shown: 1687 (PresentX 1687) presents per 2 s (last 3): 60 61 60 device removals: 0 crashes: 0 peak commit: 18139 MB ``` **Not tested** - NVIDIA and Intel GPU adapters (tested on AMD Radeon RX 9070 XT only). - Full `cargo test --workspace` run (targeted `recomp::lower` suite + `cargo check --workspace` + 60s `TitleID 7952987A` smoke run were executed). **AI use** - Assisted with code review feedback alignment, regression test authoring, and rebase verification; all diffs, tests, and hardware smoke runs were verified locally.
oni-swr commented 2026-11-26 12:07:00 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by oni-swr on 2026-11-26T11:47:42Z.


Independent amd-win test report (claim: https://github.com/xcl-dev/xcl/issues/1607#issuecomment-7190975352)

Tested: head 4dcc796b9d82220a3655494250bbdd4e00fcc560 (unchanged since claim; no other reports) vs. base b5c0275f (merge-base on amd-dev).
Hardware: RX 7800 XT, Ryzen 7 5700X3D, Windows 11 Pro 10.0.26200, debug build, stable-x86_64-pc-windows-msvc. Not release, not a retail title.

Commands (CARGO_TARGET_DIR separate, -j 4):

  • cargo test -p xcl --lib -j 4 -- --test-threads=4 --skip placed_title_textures_share_vram_and_preserve_pixels
  • each failing test again alone with --test-threads=1, on head and on base
  • cargo test -p xcl --lib -j 4 -- --test-threads=1 recomp::

Results

  • Head, full lib: 1533 passed, 11 failed, 27 ignored, 1 filtered (the skipped test).
  • New test gpu::recomp::lower::tests::infinite_loop_exits_at_loop_budget: passes.
  • Head recomp:: alone: 416 passed, 2 failed, 20 ignored (failures: f32_programs_on_the_gpu, a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier).
  • placed_title_textures_share_vram_and_preserve_pixels alone on head: passes.
  • Base, full lib: the parallel run aborted with STATUS_STACK_BUFFER_OVERRUN (known amd-dev behaviour, here in a different test than on head), so I have no clean full-run count for base. Instead I ran each of the 11 head failures alone on both commits.

Attribution (alone, --test-threads=1): the same 10 tests fail on base and on head: fuzz_validate_and_gpu_1 (#2115), dispatch_chain_native_wave64_builds_whole, a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier, f32_programs_on_the_gpu, a_dispatch_with_a_pipeline_still_building_waits_at_the_submit, a_put_off_dispatch_runs_at_the_submit_when_its_build_outlasts_the_wait_budget, bitset_runs_emit_exact_contiguous_page_ranges, giant_driver_compiles_have_their_own_lane, title_bytes_are_used_in_place_when_all_are_readable, physical_home_without_sparse_windows_uses_coherent_window. The 11th, two_pass_binds_set_the_shared_view_heap, fails only in the parallel run and passes alone on both. So no failure I found is caused by this PR. I did not investigate the root causes of the pre-existing ones.

SKIPPED: 4 lines, all f16_programs_on_the_gpu (f16 arithmetic and packed, wave32/wave64, per-lane form refused: V_MUL_F16 / V_PK_MUL_F16, #1426). These are not coverage.

Diff review: read the 3-file diff; no concrete defect found. The LOOP_BUDGET cap is exercised only by the CPU-interpreter test, so the GPU (DXIL) path of the new loop-header block is covered only by the existing per-lane GPU tests, which do not include a loop that hits the budget. I did not run a retail title or scripts/smoke.ps1.

AI use: Claude Code (Claude Sonnet 5.5), coordinated by Claude Code (Claude Opus 5.5). Results are from real runs on the hardware above.

<!-- greyfinch-sync:ivall/xcl:comment:7191174859 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2769#issuecomment-7191174859). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-26T11:47:42Z. --- Independent amd-win test report (claim: https://github.com/xcl-dev/xcl/issues/1607#issuecomment-7190975352) **Tested:** head `4dcc796b9d82220a3655494250bbdd4e00fcc560` (unchanged since claim; no other reports) vs. base `b5c0275f` (merge-base on `amd-dev`). **Hardware:** RX 7800 XT, Ryzen 7 5700X3D, Windows 11 Pro 10.0.26200, debug build, stable-x86_64-pc-windows-msvc. Not release, not a retail title. **Commands** (`CARGO_TARGET_DIR` separate, `-j 4`): - `cargo test -p xcl --lib -j 4 -- --test-threads=4 --skip placed_title_textures_share_vram_and_preserve_pixels` - each failing test again alone with `--test-threads=1`, on head and on base - `cargo test -p xcl --lib -j 4 -- --test-threads=1 recomp::` **Results** - Head, full lib: 1533 passed, 11 failed, 27 ignored, 1 filtered (the skipped test). - New test `gpu::recomp::lower::tests::infinite_loop_exits_at_loop_budget`: passes. - Head `recomp::` alone: 416 passed, 2 failed, 20 ignored (failures: `f32_programs_on_the_gpu`, `a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier`). - `placed_title_textures_share_vram_and_preserve_pixels` alone on head: passes. - Base, full lib: the parallel run aborted with STATUS_STACK_BUFFER_OVERRUN (known amd-dev behaviour, here in a different test than on head), so I have **no clean full-run count for base**. Instead I ran each of the 11 head failures alone on both commits. **Attribution (alone, `--test-threads=1`):** the same 10 tests fail on base and on head: `fuzz_validate_and_gpu_1` (#2115), `dispatch_chain_native_wave64_builds_whole`, `a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier`, `f32_programs_on_the_gpu`, `a_dispatch_with_a_pipeline_still_building_waits_at_the_submit`, `a_put_off_dispatch_runs_at_the_submit_when_its_build_outlasts_the_wait_budget`, `bitset_runs_emit_exact_contiguous_page_ranges`, `giant_driver_compiles_have_their_own_lane`, `title_bytes_are_used_in_place_when_all_are_readable`, `physical_home_without_sparse_windows_uses_coherent_window`. The 11th, `two_pass_binds_set_the_shared_view_heap`, fails only in the parallel run and passes alone on both. So no failure I found is caused by this PR. I did not investigate the root causes of the pre-existing ones. **SKIPPED:** 4 lines, all `f16_programs_on_the_gpu` (f16 arithmetic and packed, wave32/wave64, per-lane form refused: V_MUL_F16 / V_PK_MUL_F16, #1426). These are not coverage. **Diff review:** read the 3-file diff; no concrete defect found. The `LOOP_BUDGET` cap is exercised only by the CPU-interpreter test, so the GPU (DXIL) path of the new loop-header block is covered only by the existing per-lane GPU tests, which do not include a loop that hits the budget. I did not run a retail title or `scripts/smoke.ps1`. **AI use:** Claude Code (Claude Sonnet 5.5), coordinated by Claude Code (Claude Opus 5.5). Results are from real runs on the hardware above.
gut0to commented 2026-11-26 15:45:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by gut0to on 2026-11-26T15:45:29Z.

Review: COMMENTED


AI-assisted review (OpenAI GPT-6). I checked the SSA budget flow against the other lowering backends; I did not run tests or the game.

<!-- greyfinch-sync:ivall/xcl:review:6076983256 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2769#pullrequestreview-6076983256). Originally posted by [gut0to](https://github.com/gut0to) on 2026-11-26T15:45:29Z. **Review:** COMMENTED --- AI-assisted review (OpenAI GPT-6). I checked the SSA budget flow against the other lowering backends; I did not run tests or the game.
gut0to commented 2026-11-26 16:06:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by gut0to on 2026-11-26T15:45:29Z.

Code review location: crates/xcl/src/gpu/recomp/lower.rs; line 4644

@@ -4579,4 +4639,21 @@ pub(crate) mod tests {
         }
         check_mem(true);
     }
+
+    #[test]
+    fn infinite_loop_exits_at_loop_budget() {

Var::Budget is initialized at entry and then consumed at every detected loop header, matching the shared xcl_budget in the other backends. This regression covers only one self-loop, so it does not pin SSA propagation through nested headers. Could you add a nested-loop case that shows the inner loop consumes the same per-lane budget and the total work remains bounded, rather than accidentally reinitializing at an inner header? AI-assisted review (OpenAI GPT-6); I checked the new lowering against the shared-budget paths in emit.rs and dxil/kernel.rs, but did not run tests or the game.

<!-- greyfinch-sync:ivall/xcl:review-comment:4710631808 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2769#discussion_r4710631808). Originally posted by [gut0to](https://github.com/gut0to) on 2026-11-26T15:45:29Z. **Code review location:** `crates/xcl/src/gpu/recomp/lower.rs`; line 4644 ~~~~diff @@ -4579,4 +4639,21 @@ pub(crate) mod tests { } check_mem(true); } + + #[test] + fn infinite_loop_exits_at_loop_budget() { ~~~~ --- `Var::Budget` is initialized at entry and then consumed at every detected loop header, matching the shared `xcl_budget` in the other backends. This regression covers only one self-loop, so it does not pin SSA propagation through nested headers. Could you add a nested-loop case that shows the inner loop consumes the same per-lane budget and the total work remains bounded, rather than accidentally reinitializing at an inner header? AI-assisted review (OpenAI GPT-6); I checked the new lowering against the shared-budget paths in `emit.rs` and `dxil/kernel.rs`, but did not run tests or the game.
Saksukella commented 2026-11-26 18:06:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Saksukella on 2026-11-26T18:06:44Z.


Added nested_loops_share_loop_budget_across_headers in 9a6d83c1 right beside infinite_loop_exits_at_loop_budget: an infinite outer loop wrapping a K = 3 inner loop asserts that both headers decrement the same entry-initialized Var::Budget (s[0] + s[2] == LOOP_BUDGET and per-lane v[0][1] == expected_inner) without reinitializing at the inner header. Verified with gpu::recomp::lower::tests (38 passed; 0 failed) and a fresh 60s RX 9070 XT smoke (1,650 frames, 60 60 60, 0 crashes, 0 device removals, 15,548 MB peak commit).

<!-- greyfinch-sync:ivall/xcl:comment:7200066348 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2769#issuecomment-7200066348). Originally posted by [Saksukella](https://github.com/Saksukella) on 2026-11-26T18:06:44Z. --- Added `nested_loops_share_loop_budget_across_headers` in `9a6d83c1` right beside `infinite_loop_exits_at_loop_budget`: an infinite outer loop wrapping a `K = 3` inner loop asserts that both headers decrement the same entry-initialized `Var::Budget` (`s[0] + s[2] == LOOP_BUDGET` and per-lane `v[0][1] == expected_inner`) without reinitializing at the inner header. Verified with `gpu::recomp::lower::tests` (`38 passed; 0 failed`) and a fresh 60s RX 9070 XT smoke (`1,650` frames, `60 60 60`, `0` crashes, `0` device removals, `15,548 MB` peak commit).
vibryxcx commented 2026-11-27 02:21:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by vibryxcx on 2026-11-27T02:21:36Z.


Tested on the current amd-dev and reviewed against it. The tests are fine, but the parity in the description no longer holds: since 00fe5ae the other backends spend the budget by loop cost and by region in compute, and this per-lane version spends 1 per header from one program-wide budget.

Tested: RX 6800 (RDNA2, driver 32.0.21045.5002), Windows 11 Pro 26200, Rust 1.100.0, debug. This head 9a6d83c1 sits on b5c0275f. It merges onto amd-dev bf7c82ee with no conflict, so I tested that merge against bf7c82ee, cargo test -p xcl --lib -- gpu::recomp:: --test-threads=1:

  • bf7c82ee: 430 passed, 2 failed, 20 ignored.
  • merge: 432 passed, 2 failed, 20 ignored. The only difference is the two new tests (infinite_loop_exits_at_loop_budget, nested_loops_share_loop_budget_across_headers), both ok. The 2 failures are the same on both (a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier, f32_programs_on_the_gpu).
  • SKIPPED: f16_programs_on_the_gpu only (4 lines, #1426), on both.

Review

  1. Parity with the other backends on amd-dev. 00fe5ae ("bound long shader loops and keep mesh budgets simple") changed the HLSL path (recomp/mod.rs) and direct DXIL (dxil/kernel.rs, dxil/compact.rs) in two ways:

    • each iteration spends loop_cost (an 80-instruction loop runs half the iterations, gpu_an_endless_long_loop_stops_after_the_budget_by_its_cost);
    • compute and kernel programs keep per-region budgets (budget_regions, from #2793 / #2865).

    This PR's per-lane lowering spends 1 per loop-header visit from a single Var::Budget for the whole program. Under XCL_PER_LANE=1, then:

    • a long endless loop can run twice as many iterations as on the other paths;
    • a compute spin-wait that runs out the budget leaves nothing for a later loop. That is the case #2793 fixed (gpu_a_loop_after_a_spin_to_the_budget_still_runs); a per-lane counterpart of that test would show it.

    This may be deliberate. On RDNA2, per-region budgets in compute are what crash the AMD shader compiler on a retail title (#2874), so one budget is the safer shape for the driver. If so, saying it in the description (or porting only loop_cost) would make the difference intended rather than accidental.

  2. Exit from a loop header. An exhausted lane branches from the header straight to exit and skips the rest of the program, stores included. That matches what the HLSL and DXIL paths do. exit_stale now checks staleness only on the ends tails, not on the header-to-exit edges. So a register that is defined only after a loop header and read at exit will not be reported stale on the budget path. That seems acceptable for a runaway lane, but nothing tests it.

  3. Scope at runtime. All of this is under XCL_PER_LANE=1, which is off by default (pso.rs keys those entries as xcl-per-lane-…). A default title run does not reach it, so I did not run the title for this PR.

Not tested: XCL_PER_LANE=1 on a retail title (this card loses the device on bf7c82ee within minutes anyway, #2874); this head on its own base; NVIDIA.

AI use: Claude Code (Claude Opus 5.5) read the diff and 00fe5ae, ran the tests on base and merge, and wrote this comment.

<!-- greyfinch-sync:ivall/xcl:comment:7208053878 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2769#issuecomment-7208053878). Originally posted by [vibryxcx](https://github.com/vibryxcx) on 2026-11-27T02:21:36Z. --- Tested on the current `amd-dev` and reviewed against it. The tests are fine, but **the parity in the description no longer holds**: since `00fe5ae` the other backends spend the budget by loop cost and by region in compute, and this per-lane version spends 1 per header from one program-wide budget. **Tested:** RX 6800 (RDNA2, driver 32.0.21045.5002), Windows 11 Pro 26200, Rust 1.100.0, debug. This head `9a6d83c1` sits on `b5c0275f`. It merges onto `amd-dev` `bf7c82ee` with no conflict, so I tested that merge against `bf7c82ee`, `cargo test -p xcl --lib -- gpu::recomp:: --test-threads=1`: - `bf7c82ee`: 430 passed, 2 failed, 20 ignored. - merge: **432 passed**, 2 failed, 20 ignored. The only difference is the two new tests (`infinite_loop_exits_at_loop_budget`, `nested_loops_share_loop_budget_across_headers`), both ok. The 2 failures are the same on both (`a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier`, `f32_programs_on_the_gpu`). - SKIPPED: `f16_programs_on_the_gpu` only (4 lines, #1426), on both. **Review** 1. **Parity with the other backends on `amd-dev`.** `00fe5ae` ("bound long shader loops and keep mesh budgets simple") changed the HLSL path (`recomp/mod.rs`) and direct DXIL (`dxil/kernel.rs`, `dxil/compact.rs`) in two ways: - each iteration spends `loop_cost` (an 80-instruction loop runs half the iterations, `gpu_an_endless_long_loop_stops_after_the_budget_by_its_cost`); - compute and kernel programs keep **per-region** budgets (`budget_regions`, from #2793 / #2865). This PR's per-lane lowering spends **1 per loop-header visit** from a **single** `Var::Budget` for the whole program. Under `XCL_PER_LANE=1`, then: - a long endless loop can run twice as many iterations as on the other paths; - a compute spin-wait that runs out the budget leaves nothing for a later loop. That is the case #2793 fixed (`gpu_a_loop_after_a_spin_to_the_budget_still_runs`); a per-lane counterpart of that test would show it. This may be deliberate. On RDNA2, per-region budgets in compute are what crash the AMD shader compiler on a retail title (#2874), so one budget is the safer shape for the driver. If so, saying it in the description (or porting only `loop_cost`) would make the difference intended rather than accidental. 2. **Exit from a loop header.** An exhausted lane branches from the header straight to `exit` and skips the rest of the program, stores included. That matches what the HLSL and DXIL paths do. `exit_stale` now checks staleness only on the `ends` tails, not on the header-to-exit edges. So a register that is defined only after a loop header and read at exit will not be reported stale on the budget path. That seems acceptable for a runaway lane, but nothing tests it. 3. **Scope at runtime.** All of this is under `XCL_PER_LANE=1`, which is off by default (`pso.rs` keys those entries as `xcl-per-lane-…`). A default title run does not reach it, so I did not run the title for this PR. **Not tested:** `XCL_PER_LANE=1` on a retail title (this card loses the device on `bf7c82ee` within minutes anyway, #2874); this head on its own base; NVIDIA. AI use: Claude Code (Claude Opus 5.5) read the diff and `00fe5ae`, ran the tests on base and merge, and wrote this comment.
thehollowedone commented 2026-11-28 01:44:01 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-28T01:44:01Z.


Following the budget-parity review, I tested a small correction on #2769 head 9a6d83c1 merged into current amd-dev 7c795f5e.

The current base matters here: compute and graphics deliberately keep one budget because the per-region shape hit the AMD compiler (#2874); kernel programs still use per-region budgets. The candidate retains that distinction. It charges each loop header using the existing loop_cost rule, and gives kernel programs only the existing per-region owner and total counters.

Two targeted regressions exercise behavior the PR's current tests do not cover:

  • A synthetic 256-byte endless loop completes the CPU interpreter on unchanged production code but fails the new assertion: 65,536 visits versus 32,768 expected when each visit costs two units. It passes with the candidate.
  • A kernel spin that takes 65,536 visits followed by a separate three-visit loop leaves the second loop at 0/3 with the single-budget implementation, even after the code-size correction. With per-region kernel accounting it reaches 3/3 on the CPU interpreter and the RTX 3080 Ti DXIL path.

cargo test --offline --locked -j 4 -p xcl --lib gpu::recomp::lower::tests -- --test-threads=1 with the candidate: 41 passed, 0 failed, 0 ignored, including the new GPU check; four wave64 skip notices on this RTX 3080 Ti. Windows 11 build 26300, driver 621.35, Rust 1.99.1, DXC 1.8.2502.11. The full workspace suite, AMD hardware and a title run were not tested on this uncommitted candidate. This is a fix suggestion for the existing PR, not a merge-readiness claim.

Candidate diff, including the focused regressions
diff --git a/crates/xcl/src/gpu/recomp/lower.rs b/crates/xcl/src/gpu/recomp/lower.rs
index c462be09..d893da9b 100644
--- a/crates/xcl/src/gpu/recomp/lower.rs
+++ b/crates/xcl/src/gpu/recomp/lower.rs
@@ -1257,6 +1257,8 @@ fn lower_with<I: Ir>(insts: &[Decoded], stage: Stage, wave64: bool, mut ir: I, s
     if n == 0 {
         return Err("empty program".into());
     }
+    let loops = super::loop_ranges(insts);
+    let regions = if kernel { super::budget_regions(&loops) } else { Vec::new() };
     // IR blocks: 0 prologue, 1..=n the program's, n + 1 exit, n + 2 lane 0's scalar stores,
     // n + 3 every lane's vector stores, n + 4 the way to the exit of lanes outside EXEC at launch,
     // then for every coalesced guarded run (only the lanes with their EXEC bit enter): the run's
@@ -1401,6 +1403,12 @@ fn lower_with<I: Ir>(insts: &[Decoded], stage: Stage, wave64: bool, mut ir: I, s
     l.ssa.seal(&mut l.ir, 0);
     let budget = l.ir.int(LOOP_BUDGET);
     l.ssa.write(0, Var::Budget, budget);
+    if !regions.is_empty() {
+        let owner = l.ir.int(0);
+        let total = l.ir.int(LOOP_BUDGET * super::LOOP_BUDGETS_IN_ALL);
+        l.ssa.write(0, Var::BudgetOwner, owner);
+        l.ssa.write(0, Var::BudgetTotal, total);
+    }
     let lane = l.lane();
     for &r in &sregs {
         let a = l.ir.int(r as u32);
@@ -1550,18 +1558,38 @@ fn lower_with<I: Ir>(insts: &[Decoded], stage: Stage, wave64: bool, mut ir: I, s
         let body_end = block_body_end(insts, &block.insts);
         let mut cur = ib;
         if let Some(bc) = budget_cont[b] {
-            // cap a lane's loop iterations (matching emit.rs and dxil/kernel.rs LOOP_BUDGET)
-            let left = l.read(cur, Var::Budget);
-            let z = l.ir.int(0);
-            let exhausted = l.ir.icmp(Cmp::Eq, left, z);
+            // Charge long loops for their code size, as the other backends do.
+            let pc = insts[block.insts.start].pc;
+            let cost = l.ir.int(super::loop_cost(&loops, pc));
+            let mut left = l.read(cur, Var::Budget);
+            let mut total = None;
+            let region = super::budget_region(&regions, pc);
+            if let Some(r) = region {
+                let owner = l.read(cur, Var::BudgetOwner);
+                let r_value = l.ir.int(r);
+                let changed = l.ir.icmp(Cmp::Ne, owner, r_value);
+                let fresh = l.ir.int(LOOP_BUDGET * super::LOOP_BUDGETS_PER_REGION);
+                left = l.ir.select(changed, fresh, left);
+                total = Some(l.read(cur, Var::BudgetTotal));
+            }
+            let mut exhausted = l.ir.icmp(Cmp::Ult, left, cost);
+            if let Some(t) = total {
+                let depleted = l.ir.icmp(Cmp::Ult, t, cost);
+                exhausted = l.ir.bin(Bin::Or, exhausted, depleted);
+            }
             l.ir.br_if(exhausted, exit, bc);
             done[cur] = true;
             l.ir.at(bc);
             l.ssa.seal(&mut l.ir, bc);
             sealed[bc] = true;
-            let one = l.ir.int(1);
-            let next = l.ir.bin(Bin::Sub, left, one);
+            let next = l.ir.bin(Bin::Sub, left, cost);
             l.ssa.write(bc, Var::Budget, next);
+            if let (Some(r), Some(t)) = (region, total) {
+                let owner = l.ir.int(r);
+                l.ssa.write(bc, Var::BudgetOwner, owner);
+                let remaining = l.ir.bin(Bin::Sub, t, cost);
+                l.ssa.write(bc, Var::BudgetTotal, remaining);
+            }
             cur = bc;
         }
         let mut split = splits[b].iter().peekable();
@@ -1867,7 +1895,7 @@ impl<I: Ir> Lower<'_, I> {
                     let s = self.ir.icmp(Cmp::Ne, v, z);
                     self.write_scc(b, s);
                 }
-                Var::S(_) | Var::M(_) | Var::Budget => {}
+                Var::S(_) | Var::M(_) | Var::Budget | Var::BudgetOwner | Var::BudgetTotal => {}
             }
         }
         if name.starts_with("V_") && !sw.is_empty() {
@@ -4657,6 +4685,64 @@ pub(crate) mod tests {
         assert_eq!(v[0][1], LOOP_BUDGET);
     }
 
+    #[test]
+    fn long_loop_spends_its_code_size_per_header_visit() {
+        let mut lines: Vec<I> = vec![
+            ("S_MOV_B32", "ENC_SOP1", &[("SDST", 0), ("SSRC0", 128)]),
+            ("S_ADD_U32", "ENC_SOP2", &[("SDST", 0), ("SSRC0", 0), ("SSRC1", 255), ("LITERAL", 1)]),
+        ];
+        for _ in 0..30 {
+            lines.push(("S_ADD_U32", "ENC_SOP2", &[("SDST", 4), ("SSRC0", 4), ("SSRC1", 255), ("LITERAL", 1)]));
+        }
+        lines.push(("S_CMP_LG_U32", "ENC_SOPC", &[("SSRC0", 0), ("SSRC1", 128)]));
+        lines.push(("S_CBRANCH_SCC1", "ENC_SOPP", &[("SIMM16", 0xFFC0)]));
+        lines.push(ENDPGM);
+        let (mut s, mut v) = state(32);
+        s[126] = 1;
+        v[0][1] = 0;
+        let (s, _) = run(&lines, false, &s, &v);
+        assert_eq!(s[0], LOOP_BUDGET / 2, "a 256-byte loop spends two units per visit");
+    }
+
+    const SPIN_THEN_LOOP: &[I] = &[
+        ("S_MOV_B32", "ENC_SOP1", &[("SDST", 0), ("SSRC0", 128)]),
+        ("S_MOV_B32", "ENC_SOP1", &[("SDST", 1), ("SSRC0", 128)]),
+        ("S_MOV_B32", "ENC_SOP1", &[("SDST", 3), ("SSRC0", 255), ("LITERAL", LOOP_BUDGET as u64)]),
+        ("S_ADD_U32", "ENC_SOP2", &[("SDST", 0), ("SSRC0", 0), ("SSRC1", 129)]),
+        ("S_CMP_LT_U32", "ENC_SOPC", &[("SSRC0", 0), ("SSRC1", 3)]),
+        ("S_CBRANCH_SCC1", "ENC_SOPP", &[("SIMM16", 0xFFFD)]),
+        ("S_ADD_U32", "ENC_SOP2", &[("SDST", 1), ("SSRC0", 1), ("SSRC1", 129)]),
+        ("S_CMP_LT_U32", "ENC_SOPC", &[("SSRC0", 1), ("SSRC1", 131)]),
+        ("S_CBRANCH_SCC1", "ENC_SOPP", &[("SIMM16", 0xFFFD)]),
+        ENDPGM,
+    ];
+
+    #[test]
+    fn kernel_loop_after_a_full_spin_keeps_its_own_budget() {
+        let (mut s, v) = state(32);
+        s[126] = 1;
+        let (s, _) = run(SPIN_THEN_LOOP, false, &s, &v);
+        assert_eq!(s[0], LOOP_BUDGET);
+        assert_eq!(s[1], 3, "the second loop must run after the first spends one budget");
+    }
+
+    #[test]
+    fn kernel_loop_after_a_full_spin_runs_on_the_gpu() {
+        use super::super::{lower_dxil, runner};
+        if !gpu_waves() {
+            runner::skip_test("no GPU with 32-lane waves");
+            return;
+        }
+        let (dxil, _) = lower_dxil::kernel(&decode(SPIN_THEN_LOOP), false).unwrap();
+        let (mut s, _) = state(32);
+        s[126] = 1;
+        let mut input = runner::KernelState::default();
+        input.sgpr.copy_from_slice(&s);
+        let gpu = runner::run(&dxil, &input, &[]).unwrap();
+        assert_eq!(gpu.sgpr[0], LOOP_BUDGET);
+        assert_eq!(gpu.sgpr[1], 3);
+    }
+
     #[test]
     fn nested_loops_share_loop_budget_across_headers() {
         // Outer infinite loop (header at inst 2, counted in s0) wrapping an inner loop that
diff --git a/crates/xcl/src/gpu/recomp/lower_dxil.rs b/crates/xcl/src/gpu/recomp/lower_dxil.rs
index 5865c59e..1af0ddb6 100644
--- a/crates/xcl/src/gpu/recomp/lower_dxil.rs
+++ b/crates/xcl/src/gpu/recomp/lower_dxil.rs
@@ -100,7 +100,7 @@ impl DxilIr {
     fn ty(&mut self, var: Var) -> crate::gpu::dxil::module::Ty {
         match var {
             Var::M(_) | Var::Scc => self.lw.s.m.i1(),
-            Var::S(_) | Var::V(_) | Var::Budget => self.lw.s.m.i32(),
+            Var::S(_) | Var::V(_) | Var::Budget | Var::BudgetOwner | Var::BudgetTotal => self.lw.s.m.i32(),
         }
     }
 
@@ -267,7 +267,7 @@ impl Ir for DxilIr {
             Var::V(n) => VAR_VGPR + n as u32,
             Var::Scc => VAR_SCC,
             Var::M(_) => unreachable!("a lane-bit view is not a register"),
-            Var::Budget => unreachable!("loop budget is not a register"),
+            Var::Budget | Var::BudgetOwner | Var::BudgetTotal => unreachable!("loop budget is not a register"),
         };
         for &(v, x) in inputs {
             self.lw.wr(var(v), x);
diff --git a/crates/xcl/src/gpu/recomp/ssa.rs b/crates/xcl/src/gpu/recomp/ssa.rs
index 940b1553..be4c94d7 100644
--- a/crates/xcl/src/gpu/recomp/ssa.rs
+++ b/crates/xcl/src/gpu/recomp/ssa.rs
@@ -26,6 +26,8 @@ pub enum Var {
     Scc,
     /// remaining loop-header iterations for this lane (`i32`)
     Budget,
+    BudgetOwner,
+    BudgetTotal,
 }
 
 /// What the construction needs from the module builder.

AI use: Codex (GPT-6.2 Sol) traced the current lowering paths, wrote and ran the local regressions and candidate, and drafted this reply.

<!-- greyfinch-sync:ivall/xcl:comment:7231879410 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2769#issuecomment-7231879410). Originally posted by [thehollowedone](https://github.com/thehollowedone) on 2026-11-28T01:44:01Z. --- Following [the budget-parity review](https://github.com/xcl-dev/xcl/pull/2769#issuecomment-7208053878), I tested a small correction on [#2769 head `9a6d83c1`](https://github.com/xcl-dev/xcl/commit/9a6d83c1276485fdd256c3a694feb2d09504b4dc) merged into current `amd-dev` `7c795f5e`. The current base matters here: compute and graphics deliberately keep **one** budget because the per-region shape hit the AMD compiler ([#2874](https://github.com/xcl-dev/xcl/issues/2874)); kernel programs still use per-region budgets. The candidate retains that distinction. It charges each loop header using the existing `loop_cost` rule, and gives **kernel programs only** the existing per-region owner and total counters. Two targeted regressions exercise behavior the PR's current tests do not cover: - A synthetic 256-byte endless loop completes the CPU interpreter on unchanged production code but fails the new assertion: **65,536** visits versus **32,768** expected when each visit costs two units. It passes with the candidate. - A kernel spin that takes 65,536 visits followed by a separate three-visit loop leaves the second loop at **0/3** with the single-budget implementation, even after the code-size correction. With per-region kernel accounting it reaches **3/3** on the CPU interpreter and the RTX 3080 Ti DXIL path. `cargo test --offline --locked -j 4 -p xcl --lib gpu::recomp::lower::tests -- --test-threads=1` with the candidate: **41 passed, 0 failed, 0 ignored**, including the new GPU check; **four wave64 skip notices** on this RTX 3080 Ti. Windows 11 build 26300, driver 621.35, Rust 1.99.1, DXC 1.8.2502.11. The full workspace suite, AMD hardware and a title run were not tested on this uncommitted candidate. This is a fix suggestion for the existing PR, not a merge-readiness claim. <details><summary>Candidate diff, including the focused regressions</summary> ```diff diff --git a/crates/xcl/src/gpu/recomp/lower.rs b/crates/xcl/src/gpu/recomp/lower.rs index c462be09..d893da9b 100644 --- a/crates/xcl/src/gpu/recomp/lower.rs +++ b/crates/xcl/src/gpu/recomp/lower.rs @@ -1257,6 +1257,8 @@ fn lower_with<I: Ir>(insts: &[Decoded], stage: Stage, wave64: bool, mut ir: I, s if n == 0 { return Err("empty program".into()); } + let loops = super::loop_ranges(insts); + let regions = if kernel { super::budget_regions(&loops) } else { Vec::new() }; // IR blocks: 0 prologue, 1..=n the program's, n + 1 exit, n + 2 lane 0's scalar stores, // n + 3 every lane's vector stores, n + 4 the way to the exit of lanes outside EXEC at launch, // then for every coalesced guarded run (only the lanes with their EXEC bit enter): the run's @@ -1401,6 +1403,12 @@ fn lower_with<I: Ir>(insts: &[Decoded], stage: Stage, wave64: bool, mut ir: I, s l.ssa.seal(&mut l.ir, 0); let budget = l.ir.int(LOOP_BUDGET); l.ssa.write(0, Var::Budget, budget); + if !regions.is_empty() { + let owner = l.ir.int(0); + let total = l.ir.int(LOOP_BUDGET * super::LOOP_BUDGETS_IN_ALL); + l.ssa.write(0, Var::BudgetOwner, owner); + l.ssa.write(0, Var::BudgetTotal, total); + } let lane = l.lane(); for &r in &sregs { let a = l.ir.int(r as u32); @@ -1550,18 +1558,38 @@ fn lower_with<I: Ir>(insts: &[Decoded], stage: Stage, wave64: bool, mut ir: I, s let body_end = block_body_end(insts, &block.insts); let mut cur = ib; if let Some(bc) = budget_cont[b] { - // cap a lane's loop iterations (matching emit.rs and dxil/kernel.rs LOOP_BUDGET) - let left = l.read(cur, Var::Budget); - let z = l.ir.int(0); - let exhausted = l.ir.icmp(Cmp::Eq, left, z); + // Charge long loops for their code size, as the other backends do. + let pc = insts[block.insts.start].pc; + let cost = l.ir.int(super::loop_cost(&loops, pc)); + let mut left = l.read(cur, Var::Budget); + let mut total = None; + let region = super::budget_region(&regions, pc); + if let Some(r) = region { + let owner = l.read(cur, Var::BudgetOwner); + let r_value = l.ir.int(r); + let changed = l.ir.icmp(Cmp::Ne, owner, r_value); + let fresh = l.ir.int(LOOP_BUDGET * super::LOOP_BUDGETS_PER_REGION); + left = l.ir.select(changed, fresh, left); + total = Some(l.read(cur, Var::BudgetTotal)); + } + let mut exhausted = l.ir.icmp(Cmp::Ult, left, cost); + if let Some(t) = total { + let depleted = l.ir.icmp(Cmp::Ult, t, cost); + exhausted = l.ir.bin(Bin::Or, exhausted, depleted); + } l.ir.br_if(exhausted, exit, bc); done[cur] = true; l.ir.at(bc); l.ssa.seal(&mut l.ir, bc); sealed[bc] = true; - let one = l.ir.int(1); - let next = l.ir.bin(Bin::Sub, left, one); + let next = l.ir.bin(Bin::Sub, left, cost); l.ssa.write(bc, Var::Budget, next); + if let (Some(r), Some(t)) = (region, total) { + let owner = l.ir.int(r); + l.ssa.write(bc, Var::BudgetOwner, owner); + let remaining = l.ir.bin(Bin::Sub, t, cost); + l.ssa.write(bc, Var::BudgetTotal, remaining); + } cur = bc; } let mut split = splits[b].iter().peekable(); @@ -1867,7 +1895,7 @@ impl<I: Ir> Lower<'_, I> { let s = self.ir.icmp(Cmp::Ne, v, z); self.write_scc(b, s); } - Var::S(_) | Var::M(_) | Var::Budget => {} + Var::S(_) | Var::M(_) | Var::Budget | Var::BudgetOwner | Var::BudgetTotal => {} } } if name.starts_with("V_") && !sw.is_empty() { @@ -4657,6 +4685,64 @@ pub(crate) mod tests { assert_eq!(v[0][1], LOOP_BUDGET); } + #[test] + fn long_loop_spends_its_code_size_per_header_visit() { + let mut lines: Vec<I> = vec![ + ("S_MOV_B32", "ENC_SOP1", &[("SDST", 0), ("SSRC0", 128)]), + ("S_ADD_U32", "ENC_SOP2", &[("SDST", 0), ("SSRC0", 0), ("SSRC1", 255), ("LITERAL", 1)]), + ]; + for _ in 0..30 { + lines.push(("S_ADD_U32", "ENC_SOP2", &[("SDST", 4), ("SSRC0", 4), ("SSRC1", 255), ("LITERAL", 1)])); + } + lines.push(("S_CMP_LG_U32", "ENC_SOPC", &[("SSRC0", 0), ("SSRC1", 128)])); + lines.push(("S_CBRANCH_SCC1", "ENC_SOPP", &[("SIMM16", 0xFFC0)])); + lines.push(ENDPGM); + let (mut s, mut v) = state(32); + s[126] = 1; + v[0][1] = 0; + let (s, _) = run(&lines, false, &s, &v); + assert_eq!(s[0], LOOP_BUDGET / 2, "a 256-byte loop spends two units per visit"); + } + + const SPIN_THEN_LOOP: &[I] = &[ + ("S_MOV_B32", "ENC_SOP1", &[("SDST", 0), ("SSRC0", 128)]), + ("S_MOV_B32", "ENC_SOP1", &[("SDST", 1), ("SSRC0", 128)]), + ("S_MOV_B32", "ENC_SOP1", &[("SDST", 3), ("SSRC0", 255), ("LITERAL", LOOP_BUDGET as u64)]), + ("S_ADD_U32", "ENC_SOP2", &[("SDST", 0), ("SSRC0", 0), ("SSRC1", 129)]), + ("S_CMP_LT_U32", "ENC_SOPC", &[("SSRC0", 0), ("SSRC1", 3)]), + ("S_CBRANCH_SCC1", "ENC_SOPP", &[("SIMM16", 0xFFFD)]), + ("S_ADD_U32", "ENC_SOP2", &[("SDST", 1), ("SSRC0", 1), ("SSRC1", 129)]), + ("S_CMP_LT_U32", "ENC_SOPC", &[("SSRC0", 1), ("SSRC1", 131)]), + ("S_CBRANCH_SCC1", "ENC_SOPP", &[("SIMM16", 0xFFFD)]), + ENDPGM, + ]; + + #[test] + fn kernel_loop_after_a_full_spin_keeps_its_own_budget() { + let (mut s, v) = state(32); + s[126] = 1; + let (s, _) = run(SPIN_THEN_LOOP, false, &s, &v); + assert_eq!(s[0], LOOP_BUDGET); + assert_eq!(s[1], 3, "the second loop must run after the first spends one budget"); + } + + #[test] + fn kernel_loop_after_a_full_spin_runs_on_the_gpu() { + use super::super::{lower_dxil, runner}; + if !gpu_waves() { + runner::skip_test("no GPU with 32-lane waves"); + return; + } + let (dxil, _) = lower_dxil::kernel(&decode(SPIN_THEN_LOOP), false).unwrap(); + let (mut s, _) = state(32); + s[126] = 1; + let mut input = runner::KernelState::default(); + input.sgpr.copy_from_slice(&s); + let gpu = runner::run(&dxil, &input, &[]).unwrap(); + assert_eq!(gpu.sgpr[0], LOOP_BUDGET); + assert_eq!(gpu.sgpr[1], 3); + } + #[test] fn nested_loops_share_loop_budget_across_headers() { // Outer infinite loop (header at inst 2, counted in s0) wrapping an inner loop that diff --git a/crates/xcl/src/gpu/recomp/lower_dxil.rs b/crates/xcl/src/gpu/recomp/lower_dxil.rs index 5865c59e..1af0ddb6 100644 --- a/crates/xcl/src/gpu/recomp/lower_dxil.rs +++ b/crates/xcl/src/gpu/recomp/lower_dxil.rs @@ -100,7 +100,7 @@ impl DxilIr { fn ty(&mut self, var: Var) -> crate::gpu::dxil::module::Ty { match var { Var::M(_) | Var::Scc => self.lw.s.m.i1(), - Var::S(_) | Var::V(_) | Var::Budget => self.lw.s.m.i32(), + Var::S(_) | Var::V(_) | Var::Budget | Var::BudgetOwner | Var::BudgetTotal => self.lw.s.m.i32(), } } @@ -267,7 +267,7 @@ impl Ir for DxilIr { Var::V(n) => VAR_VGPR + n as u32, Var::Scc => VAR_SCC, Var::M(_) => unreachable!("a lane-bit view is not a register"), - Var::Budget => unreachable!("loop budget is not a register"), + Var::Budget | Var::BudgetOwner | Var::BudgetTotal => unreachable!("loop budget is not a register"), }; for &(v, x) in inputs { self.lw.wr(var(v), x); diff --git a/crates/xcl/src/gpu/recomp/ssa.rs b/crates/xcl/src/gpu/recomp/ssa.rs index 940b1553..be4c94d7 100644 --- a/crates/xcl/src/gpu/recomp/ssa.rs +++ b/crates/xcl/src/gpu/recomp/ssa.rs @@ -26,6 +26,8 @@ pub enum Var { Scc, /// remaining loop-header iterations for this lane (`i32`) Budget, + BudgetOwner, + BudgetTotal, } /// What the construction needs from the module builder. ``` </details> AI use: Codex (GPT-6.2 Sol) traced the current lowering paths, wrote and ran the local regressions and candidate, and drafted this reply.
throny commented 2026-11-28 17:24:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-28T17:24:37Z.


merge-check claim
head: 9a6d83c127

<!-- greyfinch-sync:ivall/xcl:comment:7242994207 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2769#issuecomment-7242994207). Originally posted by [throny](https://github.com/throny) on 2026-11-28T17:24:37Z. --- merge-check claim head: 9a6d83c1276485fdd256c3a694feb2d09504b4dc
throny commented 2026-11-28 17:46:40 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-28T17:46:40Z.


merge-check
base: 7c795f5e (amd-dev)
head: 9a6d83c127
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 on amd-dev 7c795f5e + this PR -> 1806 passed, 16 failed, 48 ignored (21 SKIPPED lines) on an RTX 4080. The base (see #2605, which changes nothing) has 1802 passed, 17 failed in the run beside it; all 16 failures here are among the base's 17, so nothing new fails on this card (the one that differs, the_mirror_sync_copies_only_the_pages_the_title_wrote, is not in this PR's area).
review: the mechanism is sound and better than before (the per-lane form had no cap at all, so a runaway loop hung the GPU), but the parity points from the thread are unanswered and the description claims a parity that current amd-dev does not have. (1) Every loop-header visit costs 1; the direct-DXIL path weighs a visit by the loop's cost, so a long loop can run up to 256 times more iterations here before the cap, and that cap exists because of driver timeouts. (2) There is one counter per lane for the whole program, set once at entry; a lane that passes 65,536 header visits in total leaves through the exit, and in compute everything after the loop, stores included, is skipped without a log line (the direct path does the same; the HLSL path breaks out of the loop and runs on). Not tested by anyone: a lane leaving early before a barrier in divergent control flow, and ballots once a lane has left.
performance: one compare and one subtraction per loop-header visit. It changes per-lane sources only: only per-lane cache entries are re-translated.
verdict: not yet: answer the two parity reviews (loop cost; what the description says), then I re-check.
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).

<!-- greyfinch-sync:ivall/xcl:comment:7243279120 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2769#issuecomment-7243279120). Originally posted by [throny](https://github.com/throny) on 2026-11-28T17:46:40Z. --- merge-check base: 7c795f5e (amd-dev) head: 9a6d83c1276485fdd256c3a694feb2d09504b4dc merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 on amd-dev 7c795f5e + this PR -> 1806 passed, 16 failed, 48 ignored (21 SKIPPED lines) on an RTX 4080. The base (see #2605, which changes nothing) has 1802 passed, 17 failed in the run beside it; all 16 failures here are among the base's 17, so nothing new fails on this card (the one that differs, the_mirror_sync_copies_only_the_pages_the_title_wrote, is not in this PR's area). review: the mechanism is sound and better than before (the per-lane form had no cap at all, so a runaway loop hung the GPU), but the parity points from the thread are unanswered and the description claims a parity that current amd-dev does not have. (1) Every loop-header visit costs 1; the direct-DXIL path weighs a visit by the loop's cost, so a long loop can run up to 256 times more iterations here before the cap, and that cap exists because of driver timeouts. (2) There is one counter per lane for the whole program, set once at entry; a lane that passes 65,536 header visits in total leaves through the exit, and in compute everything after the loop, stores included, is skipped without a log line (the direct path does the same; the HLSL path breaks out of the loop and runs on). Not tested by anyone: a lane leaving early before a barrier in divergent control flow, and ballots once a lane has left. performance: one compare and one subtraction per loop-header visit. It changes per-lane sources only: only per-lane cache entries are re-translated. verdict: not yet: answer the two parity reviews (loop cost; what the description says), then I re-check. hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Saksukella commented 2026-11-28 23:54:07 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Saksukella on 2026-11-28T23:54:07Z.


Rebased cleanly onto main (227d2cb388) and retargeted this PR's base branch to main.

Summary of updates addressing review feedback:

  • Weighted loop_cost deduction: Each loop-header visit now deducts loop_cost (1 per 128 bytes of innermost loop code, clamped to 1..=256) and checks Cmp::Ult against cost, so long loops cannot run up to 256x more iterations before hitting LOOP_BUDGET.
  • Kernel-only per-region budgets (BudgetOwner / BudgetTotal): Kernel programs track per-region budgets (LOOP_BUDGET * 2 per region, LOOP_BUDGET * 4 total). Compute and graphics shaders intentionally stay on a single program-wide Var::Budget per lane (avoiding the AMD compiler crash in #2874).
  • Exit semantics: Exhausted lanes branch directly from the loop header to exit, matching direct-DXIL semantics.
  • Regression tests & verification (RX 9070 XT):
    • cargo test --lib -p xcl recomp::lower -- --test-threads=4: 64 passed, 0 failed (including long_loop_spends_its_code_size_per_header_visit and kernel_loop_after_a_full_spin_keeps_its_own_budget).
    • cargo check --workspace: passed.
    • 60s smoke.ps1 (TitleID 7952987A, head a68bf237e5d0): 1687 frames shown (main 227d2cb388: 1674), 0 device removals, 0 crashes, 18139 MB peak commit.
<!-- greyfinch-sync:ivall/xcl:comment:7247738216 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2769#issuecomment-7247738216). Originally posted by [Saksukella](https://github.com/Saksukella) on 2026-11-28T23:54:07Z. --- Rebased cleanly onto `main` (`227d2cb388`) and retargeted this PR's base branch to `main`. Summary of updates addressing review feedback: - **Weighted `loop_cost` deduction:** Each loop-header visit now deducts `loop_cost` (`1` per `128` bytes of innermost loop code, clamped to `1..=256`) and checks `Cmp::Ult` against `cost`, so long loops cannot run up to 256x more iterations before hitting `LOOP_BUDGET`. - **Kernel-only per-region budgets (`BudgetOwner` / `BudgetTotal`):** Kernel programs track per-region budgets (`LOOP_BUDGET * 2` per region, `LOOP_BUDGET * 4` total). Compute and graphics shaders intentionally stay on a single program-wide `Var::Budget` per lane (avoiding the AMD compiler crash in #2874). - **Exit semantics:** Exhausted lanes branch directly from the loop header to `exit`, matching direct-DXIL semantics. - **Regression tests & verification (RX 9070 XT):** - `cargo test --lib -p xcl recomp::lower -- --test-threads=4`: 64 passed, 0 failed (including `long_loop_spends_its_code_size_per_header_visit` and `kernel_loop_after_a_full_spin_keeps_its_own_budget`). - `cargo check --workspace`: passed. - 60s `smoke.ps1` (`TitleID 7952987A`, head `a68bf237e5d0`): `1687` frames shown (`main` `227d2cb388`: `1674`), `0` device removals, `0` crashes, `18139 MB` peak commit.
throny commented 2026-11-29 00:30:03 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-29T00:30:03Z.


merge-check claim
head: a68bf237e5

Re-check of the head rebased onto main.

<!-- greyfinch-sync:ivall/xcl:comment:7248155095 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2769#issuecomment-7248155095). Originally posted by [throny](https://github.com/throny) on 2026-11-29T00:30:03Z. --- merge-check claim head: a68bf237e5d02a72df1f1311b40897c1aa432c57 Re-check of the head rebased onto main.
throny commented 2026-11-29 00:46:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-29T00:46:58Z.


merge-check
base: fa204595
head: a68bf237e5
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2612 passed, 0 failed, 49 ignored (27 SKIPPED lines). Base alone at fa204595: 2608 passed, 0 failed, 49 ignored.
review: re-check of the head rewritten onto main, and first a correction on my side. My check of 2026-11-28 asked for parity with the direct-DXIL path's loop-cost weighting. That was true of amd-dev at 7c795f5e, the PR's target that day (the weighting came with 00fe5aec). The PR now targets main, and neither main (fa204595) nor today's amd-dev (8942a5b9, rewritten since) has any loop-cost weighting: the direct-DXIL, compact and HLSL paths all charge 1 per loop-header visit. So the weighting and the per-region budgets this head adds to answer that point make the per-lane form stricter than every other path on main: a loop of 32 KiB or more would end after 256 header visits where the others allow 65,536, which can cut a legitimate long loop short. The comment "matching the other lowering backends" is therefore not true on main. Sorry for the detour; the earlier 1-per-visit form is the one that matches main. Still open from the thread: exit_stale ignores the header-to-exit edges; a lane leaving before a barrier in divergent flow and ballots after a lane has left are untested; a lane over budget still skips the rest silently (as the direct path does), without a log line. Process: the smoke run does not reach this code without XCL_PER_LANE=1, and AI use names no tool or model.
performance: one compare and one subtraction per loop-header visit. Per-lane sources only: only per-lane cache entries are re-translated.
verdict: not yet: on main, go back to 1 per header visit (or show why per-lane needs the weighting when no other path has it), and name the model under AI use.
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).

<!-- greyfinch-sync:ivall/xcl:comment:7248346718 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2769#issuecomment-7248346718). Originally posted by [throny](https://github.com/throny) on 2026-11-29T00:46:58Z. --- merge-check base: fa204595 head: a68bf237e5d02a72df1f1311b40897c1aa432c57 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2612 passed, 0 failed, 49 ignored (27 SKIPPED lines). Base alone at fa204595: 2608 passed, 0 failed, 49 ignored. review: re-check of the head rewritten onto main, and first a correction on my side. My check of 2026-11-28 asked for parity with the direct-DXIL path's loop-cost weighting. That was true of amd-dev at 7c795f5e, the PR's target that day (the weighting came with 00fe5aec). The PR now targets main, and neither main (fa204595) nor today's amd-dev (8942a5b9, rewritten since) has any loop-cost weighting: the direct-DXIL, compact and HLSL paths all charge 1 per loop-header visit. So the weighting and the per-region budgets this head adds to answer that point make the per-lane form stricter than every other path on main: a loop of 32 KiB or more would end after 256 header visits where the others allow 65,536, which can cut a legitimate long loop short. The comment "matching the other lowering backends" is therefore not true on main. Sorry for the detour; the earlier 1-per-visit form is the one that matches main. Still open from the thread: exit_stale ignores the header-to-exit edges; a lane leaving before a barrier in divergent flow and ballots after a lane has left are untested; a lane over budget still skips the rest silently (as the direct path does), without a log line. Process: the smoke run does not reach this code without XCL_PER_LANE=1, and AI use names no tool or model. performance: one compare and one subtraction per loop-header visit. Per-lane sources only: only per-lane cache entries are re-translated. verdict: not yet: on main, go back to 1 per header visit (or show why per-lane needs the weighting when no other path has it), and name the model under AI use. hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
futurepro62 commented 2026-11-30 02:39:57 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-30T02:39:57Z.


NVIDIA and AMD full-suite run of head a68bf237, on its own base 227d2cb and merged with current main 53e85fb1, to go with the reports above by throny, since none of them covers AMD. Nothing here fails because of this PR. On the Radeon the lib test binary stops partway on this base and on main alike (#3488), so the AMD runs are partial. The bare-head runs come first.

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace --no-fail-fast -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::bridged_dpp_agrees_with_hlsl_on_the_gpu --skip hle::d3d12x::bind::tests::two_pass_binds_set_the_shared_view_heap --skip gpu::dxil::fuzz_tests: 2586 passed, 0 failed, 47 ignored. SKIPPED (no wave64): a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu, a_per_lane_2d_or_3d_group_runs_on_the_gpu, coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu, cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu, dispatch_chain_native_wave64_builds_whole, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace --no-fail-fast -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 --skip two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs: 138 passed, 0 failed, 20 ignored, incomplete: the xcl lib test binary stopped itself partway (exit code 0x80004005, after sparse upload preparation still failed after bounded retries), so most of its tests did not run. That stop comes from #2959 on main and is not this PR's: #3488.
  • --skip leaves out tests that fail on main 53e85fb1 too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (#1651), the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests, const_and_null_mask_operands_agree_with_hlsl_on_the_gpu and mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, bridged_dpp_agrees_with_hlsl_on_the_gpu (no wave64 on this card) and two_pass_binds_set_the_shared_view_heap (heap windows are opt-in, XCL_HEAP_WINDOWS=1) fail the same way; gpu::dxil::fuzz_tests stays skipped as in earlier runs (seeds 70, 545, 1019 and 1507 failed CreateComputePipelineState with E_OUTOFMEMORY on this card; they passed on this main's baseline). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs fails on main too, since #2959 (#3441). The AMD run does not set XCL_REQUIRE_GPU.
  • Merged with main 53e85fb1 (git merge --no-ff, clean, local only), same commands and skips. NVIDIA: 2782 passed, 1 failed, 47 ignored; the one failure is concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline, which fails on main itself since #2369 (already reported there: https://github.com/xcl-dev/xcl/pull/2369#issuecomment-7264263758). AMD: 138 passed, 0 failed, 20 ignored, incomplete: the same #3488 stop, and before it gpu_compact_form_with_micro_blocks_and_literal_table_runs_as_the_plain_form (new on main with #3263) fails the same way on bare main 53e85fb1.
  • Bare main 53e85fb1 on both cards, same commands without skips, for comparison: NVIDIA fails the skipped tests plus the #2369 test; the Radeon stops at the same place.

Not tested

  • The Radeon lib tests past the #3488 stop, a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:ivall/xcl:comment:7267204291 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2769#issuecomment-7267204291). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-30T02:39:57Z. --- NVIDIA and AMD full-suite run of head `a68bf237`, on its own base `227d2cb` and merged with current `main` `53e85fb1`, to go with the reports above by throny, since none of them covers AMD. Nothing here fails because of this PR. On the Radeon the lib test binary stops partway on this base and on `main` alike (#3488), so the AMD runs are partial. The bare-head runs come first. **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace --no-fail-fast -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::bridged_dpp_agrees_with_hlsl_on_the_gpu --skip hle::d3d12x::bind::tests::two_pass_binds_set_the_shared_view_heap --skip gpu::dxil::fuzz_tests`: **2586 passed, 0 failed, 47 ignored**. SKIPPED (no wave64): `a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu`, `a_per_lane_2d_or_3d_group_runs_on_the_gpu`, `coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu`, `cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu`, `dispatch_chain_native_wave64_builds_whole`, `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`, `the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu`. - Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace --no-fail-fast -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 --skip two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs`: **138 passed, 0 failed, 20 ignored, incomplete**: the `xcl` lib test binary stopped itself partway (exit code `0x80004005`, after `sparse upload preparation still failed after bounded retries`), so most of its tests did not run. That stop comes from #2959 on `main` and is not this PR's: #3488. - `--skip` leaves out tests that fail on main `53e85fb1` too, not because of this PR. On NVIDIA: `heap_window_out_of_memory_falls_back_to_the_switch_form` (#1651), the four `gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu` tests, `const_and_null_mask_operands_agree_with_hlsl_on_the_gpu` and `mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu` ([follow-up on #1651](https://github.com/xcl-dev/xcl/issues/1651#issuecomment-7146069648)) fail because `runner::skip_test` turns their skips into failures under `XCL_REQUIRE_GPU=mesh`, `bridged_dpp_agrees_with_hlsl_on_the_gpu` (no wave64 on this card) and `two_pass_binds_set_the_shared_view_heap` (heap windows are opt-in, `XCL_HEAP_WINDOWS=1`) fail the same way; `gpu::dxil::fuzz_tests` stays skipped as in earlier runs (seeds 70, 545, 1019 and 1507 failed `CreateComputePipelineState` with `E_OUTOFMEMORY` on this card; they passed on this main's baseline). On AMD: `fuzz_validate_and_gpu_1` fails on seed 540 (`res[833]` 0x7 vs CPU 0x6). `two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs` fails on main too, since #2959 (#3441). The AMD run does not set `XCL_REQUIRE_GPU`. - **Merged with `main` `53e85fb1`** (`git merge --no-ff`, clean, local only), same commands and skips. NVIDIA: **2782 passed, 1 failed, 47 ignored**; the one failure is `concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline`, which fails on `main` itself since #2369 (already reported there: https://github.com/xcl-dev/xcl/pull/2369#issuecomment-7264263758). AMD: **138 passed, 0 failed, 20 ignored, incomplete**: the same #3488 stop, and before it `gpu_compact_form_with_micro_blocks_and_literal_table_runs_as_the_plain_form` (new on `main` with #3263) fails the same way on bare `main` `53e85fb1`. - Bare `main` `53e85fb1` on both cards, same commands without skips, for comparison: NVIDIA fails the skipped tests plus the #2369 test; the Radeon stops at the same place. **Not tested** - The Radeon lib tests past the #3488 stop, a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Foniass commented 2026-12-01 08:55:13 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:55:13Z.


Triage (#1607) – head a68bf23

No other PR adds a loop budget to the per-lane SSA lowering (recomp/lower.rs). #2793 adds per-region budgets to the plain, compact and kernel DXIL backends but does not touch this file. This PR defines its own private copies of LOOP_BUDGETS_PER_REGION, LOOP_BUDGETS_IN_ALL, budget_regions and budget_region, which #2793 puts in recomp/mod.rs; if both land, one copy should go. The comment says loop_cost (1 unit per 128 bytes of the innermost loop) matches the other backends, but on main the plain and compact backends spend 1 per header visit and nothing on main defines loop_cost. So a long loop gets fewer iterations under XCL_PER_LANE=1 than under the default backend. Either drop the cost or change the comment. The branch conflicts with main.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7305960353 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2769#issuecomment-7305960353). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T08:55:13Z. --- **Triage (#1607)** – head a68bf23 No other PR adds a loop budget to the per-lane SSA lowering (`recomp/lower.rs`). #2793 adds per-region budgets to the plain, compact and kernel DXIL backends but does not touch this file. This PR defines its own private copies of `LOOP_BUDGETS_PER_REGION`, `LOOP_BUDGETS_IN_ALL`, `budget_regions` and `budget_region`, which #2793 puts in `recomp/mod.rs`; if both land, one copy should go. The comment says `loop_cost` (1 unit per 128 bytes of the innermost loop) matches the other backends, but on main the plain and compact backends spend 1 per header visit and nothing on main defines `loop_cost`. So a long loop gets fewer iterations under `XCL_PER_LANE=1` than under the default backend. Either drop the cost or change the comment. The branch conflicts with main. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

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

Merge

Merge the changes and update on Forgejo.

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

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

No due date set.

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