shader: lower s_xor_b32 in the mesh frontend, with s_movk_i32/s_xor_b32 tests (Part of #2413) #3637
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!3637
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3635"
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?
@mumba17 on GitHub · 2026-11-30 18:53 UTC · original
mumba17:shader/mesh-movk-xor→main· +17 −2 · 2 files · 3 commits · merged 2026-12-01 00:12 UTCPart of #2413.
The C++ mesh frontend (
src/gfx1013_direct_mesh.inl) refuseds_xor_b32asunsupported mesh instruction or EXEC state. It was the first refusal for 41 of the 454 cached slot 57 requests in my local census.#3640 landed
s_movk_i32for SGPR destinations while this PR was open. I merged main and kept that implementation. This PR now addss_xor_b32and tests for both instructions.Change
s_xor_b32joins the existing SOP2 bitwise branch next tos_or_b32ands_and_b32. It lowers toxor i32, with SCC = (result != 0). A destination of 106 or above is still refused, because that branch only takes SGPR destinations.Tests
In
tests/native_direct_mesh_check.py, next to the scalar EXEC/VCC write checks:scalar-movk-xor:s_movk_i32 s20, 0xfffe, thens_xor_b32 s21, s20, -1, feedsv_and_b32 v1, s21, v0and the exported X position. The test assertsxor i32 -2, -1(so thes_movk_i32immediate is sign-extended) and that theandreaching the position export uses that result.s_movk_i32to VCC, EXEC and M0, ands_xor_b32to EXEC and VCC. Each one must be refused at+0x14with its exact reason.Mutation checks on the merged branch, each caught by
native_direct_mesh:s_xor_b32asor;s_xor_b32from the SOP2 branch;s_movk_i32immediate in the shared scalar ALU (gfx1013_direct_compute.inl).Verification
a0e126c2,ctest --preset release -R "mesh|compile_dxil" -j 4: 202 passed (the twomesh_two_exitscases skip, as on main).compile_dxil --refusalsover the 454 cached slot 57 requests (layout from #3418): nos_xor_b32ors_movk_i32refusal is left.🤖 Generated with Claude Code
@lukaslw-lab on GitHub · 2026-11-30 19:09 UTC · original · approved these changes
Reviewed
9d21285bby reading the diff; not built or run. I also disassembled our own cache of slot 57 programs to see which forms of these two instructions real code uses.Verdict: approve. Both lowerings match the scalar analysis they sit next to, and neither can create heap or mask provenance. No MUST, no SHOULD.
s_movk_i32writes the same sign-extendedi.aconstant astransfer()(gfx1013_compute_native.cpp:891-892) and leaves the mesh SCC alone, as the ISA does. Overwriting an SGPR that held a saved EXEC mask turns it into a constant, so a later restore from it stays refused. Inside a per-lane skip, the write goes throughalu.write, so the skip-end invalidation covers it.s_xor_b32:transfer()has no case for it, so the destination symbol becomes unknown (:908-910).root_valuesonly extends ons_and_b32ands_lshl_b32, so an xor result can never pass as a masked root-constant heap slot. The value and SCC use the existingor/andcode.Checked against real programs: 310 cached slot 57 programs from our runs, disassembled:
s_movk_i32vcc_lo, none M0s_xor_b32The one
vcc_lowrite (a34e610e +0x2ef0) comes afterv_writelane_b32spills VCC tov127. The compiler then usesvcc_lo/vcc_hias words 2–3 of a buffer descriptor. Keeping that refused, as this PR does, matches the frontend's other VCC writes. It needs VCC-as-SGPR support, which is separate work.Tests:
scalar-movk-xorproves the sign extension (xor i32 -2, -1) and that the result reaches the position export. The five negative controls pin each destination refusal. CI did not runnative_direct_mesh(not in theprfilter); the author ran it locally (192 passed).shader: lower s_movk_i32 and s_xor_b32 in the mesh frontend (Part of #2413)to shader: lower s_xor_b32 in the mesh frontend, with s_movk_i32/s_xor_b32 tests (Part of #2413)@R0Y00 on GitHub · 2026-11-30 19:40 UTC · original · reviewed
Windows passed on this head. The failing Linux job is
tests/startup_close_guard_check.py: the Close fixture extracts the trace added by #3640 and its fake state has no trace recording field. I reproduced the failure separately from the mesh lowering and opened #3644 with the narrow fix. Please rerun the Linux check against a base containing that fix before merging this PR.@mumba17 on GitHub · 2026-11-30 19:59 UTC · original
Thanks for the review and the real-program table. While this was open, #3640 landed its own
s_movk_i32handler (SGPR destinations, through the shared scalar ALU). I merged main and kept that one, so thes_movk_i32code you reviewed is gone. This PR is nows_xor_b32plus tests for both.Two test changes came with it:
s_movk_i32now expect the genericunsupported mesh instruction or EXEC state: s_movk_i32.scalar-movk-xorstill checks the sign extension, now against #3640's lowering.I re-ran the mutation checks on the merged head
e5c65430. Each one failsnative_direct_mesh:xorlowered asor;s_xor_b32dropped;s_movk_i32immediate.The mesh suite passes, 202/202. The
vcc_locase stays refused, as you said.@lukaslw-lab on GitHub · 2026-11-30 20:05 UTC · original · approved these changes
Re-reviewed
a671a700by reading the diff; not built or run. Main has been merged twice since my last review. The PR now keeps #3640'ss_movk_i32and addss_xor_b32plus tests. Its own lines are the same as ate5c65430.Verdict: approve. No MUST, no SHOULD.
s_xor_b32joins the SOP2 bitwise branch (src/gfx1013_direct_mesh.inl:1517-1528). It uses the sameknown()guard, the same unknown-destination fallback and SCC = result ≠ 0 ass_or_b32/s_and_b32.root_valuesis not propagated through xor, so a masked root constant loses its provenance there. That is the conservative choice, and an xor'd heap slot stays refused.transfer()has nos_xor_b32case, so the symbolic state is the same as fors_or_b32.s_movk_i32handler (:1504) takes onlydst < 106. VCC/EXEC/M0 destinations fall through to the generic refusal, which matches the updated test reasons. A VCC destination, as ata34e610e+0x2ef0 in my earlier census, stays refused.0xb014fffe=s_movk_i32 s20, 0xfffe; SOP2 op 180x8915c114=s_xor_b32 s21, s20, -1; VOP20x36020015=v_and_b32 v1, s21, v0. The negative words differ only insdst(0x6a/0x7e/0x7c), inserted at+0x14.Tests:
scalar-movk-xorproves sign extension (xor i32 -2, -1) and that the xor result reaches the position export. The five refusals pin both opcodes' non-SGPR destinations.native_direct_meshis not in the Windowsprpreset filter, so CI does not run it. The author ran it locally on the merge witha0e126c2.