Recompiler: preserve control flow across structured jumps #760
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/765"
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?
Imported from ivall/xcl. Originally posted by Abuudiii on 2026-11-24T04:51:39Z.
Fixes #701 in the legacy structured emitter. Reopen a skip guard when a later branch can set it and preserve actual jumps into the else arm.
What is in it
Tested
f4ce27cand pass with this patch. Exact SGPR results passed on RX 9070 under GE-Proton11-7 / vkd3d-proton 3.1 / DXC 1.9.2609.5: 2 CPU tests and 1 GPU test, no skips.cargo test --workspace --no-fail-fast -- --test-threads=1: 704 passed, 0 failed, 41 ignored; the two wave64 tests skipped (gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware). All three PR regressions ran and passed.64b3f35:cargo test --workspace -- --test-threads=4: 704 passed, 0 failed, 41 ignored, no GPU skips.Regression run
Native Windows runs reported by @ryosen0.
Not tested
AI use
Imported from ivall/xcl. Originally posted by JoaoPauluu on 2026-11-24T04:54:29Z.
Test report: #765 on NVIDIA under Wine + vkd3d-proton (Linux)
This complements the RX 9070 run in the description with a 32-lane NVIDIA GPU, through the same kind of stack (Wine, vkd3d-proton 3.1, DXC 1.9.2609.5).
Setup
experimental-11.0-20261112(wine-11.0), vkd3d-proton v3.1 (4522cc1a) + the patch from #257, DXVK from Proton, DXC 1.9.2609.5,DXVK_CONFIG="dxgi.hideNvidiaGpu = False"x86_64-pc-windows-gnu(mingw-w64-gcc 16.2.0), debug build of this PR's head4cfd951Results (lib test binary under Wine,
--test-threads=1)structured_: 3 passed, 0 failed, 0 ignored, in 2 of 2 runs:gpu_structured_branch_targets_match_rdna2(ran, not skipped),structured_jump_into_else_preserves_target,structured_repeated_loop_exit_rechecks_guardgpu::recomp,--skip gpu_more_atomics_sub_dword_scratch_valu(that test hangs NVIDIA under vkd3d-proton, dxil-spirv#372 / #175): 185 passed, 0 failed, 18 ignored.SKIPPED:gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64)Not tested
AI use: Claude Code (Claude Opus 5.5) built the tests, ran them on the machine above and wrote this report. The counts are pasted from those runs. The account owner asked for test reports to be posted while they were away and has not reviewed this one.
Imported from ivall/xcl. Originally posted by eizispark on 2026-11-24T05:01:05Z.
Hardware check of
4cfd95109706b8c95e80efe3a20469df9378bbd8(verified clean merge withmain64b3f35): pass.Tested
rustc 1.100.0 (0ef1bc386 2026-11-09), release + test profilecargo test --workspace -- --test-threads=4:704 passed, 0 failed, 41 ignored(GPU tests skipped on this adapter:none)gpu::recomp::tests(gpu_structured_branch_targets_match_rdna2,structured_jump_into_else_preserves_target,structured_repeated_loop_exit_rechecks_guard):3 passed, 0 failedRegression run
main(f4ce27c):PR (
4cfd951):Not tested
AI use
scripts/smoke.ps1harness on this machine and formatted this report.Imported from ivall/xcl. Originally posted by ryosen0 on 2026-11-24T05:10:54Z.
Native Windows cross-check for
4cfd951(RTX 3060 Ti 8 GB, wave32, Ryzen 7 9800X3D, driver 32.0.16.1742, Windows 11), covering the two gaps in Not tested:Native Windows GPU suite —
cargo test --workspace --no-fail-fast -- --test-threads=1: 704 passed, 0 failed, 41 ignored, exit 0. 2 GPU SKIPPED (gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware— no wave64 on this adapter); your two emitter regressions and the register-readback test pass natively.Paired retail smoke — same title, same duration, release builds, no uncommitted changes; both blocks verbatim.
Main (
f4ce27c, this PR's merge-base):Head (
4cfd951):Both steady 60 presents / 2 s, no device removal — a no-regression check on the retail boot/menus path, not a repro of #701's shader (that stays covered by your synthetic regressions).
AI use: GPT-6.2 Astra (API model selector) in DSH ran the suite and both smokes and drafted this comment; the human contributor reviewed the numbers before posting.
Imported from ivall/xcl. Originally posted by ethandepstein-del on 2026-11-24T05:14:03Z.
Independent native Windows NVIDIA RTX 5080 build/test run and code review at head
4cfd95109706b8c95e80efe3a20469df9378bbd8.Code Review
#701cases in the legacy structured emitter:else_okscansc.edgesdirectly (binary-searched by instruction-orderedsrc) to reject any branch from[end, t)targeting[t, u), catching nested conditionals totthatstructurable_topreviously swallowed as an innerif.emit_structuredclosesguardwhenever!g.is_disjoint(&raised)so a subsequent branch raising the same skip flag re-opens a fresh guard check before the following block.structured = trueandfalsemodes.Tested
617.42/32.0.16.1742), Windows 11 Pro 25H2 (26200.9974),rustc 1.100.0 (0ef1bc386 2026-11-09), DXC from Windows SDK10.0.26100.0, debug build.cargo build --workspace && cargo test --workspace -- --test-threads=4ok):gpu::recomp::tests::structured_repeated_loop_exit_rechecks_guardgpu::recomp::tests::structured_jump_into_else_preserves_targetgpu::recomp::tests::gpu_structured_branch_targets_match_rdna2(executed on RTX 5080, not skipped)gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask(no wave64)gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware(no wave64)Not tested
d3d12SDKLayers.dllnot installed on this host), AMD/wave64 hardware, release build, and retail titles.AI use: Antigravity (Gemini 4 Neon) performed the code review, ran the RTX 5080 workspace tests, and drafted this comment.
Imported from ivall/xcl. Originally posted by NathanTheophile on 2026-11-24T07:00:26Z.
A random-program check of
4cfd951with @QemmHD's #701 harness (structure_fuzz.rsfrom6e9c949). It's adapted to run without #172: on each tree it compares only main's two forms, the default path and thepcchain, against the harness's CPU reference. The same harness ran onmainand on the other #701 PRs, each with its own build directory.mainbeaa2454cfd9511b4a1404255402(with #728)On #729, seeds 431 and 3252 also give wrong SGPRs on the GPU with 16 inputs each, and identical ones on
main, so they are real miscompiles. This matches @QemmHD's leftovers on #728. On #765 and #721, those seeds are right.Tested: NVIDIA GeForce RTX 4060 Laptop GPU (driver 616.87, 32-lane waves, so wave64 runs split), Windows 11 26200, Rust 1.100.0 MSVC, DXC 1.8.2502.11, debug. Not tested: AMD / native wave64; the harness's general-form (#172) checks, which this adaptation drops.
AI-assisted: Claude Code, Claude Opus 5.5.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-24T22:49:32Z.
Independent confirmation of this fix on current
main, from a different shape of the same bug: two conditional branches whose targets share the start of an else arm.Tested
main689f2db: all 32 words store 9. The structured emitter nests the two conditions and skips the else arm, so the expected 13 is never written.689f2db(a local rebase; the one conflict was inrecomp/mod.rs, next tomain's separate pending-flag fix): all three branch outcomes give the expected values (13, 13, 11).305bbb77ddc3ff2d,6e3fd903765f4376,bf82bfb95451bef8,c3ae68197a76d57f,d3c6619783fb3e57,ee2e847c35bba72c,fbf59c380949b267.else_okedge rejection, all 7 pass a per-lane control-trace comparison against the guest branches; without it, all 7 fail.6e3fd903was built and bound. We have no per-dispatch trace, so whether the title takes the wrong arm with real inputs is not shown.Not tested
The rebased head and a second regression test (a compute dispatch with two branches to the else arm) are ready on our side. We can't push them to a fork just now, because our token lacks the
workflowscope thatmain's newstale.ymlrequires. @Abuudiii, if you rebase ontomain, the conflict is a few lines inrecomp/mod.rs.AI use: Claude Code (Claude Opus 5.5) and Codex helpers ran the check and the GPU tests on our machine; Claude Code wrote this.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-24T22:56:52Z.
Follow-up to the check above:
cargo test --workspace(debug) on689f2dbwith this PR rebased plus the extra regression test: 979 passed, 0 failed, 45 ignored. The 22 skip notices are 18 native-wave64, 3 unsupported f16 variants and 1 heap windows. The two-branches-to-the-else GPU test ran without a skip. Still not tested: AMD and a smoke pair.AI use: a Codex helper ran the suite on our machine; Claude Code wrote this.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-24T23:03:34Z.
@Abuudiii the rebase I mentioned above is now on a branch you can pull:
Kalmarv:shared-else-765-rebased. It'see80f924(this PR rebased ontomain689f2db, with the onerecomp/mod.rsconflict resolved) plusafc55fcd, the extra regression test (a compute dispatch with two branches into the else arm). The workspace run above was on that head. Take it, cherry-pick from it, or ignore it, whichever suits you.AI use: Claude Code (Claude Opus 5.5) did the rebase and wrote this.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T11:16:17Z.
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T07:41:39Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:05:30Z.
Triage (#1607) – head
4cfd951Partial overlap with main: commit
b8b1f49("jumps to outer loop heads and into loops are structured") already closes the open guard inemit_structuredwhen an item can raise a flag the guard has tested, which is the first half of this PR. The second half (theelse_okcheck for an edge from the if arm into the else arm, and removing thebranch from the if to the start of the elserefusal instructurable_uncached) is not on main, and #701 is still open. Earlier attempts #721, #728 and #729 were closed unmerged.The branch conflicts with main (
else_oknow takes&Conts); after a rebase the guard hunk should be dropped in favour of main's and the two tests rerun against main's code.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.