Recompiler: classify wave64 VS / PS by whether a 32-lane cut changes them (#336) #517
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!517
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/517/head"
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?
@emirduran707 on GitHub · 2026-11-24 01:12 UTC · original
emirduran707:wave64-partition→main· +1770 −2 · 4 files · 2 commits · merged 2026-11-25 00:59 UTCStacked on #341; only the top commit (
dfc5578) belongs here. Part of #336. Reworked after the reviews below (QemmHD, CuteBooty, upipibi); #528 (stale scalars) is folded in.A GPU that runs a console wave64 VS / PS in 32-lane waves runs each half of the console wave on its own.
upper_lanes(#133) follows what lanes ≥ 32 hold when they are read; this classifies the other ways the cut shows: wave-wide votes are taken per half, and lane counts, ranks, first-lane indices, masks used as numbers and other lanes' values differ in a half. Classification only – nothing translates by it yet, so there is no behaviour change.What is in it
gpu/recomp/partition.rs(new),partition::classify: a forward data-flow pass over the program's blocks (cfg, #341) with taint bits per register, run twice (the second with stale scalars), reportingTier::Exact/Tier::MayDifferand the reasons:lane-count,rank,first-lane,lane-id,mask-data,cross-lane,tainted-exec); DPP16 row / bank masks andv_writelanearelane-id,row_bcastiscross-lane, a number combined with a mask ismask-data;vccz/vccnz,execz/execnz,sccon a mask) unless the side taken with the mask empty is the join or ends the program writing nothing, the other side starts by narrowing EXEC to the mask (for a mask other than EXEC) and does not widen it again before the join (a forward flow of the registers that are zero in a half that skipped the side, and of those that hold the EXEC it had at the vote: EXEC may be written only from the first, and must reach the join as the second) – or the mask is all or none of the active lanes (under a narrowed EXEC only if neither side widens EXEC before the join) (vote-branch,unsafe-execz-branch);stale-scalar); masks that only accumulate behind the vote (s_andn2_b64/s_or_b64of themselves with a mask zero in that half) are not stale.x64_masks::uses(read-modify-write destinations, SDWA scalar sources, SMEM offsets,src_vccz/src_execz) plussrc_scc, NSA addresses, and image loads by their DMASK (upper_lanes::vgpr_writes, nowpub(super)).Exactand exported something else when cut), one per reason, and the exact cases (if that narrows EXEC, uniform votes, the discard early-out, a load at a uniform address, nested restores).Not yet (the next parts of #336): exact idioms (waterfall loops, spill slots, wave-aggregated atomics). Unknown counts as
MayDiffer.Size: 860 lines of code and 572 of tests. The review showed that leaving the stale-scalar rule to a later PR makes this one report
Exactfor programs that differ, so it is in here; what is left (idioms) only turnsMayDifferintoExactand comes separately.Tested
x86_64-pc-windows-msvc; DXC 1.9.2602.17; debug for the suite, release for the runs.cargo test --workspace -- --test-threads=4atdfc5578: 726 passed, 0 failed, 41 ignored; noSKIPPEDlines.vote-branch6 375,cross-lane3 824,unsafe-execz-branch2 858,tainted-exec2 966,stale-scalar1 418,mask-data815,lane-count432,lane-id420,first-lane353. (Before the first review: 9 424 Exact; at ad4add0: 7 208; at c5e0ded: 6 043; at 223065f: 6 121; some of each wrong.)Regression run
Nothing in the runtime calls the new code, so this only shows the build is unchanged in use. The
gpu:line names a virtual display adapter of this machine (what #281 / #282 / #285 fix); XCL's log namesbackend 'real' – AMD Radeon RX 9060 XT (16188 MiB VRAM).main:
PR:
Not tested
MayDifferprograms actually differ on a 32-lane GPU (no 64-lane reference on the GPU yet; the review's interpreter checked the counter-examples).AI use
🤖 Generated with Claude Code
@PHeitor1 on GitHub · 2026-11-24 01:26 UTC · original
Tested
ed04b05(with #341 under it) merged ontomain508a0c7, on a GPU that runs wave64 VS / PS as two 32-lane halves, the case this classifies.RTX 5060 Ti 8 GB (Blackwell, 32-lane waves), NVIDIA 621.24, Ryzen 5 5600X, Windows 11 Pro 26300 (native, Graphics Tools + XGameRuntime installed), rustc 1.100.0 MSVC, debug,
cargo test --workspace --no-fail-fast -- --test-threads=4, noXCL_SAMPLE_*.Pass: 702 passed, 0 failed, 41 ignored. SKIPPED: only the 2
no wave64tests. All 15gpu::recomp::partition::testspass. Thecfgtests from #341 pass too.No behaviour change to check on the GPU yet, since nothing translates by the tier. Once a part of #336 acts on
MayDiffer, I can run it here.Run and written with Claude Code (Claude Opus 5.5).
@QemmHD on GitHub · 2026-11-24 01:47 UTC · original
Thanks for this. The structure (a forward pass over the #341 blocks, with reasons per sink) reads well, and the fixed point is fine: taint only grows, flags only fall, and a tainted VCC / SCC / EXEC reaches its branch, also across a back edge. Your 10
Exacttest programs also hold up under 5 000 random cuts in a small reference interpreter I wrote for this review.The problem is in the direction that matters for NVIDIA: I found programs that get
Tier::Exactbut export something else when the wave is cut. Each one below was run as one 64-lane wave and as two 32-lane halves (your half model: lanes keep their position mod 32, upper mask word 0), except 2 and 6, which are argued from the operand tables. The snippets are in your test style, and all of them currently return[].1.
uniformis not "every lane has it" (partition.rs:261, :283-289). A write under a narrowed EXEC and av_cndmaskwith a per-lane selector both leave the VGPRuniform, sov_readfirstlaneis notcross-lane, and a compare of it becomes a "uniform" vote.With only lane 32 passing, the wave exports s5 everywhere, while the upper half exports s6. The same holds for
v_cndmask_b32 v6, 0, v7, vcc(VCC is never looked at byall_uniform), for DPP results (androw_mask, which names rows of the wave), and forv_readlaneof a lane the half did not launch.2. Image loads (:135, :287).
rdna2::vgpr_usesgives four data registers whatever DMASK says, so a DMASK=1 sample "overwrites" v1..v3 and clears their taint;upper_lanes::vgpr_writesalready handles this. NSA address registers are not read at all, and the"ENC_MIMG_NSA1" | "ENC_MIMG_NSA2"arms never match, because the decoder keepsENC_MIMG.3. A scalar written behind an exempted vote is
Exact(:429-436). The description lists this as not followed yet, but then it should count asMayDiffer; as it stands, "unknown counts as MayDiffer" and "a lower bound for exact programs" do not hold.A loop's trip count read after the loop behaves the same way.
Cfg::control_dependencefrom #341 looks like the tool for this, and it is unused here.4. The vote exemptions check less than they assume (:266, :297-304, :329-340, :429).
vccz → join; exec &= vcc; …; exec = saved; v1 = 1.0; joinisExact.execz → null export, while the run side restores EXEC and exports.vcmp_uniformdoes not checkexec_launch, although the comment at :75 says "under the launch EXEC".scc_votegoes stale when EXEC or the mask register is rewritten before the branch (e.g.s_and_saveexec; s_mov_b64 exec, s10; s_cbranch_scc0).5. A vote read as data is not tainted (:295-305, :170-172, :279).
Your
a_scalar_condition_selected_into_a_mask…test with this SCC as its condition is alsoExact. So aresrc_vccz/src_execz/src_sccoperands, and 32-bit operations on mask words:s_mov_b32 s20, exec_lo; v_mov_b32 v0, s20losesmask-data, ands_or_b32 s20, vcc_lo, vcc_hi; s_cbranch_scc0is not a vote. Carry masks (v_add_co_u32) are not flagged as masks either.6. Register uses (:133-158, :256, :278).
x64_masks::usesalready models whatregs()misses:s_cmov*,s_addk,s_mulk,s_bitset*) clear the taint:s_bcnt1 s20, exec; s_addk_i32 s20, 1exports clean;Separately,
writes_execonly looks at s126, sos_mov_b32 exec_hi, 0is neither a sink nor the end ofexec_launch; and a number written to EXEC (s_mov_b64 exec, 1) is not a reason.7. Precision. An all-discarded early-out inside an
ifmakes the enclosingexeczpost-dominatorExit, so theifbecomesunsafe-execz-branchalthough it is exact (no difference over 500 random cuts); that may be part of the 1 443. Spill slots (v_writelane/v_readlaneof the same lane) arecross-lane, althoughupper_lanesresolves them.8. Small things.
is_storemisses the otherDS_*writes.first-lane,tainted-exec,unsafe-execz-branchandno-graphhave no test. The commit subject is 80 characters. Time is fine: 40 000 instructions in 78 ms in release.The 29 counter-examples (all failing on
ed04b05) and the interpreter are on a local branch; I can share them as a patch if useful.Reviewed on an RTX 4070 SUPER machine (CPU unit tests only for this PR). Points 1, 5 and the counter-example runs were checked by hand against the code before posting.
AI-assisted review (Claude Code; Claude Opus 5.5 and Claude Fable 5.2).
Discord: bigpeppa.
@emirduran707 on GitHub · 2026-11-24 01:52 UTC · original
Thank you – this is exactly the review this needed, and you're right on every point I've checked so far; an
Exactthat is wrong is the failure that matters here. Yes please, the patch with the 29 counter-examples (and the interpreter, if you're happy to share it) would be very useful: I'd like every one of them in the tests.What I'll do on this PR:
v_cndmask/carry-in on a mask that isn't all-or-none), not from DPP/SDWA/permlane or av_readlaneof a lane the half may not have.upper_lanes::vgpr_writesdoes) and NSA address registers read; the deadENC_MIMG_NSA*arms go.scc_voteis dropped when EXEC or the mask register is rewritten before the branch; thevcmp_uniformcomment fixed to what it checks.src_vccz/src_execz/src_sccand mask words read as numbers are tainted; 32-bit ops on mask words and carry masks kept as masks; read-modify-write destinations read (reusingx64_masks::useswhere it fits); SMEM offset / SDWA scalar sources read; EXEC's high word and numbers written to EXEC handled.DS_*writes, tests for every reason, and a shorter subject.AI use: Claude Code with Claude Opus 5.5 wrote this reply.
@4MDomo on GitHub · 2026-11-24 01:53 UTC · original
NVIDIA test report for
ed04b05(this PR's head, stack included).Tested
stable-x86_64-pc-windows-msvc; DXC 1.8.2502.11 (Windows SDK 10.0.26100.0); debug.cargo test --workspace -- --test-threads=4ated04b05: 698 passed, 0 failed, 41 ignored.gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware. Same asmain508a0c7.Not tested
AI use
@QemmHD on GitHub · 2026-11-24 02:05 UTC · original
Glad it helps. The tests and the interpreter are one commit on top of
ed04b05:github.com/QemmHD/xcl@3562891git fetch https://github.com/QemmHD/xcl review/517-counterexamples && git cherry-pick 3562891Everything is in
mod review_517at the end of the tests module inpartition.rs(lines 607-1470): the interpreter (run/cut/must_differ) at 678-955, then 36review_517_*tests. Oned04b05that's 22 passed, 29 failed. The failing ones are the counter-examples; each first asserts that a launched lane exports something different between the 64-lane run and the two halves, then that the classifier isn'tExact. The interpreter covers only the ~30 instructions these tests use (DPP followsemit.rs:2509-2533), so treat it as test scaffolding, not a reference model. Feel free to rename, trim or restructure anything.AI-assisted (Claude Code, Claude Opus 5.5).
Discord: bigpeppa.
@tugasky on GitHub · 2026-11-24 02:03 UTC · original · edited 2026-11-24 02:08 UTC
A second machine ran the census with the PR's own code, unmodified and without writing a
test into the tree. Nothing here needed the title: the carved shader containers are in a
folder, so the same
partition::classifycan be driven directly. The counts came outidentical to yours, reason for reason, which is the useful part.
Machine: Windows 11 Pro 26300, Ryzen 7 9700X (8C/16T), Rust 1.98.0
x86_64-pc-windows-msvc, DXC 1.9.2602.17, Radeon RX 9070 XT (RDNA4, 16 GB), driver32.0.32029.2010. Release build.
How: a throwaway
src/bin(not committed, deleted afterwards) walked the 26 503carved containers, took each program's code, decoded it the way
wave_lane_readsdoes –rdna2::decodein a loop, thenrdna2::resolve_far_jumps– and calledpartition::classify(&insts). The stage comes fromrecomp::interface, the wave sizefrom
recomp::detect_wave64.13 034 distinct programs, 9 255 distinct Exact (71.0 %). Every program decoded and every
one formed a graph: 0 undecoded dwords, 0
no-graph, no panic. 26.8 s of classify timeover the 13 210 programs (mean 2.0 ms); two runs, 127.1 s and 50.6 s wall (the first was
the cold file cache), identical counts.
The distinct-program numbers and the reason counts match yours exactly –
cross-lane2 473,
tainted-exec2 215,vote-branch1 817,unsafe-execz-branch1 443,mask-data619,lane-count432,first-lane353,lane-id186 – so the pass isdeterministic and machine-independent, as a pure software pass should be.
Two numbers the PR body does not have, which change how much the cut matters:
and 10 974 of 12 101 PS. Almost every graphics program of this title is exposed to the
32-lane cut, so the 71 % Exact rate is a rate over the whole graphics corpus, not over
an unusual corner of it.
makes the order of the next parts of #336 measurable:
unsafe-execz-branch861 PS + 1VS,
vote-branch248 PS + 2 VS,cross-lane155 PS + 4 VS,lane-count40 PS,mask-data6 VS. The commonest shapes are those singletons pluscross-lane+tainted-exec+vote-branch719,cross-lane+tainted-exec501 andcross-lane+mask-data+tainted-exec+vote-branch410.Suite: the branch head is three commits behind
main(basea6f5f7a; #486 came after),so I tested the merge with
7ebf1b8, which is what the merge check builds:cargo build --workspace --release(thee2etests needxcl_testtitle.exe), thencargo test --workspace --release -- --test-threads=4→ 699 passed, 0 failed, 41ignored, no test skipped. That is your 698 plus the one test #486 adds. The 15
partition::testsall pass on their own as well.Not tested (same as you): whether a MayDiffer program actually differs on a 32-lane
GPU (needs a 64-lane reference), and NVIDIA.
No game data in this comment – only counts printed by the tool.
AI use: written with Cline; the runs are from my machine.
@emirduran707 on GitHub · 2026-11-24 02:26 UTC · original
Updated to ad4add0 (one commit on #341; #528 folded in and closed). Each of your points as I handled it:
v_cndmask, carry-in) all-or-none;v_readlaneis alwayscross-lane.upper_lanes::vgpr_writes, now shared), NSA addresses read, the deadENC_MIMG_NSA*arms gone.v_cmpx, whole-quad mode, a nested if's restore, an if/else flip (s_or_saveexec+s_xor exec), and a restore right before the join with no lane work after it.scc_voteis dropped when EXEC or its mask register is rewritten; thevcmp_uniformcomment says what it checks.mask-data;src_vccz/src_execz/src_scc; 32-bit ops on mask words keep them masks (and vote through SCC); carry-outs are masks.x64_masks::uses(read-modify-write destinations read, SDWA / SMEM offset sources); EXEC's high word, a single word of EXEC, and numbers written to EXEC are reasons.DS_*writes; a test per reason; subject shortened.Your snippets are tests (some tightened: the exec_hi one now has no divergent compare after it, so it only passes for the right reason); all 31 tests pass, suite 714 / 0 / 41. Over the pack: 7 208 Exact (was 9 424 before, which included wrong ones). 7 (precision: early-out inside an if, spill slots) is next, once the soundness side is settled – your patch with the 29 cases would let me check every one of them too.
AI use: Claude Code with Claude Opus 5.5 made the changes, ran the tests and wrote this reply.
@QemmHD on GitHub · 2026-11-24 02:43 UTC · original
Ran all 29 counter-examples against
ad4add0(the test module applies unchanged): 26 fixed, 3 stillExact.review_517_a4_a_dpp_row_mask_names_rows_of_the_wave:v_mov_b32_dpp v0, v6 quad_perm:[0,1,2,3] row_mask:0xc, then export.source_taint(partition.rs:243-273) has no rule for DPP row / bank masks; DPP only dropsuniform(:362-367), and a 32-lane wave has no rows 2–3.review_517_c3_a_uniform_compare_under_a_narrowed_exec:v7 = s3; vcc = v4 > v5; s_and_saveexec s10, vcc; v_cmp_gt_u32 s2, v7; s_cbranch_vccz join; exec |= s10; v0 = 1.0; join: exec |= s10; exp.vcmp_uniform/uniform_maskare set withoutexec_launch(:342, :357), andvote()acceptsuniform_maskwithout it (:718-719, unlikeis_voteat :631). A half with no lanes left sees VCC = 0 and skips the body.review_517_h_writelane_then_a_per_lane_read:v_writelane_b32 v0, s5, 5, then a per-lane export. It only clearsuniform(:367); it needslane-idtaint, since lane 5 of each half is console lanes 5 and 37.Separately, P3 lost precision: the plain
if(no early-out) wasExactoned04b05and is nowstale-scalar, tainted-exec.stale_at_joins(:670-678) marks the masks88stale although the region only changes it in lanes that are in EXEC, so a half that skipped the region still holds the right bits. Not a correctness bug.Your 31 tests and the
cfgtests pass, and the random-cut check of yourExactprograms finds no difference (5 000 cuts).Branch with the module on top of
ad4add0: https://github.com/QemmHD/xcl/tree/review/517-recheck (git fetch https://github.com/QemmHD/xcl review/517-recheck).AI-assisted (Claude Code, Claude Opus 5.5).
Discord: bigpeppa.
@emirduran707 on GitHub · 2026-11-24 03:14 UTC · original
Thanks. Updated to c5e0ded (still one commit on #341). All three are fixed, and P3 is back to
Exact:a4): a DPP16 row or bank mask other than0xFislane-id(a 32-lane wave has rows 0 and 1 only);row_bcast15/row_bcast31(DPP_CTRL0x142 / 0x143) arecross-lane.c3): a mask that is all or none of the active lanes counts as uniform only under the launch EXEC, as inis_vote. Under a narrowed EXEC a half may have no lanes left and take the other side, so the vote is accepted only if neither side turns lanes on again before the join.v_writelane(h):lane-id, since lane k of each half is a different console lane.if): a mask that only accumulates behind the vote (s_andn2_b64/s_or_b64of itself with VCC or EXEC) is not marked stale, since a half with no active lanes leaves its bits as they were.stale_at_joinsalso follows both operands of ans_and_b64into EXEC now.All four are tests in the PR now, so it has 35 tests. Your module on c5e0ded: 35 of its 36 tests pass. The one that fails,
review_517_p1_an_sgpr_spill_slot_is_exact_but_reported, expects["cross-lane"]and now gets["cross-lane", "lane-id"], because the spill goes throughv_writelane. It is stillMayDiffer; the spill-slot idiom that would make itExactis the next part of #336.Cost over the same shader pack: 6 043
Exactinstead of 7 208 (3 953 of 10 974 PS; VS unchanged at 2 090 of 2 236). The reasons that grew arevote-branch(3 973 → 5 979, thec3rule) andlane-id(186 → 420, the DPP masks andv_writelane).@QemmHD on GitHub · 2026-11-24 03:15 UTC · original
Confirmed on
c5e0ded: with our module applied, 70 passed and 1 failed (your 35, plus 35 of our 36). All 29 counter-examples are now not-Exact, and P3 isExactagain. The one failure is ourp1_an_sgpr_spill_slot_is_exact_but_reported, as you said: it pinned the exact reason list (["cross-lane"]).["cross-lane", "lane-id"]is stillMayDiffer, so our test was too strict, not your code. Fine to relax it to "notExact", or drop it until the spill-slot idiom lands.No further soundness findings from our side. The
Exactcount going from 7 208 to 6 043 looks like the right trade until the precision idioms come back.AI-assisted (Claude Code, Claude Opus 5.5).
Discord: bigpeppa.
@CuteBooty on GitHub · 2026-11-24 03:23 UTC · original
Five more ways
c5e0dedsaysExactfor a program that differs when the wave is cut. Each was run with QemmHD's interpreter (review/517-recheckapplied toc5e0ded, plusS_XOR_B64and theS_OR/S_ANDN2_SAVEEXEC/S_ANDN2_WREXECarms): with lane 3 alone passingCMP, lanes 32..63 export something else, andclassifygives no reason. A to D are inad4add0too.In all of them
SAVE20iss_mov_b64 s[20:21], execat the start;CMP,NARROW,BODY,RESTORE,EXPare yours;BODY1isv_mov_b32 v1, 1.0;execz +nskips n dwords.widens_aftercall invotepassesskip_first = truewithmaskNone too, where the first instruction is not a checked narrowing.CMP, SAVE20, NARROW, execz +2, s_mov_b64 exec, s20, BODY, RESTORE, EXP(the same withs_andn2_saveexec_b64 s14, s20ors_andn2_wrexec_b64 s14, s20first ands_mov_b64 exec, s20at the join). WithBODYin front of the write all three are reported. The skip also keeps a save in that position out ofsaved(a bounded restore is thenunsafe-execz-branch: precision only).saved.extend(mask)is never taken back.CMP, vccz +5, NARROW, s_mov_b64 vcc, s10, s_mov_b64 exec, vcc, BODY, RESTORE, EXPsavedhas no order and is not invalidated. Both of these, withBODYfirst so that A plays no part:CMP, SAVE20, NARROW, execz +5, BODY, s_mov_b64 s12, exec, s_mov_b64 s12, s20, s_mov_b64 exec, s12, BODY, RESTORE, EXPCMP, SAVE20, NARROW, execz +4, BODY, s_mov_b64 exec, s20, BODY, SAVE20, RESTORE, EXPWithout the rewrite the first is
Exact, and is exact.s_or_saveexec_b64 s10, s10puts s10 insavedby its own destination, andelse_flipexcuses it as well; here s10 is the EXEC from before the vote, so the flip turns on the lanes the vote left out.CMP, SAVE20, NARROW, execz +4, BODY, s_or_saveexec_b64 s10, s10, s_xor_b64 exec, exec, s10, BODY1, s_mov_b64 exec, s20, EXPWith
execz +1(the flip at the join, as compilers emit it) the halves match the wave.c5e0ded) Accumulating with a VCC wider than EXEC. Theaccumulatesexemption needs VCC to have no lane outside EXEC.CMP, SAVE20, s_mov_b64 s88, exec, NARROW, s_mov_b64 vcc, s20, execz +2, BODY, s_andn2_b64 s88, s88, vcc, s_mov_b64 exec, s20, s_and_b64 exec, exec, s88, BODY1, s_mov_b64 exec, s20, EXPWith a compare under the narrowed EXEC instead of the move it is
Exact, and is exact.Possible fixes: A, skip only when
narrows_exec_bychecked that instruction; B and C, accept a restore only if a save made inside the side reaches it unchanged on every path; D, no exemption unless the OR's source is bounded by this vote; E, exempt VCC only when it was last written by a compare under the current EXEC.I can post the tests as a branch or a patch if you want them.
Tested:
cargo test -p xcl --lib -- partition::tests(CPU only, debug, rustc 1.100.0 MSVC, Windows 11 Pro 26200) onc5e0ded+ QemmHD's module + these: 77 passed, 11 failed. The 11: 9 witnesses for A to E, the precision case under A, andreview_517_p1(its known strict reason list).Not tested: whether any retail program has these shapes (B to E look unusual for compiler output); nothing ran on a GPU.
AI use: Claude Code (Claude Opus 5.5) found the cases and wrote the tests and this comment; Codex (GPT-6.2 Astra) reviewed them by reading the code, without running anything.
@emirduran707 on GitHub · 2026-11-24 04:00 UTC · original
Thanks, all five confirmed and fixed in 223065f. A to D come from the same flaw: the side's "saved" masks were an unordered set. So I replaced the set with an ordered data flow rather than patching each case.
widens_afternow runs a forward data flow over the side's blocks. It tracks which scalar registers (EXEC and VCC included) are zero in a half that skipped the side, intersected over every way into a block. A write to EXEC of a value not known to be zero there widens EXEC.m & exec.s10is no longer zero.s10is, which it is whens10comes from a saveexec in the side, and not when it is the EXEC from before the vote.stale_at_joinsuses the same flow for the side the wave runs. An accumulations &= ~m/s |= mis exempt only whenmis zero in that half at that point.Each case is a test now (five tests, 40 in all), with the exact variants you gave as
Exactchecks: C without the rewrite, D with the flip at the join, and E with a compare under the narrowed EXEC. All five fail on c5e0ded and pass on 223065f. QemmHD's module on 223065f gives the same result as before: 35 of 36, with onlyp1's strict reason list failing.Over the same shader pack: 6 121
Exact(4 017 of 10 974 PS, 2 104 of 2 236 VS), up from 6 043 (unsafe-execz-branch3 211 → 2 858,vote-branch5 979 → 6 011). The slowest program takes 169 ms (one thread, release).No need for the branch, thanks; the description of each case was enough to write the tests.
@upipibi on GitHub · 2026-11-24 04:32 UTC · original
Three more programs that
classifyreturns asExact(no reasons) on223065f, though a 32-lane cut changes what they export. None is among the 34 counter-examples above. I ranclassifyfrom a scratch test inpartition.rs'smod tests, using the PR's own helpers and constants. Whether each one diverges is argued by hand under the same half model the earlier reviews used (I had no interpreter), so please run them through QemmHD's interpreter.A. A vote on VCC whose taken side narrows EXEC and never restores it (
partition.rs:688-690,:788-791)Your test
a_vcc_vote_that_narrows_exec_first_is_exactwithRESTOREremoved:CMP; s_cbranch_vccz join; s_and_saveexec_b64 s10, vcc; v0 = 1.0; join: exp.If only lane 3 passes, the wave leaves EXEC = {3}, so lanes 32..63 export nothing. The upper half alone has VCC = 0, jumps to the join with its whole EXEC, and all its lanes export.
stale_at_joinsleaves EXEC out ("which the join restores"), andvoteonly checks that the side doesn't widen EXEC. Possible fix: for a non-EXEC mask, require EXEC to be the pre-vote EXEC on every path into the join, or mark EXEC stale at the join when the side writes it without restoring it.B. A write under the launch mask, then
s_wqm_b64, then a compare (:364,:380-384, early return at:773)v_mov_b32 v4, s3; s_wqm_b64 exec, exec; v_cmp_gt_u32 vcc, s2, v4; s_cbranch_vccz +1; v0 = 1.0; exp.The helper lanes that WQM turns on never got the write to
v4, so the compare isn't all-or-none. A helper lane in the lower half can make the wave's VCC non-zero while the upper half alone sees VCC = 0.whole_quad_mode_at_the_start_keeps_the_launch_maskcovers only the other order (WQM first, then the write). Possible fix: clearuniform/uniform_maskwhen EXEC moves between L and wqm(L).C. A number combined into a mask (
:347-351,:363)s_and_b64 exec, exec, 1; v0 = 1.0; exp: the wave exports lane 0, while the two halves export lanes 0 and 32. The same AND applied to a uniform VCC before a vote is alsoExact. Onlys_movinto EXEC is checked for "a number written to EXEC", andmask_uniformaccepts any operand that isn't a mask. Possible fix: a bitwise mask op whose other operand is neither a mask nor 0 / -1 getsmask-dataand losesuniform_mask.All three classify outputs, with the scratch test's input programs:
Nothing calls
classifyyet, so these matter for the later parts of #336. A is one instruction away from your own test; B and C are unusual for compiler output.AI-assisted (Claude Code), read-only review plus one scratch test run of
classify.@emirduran707 on GitHub · 2026-11-24 04:59 UTC · original
Thanks, all three hold, and all are fixed in
dfc5578:x | 0,x | x,x & x, …). On every edge into the join the side must hand over that EXEC, or, for an EXEC vote (where the skipping half had no lanes), an EXEC that is zero there. Both of your T1 forms are nowvote-branch. This also closes a hole in the old trailing-restore exemption: a restore into the join is accepted only if what it restores is the vote's EXEC.s_wqm_b64into EXEC now drops "every lane's value" for VGPRs and "all or none" for masks written before it, since the helper lanes it turns on never got those writes. WQM first, then the write (your existing control case), staysExact.mask-data. A new per-SGPR flag says the register holds a set of lanes: a mask, or a scalar condition selected as -1 / 0.s_and_b64 exec, exec, 1, the same throughs[20:21] = 1, and a uniformvcc &= 1before a vote are all reported now. Ans_cselect_b64 -1, 0mask ANDed with EXEC staysExact.Each is a test (three tests, 43 in all). All three fail on 223065f and pass on
dfc5578. QemmHD's module gives the same result as before: 35 of 36, with onlyp1's strict reason list failing.Same shader pack: 6 057
Exact(3 954 of 10 974 PS, 2 103 of 2 236 VS), down from 6 121 (mask-data635 → 815,vote-branch6 011 → 6 375). The slowest program takes 173 ms.@thiagocalile on GitHub · 2026-11-24 19:27 UTC · original
Independent AMD RDNA2 (native wave64) test report on exact head
dfc557881b9d608bb6f38f0d77497bf759ed2a73(without rebasing or edits).Tested
32.0.21045.29003;XCL_ADAPTER=radeon, native wave64 + mesh shaders), AMD Ryzen 7 5700X3D, 47.9 GB RAM, Windows 11 (26200), Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC1.8.2502.11, debug build.XCL_ADAPTER=radeon cargo test -p xcl --lib gpu::recomp -- --test-threads=4: 232 passed, 0 failed, 18 ignored (0 GPU skips).XCL_ADAPTER=radeon cargo test --workspace --no-fail-fast -- --test-threads=4: 723 passed, 3 failed, 41 ignored. The 3 failures are pre-existing on this RX 6600 onmain(placed_title_textures_share_vram_and_preserve_pixels: 3D 64x64x64 4 mips subresource 2 mismatch, plus 2 mutex-poison cascades; covered by #1028).Not tested
scripts/smoke.ps1(no retail executable here), D3D12 debug layer (nod3d12SDKLayers.dll), NVIDIA / Intel / WARP, Linux / Wine.AI use
dfc5578, ran the tests on my RX 6600, and drafted this report; I checked the output before posting.@PHeitor1 on GitHub · 2026-11-24 21:50 UTC · original
NVIDIA report on the exact head
dfc5578, and on it merged ontomain1d027e5(clean). My earlier report was fored04b05.Tested
XCL_*set.cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4.dfc5578as it is: 726 passed, 0 failed, 41 ignored. SKIPPED:gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware(no wave64).dfc5578merged onto1d027e5: 1009 passed, 0 failed, 43 ignored. Plain1d027e5: 959 passed, 0 failed, 43 ignored (2 runs). The SKIPPED lines are the same in both.gpu::recomp::partitiontests pass in both trees. Nonvlddmkmevent in any run.Not tested: whether a
MayDifferprogram differs when run on this GPU (nothing translates by the tier yet), a shader pack, release, a title.Run and written with Claude Code (Claude Opus 5.5).