Skip to content

shader: count a 32-bit SALU write in a mesh SAVEEXEC arm as one SGPR (Part of #3703) - #3785

Merged
R0Y00 merged 1 commit into
R0Y00:mainfrom
mumba17:shader/mesh-saveexec-salu32-writes
Dec 2, 2026
Merged

R0Y00 merged 1 commit into
R0Y00:mainfrom
mumba17:shader/mesh-saveexec-salu32-writes

Conversation

@mumba17

@mumba17 mumba17 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Part of #3703. Fixes the 13 programs that stop at unproven mesh mask operand on the current stack.

Problem

validate_saveexec records every scalar destination written in a SAVEEXEC then arm as a register pair. That covers lane masks, but a 32-bit SALU write also marked its neighbour. Those writes become the arm's scalar_clobbers, which are cleared at the join.

In all 13 programs, a lane mask lives in s[8:9] (s_cselect_b64 s[8:9], exec, 0) across a nested SAVEEXEC whose then arm runs s_lshl_b32 s7, .... The join cleared s8, and the later s_and_b64 s[2:3], vcc, s[8:9] was refused as an unproven mask.

The same over-count made an else arm that reads such a neighbour refuse as else arm reads a scalar the then arm writes.

Change (gfx1013_direct_mesh.inl)

In the then-arm scan, a SOP1/SOP2/SOPK result marks dst+1 only when the opcode name has 64 (the _b64/_u64/_i64 forms, plus *_b64 sources such as s_bcnt1_i32_b64, kept as before). VOP results with an SGPR destination (compare masks, v_readfirstlane) and scalar loads are unchanged.

Tests (tests/native_direct_mesh_check.py)

  • saveexec-then-b32-neighbour: the then arm writes s29 with s_mov_b32, and the else arm reads s30. It lowers to phi [ 7, then ], [ 3, else ].
  • saveexec-then-b64-pair: s_mov_b64 s[30:31] in the then arm still keeps the else arm's read of s31 refused.
  • Mutations, each failing the suite:
    • always marking the pair (the old rule) fails the first test;
    • never marking it for SALU fails the second.

Validation (Windows 11, MSVC, Windows SDK 10.0.26100)

Independent of #3782; the two touch different lines.

AI-assisted.

🤖 Generated with Claude Code

The then-arm scan recorded every scalar destination as a register pair,
so a 32-bit write such as s_lshl_b32 s7 also marked s8 as written. At
the join s8 was clobbered, and a lane mask kept there was lost; the
else arm also could not read the neighbour. Record the pair only for
64-bit SALU forms and for non-SALU writes (compare masks, readlane),
as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants