startup: lower constant-lane SGPR spills on wave64 lanes and in vertex stages in gfx2hlsl (Part of #1723) #2712
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!2712
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2712/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?
@tedin7 on GitHub · 2026-11-26 03:08 UTC · original
tedin7:x2w-spill-wave64→main· +359 −9 · 6 files · 2 commits · merged 2026-11-26 05:40 UTCPart of #1723
What this unblocks: constant-lane SGPR spills (
v_writelane_b32 vN, sM, k/v_readlane_b32 sD, vN, k) in wave64 programs (lanes 32..63) and in vertex stages now translate instead of being refused ("lane 40 outside 0..31", "lowered in pixel stages only").Extends #2637, #2524 and #2127: they cover pixel lanes 0..31 (with branches) and the slot 57 mesh stage; the lane range and the vertex stage were still refused.
What changed
The slot model (one scalar per (VGPR, lane)) only needs the two instructions to touch lane k and to ignore EXEC, which holds in every stage. So:
SPILL_LANES = 64) and the vertex stage joins pixel and mesh (SPILL_STAGES);v_readlane/v_writelane). So k and k+32 name one slot in wave32 and two in wave64: a spill VGPR whose lanes include such a pair stays refused by name (require_spill_lanes_apart, new in this PR; it applies to pixel and vertex stages only, because slot 57 mesh is always wave64 and keeps lanes k and k+32 as two slots).What stays refused
Lane 64 and up, register-chosen lanes, compute stages, a VGPR with any non-spill use, and any branches outside the pixel proof of #2524 (vertex stages with branches stay refused).
Tests
New
tests/startup_gfx2hlsl_spill_wave64_check.py(registered inCMakeLists.txt, noted indocs/experiments.md): wave64 pixel slots, the vertex stage, two VGPRs holding lanes 8 and 40, the k/k+32 pair refusal, and adrawmode with a CPU reference and wrong-lane / ignored-overwrite mutations.startup_gfx2hlsl_sgpr_spill_check.pynow expects lane 64 and the k/k+32 pair refused and the vertex stage accepted. Onorigin/mainthe new check fails (wave64 pixel slots translate,vertex stage slots translate,lanes 8 and 40 of two different VGPRs are accepted); with the change it passes.Verification
python3 -B tests/startup_gfx2hlsl_spill_wave64_check.py: PASS (fails onorigin/main);... binary llvm-mc-19: PASSpython3 -Bofstartup_gfx2hlsl_sgpr_spill_check.py,startup_gfx2hlsl_spill_branches_check.py,startup_mesh57_lane_spill_check.pyand the otherstartup_mesh57_*_check.py: PASStests/startup_gfx2hlsl_*_check.pyrun with no arguments on this branch and onorigin/main: same result per script (export_null_drawandmul24_align_drawneed a compiler and renderer and exit 1 on both); the only new script isspill_wave64_check.6c16fcd62): dev 28/28 and release 28/28 passed (spill_wave64 controls, warp and hardware, sgpr_spill, mesh57). The review found one regression, fixed inbcb42f915(the pair rule no longer runs for the mesh stage;startup_mesh57_lane_spill_check.pynow keeps lanes 3 and 35 of one VGPR translating, and fails without the fix). Win2025 (Windows Server 2025) on the fixed headbcb42f9150: dev 28/28 and release 28/28 passed (startup_gfx2hlsl_spill_wave64_controls/_warp/_hardware, startup_mesh57_lane_spill (controls), _warp, hardware, startup_gfx2hlsl_sgpr_spill*; one mesh57 hardware test skipped by design).Copy-paste (build and run the spill tests):
AI-assisted; commands listed were executed locally.
Symptom: the constant-lane spill idiom v_writelane_b32 vN, sM, k / v_readlane_b32 sD, vN, k was refused for k >= 32 ("lane 40 outside 0..31") and in every vertex stage ("lowered in pixel stages only"), although a wave64 program spills into lanes 0..63 and a vertex stage uses the same idiom. Root cause: the slot model (one scalar per (VGPR, lane)) was limited to wave32 lanes and pixel stages. Neither limit is needed by the model: the two instructions touch only lane k and ignore EXEC in every stage. Change: lanes 0..63 and vertex stages are accepted. The translator does not know the wave size and a wave32 program takes the lane select modulo 32, so a spill VGPR whose lanes include k and k + 32 (one slot in wave32, two in wave64) is refused by name. Lane 64+, compute stages, register lanes, branches (open #2524 territory) stay refused. Test: tests/startup_gfx2hlsl_spill_wave64_check.py (controls fail before: lanes 32..63 and the vertex stage refused). The existing sgpr_spill controls now expect lane 64 and the k/k+32 pair refused and the vertex stage accepted. Win2025 WARP dev and release, DXC and FXC: the pixel draw matches the slot reference on 256/256 pixels, the vertex draw exports the reference param0, and all five wrong-lane/ignored-overwrite mutations fail. (cherry picked from commit c7fe3e44b10ffb4ebdf40caab7d8306926b3a881)@tedin7 on GitHub · 2026-11-26 03:35 UTC · original
Independent Stage-2 review of head
bcb42f9150: PASS.startup_mesh57_lane_spill_check.py:got 'unsupported: ... one slot in wave32 and two in wave64', want 'ok').s_mov_b32 exec_lo, 0before the lane ops still translates (both instructions ignore EXEC).vsdropped from SPILL_STAGES,lane + 32->lane + 33.--no-skip-build,--targets offscreen_check --regex '^startup_gfx2hlsl_(sgpr_spill|spill_wave64|spill_branches)|^startup_mesh57': dev 28/28 and release 28/28 passed on this head, includingstartup_gfx2hlsl_spill_wave64_warp/_hardwareandstartup_mesh57_lane_spill_warp/_hardware.Marked Ready. @MasterDomino
AI-assisted; commands listed were executed locally.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-26 03:35 UTC · original · edited 2026-11-26 03:38 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
bcb42f9ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
@tedin7 on GitHub · 2026-11-26 05:12 UTC · original
Checked the automated review comment from 03:35Z on head
bcb42f915. It is only a status summary: code review "Completed",has_any_findings: false,has_unresolved_findings: false. There is no finding to fix and no review thread to resolve, so no code change.Commands run:
gh pr view 2712 --json comments,reviewsand a GraphQLreviewThreadsquery (0 threads).AI-assisted; commands listed were executed locally.
@R0Y00 on GitHub · 2026-11-26 05:39 UTC · original · approved these changes
Reviewed the constant-lane spill proof and ran the host spill, branch, wave64 and mesh57 controls with main
651577a0combined. The synthetic pixel, vertex and mesh draw checks passed on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656, both on Windows 11 build 26200. The lane and overwrite mutants were caught. An unknown-size VS/PS still refuses lane pairs that could alias, and slot 57 retains its two distinct wave64 lanes.