Recompiler: close four wave64-on-wave32 partition classifier soundness holes #2112
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2122"
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 Decodere on 2026-11-25T05:13:42Z.
What is in it
Closes four soundness holes in the wave64-on-wave32 partition classifier (
crates/xcl/src/gpu/recomp/partition.rs) where cut-dependent shaders were misclassified asTier::Exact:SRC2handling (uses(),source_taint(),step()):u.lane_maskinstep()soV_CNDMASK_B32/V_ADD_CO_CI_U32/V_SUB_CO_CI_U32/V_SUBREV_CO_CI_U32no longer dropLANE_ID/ mask taint from their mask operand.SRC2presence inuses(): decodes valid SGPR pairs includingEXEC(126), excludesM0(124) /NULL(125) / constants instead of mis-mapping them toVCC, and falls back to[VCC, VCC + 1]only for VOP2 forms withoutSRC2.MASK_DATAinsource_taint()unlessSRC2is0/-1/null(125 | 128 | 193) or a trackedst.lanesSGPR pair (or trackedVCCfor VOP2).WREXEClane-set check (source_taint()): Includesn.contains("WREXEC")alongsideSAVEEXECin the bitwise lane-set check (and treats125nullas a zero lane set), catchingS_ANDN1_WREXEC_B64/S_ANDN2_WREXEC_B64with non-lane operands asmask-data.EXECwrites (step()): Computeslane_src/lanes_made(including checkingSDSTforS_CMOV_B*) before thewrites_execsink check, flagging any non-lane write toEXEC(e.g.S_MOV_B64 exec, s[0:1]wheres[0:1]holds a number,S_CSELECT_B64 exec, 1, 0,S_CMOV_B64 exec, 1,S_NOT_B64 exec, 1) and single-wordEXECwrites withMASK_DATA(both recording"mask-data"and taintingEXEC).SAVEEXEC& non-maskS_ANDN2*uniformity (step()): Replaces|| n.contains("SAVEEXEC")inkeeps_uniformwith an explicit allowlist of non-complement ops (excludingS_NOR/S_NAND/S_XNOR/S_ORN1/S_ORN2/S_XOR_SAVEEXEC_B64), and requiresS_ANDN2_*SSRC0to be zero (125 | 128) or a tracked mask SGPR pair (st.mask[s] && st.mask[s + 1]) rather than-1or a non-mask SGPR.gpu::recomp::partition::tests.Part of #336
Tested
Environment: Windows 11 Home 26200, Intel Core i5-11400F, 32 GB RAM, NVIDIA GeForce RTX 4060 8 GB (driver 621.14, wave32), Rust 1.100.0, DXC
1.9.2609.5(01b62ad4).cargo test -j 4 -p xcl --lib gpu::recomp::partition::tests -- --nocapture): 44 passed, 4 failed — all 4 new counter-example tests (lane_mask_taint_and_non_lane_selectors_are_caught,wrexec_with_non_lane_operand_is_mask_data,non_lane_exec_writes_are_mask_data,complement_saveexec_and_andn2_with_non_mask_are_not_uniform) returned[](Tier::Exact) pre-fix.cargo test --release -p xcl --lib gpu::recomp::partition::tests -- --nocapture): 48 passed, 0 failed (pure CPU unit tests, CI WARP-safe).cargo build --release --workspaceandcargo test --release --workspace -- --test-threads=4 --nocapture): 1,158 passed, 0 failed, 46 ignored across 21 test binaries (1102inxcllib,56across the remaining 20 binaries), with 27SKIPPEDlines on this RTX 4060:no wave64(RTX 4060 is wave32-only)per-lane form: refused(wave32 f16 arithmetic, f16 packed, f32 conversions)no d3d12SDKLayers.dll/no D3D12 debug layercannot disable the driver cache(Windows Developer Mode not enabled)no heap windowsRegression run
Paired 60 s runs via
scripts/smoke.ps1on cleanorigin/main(f5c5bdf0) and clean PR head (ddcda018):Main (
f5c5bdf0e91035f8f1404f46f4f2f7aedc259e7f):PR (
ddcda0184c4fb347a1546f9c61be127c70795713):Not tested
no wave64skips on RTX 4060), D3D12 debug layer tests (2 skips withoutd3d12SDKLayers.dll), driver cache disable toggle (1 skip without Windows Developer Mode), and heap-window OOM fallback (1 skip withoutXCL_HEAP_WINDOWS).title: 29640639, andpartition::classifyis classification-only (not yet wired into runtime translation).AI use
Google Antigravity (Gemini 4 Neon) wrote the
partition.rssoundness fixes, unit tests, and this PR description. All pre-fix/post-fix unit tests, full release workspace tests, paired 60 s smoke runs, andscripts/pr_check.py --localvalidation were run locally on this machine.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T06:18:47Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: 1038 passed, 1 failed in one parallel run; the failing test passes on a single-threaded rerun (1039/0). Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.Thanks!
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-28T20:18:46Z.
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-01T07:25:19Z.
Triage (#1607) – head
ddcda01No other open PR changes
partition.rs, and main has not touched the file since this PR's base (f5c5bdf), so none of the four fixes are on main yet.No correctness problems found. The change makes the classifier more conservative: any EXEC write that is not a lane set (
lanes_made), and any v_cndmask/carry-in selector that is not a lane set, is nowmask-data, and complement SAVEEXEC forms no longer keep uniformity. More programs may leave the Exact tier, so a before/after tier count on a shader pack would show what this costs.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by Decodere on 2026-12-02T07:47:09Z.
Keeping open: still fixes the four wave64-on-wave32 partition classifier soundness holes in
crates/xcl/src/gpu/recomp/partition.rs;MERGEABLE/CLEANwith green CI and waiting for review / merge-checks. (AI note: checked with Antigravity, Gemini 4 Neon.)Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-12-02T21:01:46Z.
merge-check
base:
5ad98adbc3head:
ddcda0184cmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3009 passed, 0 failed, 52 ignored; SKIPPED: 25 (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps); failing: none
review: read the whole diff (1 file, +215 -23). No problem found in it. Two older gaps stay, see below.
st.lanes[s] = st.mask[s] || lanes_made: a mask thats_cmov_b64/s_cselect_b64may have replaced by a number still counts as a set of lanes. Withis_vcmp(d) || (is_valu(d) && n.contains("_CO_")) || lanes_made6 of the 90 are left.st.v[v] = t: a VGPR write under a narrowed EXEC drops the taint of the lanes that are off, which keep their old value. Example, Exact on main and here: v0 =v_mbcnt_lo(-1, 0),s_and_saveexecon a compare, v0 = 1.0, restore EXEC, export v0. Withif st.exec_launch { t } else { t | st.v[v] }as well, 0 of 320,000 are left and the 48partitiontests pass.partition::classifyoutside its tests yet.performance: none at run time, the classifier is not called yet.
verdict: safe to merge
hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300 / Claude Code (Claude Opus 5.5)
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.