Recompiler: the first structured form runs code a taken jump skips, and skips an else it jumps into #696

Open
opened 2026-11-24 03:48:01 +00:00 by QemmHD · 2 comments
QemmHD commented 2026-11-24 03:48:01 +00:00 (Migrated from github.com)
Contributor

Imported from ivall/xcl. Originally posted by QemmHD on 2026-11-24T03:48:01Z.


Two shapes that the first structured form (emit_structured / structured_span, used for single-entry stretches when the general structurizer isn't on) translates wrongly on main (checked at dd2ae9a). Found while reviewing #172; neither comes from #172, and #172's general form gets both right.

1. A jump to a target whose skip flag is already pending leaves the open guard in place (gpu/recomp/mod.rs:924)
The jump doesn't close the open if (!(xcl_skip_…)), so the items after it still run. Shape: a loop with two exits to the same block, plus an if before the latch (two_breaks_program with s11 = 2).
s0..s4 expected [1,1,0,1,0]; the pc chain path (Options { structured: false }) and the default path give [1,1,1,1,1].

2. A jump from the if branch to the start of the else branch is treated as a skip to the end of the if branch (gpu/recomp/mod.rs:693, item_at)
The else branch never runs. Expected [1,1,0,1,1], got [1,1,0,0,1].

Both reproduce on the GPU (RTX 4070 SUPER, NVIDIA 621.24, wave32) and against a CPU reference run. In a random run of 1 200 small programs (600 wave32, 600 split wave64), the pc chain and the default path differed from the CPU reference in 13; the general form of #172 in none.

Tests (test-only commit 6e9c949, branch https://github.com/QemmHD/xcl/tree/review/172-structure, crates/xcl/src/gpu/recomp/tests/structure_fuzz.rs):

  • first_form_runs_code_a_taken_jump_skips and first_form_skips_the_else_branch_it_jumps_into: CPU, #[should_panic] until fixed;
  • gpu_first_form_counter_examples_are_right_in_the_general_form: both shapes on the GPU, in every form.

Since Options { structured: false } still goes through this form for single-entry stretches, it also affects #172's own GPU test, which uses that path as its reference.

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

<!-- greyfinch-sync:ivall/xcl:issue:6574164669 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/701). Originally posted by [QemmHD](https://github.com/QemmHD) on 2026-11-24T03:48:01Z. --- Two shapes that the first structured form (`emit_structured` / `structured_span`, used for single-entry stretches when the general structurizer isn't on) translates wrongly on `main` (checked at `dd2ae9a`). Found while reviewing #172; neither comes from #172, and #172's general form gets both right. **1. A jump to a target whose skip flag is already pending leaves the open guard in place** (`gpu/recomp/mod.rs:924`) The jump doesn't close the open `if (!(xcl_skip_…))`, so the items after it still run. Shape: a loop with two exits to the same block, plus an `if` before the latch (`two_breaks_program` with s11 = 2). s0..s4 expected `[1,1,0,1,0]`; the `pc` chain path (`Options { structured: false }`) and the default path give `[1,1,1,1,1]`. **2. A jump from the if branch to the start of the else branch is treated as a skip to the end of the if branch** (`gpu/recomp/mod.rs:693`, `item_at`) The else branch never runs. Expected `[1,1,0,1,1]`, got `[1,1,0,0,1]`. Both reproduce on the GPU (RTX 4070 SUPER, NVIDIA 621.24, wave32) and against a CPU reference run. In a random run of 1 200 small programs (600 wave32, 600 split wave64), the `pc` chain and the default path differed from the CPU reference in 13; the general form of #172 in none. Tests (test-only commit `6e9c949`, branch https://github.com/QemmHD/xcl/tree/review/172-structure, `crates/xcl/src/gpu/recomp/tests/structure_fuzz.rs`): - `first_form_runs_code_a_taken_jump_skips` and `first_form_skips_the_else_branch_it_jumps_into`: CPU, `#[should_panic]` until fixed; - `gpu_first_form_counter_examples_are_right_in_the_general_form`: both shapes on the GPU, in every form. Since `Options { structured: false }` still goes through this form for single-entry stretches, it also affects #172's own GPU test, which uses that path as its reference. AI-assisted (Claude Code, Claude Opus 5.5). Discord: bigpeppa.
towiice commented 2026-11-24 07:06:09 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ivall/xcl. Originally posted by towiice on 2026-11-24T04:11:23Z.


Both shapes reproduced on a GTX 1650 SUPER (wave32, DXC 1.9) and fixed in two draft PRs: #728 (shape 2, the jump into the else branch) and #729 (shape 1, stacked on #728 for the test helper). Both wait for xcl-smoke runs from someone with a title. Claude Code (Claude Sonnet 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7121789084 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/issues/701#issuecomment-7121789084). Originally posted by [towiice](https://github.com/towiice) on 2026-11-24T04:11:23Z. --- Both shapes reproduced on a GTX 1650 SUPER (wave32, DXC 1.9) and fixed in two draft PRs: #728 (shape 2, the jump into the else branch) and #729 (shape 1, stacked on #728 for the test helper). Both wait for `xcl-smoke` runs from someone with a title. Claude Code (Claude Sonnet 5.5).
NathanTheophile commented 2026-11-24 07:06:56 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ivall/xcl. Originally posted by NathanTheophile on 2026-11-24T07:02:36Z.


On Windows with an RTX 4060 Laptop GPU, the same synthetic regression passed 18/24 register comparisons on main (beaa245), 24/24 on #721 (1b4a140) and #765 (4cfd951), 20/24 on #728 (cff9cf7), and 22/24 on #729 (4255402). The nested else jump still failed on #729. All PR-owned tests passed.

I’d keep #765 as the candidate. cargo test --workspace --no-fail-fast -- --test-threads=4 reported 704 passed, 0 failed, 41 ignored, and two wave64 capability skips. Its description check passed. Required CI and maintainer validation still apply. The local comparison used synthetic fixtures only.

AI use

  • Codex (GPT-6) wrote and ran the shared test and assisted with the comparison.
<!-- greyfinch-sync:ivall/xcl:comment:7124552992 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/issues/701#issuecomment-7124552992). Originally posted by [NathanTheophile](https://github.com/NathanTheophile) on 2026-11-24T07:02:36Z. --- On Windows with an RTX 4060 Laptop GPU, the same synthetic regression passed 18/24 register comparisons on main (`beaa245`), 24/24 on #721 (`1b4a140`) and #765 (`4cfd951`), 20/24 on #728 (`cff9cf7`), and 22/24 on #729 (`4255402`). The nested else jump still failed on #729. All PR-owned tests passed. I’d keep #765 as the candidate. `cargo test --workspace --no-fail-fast -- --test-threads=4` reported 704 passed, 0 failed, 41 ignored, and two wave64 capability skips. Its description check passed. Required CI and maintainer validation still apply. The local comparison used synthetic fixtures only. **AI use** - Codex (GPT-6) wrote and ran the shared test and assisted with the comparison.
Sign in to join this conversation.
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#696
No description provided.