shader: lower VCC-mask and if-only mesh SAVEEXEC shapes in a lane skip (Part of #2413) #3668

Merged
mumba17 merged 5 commits from upstream-pr/3668 into main 2026-12-01 03:11:44 +00:00
mumba17 commented 2026-11-30 22:51:27 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by mumba17 on 2026-11-30T22:51:27Z.


Part of #2413. Stacked on #3645. Only the last three commits are new: 70103884, 9cccc933, 319ec35e. The rest is #3645.

With #3635/#3645/#3646/#3655 applied, unsupported mesh SAVEEXEC operands was the first refusal for 19 of the 454 cached slot 57 requests. All 19 have the form s_and_saveexec_b64 sD, vcc. Once the operand was accepted, two more shapes showed up behind it.

  1. VCC as the mask (70103884). The compiler often saves EXEC against a compare's VCC directly. graphics_lane_mask already returns this lane's VCC bit, so source 106 is now accepted next to an even SGPR pair. vcc_hi stays refused.
  2. If without an else (9cccc933). Here the EXECZ target restores the saved mask (s_mov_b64 exec, sD) instead of starting an else arm with s_andn2_b64 exec, sD, exec. This is lowered as a then-only diamond that joins at the EXECZ target. Between the target and the restore, only scalar loads, s_waitcnt, s_clause and s_nop may sit; the existing diamond-join gap from #3633 lowers them once for the wave. Anything else still refuses with "else arm lacks the saved-mask inverse".
  3. Then-arm VCC writes (319ec35e). Most of these then arms compare into VCC. #3645's review follow-up refused that. Following @lukaslw-lab's other option, VCC is now clobbered at the join instead, along with its wave words through after_graphics_write. The arm still reads its own lane's bit, and any VCC read after the join refuses. v_div_scale stays refused.

Census, the 19 requests:

  • Before: all 19 stop at unsupported mesh SAVEEXEC operands.
  • After: 18 stop at a SAVEEXEC nested inside the then arm (then arm depends on EXEC), which needs a stack of diamonds and is left for a follow-up. 1 stops at then arm lacks an EXECZ skip.

Tests (tests/native_direct_mesh_check.py):

  • Positives:
    • saveexec-vcc;
    • saveexec-if and saveexec-if-gap, where the then edge selects 2 and the else edge keeps the old v1;
    • saveexec-if-then-vcc;
    • saveexec-then-vopc, saveexec-then-vop3-vcc and saveexec-then-carry, which were refusals in #3645 and now lower.
  • Refusals:
    • saveexec-vcc-hi;
    • saveexec-if-salu-gap;
    • saveexec-if-wrong-restore;
    • VCC read after the join: saveexec-then-vcc-read-after (if/else form) and saveexec-if-vcc-read-after (if-only form). Both refuse with graphics register undefined on an incoming path: 106.
  • Mutations: each fails native_direct_mesh:
    • VCC refused again;
    • the if-only path refused;
    • any instruction allowed in the gap;
    • a restore from any pair accepted;
    • no VCC clobber at the join (caught by the if-only read-after control).
  • One mutation survives: dropping the odd-source check. vcc_hi (107) is already refused by the range check, and the odd SGPR pairs are covered by #3645's controls.

ctest -R "mesh|compile_dxil": 204/204.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5575217263 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3668). Originally posted by [mumba17](https://github.com/mumba17) on 2026-11-30T22:51:27Z. --- Part of #2413. **Stacked on #3645.** Only the last three commits are new: `70103884`, `9cccc933`, `319ec35e`. The rest is #3645. With #3635/#3645/#3646/#3655 applied, `unsupported mesh SAVEEXEC operands` was the first refusal for 19 of the 454 cached slot 57 requests. All 19 have the form `s_and_saveexec_b64 sD, vcc`. Once the operand was accepted, two more shapes showed up behind it. 1. **VCC as the mask** (`70103884`). The compiler often saves EXEC against a compare's VCC directly. `graphics_lane_mask` already returns this lane's VCC bit, so source 106 is now accepted next to an even SGPR pair. `vcc_hi` stays refused. 2. **If without an else** (`9cccc933`). Here the EXECZ target restores the saved mask (`s_mov_b64 exec, sD`) instead of starting an else arm with `s_andn2_b64 exec, sD, exec`. This is lowered as a then-only diamond that joins at the EXECZ target. Between the target and the restore, only scalar loads, `s_waitcnt`, `s_clause` and `s_nop` may sit; the existing diamond-join gap from #3633 lowers them once for the wave. Anything else still refuses with "else arm lacks the saved-mask inverse". 3. **Then-arm VCC writes** (`319ec35e`). Most of these then arms compare into VCC. #3645's review follow-up refused that. Following @lukaslw-lab's other option, VCC is now clobbered at the join instead, along with its wave words through `after_graphics_write`. The arm still reads its own lane's bit, and any VCC read after the join refuses. `v_div_scale` stays refused. **Census, the 19 requests:** - Before: all 19 stop at `unsupported mesh SAVEEXEC operands`. - After: 18 stop at a SAVEEXEC nested inside the then arm (`then arm depends on EXEC`), which needs a stack of diamonds and is left for a follow-up. 1 stops at `then arm lacks an EXECZ skip`. **Tests** (`tests/native_direct_mesh_check.py`): - Positives: - `saveexec-vcc`; - `saveexec-if` and `saveexec-if-gap`, where the then edge selects 2 and the else edge keeps the old v1; - `saveexec-if-then-vcc`; - `saveexec-then-vopc`, `saveexec-then-vop3-vcc` and `saveexec-then-carry`, which were refusals in #3645 and now lower. - Refusals: - `saveexec-vcc-hi`; - `saveexec-if-salu-gap`; - `saveexec-if-wrong-restore`; - VCC read after the join: `saveexec-then-vcc-read-after` (if/else form) and `saveexec-if-vcc-read-after` (if-only form). Both refuse with `graphics register undefined on an incoming path: 106`. - Mutations: each fails `native_direct_mesh`: - VCC refused again; - the if-only path refused; - any instruction allowed in the gap; - a restore from any pair accepted; - no VCC clobber at the join (caught by the if-only read-after control). - One mutation survives: dropping the odd-source check. `vcc_hi` (107) is already refused by the range check, and the odd SGPR pairs are covered by #3645's controls. `ctest -R "mesh|compile_dxil"`: 204/204. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
lukaslw-lab commented 2026-12-01 01:22:25 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-01T01:22:25Z.

Review: COMMENTED


Reviewed 319ec35e (the three commits over #3645) by reading the diff; not built or run.

Verdict: comment. VCC as the mask, the if-only diamond and the join clobber are right. But allowing then-arm compares into VCC exposes a wave-level VCC word the arm does not narrow. No MUST. I'd approve once it is closed.

  • SHOULD Inside the then arm, vcc_words carry the else lanes' bits. The in-skip SAVEEXEC never narrows exec_value. A then-arm VOPC with uniform operands therefore writes vcc_words = select(pred, exec_value, 0) from the parent EXEC (the i.dst==106 branch of the v_cmp_ lowering). Hardware writes only then-lane bits. vcc_nonempty happens to agree, because the arm runs only when a then lane exists. But a scalar mask read of vcc in the arm sees the else lanes: s_and_b64 s[30:31], vcc, s[x:y] with its SCC, then s_cbranch_scc* (allowed in the if-only arm, where lane_else is 0), or s_bcnt1. #3645 refused all then-arm VCC writes, so this is new. Refusing scalar reads of 106/107 in the then-arm scan, or clearing vcc_words inside the arm, would close it. The existing controls compare s21 with v0, which is not uniform, so they never set the words.
  • NIT The if-only scan accepts SMEM, s_waitcnt, s_clause and s_nop between the EXECZ target and the restore. Since #3646, the join gap also lowers s_cmp* and 32-bit SALU there. After a rebase, the scan could use the same list. It fails closed as it is (saveexec-if-salu-gap).
  • Checked, no finding:
    • VCC mask: graphics_lane_mask returns the lane bit. vcc_hi and odd pairs refuse.
    • If-only: alternate == join, so the else edge is the entry state. restores routes the s_mov_b64 exec, sD restore through the existing gap logic.
    • Join clobber: alu.write(106/107, {}) calls after_graphics_write, which clears both words and vcc_nonempty. The else arm still refuses VCC-reading sources through then_writes.
    • Merges cleanly with main a3bfd019.

Tests: the new positives and the two read-after controls reach the new code. CI at this head (22:51 UTC) ran before #3644 put native_direct_mesh into the pr filter, so only your local run covers them.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6123500066 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3668#pullrequestreview-6123500066). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-01T01:22:25Z. **Review:** COMMENTED --- Reviewed `319ec35e` (the three commits over #3645) by reading the diff; not built or run. **Verdict: comment.** VCC as the mask, the if-only diamond and the join clobber are right. But allowing then-arm compares into VCC exposes a wave-level VCC word the arm does not narrow. No MUST. I'd approve once it is closed. - **SHOULD** Inside the then arm, `vcc_words` carry the else lanes' bits. The in-skip SAVEEXEC never narrows `exec_value`. A then-arm VOPC with uniform operands therefore writes `vcc_words = select(pred, exec_value, 0)` from the parent EXEC (the `i.dst==106` branch of the `v_cmp_` lowering). Hardware writes only then-lane bits. `vcc_nonempty` happens to agree, because the arm runs only when a then lane exists. But a scalar mask read of `vcc` in the arm sees the else lanes: `s_and_b64 s[30:31], vcc, s[x:y]` with its SCC, then `s_cbranch_scc*` (allowed in the if-only arm, where `lane_else` is 0), or `s_bcnt1`. #3645 refused all then-arm VCC writes, so this is new. Refusing scalar reads of 106/107 in the then-arm scan, or clearing `vcc_words` inside the arm, would close it. The existing controls compare `s21` with `v0`, which is not uniform, so they never set the words. - **NIT** The if-only scan accepts SMEM, `s_waitcnt`, `s_clause` and `s_nop` between the EXECZ target and the restore. Since #3646, the join gap also lowers `s_cmp*` and 32-bit SALU there. After a rebase, the scan could use the same list. It fails closed as it is (`saveexec-if-salu-gap`). - Checked, no finding: - VCC mask: `graphics_lane_mask` returns the lane bit. `vcc_hi` and odd pairs refuse. - If-only: `alternate == join`, so the else edge is the entry state. `restores` routes the `s_mov_b64 exec, sD` restore through the existing gap logic. - Join clobber: `alu.write(106/107, {})` calls `after_graphics_write`, which clears both words and `vcc_nonempty`. The else arm still refuses VCC-reading sources through `then_writes`. - Merges cleanly with main `a3bfd019`. Tests: the new positives and the two read-after controls reach the new code. CI at this head (22:51 UTC) ran before #3644 put `native_direct_mesh` into the `pr` filter, so only your local run covers them.
R0Y00 commented 2026-12-01 03:10:55 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-01T03:10:55Z.

Review: APPROVED


Reviewed the in-skip SAVEEXEC extension. The lowering supports a VCC condition and the if-only restore form, and invalidates the then arm's VCC values at the join. ctest --test-dir <build> --no-tests=error -j1 -R '^native_direct_mesh$' --output-on-failure passed in the integration, including the accepted if/else and if-only shapes and the downstream VCC refusal controls.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6124495921 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3668#pullrequestreview-6124495921). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-01T03:10:55Z. **Review:** APPROVED --- Reviewed the in-skip SAVEEXEC extension. The lowering supports a VCC condition and the if-only restore form, and invalidates the then arm's VCC values at the join. `ctest --test-dir <build> --no-tests=error -j1 -R '^native_direct_mesh$' --output-on-failure` passed in the integration, including the accepted if/else and if-only shapes and the downstream VCC refusal controls.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!3668
No description provided.