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

Manually merged
github merged 2 commits from gh-pr/26/head into gh-pr/26/base 2026-11-27 03:14:20 +00:00
Owner

@⁠Sr-0w on GitHub · 2026-11-25 10:46 UTC · original
Sr-0w:shaders/mask-forms → main · +280 −5 · 14 files · 2 commits · merged 2026-11-25 11:02 UTC

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

**@⁠Sr-0w** on GitHub · 2026-11-25 10:46 UTC · [original](https://github.com/ThatRecompDev/five-star-recomp/pull/26) `Sr-0w:shaders/mask-forms` → `main` · +280 −5 · 14 files · 2 commits · merged 2026-11-25 11:02 UTC **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.com/claude-code)
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 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SKtJsfjasPuTLtS3mEXFru
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 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XTYmP8DzdtgeCMD6HPuCyc
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 03:14:20 +00:00
github manually merged commit 12cc9e5740 into gh-pr/26/base 2026-11-27 03:14:20 +00:00
Author
Owner

@⁠ThatRecompDev on GitHub · 2026-11-25 11:01 UTC · original

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** on GitHub · 2026-11-25 11:01 UTC · [original](https://github.com/ThatRecompDev/five-star-recomp/pull/26#issuecomment-7160492969) 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!
This discussion has been locked. Commenting is limited to contributors.
No description provided.