Skip to content

Shaders: lane masks keep their bool form unless a read may see an integer - #26

Merged
ThatRecompDev merged 2 commits into
ThatRecompDev:mainfrom
Sr-0w:shaders/mask-forms
Nov 25, 2026
Merged

ThatRecompDev merged 2 commits into
ThatRecompDev:mainfrom
Sr-0w:shaders/mask-forms

Conversation

@Sr-0w

@Sr-0w Sr-0w commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Stacked on #25 (its decoder fix is the first commit here: the new case's assembled code comes from llvm-mc 23). Review only the second commit; I'll rebase once #25 is in.

Mask tracking follows emission order, so a register that is a lane mask on one path and an integer on another is kept in its integer variables: a ballot for each mask write, and lane_bit for each mask read. The rule that picks those registers was global: any register ever used both ways. On wave64 programs that is nearly every mask, since the translated code also uses the same SGPR pairs as integers elsewhere.

The first translation now records, per block, the form each read assumed and each write left (MaskForms/BlockForms). MaskFormAnalysis carries the forms each register may hold along the branches (registers not written yet are integers) and keeps only those a read may reach in the other form. The second translation is unchanged.

CS_ScreenProbes_ActivateProbes (wave64, 122k dwords of code):

before after
masks kept as integers 33 of 34 1 (s0, also an s_getpc/s_setpc address)
vw_ballot in the HLSL 32,393 17,411
lane_bit in the HLSL 20,976 2,167
waveActiveBallot in the DXIL, with #24 11,060 925
  • Test: the new case cs_mask_after_integer (w32/w64, every form the compute cases run in). As a mutation check, Mixed returning nothing fails 14 of the 26 mask cases (cs_mask_on_taken_path, cs_integer_on_taken_path and the others).
  • Docs: the mask paragraph of shader-translation.md.
  • Shaders and Architecture tests green.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XTYmP8DzdtgeCMD6HPuCyc

Sr-0w and others added 2 commits November 25, 2026 11:25
llvm-mc 23 writes source code 0x80 (inline constant 0) into the VOP3 sources
an instruction does not read, where older releases wrote 0: a compare such as
v_cmp_gt_u32_e64 s40, 4, v0 assembles to d4c40028 02020084. llvm-objdump
lists it as the same compare, but the decoder made it .long, so any new test
case with a VOP3 compare failed to translate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SKtJsfjasPuTLtS3mEXFru
…eger

Mask tracking follows emission order, so a register that is a lane mask on
one path and an integer on another is kept in its integer variables (a
ballot per mask write, lane_bit per mask read). The rule was global: any
register ever used both ways. The first translation now records per block
the form each read assumed and each write left (MaskForms); MaskFormAnalysis
carries the forms along the branches and keeps only registers a read may
reach in the other form.

CS_ScreenProbes_ActivateProbes (wave64): 33 of 34 masks were kept as
integers, now 1 (s0, also an s_getpc/s_setpc address); HLSL vw_ballot
32,393 -> 17,411, lane_bit 20,976 -> 2,167. New case cs_mask_after_integer;
the analysis returning nothing fails 14 of the mask cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XTYmP8DzdtgeCMD6HPuCyc
@ThatRecompDev

Copy link
Copy Markdown
Owner

this one's great, 33 of 34 masks down to 1 on ActivateProbes and 11k → 925 ballots with #24 is a huge cut. merging both #25 and this now.

one small nit: it adds two cs_mask_after_integer_w64 binaries with different hashes (582c2aa9… and fc484ed9…), one of them is probably a leftover from an earlier assemble. harmless, but if you're touching it again feel free to drop the stale one.

also, the windows failure on the first run wasn't you: it was our profiler test (ManagedProfileSummaryTests) being timing-sensitive on busy runners. we've made it deterministic on main now, so it shouldn't bite your next PRs.

thanks again!

@ThatRecompDev
ThatRecompDev merged commit 6a0f66c into ThatRecompDev:main Nov 25, 2026
3 of 4 checks passed
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