Skip to content

Recompiler: keep pending skip jumps in one variable - #1510

Closed
2blponeyy wants to merge 1 commit into
xcl-dev:mainfrom
2blponeyy:recompiler/one-skip-variable
Closed

2blponeyy wants to merge 1 commit into
xcl-dev:mainfrom
2blponeyy:recompiler/one-skip-variable

Conversation

@2blponeyy

@2blponeyy 2blponeyy commented Nov 24, 2026 •

Copy link
Copy Markdown

Structured code keeps a forward jump it cannot nest – a loop break, a jump past a join, s_endpgm before the end – pending until its target, and every level skips its code meanwhile. Each target had its own bool xcl_skip_<pc>, and every guard tested all the flags that could be set at that point: if (!(xcl_skip_a || xcl_skip_b || …)), written out again with the whole set each time a jump was added or reached. With many crossing jumps that is quadratic. In one retail compute program it is 12 804 guards of up to 10 700 characters: 100 MB of its 155 MB of HLSL.

Nothing runs while a jump is pending, so no second one can be set. One uint xcl_skip (the pending target, 0xFFFFFFFF for none) now holds them all, and a guard is one comparison. Part of #1269.

What is in it

  • crates/xcl/src/gpu/recomp/mod.rs: xcl_skip replaces the per-target flags. Each guard is xcl_skip == none, plus the targets of jumps into the loop that follows (those jumps run the loop). The reset at a target now comes before the guard of the jumps still pending, which would otherwise skip it.
  • crates/xcl/src/gpu/recomp/tests.rs: crossing_jumps_keep_guards_small, 32 crossing jumps. On main they translate to 1 085 uses of xcl_skip and the test fails; with this change there are 156. The test runs the program on the GPU for six patterns of taken jumps and checks that each one skips exactly the blocks up to its target.

Tested

  • NVIDIA GeForce RTX 5070 Ti (wave32 only), Windows 10 with Agility SDK 1.620.2, DXC 1.9.2609.5, Rust stable-x86_64-pc-windows-msvc; tests in debug, smoke runs in release
  • cargo test --workspace -- --test-threads=4: 756 passed, 0 failed, 41 ignored (SKIPPED: gpu_wave32_program_in_wave64_hardware, gpu_geometry_wave32_prefix_count_over_a_mask, both "no wave64")
  • On main the new test fails (1 085 uses); with the change it passes, GPU part included.
  • Old against new translator, not committed: the 1 000 random loop nests of jumps_to_outer_loop_heads_are_structured, as wave32 programs (the test runs its GPU part only with wave64), ran on the GPU translated by main and by this change, with the same register state in all 1 000.
  • xcl shaders shaders.rpf --recomp on a retail pack (26 698 programs, XCL_RECOMP_WINDOWS=4): all 26 698 still translated. The largest CS goes from 154.6 MB of HLSL to 54.0 MB, the pack from 10 759 MB to 10 661 MB, and the other programs barely change size (the next largest, 31.0 MB, by 60 bytes).

Regression run
The PR's run came after main's, with the shader cache main's run had filled. That probably explains its higher frame count.

main:

xcl-smoke v1
commit: 037aecd57e8a2ae55154d5e0dfb7119e75430f5b
gpu: NVIDIA GeForce RTX 5070 Ti
title: 5463ad3d
seconds: 60
exit: 0x0
frames shown: 1067 (PresentX 1067)
presents per 2 s (last 3): 60 60 54
device removals: 0
crashes: 0
peak commit: 15649 MB

PR:

xcl-smoke v1
commit: 28b41d162de00337fdbb8e1285b9a09a9188b9e5
gpu: NVIDIA GeForce RTX 5070 Ti
title: 5463ad3d
seconds: 60
exit: 0x0
frames shown: 1612 (PresentX 1613)
presents per 2 s (last 3): 57 60 60
device removals: 0
crashes: 0
peak commit: 16234 MB

Not tested

  • The GPU part of jumps_to_outer_loop_heads_are_structured (wave64 only) and any wave64 GPU: no AMD or Intel hardware.
  • Whether DXC and the driver now build the 54 MB program in reasonable time; 41 MB of it is indentation, and it still gets -O0.
  • Whether the 60 s smoke run reaches a program with skip guards.
  • HANDOFF.md (line 1281) still describes the xcl_skip_<target> flags.

AI use

  • Capy (Claude Opus 5.5): measured the HLSL of the pack and found the guards, wrote the change, the test and this description, and ran the tests and smoke runs above.

Structured code skips the code up to the target of a forward jump it cannot
nest (loop breaks, jumps past a join, s_endpgm before the end) with a flag
per target. Every guard tested each flag that could be set at that point:
`if (!(xcl_skip_a || xcl_skip_b || ...))`, reopened with the whole set each
time a jump was added or resolved. With many crossing jumps that is
quadratic: one compute program of a retail pack had 12 804 guards of up to
10 700 characters, 100 MB of its 155 MB of HLSL.

Nothing runs while a jump is pending, so no second one can be set: one
`uint xcl_skip` (the pending target, 0xFFFFFFFF for none) holds them all and
a guard is `xcl_skip == none`, plus the targets of jumps into the loop that
follows, which run it. The reset at a target now comes before the guard of
the jumps still pending, which would otherwise skip it.

Retail pack (26 698 programs, 4 memory windows): that program 154.6 MB of
HLSL -> 54.0 MB, the pack 10 759 MB -> 10 661 MB, all still translated.

Assisted-by: Capy (Claude Opus 5.5)
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@DarkPanda69

Copy link
Copy Markdown

AMD run with 64-lane waves, which this PR lists as not tested, so the GPU part of jumps_to_outer_loop_heads_are_structured runs here.

Tested: pass, head 28b41d1 applied on its base main 9e3831e, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17.
cargo test -p xcl --lib -- gpu::recomp --test-threads=4:

  • AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010, native wave64: 193 passed, 0 failed, 18 ignored, 0 SKIPPED. jumps_to_outer_loop_heads_are_structured ok.
  • NVIDIA RTX 3060, driver 32.0.16.1088, waves 32 only: 193 passed, 0 failed, 18 ignored, 2 SKIPPED (no wave64). Same test ok.

Not tested: DXC and driver build time of the 54 MB program; Intel; the whole workspace suite; a title.

AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

@2blponeyy

Copy link
Copy Markdown
Author

Closing as a duplicate of #1345, which makes the same change and came first. I'll post a test report on #1345 from an NVIDIA 32-lane GPU (RTX 5070 Ti), which its description lists as not tested.

@2blponeyy 2blponeyy closed this Nov 24, 2026
@DavidM1911

Copy link
Copy Markdown
Contributor

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants