Recompiler: a jump from the if branch to its else branch runs the else branch (#701) #728

Closed
github-bot wants to merge 1 commit from gh-pr/728/head into gh-pr/728/base
Owner

@⁠towiice on GitHub · 2026-11-24 04:11 UTC · original
towiice:recompiler-else-jump-target → main · +49 −1 · 2 files · 1 commits · closed without merging

Part of #701 (shape 2). In the first structured form, a conditional jump inside the if branch of an if / else to the start of the else branch ends at the end of the if branch (hi). item_at took it for a skip to the end of the branch and built an if with no else around the rest of the branch, which includes the s_branch over the else. The jump then lands after the else and the else branch never runs. Now, in the if branch of an if / else (exit is set), a jump to hi is raised as a skip flag; the if / else is rejected as before and the else branch runs under the flag.

Shape 1 of #701 (a second jump to a pending flag) is a separate bug and a separate PR: stacked on this one only for the test helper.

What is in it

  • crates/xcl/src/gpu/recomp/mod.rs (item_at): the t == hi && exit.is_some() case no longer forms an if.
  • crates/xcl/src/gpu/recomp/tests.rs: run_scalar_program (runs a scalar-only program and returns s0..s15) and gpu_a_jump_from_the_if_branch_to_the_else_branch_runs_it, a hand-written program run on the GPU in the structured form and in the pc chain, for the four (s10, s11) combinations.

Tested

  • NVIDIA GeForce GTX 1650 SUPER (wave32 only), Windows 11 build 26300, Rust 1.98.1 x86_64-pc-windows-gnullvm (llvm-mingw 20261117), DXC 1.9.2609.5, debug
  • the new test fails on main (structured: true, s10 = 1, s11 = 0: [1, 0, 0, 1], want [1, 0, 1, 1]) and passes with the fix
  • cargo test -p xcl --lib -- --test-threads=4 (with DXC): 659 passed, 3 failed, 21 ignored on this branch plus the PR below; on main the same run gives 657 passed and the same 3 failures: title_textures::placed_title_textures_share_vram_and_preserve_pixels, title_textures::transitions_apply_when_their_list_is_submitted, vram::d32s8_targets_take_their_own_size_of_video_memory. They pass when hle::d3d12x runs alone, so they look like GPU contention on this 4 GB card, not a change of mine.

Regression run
None: I have no title for scripts/smoke.ps1. This changes crates/xcl/src, so the two xcl-smoke blocks have to come from someone with a title.

main:
not run

PR:
not run

Not tested

  • the retail title and scripts/smoke.ps1; wave64 (this GPU has none); AMD; MSVC; the rest of the workspace (e2e, integration tests) on this branch
  • the 1 200-program random run from #701: its fuzz tests are in a branch of #172, not in main

AI use

  • Claude Code (Claude Sonnet 5.5) wrote the program, the test and the fix and ran the tests; the diagnosis of the two shapes is from #701.
**@⁠towiice** on GitHub · 2026-11-24 04:11 UTC · [original](https://github.com/xcl-dev/xcl/pull/728) `towiice:recompiler-else-jump-target` → `main` · +49 −1 · 2 files · 1 commits · closed without merging Part of #701 (shape 2). In the first structured form, a conditional jump inside the if branch of an if / else to the start of the else branch ends at the end of the if branch (`hi`). `item_at` took it for a skip to the end of the branch and built an if with no else around the rest of the branch, which includes the `s_branch` over the else. The jump then lands after the else and the else branch never runs. Now, in the if branch of an if / else (`exit` is set), a jump to `hi` is raised as a skip flag; the if / else is rejected as before and the else branch runs under the flag. Shape 1 of #701 (a second jump to a pending flag) is a separate bug and a separate PR: stacked on this one only for the test helper. **What is in it** - `crates/xcl/src/gpu/recomp/mod.rs` (`item_at`): the `t == hi && exit.is_some()` case no longer forms an if. - `crates/xcl/src/gpu/recomp/tests.rs`: `run_scalar_program` (runs a scalar-only program and returns s0..s15) and `gpu_a_jump_from_the_if_branch_to_the_else_branch_runs_it`, a hand-written program run on the GPU in the structured form and in the `pc` chain, for the four (s10, s11) combinations. **Tested** - NVIDIA GeForce GTX 1650 SUPER (wave32 only), Windows 11 build 26300, Rust 1.98.1 `x86_64-pc-windows-gnullvm` (llvm-mingw 20261117), DXC 1.9.2609.5, debug - the new test fails on `main` (`structured: true, s10 = 1, s11 = 0`: `[1, 0, 0, 1]`, want `[1, 0, 1, 1]`) and passes with the fix - `cargo test -p xcl --lib -- --test-threads=4` (with DXC): 659 passed, 3 failed, 21 ignored on this branch plus the PR below; on `main` the same run gives 657 passed and the same 3 failures: `title_textures::placed_title_textures_share_vram_and_preserve_pixels`, `title_textures::transitions_apply_when_their_list_is_submitted`, `vram::d32s8_targets_take_their_own_size_of_video_memory`. They pass when `hle::d3d12x` runs alone, so they look like GPU contention on this 4 GB card, not a change of mine. **Regression run** None: I have no title for `scripts/smoke.ps1`. This changes `crates/xcl/src`, so the two `xcl-smoke` blocks have to come from someone with a title. main: not run PR: not run **Not tested** - the retail title and `scripts/smoke.ps1`; wave64 (this GPU has none); AMD; MSVC; the rest of the workspace (e2e, integration tests) on this branch - the 1 200-program random run from #701: its fuzz tests are in a branch of #172, not in `main` **AI use** - Claude Code (Claude Sonnet 5.5) wrote the program, the test and the fix and ran the tests; the diagnosis of the two shapes is from #701.
In the first structured form, a conditional jump inside the if branch of an
if / else to the start of the else branch ended at the end of the if branch
(`hi`), so it was taken for a skip over the rest of the branch: an if with no
else, whose body included the s_branch over the else. The jump then fell into
the code after the else and the else branch never ran. In an if branch with an
else (exit set), a jump to `hi` is raised as a skip flag instead; the if / else
is then rejected as before and the else runs under the flag.

The test runs the program on the GPU in the structured form and in the pc chain.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:30:43 +00:00
github-bot closed this pull request 2026-11-26 04:30:43 +00:00
Author
Owner

@⁠LocranKing on GitHub · 2026-11-24 04:46 UTC · original

Tested on Windows 11 + NVIDIA GeForce RTX 3060 Ti (8 GB, wave32).

Tested

  • Commit: cff9cf70ce8d1c727402212d13102c6ec9b321e1 (pr-728, clean tree)
  • Hardware / software: Windows 11 Home Build 26200, AMD Ryzen 5 5500, 31.8 GB RAM, NVIDIA GeForce RTX 3060 Ti (8024 MiB VRAM, driver 32.0.16.2101), rustc 1.100.0 (x86_64-pc-windows-msvc, MSVC 14.44.35207), DXC 1.9.2602.17 (SDK 10.0.26100.0), --release
  • cargo test --workspace --release --no-fail-fast -- --test-threads=4: 686 passed, 0 failed, 41 ignored, exit 0; 2 (no wave64) skipped (gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware)

Regression run (scripts/smoke.ps1, 60 s, XCL_NETWORK=0, title folder name redacted)

main (64b3f35):

xcl-smoke v1
commit: 64b3f35599bb7102f55d640e1a791e7d6dd3b175
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 544 (PresentX 545)
presents per 2 s (last 3): 22 22 21
device removals: 0
crashes: 0
peak commit: 15491 MB

PR #728 (cff9cf7):

xcl-smoke v1
commit: cff9cf70ce8d1c727402212d13102c6ec9b321e1
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1522 (PresentX 1522)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14745 MB

Not tested: Debug build, XCL_SAMPLE_RPF / shader corpus tests on this branch, AMD / wave64 hardware.

AI use: Antigravity (Gemini 4 Hydrogen) ran the build, tests, and smoke runs and drafted this report from the command outputs.

**@⁠LocranKing** on GitHub · 2026-11-24 04:46 UTC · [original](https://github.com/xcl-dev/xcl/pull/728#issuecomment-7122333918) Tested on Windows 11 + NVIDIA GeForce RTX 3060 Ti (8 GB, wave32). **Tested** - Commit: `cff9cf70ce8d1c727402212d13102c6ec9b321e1` (`pr-728`, clean tree) - Hardware / software: Windows 11 Home Build 26200, AMD Ryzen 5 5500, 31.8 GB RAM, NVIDIA GeForce RTX 3060 Ti (`8024 MiB VRAM`, driver `32.0.16.2101`), `rustc 1.100.0` (`x86_64-pc-windows-msvc`, MSVC `14.44.35207`), DXC `1.9.2602.17` (SDK `10.0.26100.0`), `--release` - `cargo test --workspace --release --no-fail-fast -- --test-threads=4`: **686 passed, 0 failed, 41 ignored**, exit `0`; `2 (no wave64)` skipped (`gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`) **Regression run** (`scripts/smoke.ps1`, 60 s, `XCL_NETWORK=0`, title folder name redacted) main (`64b3f35`): ``` xcl-smoke v1 commit: 64b3f35599bb7102f55d640e1a791e7d6dd3b175 gpu: NVIDIA GeForce RTX 3060 Ti title: retail-1.0.2.1 seconds: 60 exit: 0x0 frames shown: 544 (PresentX 545) presents per 2 s (last 3): 22 22 21 device removals: 0 crashes: 0 peak commit: 15491 MB ``` PR #728 (`cff9cf7`): ``` xcl-smoke v1 commit: cff9cf70ce8d1c727402212d13102c6ec9b321e1 gpu: NVIDIA GeForce RTX 3060 Ti title: retail-1.0.2.1 seconds: 60 exit: 0x0 frames shown: 1522 (PresentX 1522) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14745 MB ``` **Not tested:** Debug build, `XCL_SAMPLE_RPF` / shader corpus tests on this branch, AMD / wave64 hardware. **AI use:** Antigravity (`Gemini 4 Hydrogen`) ran the build, tests, and smoke runs and drafted this report from the command outputs.
Author
Owner

@⁠ItsMrDubey on GitHub · 2026-11-24 04:57 UTC · original

Test report for cff9cf70ce8d1c727402212d13102c6ec9b321e1 (this PR's head)

Tested

  • NVIDIA GeForce RTX 4070 Ti 12 GB (Ada), driver 617.14; Intel Core i9-10900K, 32 GB RAM; Windows 11 Pro build 26300
  • Rust 1.88.0 (stable-x86_64-pc-windows-msvc), debug; DXC 1.9.2602.17 from Windows SDK 10.0.26100
cargo build --workspace
cargo test --workspace --no-fail-fast -- --test-threads=4

16 test binaries: 685 passed, 1 failed, 41 ignored. Same machine, main 64b3f3559: 700 passed, 1 failed, 41 ignored.

This PR's tests:

  • gpu::recomp::tests::gpu_a_jump_from_the_if_branch_to_the_else_branch_runs_it: ok

Failures:

  • hle::kernelx::tests::xmem_virtual_query_marks_cpu_readable_memory fails on this machine on every run, on this PR's head and on main 64b3f3559 alike (5 of 5 reruns on main), so it is not from this PR. #650 fixes it here.

16 test binaries instead of main's 17 because this branch predates tests/sparse_reinit.rs; nothing crashed.

SKIPPED (no wave64 on this GPU): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.

AI use: Claude Code (Claude Opus 5.5) ran the builds and tests and wrote this report from their output.

**@⁠ItsMrDubey** on GitHub · 2026-11-24 04:57 UTC · [original](https://github.com/xcl-dev/xcl/pull/728#issuecomment-7122492756) Test report for `cff9cf70ce8d1c727402212d13102c6ec9b321e1` (this PR's head) **Tested** - NVIDIA GeForce RTX 4070 Ti 12 GB (Ada), driver 617.14; Intel Core i9-10900K, 32 GB RAM; Windows 11 Pro build 26300 - Rust 1.88.0 (`stable-x86_64-pc-windows-msvc`), debug; DXC 1.9.2602.17 from Windows SDK 10.0.26100 ``` cargo build --workspace cargo test --workspace --no-fail-fast -- --test-threads=4 ``` 16 test binaries: **685 passed, 1 failed, 41 ignored**. Same machine, `main` `64b3f3559`: 700 passed, 1 failed, 41 ignored. This PR's tests: - `gpu::recomp::tests::gpu_a_jump_from_the_if_branch_to_the_else_branch_runs_it`: ok Failures: - `hle::kernelx::tests::xmem_virtual_query_marks_cpu_readable_memory` fails on this machine on every run, on this PR's head and on `main` `64b3f3559` alike (5 of 5 reruns on `main`), so it is not from this PR. #650 fixes it here. 16 test binaries instead of `main`'s 17 because this branch predates `tests/sparse_reinit.rs`; nothing crashed. SKIPPED (no wave64 on this GPU): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. AI use: Claude Code (Claude Opus 5.5) ran the builds and tests and wrote this report from their output.
Author
Owner

@⁠QemmHD on GitHub · 2026-11-24 05:03 UTC · original · edited 2026-11-24 05:04 UTC

Verified with the CPU-reference harness from #701, ported to main + #728 + #729: QemmHD/xcl review/701-fixes (fed3380, test-only). RTX 4070 SUPER (621.24), DXC 1.8.2502.11, main 64b3f35.

variant random first-form programs that walk wrong (CPU, 20 000 seeds) GPU mismatches (600 wave32 + 600 split wave64)
main 513 / 4 785 14 / 1 200
#728 only 427 / 4 789 12
#729 only 116 / 4 785 4
both 7 / 4 789 2

With both PRs, both #701 tests and both of your tests pass, and the full suite gives 715 passed, 0 failed, 41 ignored (main: 701 / 0 / 41; +14 = the 2 PR tests and 12 ported harness tests). No program that walked right on main goes wrong with both.

  1. Please merge them together. #728 alone breaks 4 random programs that were right on main (seeds 2310, 10091, 19167, 19176: e.g. 2310 moves from the pc chain into the first form and is wrong without #729). All 4 are right with both.
  2. The same bug one level down. All 7 leftovers are one shape: an if/else inside an outer if branch, whose s_branch over its own else lands on the start of the outer else. else_end accepts u == hi, so the jump is emitted as nothing and the outer else is skipped (s10 = s11 = 0: s3 comes out 0 instead of 1, in both forms). Test: first_form_runs_the_else_a_nested_jump_lands_in (should_panic until fixed), with gpu_nested_jump_into_else_in_each_form on the GPU. Adding && !(u == hi && exit.is_some()) to the else_end filter in item_at's If arm (mod.rs:701 on #729) takes it to 0 / 4 789 on the CPU and 0 / 1 200 on the GPU, with your tests still passing.

AI-assisted (Claude Code, Claude Opus 5.5).
Discord: bigpeppa.

**@⁠QemmHD** on GitHub · 2026-11-24 05:03 UTC · [original](https://github.com/xcl-dev/xcl/pull/728#issuecomment-7122579717) · edited 2026-11-24 05:04 UTC Verified with the CPU-reference harness from #701, ported to `main` + #728 + #729: [QemmHD/xcl `review/701-fixes`](https://github.com/QemmHD/xcl/tree/review/701-fixes) (`fed3380`, test-only). RTX 4070 SUPER (621.24), DXC 1.8.2502.11, main `64b3f35`. | variant | random first-form programs that walk wrong (CPU, 20 000 seeds) | GPU mismatches (600 wave32 + 600 split wave64) | |---|---|---| | main | 513 / 4 785 | 14 / 1 200 | | #728 only | 427 / 4 789 | 12 | | #729 only | 116 / 4 785 | 4 | | both | **7 / 4 789** | **2** | With both PRs, both #701 tests and both of your tests pass, and the full suite gives 715 passed, 0 failed, 41 ignored (main: 701 / 0 / 41; +14 = the 2 PR tests and 12 ported harness tests). No program that walked right on `main` goes wrong with both. 1. **Please merge them together.** #728 alone breaks 4 random programs that were right on `main` (seeds 2310, 10091, 19167, 19176: e.g. 2310 moves from the `pc` chain into the first form and is wrong without #729). All 4 are right with both. 2. **The same bug one level down.** All 7 leftovers are one shape: an if/else inside an outer `if` branch, whose `s_branch` over its own else lands on the start of the *outer* else. `else_end` accepts `u == hi`, so the jump is emitted as nothing and the outer else is skipped (s10 = s11 = 0: s3 comes out 0 instead of 1, in both forms). Test: `first_form_runs_the_else_a_nested_jump_lands_in` (`should_panic` until fixed), with `gpu_nested_jump_into_else_in_each_form` on the GPU. Adding `&& !(u == hi && exit.is_some())` to the `else_end` filter in `item_at`'s `If` arm (`mod.rs:701` on #729) takes it to 0 / 4 789 on the CPU and 0 / 1 200 on the GPU, with your tests still passing. AI-assisted (Claude Code, Claude Opus 5.5). Discord: bigpeppa.
Author
Owner

@⁠raylitebull on GitHub · 2026-11-24 10:44 UTC · original

Closing as a duplicate of #765 for #701, which passes the PR description check (whereas this PR fails PR description).

**@⁠raylitebull** on GitHub · 2026-11-24 10:44 UTC · [original](https://github.com/xcl-dev/xcl/pull/728#issuecomment-7129178627) Closing as a duplicate of #765 for #701, which passes the `PR description` check (whereas this PR fails `PR description`).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.