Recompiler: close nested loop ranges with prefix maxima #1642
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1642
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1642"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@pmilewsskiedu-gif on GitHub · 2026-11-24 18:34 UTC · original
pmilewsskiedu-gif:perf/nested-loop-1269→main· +96 −7 · 1 files · 1 commits · openPart of #1269. The structured shader translator's
nested_loop_rangespreviously searched every pair of backward-jump intervals repeatedly until all strict overlaps were closed. Crossing chains can make this superquadratic. Close later-starting ranges first and query a Fenwick prefix maximum to compute the same fixed point in O(L log L), keeping the original strict endpoint and equal-start semantics.What is in it
crates/xcl/src/gpu/recomp/mod.rs: replace repeated pair scans for nested loop closure with a descending-start prefix-max pass, including zero/one-range fast paths.Tested
cargo build --workspaceandcargo test --workspace -- --test-threads=4: 778 passed, 0 failed, 41 ignored. GPU SKIPPED messages: two tests on unavailable native wave64; one heap-window test on unavailable heap windows.cargo build --release -p xcl: passed.xcl shaders <pack> --recomp --top 0), both builds translated 26,698 programs with zero errors and emitted an aggregate 9,665.7 MB HLSL. The report lines matched except timing. Matched HLSL-dump pair: main9e3831e110.3 s, this branch15e7f71109.2 s (CLI-reported translation scan time). This small ~1% difference is within run noise, not a claim about DXC or GPU driver compilation.XCL_DUMP_EVERY=100 XCL_DUMP_HLSL=<separate local folders>: 253/253 sampled generated HLSL files, 85.1 MiB, identical SHA-256 on main and this branch, no missing/extra files. No game data or dumps are committed.Regression run
Both binaries were copied sequentially to the exact same temporary xcl.exe path and working directory on this computer, with SHA-256 verification after each swap. The title and run settings are identical. This controls for executable-path-dependent driver caches. All runs used
scripts/smoke.ps1 -Seconds 60; no crash/device removal.Pair 1, shared executable path:
Pair 2, same path and same build order:
Caveat: Earlier tests from different release-executable paths yielded consistently lower frames/higher memory on the patch path (~1.25k frames/25 GB) than on the main path (~1.65k/14.8 GB). Moving the unmodified main binary to a third shared path reproduced the high-memory/low-frame state, establishing executable path or cache state as a confounder. The same-path tests above do not show a consistent regression, but these 60-second runs are too variable to claim FPS or memory benefits.
Not tested
AMD/Intel GPU hardware; long-duration gameplay; full-byte HLSL comparison for every shader (sampled 253); cold cache and fixed driver-state PSO compile timings.
AI use
ChatGPT GPT-6 with Chat On Steroids Core wrote the source and tests, ran the Windows tests, synthetic/retail benchmarks and RTX 4060 Ti smoke checks, and prepared this PR. An independent Chat On Steroids worker reviewed the algorithm and every diff line; it made no edits.
@nnonno91 on GitHub · 2026-11-24 19:19 UTC · original
Independent AMD run and synthetic loop-closure scaling at
15e7f71bb755ed35c1a79f8a3564f028cf5746bd(basec160d86ef2efe3a07e4dfb473e4fa72eafb413c0).Tested
XCL_ADAPTER='AMD Radeon'. Workspace builds used the unoptimized profile with debug info disabled.cargo build --workspace --lockedpassed.cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --show-outputreported 778 passed, 0 failed, 41 ignored. The bundled title passed. One GPU skip is included in the pass count (heap_window_out_of_memory_falls_back_to_the_switch_form, heap windows off).XCL_REQUIRE_GPU=wave64,mesh,cargo test --locked -p xcl --lib -- interval_closure gpu_scalar_loop_and_scc jumps_to_outer_loop_heads_are_structured --test-threads=1 --nocapturegave 4 passed, 0 failed, 0 ignored, 0 skips. The structured-control-flow test reported 120 of 120 programs structured and 120 run both ways, including 70 jumps into a loop.close_nested_loop_rangesverbatim (rustc --edition=2021 -C opt-level=3 pr1642-loop-closure-probe.rs -o pr1642-loop-closure-probe.exe, then ran the exe). The outputs matched for 512 seeded input sets and each set's shuffled order (1,024 comparisons). Inputs included duplicate and touching ranges and addresses nearu64::MAX. The chain cases below also matched the independently constructed expected ranges.Each chain was
(i, i+2)in ascending order. Medians use nine alternating-order samples, one call per old sample and 512 calls averaged per new sample. Input copies were prepared before timing.Not tested
Retail packs or titles, full translator timing, DXC or driver compile timing, and other GPUs. The timing table covers only the CPU interval-closure step on these synthetic inputs.
AI use
OpenAI Codex (GPT-6 family, exact variant unavailable) wrote the temporary comparison harness, ran the tests, and drafted the report.
@DavidM1911 on GitHub · 2026-11-24 21:06 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
@throny on GitHub · 2026-11-25 10:28 UTC · original
Test report for exact head
15e7f71.Tested
cargo build --workspace && cargo test --workspace -- --test-threads=4on15e7f71as it is (its own base): 778 passed, 0 failed, 41 ignored.SKIPPED: 3 lines (no wave64 on this adapter, and the like).scripts/smoke.ps1, the retail title, 60 s, release builds,main568e7dbfirst, then this head. Both runs started without the preload list newer builds leave behind (used-pipelines.txtin the DXIL cache), which makes builds on an older base run out of memory at start:main:
PR:
Not tested: AMD, the head merged onto current
main, a world load.AI use: Claude Code (Claude Opus 5.5) ran this and wrote the report; the diff was read for safety by a Claude Opus 5.5 sub-agent before it was built.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.