Recompiler: invalidate SGPR state on S_MOVRELSD_2_B32 in upper_lanes #1606
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1616"
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 OtavioTadeu on 2026-11-24T18:15:41Z.
What is in it
XCL-BT-037(Part of #1488): invalidate SGPR abstract state inrecomp::upper_lanes::steponS_MOVRELSD*instructions (matchingS_MOVRELD*).movrelsd2_invalidates_sgprsunit test verifyingS_MOVRELSD_2_B32prevents stale SGPR subset assumptions across whole-wave operations.Tested
cargo test -p xcl --lib gpu::recomp::upper_lanes: 10 passed, 0 failedcargo test --workspace -- --test-threads=4: 777 passed, 0 failed, 41 ignored (SKIPPED GPU tests:gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask[no wave64],gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware[no wave64],heap_window_out_of_memory_falls_back_to_the_switch_form[no heap windows])Regression run
scripts/smoke.ps1 -Game retail_title -Seconds 60(mainbaseline vs PR head on NVIDIA GeForce GTX 1660 SUPER):Not tested
AI use
upper_lanesfix, unit test, and commit message; human reviewed.Imported from ivall/xcl. Originally posted by Anon64 on 2026-11-24T18:23:32Z.
Regression run for this PR: head
fd75fde, based onmain9e3831e. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release,XCL_NETWORK=0, A pressed every 4 s from 20 s,scripts/smoke.ps1on a retail title for 60 s, back to back with themainrun.main
9e3831e:this PR:
No device removals or crashes; 98 % of main's frames, 89 % of its peak commit.
Peak commit on this machine is mostly the pipeline preload's DXC compiles (#1035) and varies a lot from run to run, so it says little about this PR.
Not tested: the whole suite; whether the title reaches the changed code in these 60 s.
Written with Claude Code (Claude Opus 5.5) from runs on this machine.
Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T19:01:01Z.
Full-suite run, since this PR has no test report yet. Tested exact head
fd75fde(on its base9e3831e).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form: 776 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.movrelsd2_invalidates_sgprs.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 777 passed, 0 failed, 41 ignored. SKIPPED:heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).heap_window_out_of_memory_falls_back_to_the_switch_formwas skipped with--skip. It fails on main9e3831etoo, not because of this PR: underXCL_REQUIRE_GPU=mesh,runner::skip_testturns every skip except "no wave64" into a failure, including this test's opt-in "no heap windows" skip (XCL_HEAP_WINDOWSunset). Reported as #1651.Not tested
AI use
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T20:37:45Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored.Thanks!
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-28T08:00:11Z.
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 BBareth on 2026-11-30T19:20:40Z.
merge-check claim
head:
fd75fde65eImported from ivall/xcl. Originally posted by BBareth on 2026-11-30T19:40:35Z.
merge-check
base:
ff0c364b3dhead:
fd75fde65emerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2890 passed, 0 failed, 51 ignored; 28 SKIPPED lines, as on the base; failing: none. The base alone, run in the same batch: 2888 passed, 1 failed, 51 ignored, 28 SKIPPED lines; its one failure,
hle::d3d12x::pso_async::used_tests::emission_resolves_the_retained_recipe_after_title_address_reuse, passed in this merged run and in the six others of the batch, so it is intermittent on the base and not this PR's. The new testmovrelsd2_invalidates_sgprspassed.review: no blocking finding; one file, every hunk read.
upper_lanes::steptreated onlyS_MOVRELD*as a write to an SGPR chosen by M0;S_MOVRELSD_2_B32writess[dst + m0]too, so the analysis kept stale knowledge of the SGPRs across it. It now forgets them the same way (s125 stays zero as before). The change can only make the analysis more conservative: a read it used to call a known constant becomes unknown. The test builds exactly that case and expectsRead::Unknown.performance: none at run time; at translation, a program with S_MOVRELSD_2_B32 may lose an upper-lane shortcut it was given wrongly.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 621.24 (32.0.16.2124); i7-12700K; Windows 11 26200. Claude Code, Claude Fable 5.2 read the diff, ran the build and the suite and wrote this check.
Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-30T19:50:48Z.
merge-check claim
head:
fd75fde65eImported from ivall/xcl. Originally posted by saintwolf on 2026-11-30T19:57:33Z.
merge-check
base:
ff0c364b3dhead:
fd75fde65emerge: clean (trial merge 4fc8c093ef139f578aef77e2ee2a8635586661f1; git diff --check clean; +8/-1 in crates/xcl/src/gpu/recomp/upper_lanes.rs)
build: cargo build --workspace -> ok (39 lib + 19 test warnings, all pre-existing; none from the changed lines)
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2890 passed, 0 failed, 51 ignored (base
ff0c364bis 2889 + 1 new test). SKIPPED: 27, the standard set for this card. The new movrelsd2_invalidates_sgprs passes in the targeted upper_lanes run (12/12, including all 11 pre-existing tests of the module) and inside the full suite. I also ran the same test on the base with only the test added (no fix): it failed there with left: [Const(4294967295)] right: [Unknown] - the stale u32::MAX constant knowledge surviving across S_MOVRELSD_2_B32 - and passes with the fix.review: no blocking finding; one file, every hunk read. The fix: upper_lanes::step (upper_lanes.rs:549) treated only S_MOVRELD* as a write to an M0-chosen SGPR, but S_MOVRELSD_2_B32 (rdna2_spec.rs:612, opcode 73 - the only S_MOVRELSD variant in the spec) also writes an SGPR at an M0-dependent offset: the HLSL path's smovrel (emit.rs:1752-1797) emits the write as s[dst + ((m0 >> 16) & 0x3FF)], i.e. any of s[dst..dst+113]. Before the fix the instruction fell into the generic SALU handling, which forgets only its literal SDST, so the wave64-on-wave32 upper-lane analysis (this module: what lanes 32..63 hold on 32-lane hardware) kept stale constant knowledge of the other SGPRs across it - e.g. a mask register a whole-wave reduction later reads could have been overwritten by the relative move. The added arm applies the same forget-everything treatment as S_MOVRELD* (all SGPRs to Word::Any, s125/M0 stays Zero, EXEC's upper word preserved from before the instruction, as that arm already does); it can only make the analysis more conservative (a read it called a known constant becomes unknown), never the other way. I verified the test builds the case it claims: it seeds a known mask into s10 (WWM saves EXEC, MASK = s18 & saved-exec), then S_MOVRELSD_2_B32 s10, s20 - which can write s10 itself (offset 0) as well as every higher SGPR up to s123 - before the reduction (SEED + X1) that the analysis used to follow through to Read::Const(u32::MAX) (the adjacent test at upper_lanes.rs:873 asserts exactly that constant for the same sequence without the MOVRELSD); with the fix the read of lane 32 (READ32) must be Read::Unknown, and V55 is in the chain so the Unknown answer hinges on the mask analysis rather than on v55 being unwritten. I also ran the new test against the base with only the test added (no fix): it FAILs there and passes with the fix, so it fails without the fix. Dupe: #1607 group D46 is #1616 + #1726 (closed), so this is the surviving open member. Same-file sibling: open #2136 (Decodere, +124/-10 in upper_lanes.rs, MERGEABLE) fixes different instructions (NULL dest, B32 SAVEEXEC, MIMG TFE/LWE) in the same file; both land in some order and the later one rebases. Related: open #1823 adds direct-DXIL-vs-HLSL parity tests covering the movrel family. Thread: Anon64's retail smoke (RTX 3060, 60 s, main vs head back to back: 1587 vs 1551 frames shown, 0 crashes, 0 device removals, 98 % of main's frames - within smoke noise), futurepro62's full suite on exact head (RTX 5070 Ti: 776/0/41; AMD iGPU: 777/0/41, new test passed on both, on the older base
9e3831e), DavidM1911's lib all-pass on an RTX 3060 Ti with the branch merged into current main, and BBareth's safe check (2890/0/51 on this head, with the intermittent base flake emission_resolves_the_retained_recipe_after_title_address_reuse noted - I saw the same flake in my base batch too).performance: none at run time; at translation, a program containing S_MOVRELSD_2_B32 loses upper-lane shortcuts the analysis used to grant it across that instruction - the shortcuts were unsound, so this removes wrong fast paths, not right ones.
verdict: safe to merge
hardware / tool and model: RTX 4070 SUPER (driver 32.0.16.2140), Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 / OpenCode, Qwen 3.8 27B
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:17:50Z.
Triage (#1607) – head
fd75fde#1726 made the same change to
upper_lanes::stepand was closed in favour of this PR. Main still has onlyS_MOVRELDthere, so the fix is not merged.Problem in the test:
movrelsd2_invalidates_sgprsputs SDST = 10, the mask register SEED reads. Without the fix, the genericsgpr_outputspath already marks s10 asAnyfor the unhandled SOP1, so the read is alreadyUnknownand the test passes on main. A destination the SDST field does not name, as in #1726's test (SDST 10 withm0 = 0x10000writing s11), would exercise the fix. Note also that the destination offset isM0[25:16].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.