Shader: 78 compute programs are refused as "a program input" when a mask is spilled to a VGPR lane and read back #578

Open
opened 2026-11-28 05:52:31 +00:00 by github-bot · 4 comments
Owner

@⁠ShadyUnderLight on GitHub · 2026-11-28 05:45 UTC · original

Measured, and the message is wrong: the value it names is never a program input. Refs #4.

Where. Lower::mask_number (crates/victory-shader/src/emit/lower.rs) refuses when the value whose bits are wanted has no writing instruction (def_block.get(&lo)). The message said "a program input", which sent this issue after the SGPRs the title passes in.

What it actually is. Dump of one headless run at 2f4d81e0 (M5 Max, Series X, 480 s, 2,816 frames): 1,554 refused containers; 209 of them refuse with this message (207 compute, 2 pixel), and the run logged it for 84 unique compute hashes. Every failure point was disassembled: 197 of 207 stop at s_cbranch_execz, the other 10 at v_writelane_b32/s_cbranch_scc0. A temporary trace in mask_number recorded 19,558 refusals, every one from a joining value with no writing instruction — never a live-in.

The console compiler spills the mask to a VGPR lane and reads it back, and the read-back joins the loop register. compute daff9d66adf677aa at 0x9edc:

9eb8: v_writelane_b32 v141, s34, 7
9ec0: v_writelane_b32 v141, s85, 8
9ec8: v_readlane_b32 s34, v141, 3
9ed0: s_nand_b32 s34, s34, exec_lo
9ed4: s_mov_b32 exec_lo, s102
9ed8: s_and_b32 exec_lo, s34, exec_lo
9edc: s_cbranch_execz label_A7A0

Why #304's proof does not reach these joins. Of 5,883 distinct (block, register) joins refused here: 3,102 sit in blocks with no EXEC join at all, so exec_copies_at_joins never looks at them; 2,780 have an edge whose argument neither equals nor implies that edge's EXEC mask; 1 is read through another join. Two strengthenings were implemented and swept — the join ⊆ the block's entry EXEC, and each edge's argument ⊆ that edge's EXEC argument — and no program newly translates. That is semantic: these registers hold "lanes still looping", so at the join they include lanes that are not running; a ballot there drops exactly those bits, which is why mask_dword ballots only the active mask.

What lands now. The wording, only. Lower::unwritten_mask names which of the three shapes a program has — a mask spilled to a VGPR lane and read back and joined where no instruction writes it (206 of 209), a join with no writer that no spill is found for (3), or a program input (a value in Program::inputs; none in this corpus). What is accepted and refused, and the code emitted, do not change. Tests: mask_tests::a_mask_spilled_to_a_vgpr_lane_and_read_back_says_so (fails on 2f4d81e0: it reports "a program input") and mask_tests::a_join_of_two_compares_is_no_spilled_mask (a look-alike that stays refused). Sweep of the dump before and after: 0 newly translated, 0 outputs changed, 0 regressions, the 209 reason texts the only difference.

What the translation itself needs, and why it waits. Of the 209 containers, 176 then refuse at "an image descriptor's dwords 5 to 7" (#544) and 15 at "a buffer's dword 1" (#411); of the run's 84, 65 and 13. Making this branch translate adds no translation before those two land, so it is parked behind them.

**@⁠ShadyUnderLight** on GitHub · 2026-11-28 05:45 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/574) Measured, and the message is wrong: the value it names is never a program input. Refs #4. **Where.** `Lower::mask_number` (`crates/victory-shader/src/emit/lower.rs`) refuses when the value whose bits are wanted has no writing instruction (`def_block.get(&lo)`). The message said "a program input", which sent this issue after the SGPRs the title passes in. **What it actually is.** Dump of one headless run at `2f4d81e0` (M5 Max, Series X, 480 s, 2,816 frames): 1,554 refused containers; 209 of them refuse with this message (207 compute, 2 pixel), and the run logged it for 84 unique compute hashes. Every failure point was disassembled: 197 of 207 stop at `s_cbranch_execz`, the other 10 at `v_writelane_b32`/`s_cbranch_scc0`. A temporary trace in `mask_number` recorded 19,558 refusals, every one from a joining value with no writing instruction — never a live-in. The console compiler spills the mask to a VGPR lane and reads it back, and the read-back joins the loop register. `compute daff9d66adf677aa` at `0x9edc`: ``` 9eb8: v_writelane_b32 v141, s34, 7 9ec0: v_writelane_b32 v141, s85, 8 9ec8: v_readlane_b32 s34, v141, 3 9ed0: s_nand_b32 s34, s34, exec_lo 9ed4: s_mov_b32 exec_lo, s102 9ed8: s_and_b32 exec_lo, s34, exec_lo 9edc: s_cbranch_execz label_A7A0 ``` **Why #304's proof does not reach these joins.** Of 5,883 distinct (block, register) joins refused here: 3,102 sit in blocks with no EXEC join at all, so `exec_copies_at_joins` never looks at them; 2,780 have an edge whose argument neither equals nor implies that edge's EXEC mask; 1 is read through another join. Two strengthenings were implemented and swept — the join `⊆` the block's entry EXEC, and each edge's argument `⊆` that edge's EXEC argument — and no program newly translates. That is semantic: these registers hold "lanes still looping", so at the join they include lanes that are not running; a ballot there drops exactly those bits, which is why `mask_dword` ballots only the active mask. **What lands now.** The wording, only. `Lower::unwritten_mask` names which of the three shapes a program has — a mask spilled to a VGPR lane and read back and joined where no instruction writes it (206 of 209), a join with no writer that no spill is found for (3), or a program input (a value in `Program::inputs`; none in this corpus). What is accepted and refused, and the code emitted, do not change. Tests: `mask_tests::a_mask_spilled_to_a_vgpr_lane_and_read_back_says_so` (fails on `2f4d81e0`: it reports "a program input") and `mask_tests::a_join_of_two_compares_is_no_spilled_mask` (a look-alike that stays refused). Sweep of the dump before and after: 0 newly translated, 0 outputs changed, 0 regressions, the 209 reason texts the only difference. **What the translation itself needs, and why it waits.** Of the 209 containers, 176 then refuse at "an image descriptor's dwords 5 to 7" (#544) and 15 at "a buffer's dword 1" (#411); of the run's 84, 65 and 13. Making this branch translate adds no translation before those two land, so it is parked behind them.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 05:52:31 +00:00
Author
Owner

@⁠ShadyUnderLight on GitHub · 2026-11-28 05:46 UTC · original

/claim

**@⁠ShadyUnderLight** on GitHub · 2026-11-28 05:46 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/574#issuecomment-7234872261) /claim
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-28 05:46 UTC · original

Claimed by @⁠ShadyUnderLight. Open a draft pull request with Refs #574 in its description within 24 hours, or the claim expires.

**@⁠github-actions[bot]** on GitHub · 2026-11-28 05:46 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/574#issuecomment-7234874116) Claimed by @⁠ShadyUnderLight. Open a draft pull request with `Refs #574` in its description within 24 hours, or the claim expires.
Author
Owner

@⁠ShadyUnderLight on GitHub · 2026-11-28 06:19 UTC · original

Measured, and the shape is none of the three above: the message is wrong again.

Dump of one headless run at 2f4d81e0 (M5 Max, Series X, 480 s, 2,816 frames): 1,554 refused containers. Swept, 209 of them still refuse with this message (207 compute, 2 pixel); the run itself logged it for 84 unique compute hashes.

Where they stop. Disassembled every failure point: 197 of 207 stop at s_cbranch_execz, the other 10 at v_writelane_b32/s_cbranch_scc0. None is a program input: a temporary trace in mask_number recorded 19,558 refusals, every one from a joining value with no writing instruction (a phi), never from a live-in.

The mask is spilled into a VGPR lane, read back and joined. compute daff9d66adf677aa at 0x9edc:

9eb8: v_writelane_b32 v141, s34, 7
9ec0: v_writelane_b32 v141, s85, 8
9ec8: v_readlane_b32 s34, v141, 3
9ed0: s_nand_b32 s34, s34, exec_lo
9ed4: s_mov_b32 exec_lo, s102
9ed8: s_and_b32 exec_lo, s34, exec_lo
9edc: s_cbranch_execz label_A7A0

Why #304's proof does not reach them. Of 5,883 distinct (block, register) joins refused here: 3,102 sit in blocks with no EXEC join at all, so exec_copies_at_joins never looks at them; 2,780 have an edge whose argument mask neither equals nor implies that edge's EXEC mask; 1 is read through another join. Two strengthenings were implemented and swept — the join's merged mask ⊆ the block's entry EXEC, and each edge's argument ⊆ that edge's EXEC argument — and no program newly translates.

That is semantic, not a missing rule: these registers hold "lanes still looping", so at the join they include lanes that are not running (s_mov_b32 exec_lo, s102 puts them back later). A ballot there drops exactly those bits, which is why mask_dword ballots only the active mask.

What this refusal is worth on its own: nothing yet. Of the 209 containers, 176 then refuse at "an image descriptor's dwords 5 to 7" (#544) and 15 at "a buffer's dword 1" (#411); of the run's 84, 65 and 13. This branch cannot add a translation before #544 and #411 land, so it is parked behind them.

What should change now: the message. "a program input" sent this issue down the wrong path for a day; it should name the spilled-mask shape ("a lane mask spilled to a VGPR lane and read back, at a join with no writing instruction"), which is a diagnostics change only, with a test that pins the wording.

**@⁠ShadyUnderLight** on GitHub · 2026-11-28 06:19 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/574#issuecomment-7235225578) **Measured, and the shape is none of the three above: the message is wrong again.** Dump of one headless run at `2f4d81e0` (M5 Max, Series X, 480 s, 2,816 frames): 1,554 refused containers. Swept, 209 of them still refuse with this message (207 compute, 2 pixel); the run itself logged it for 84 unique compute hashes. **Where they stop.** Disassembled every failure point: 197 of 207 stop at `s_cbranch_execz`, the other 10 at `v_writelane_b32`/`s_cbranch_scc0`. None is a program input: a temporary trace in `mask_number` recorded 19,558 refusals, every one from a joining value with no writing instruction (a phi), never from a live-in. The mask is spilled into a VGPR lane, read back and joined. `compute daff9d66adf677aa` at `0x9edc`: ``` 9eb8: v_writelane_b32 v141, s34, 7 9ec0: v_writelane_b32 v141, s85, 8 9ec8: v_readlane_b32 s34, v141, 3 9ed0: s_nand_b32 s34, s34, exec_lo 9ed4: s_mov_b32 exec_lo, s102 9ed8: s_and_b32 exec_lo, s34, exec_lo 9edc: s_cbranch_execz label_A7A0 ``` **Why #304's proof does not reach them.** Of 5,883 distinct (block, register) joins refused here: 3,102 sit in blocks with no EXEC join at all, so `exec_copies_at_joins` never looks at them; 2,780 have an edge whose argument mask neither equals nor implies that edge's EXEC mask; 1 is read through another join. Two strengthenings were implemented and swept — the join's merged mask `⊆` the block's entry EXEC, and each edge's argument `⊆` that edge's EXEC argument — and **no program newly translates**. That is semantic, not a missing rule: these registers hold "lanes still looping", so at the join they include lanes that are not running (`s_mov_b32 exec_lo, s102` puts them back later). A ballot there drops exactly those bits, which is why `mask_dword` ballots only the active mask. **What this refusal is worth on its own: nothing yet.** Of the 209 containers, 176 then refuse at "an image descriptor's dwords 5 to 7" (#544) and 15 at "a buffer's dword 1" (#411); of the run's 84, 65 and 13. This branch cannot add a translation before #544 and #411 land, so it is parked behind them. **What should change now:** the message. "a program input" sent this issue down the wrong path for a day; it should name the spilled-mask shape ("a lane mask spilled to a VGPR lane and read back, at a join with no writing instruction"), which is a diagnostics change only, with a test that pins the wording.
github-bot changed title from Shader: 78 compute programs read a program-input lane mask as data to Shader: 78 compute programs are refused as "a program input" when a mask is spilled to a VGPR lane and read back 2026-11-28 07:01:11 +00:00
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-29 08:50 UTC · original

The claim by @⁠ShadyUnderLight has expired: no pull request referenced it within 24 hours. This issue is free to claim.

**@⁠github-actions[bot]** on GitHub · 2026-11-29 08:50 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/574#issuecomment-7253365888) The claim by @⁠ShadyUnderLight has expired: no pull request referenced it within 24 hours. This issue is free to claim.
This discussion has been locked. Commenting is limited to contributors.
No description provided.