Recompiler: scalars written behind a vote and read after it are partition-dependent (#336) #528
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!528
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/528/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:23 UTC · original
emirduran707:wave64-stale→main· +1061 −1 · 4 files · 3 commits · closed without mergingStacked on #517 (which is stacked on #341); only the top commit (
741efd7) belongs here. Part of #336.A half whose mask is empty takes the other side of a vote (or skips its lane-masked side), so it never runs the scalar code the wave runs there. A scalar that code writes and that is read after the sides join holds something else in that half – one of the ways #517 left to follow. Classification only: nothing translates by it yet.
What is in it
gpu/recomp/partition.rs:classifyruns its data-flow pass twice. The first finds the votes – branches on a mask, unless every half has lanes and votes as the wave does (the launch EXEC, or a mask that is all or none of its lanes) – and the scalars written in the blocks each one decides (SGPRs, VCC, M0, SCC; not EXEC, which the join restores), fromcfg's control dependence with nested branches' blocks included. The second marks those scalars stale where the vote's sides join; a stale value reaching an export, a store, a branch or EXEC is the new reasonstale-scalar.Tested
x86_64-pc-windows-msvc; DXC 1.9.2602.17; debug for the suite, release for the runs.cargo test --workspace -- --test-threads=4at741efd7: 700 passed, 0 failed, 41 ignored; noSKIPPEDlines.stale-scalarin 2 468 programs; no panic; at most 99 ms for one program (two passes; nothing calls this on a title's path yet).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
AI use
@4MDomo on GitHub · 2026-11-24 01:53 UTC · original
NVIDIA test report for
741efd7(this PR's head, #517 and #341 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=4at741efd7: 700 passed, 0 failed, 41 ignored (the same 700 as on the RX 9060 XT).gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware. Same asmain508a0c7.Not tested
AI use
@tugasky on GitHub · 2026-11-24 02:12 UTC · original
Same harness as the #517 census, run again on this stack, so the numbers below are a
delta over the same 13 210 programs of the same retail pack, not a separate sample.
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,
741efd7merged into7ebf1b8(the stack's base isa6f5f7a, three commits behindmain; the merge touches only README andtitle_textures.rs, sopartition.rsis the PR's).stale-scalarYour 8 767 / 6 620 / 2 147 and
stale-scalarin 2 468 programs come out here exactly.13 034 distinct programs still, 8 598 distinct Exact (was 9 255), so the 657 newly gated
programs are 657 distinct ones – no program is counted twice in that drop. No panic,
0 undecoded dwords, 0
no-graph.What the 657 cost, attributed. 447 of them (68.0 %) are gated by
stale-scalaralone(442 PS + 5 VS). The other 210 carry
stale-scalar+tainted-execand nothing else(186 PS + 24 VS), which is the rule doing what it should: the stale scalar also reaches
EXEC or a branch, so control is tainted too. That accounts for the second finding –
tainted-execis the only other reason that moves, 2 215 → 2 612 (+397): 210 are thosenewly gated programs, the remaining 187 are programs that were already MayDiffer and
whose stale scalar now also taints control. Every other reason is unchanged to the
program:
cross-lane2 473,vote-branch1 817,unsafe-execz-branch1 443,mask-data619,lane-count432,first-lane353,lane-id186. So the rule ispurely additive on this corpus, and its cost is 657 programs, not 2 468 – the other
2 011 already differed for another reason.
Order of the remaining parts of #336 is now measurable the same way (programs whose
only reason is this one):
unsafe-execz-branch744, thenstale-scalar447 (the onesthis PR adds),
vote-branch206,cross-lane150,lane-count40,mask-data6. TheEXECZ/EXECNZ rule is still first.
Cost: 65.2 s of classify time over the 13 210 programs, against 24.6 s and 26.8 s in
two runs of #517 alone on this machine (mean 4.9 ms, slowest program 82.2 ms; your machine
reports 99 ms). Fine for a census, and worth knowing before anything calls this on a
title's path.
Suite:
cargo build --workspace --release, thencargo test --workspace --release -- --test-threads=4→ 701 passed, 0 failed, 41ignored, no test skipped (your 700 plus the one test #486 adds on
main). The 17partition::testspass on their own as well.Not tested (same as you): whether the flagged programs actually differ on a 32-lane
GPU, 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
Folded into #517 (ad4add0) after its review: leaving the stale-scalar rule to a later PR made #517 report Exact for programs that differ.
AI use: Claude Code with Claude Opus 5.5 wrote this note.
Pull request closed