shader: lower additional mesh SAVEEXEC patterns (Part of #3703) #3843

Merged
timbot103 merged 23 commits from upstream-pr/3843 into main 2026-12-03 04:28:04 +00:00
timbot103 commented 2026-12-02 08:42:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T08:42:21Z.


Part of #3703.

Summary

Targets the two #3703 mesh SAVEEXEC refusal buckets (mesh SAVEEXEC then arm depends on EXEC, 84 programs, and mesh SAVEEXEC VCC test requires an immediate VCC branch, 77 programs):

  • Evaluates s_and_b64/s_and_b32 mask tests at their original PC (setting SCC immediately and capturing the wave-uniform nonempty predicate for scheduled VCC/SCC branches across independent vector/32-bit scalar work, including dead SGPR-pair destinations), plus wave-uniform 32-bit Sopc forward SCC branches inside SAVEEXEC THEN arms.
  • Accepts common 32-bit scalar/SMEM tails before either restore form (find_restore), tracked EXEC mask copies (s_and_b64) and selects (s_cselect_b64 ... exec, 0) via needs_exact_exec, and Encoding::Mix ops in the vector-only inverse arm. Clobbers, escaping branches, backward loops, and leaked scalar values remain refused.

Verification

  • ctest --preset pr --no-tests=error --output-on-failure -R '^native_mesh_saveexec_exec_vcc_ir$': passed (16 positive DXIL cases + 22 refusal controls).
  • Debug (dev) and Release (release): 3/3 passed (native_mesh_saveexec_exec_vcc_ir|native_direct_mesh|native_direct_container), zero skips, zero new C++20 /W4 warnings on edited lines.
  • tests/bidi_controls_check.py, tests/docs_links_check.py, and git diff --check origin/main..HEAD passed.
  • Opened as Draft under #3514's 5-PR ready cap.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5602910599 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3843). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-02T08:42:21Z. --- Part of #3703. ### Summary Targets the two #3703 mesh `SAVEEXEC` refusal buckets (`mesh SAVEEXEC then arm depends on EXEC`, 84 programs, and `mesh SAVEEXEC VCC test requires an immediate VCC branch`, 77 programs): - Evaluates `s_and_b64`/`s_and_b32` mask tests at their original PC (setting SCC immediately and capturing the wave-uniform nonempty predicate for scheduled VCC/SCC branches across independent vector/32-bit scalar work, including dead SGPR-pair destinations), plus wave-uniform 32-bit `Sopc` forward SCC branches inside `SAVEEXEC` THEN arms. - Accepts common 32-bit scalar/SMEM tails before either restore form (`find_restore`), tracked EXEC mask copies (`s_and_b64`) and selects (`s_cselect_b64 ... exec, 0`) via `needs_exact_exec`, and `Encoding::Mix` ops in the vector-only inverse arm. Clobbers, escaping branches, backward loops, and leaked scalar values remain refused. ### Verification - `ctest --preset pr --no-tests=error --output-on-failure -R '^native_mesh_saveexec_exec_vcc_ir$'`: passed (16 positive DXIL cases + 22 refusal controls). - Debug (`dev`) and Release (`release`): 3/3 passed (`native_mesh_saveexec_exec_vcc_ir|native_direct_mesh|native_direct_container`), zero skips, zero new C++20 `/W4` warnings on edited lines. - `tests/bidi_controls_check.py`, `tests/docs_links_check.py`, and `git diff --check origin/main..HEAD` passed. - Opened as Draft under `#3514`'s 5-PR ready cap.
lukaslw-lab commented 2026-12-02 08:48:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T08:48:43Z.

Review: APPROVED


Reviewed fa774fcb (draft) by reading the diff; not built or run.

Verdict: approve. The scheduled VCC and SCC tests are matched only when nothing in between can change what the branch reads, and the new then-arm forms take the exact-EXEC path. No MUST.

  • SHOULD Run a before/after m86 census on f365f125 for the real gain on the 84 + 77. The tests now match across independent work, and a mask copy no longer needs a nested child. Both widen accepted shapes, so the census would also show that no program changes to a different refusal.
  • NIT This conflicts with #3707 (ours) and #3806 in lower_mesh. #3707 adds the same 32-bit SALU list and lane_free for loops that saveexec_scalar_tail (gfx1013_direct_mesh.inl:610) now holds. Whichever merges second can reuse the other's list. I will do that on #3707 if this lands first.
  • Checked, no finding:
    • Scheduled test (:812): an instruction in between may not read the AND's destination, EXEC, VCCZ or EXECZ, nor write the destination or the mask pair. A VOPC writing VCC, SMEM, or a compare ends the scan, and vcc_test then refuses. Scalar ALU in between disables only the SCC form. At the AND (:1674), SCC is the proven uniform bit, which equals "AND nonempty" inside a nonempty arm, and the AND's destination is cleared.
    • Arm SCC compares (:803): forward within the arm. Where a proof is needed (after allocation or before an else arm), both inputs must be wave-uniform, and a forward edge into the span is refused. group_flow is cleared for every matched test.
    • s_and_b64 sN, exec, x and s_cselect_b64 sN, exec, 0 set needs_exact_exec (:866), so the diamond computes exact masks instead of refusing. The s_cselect_b64 fix keeps an unknown EXEC word empty instead of selecting it.
    • find_restore (:660) accepts only saveexec_scalar_tail ops before the restore, and records their writes in gap_writes. diamond_joined uses the same list as before.

Tests: native_mesh_saveexec_exec_vcc_ir (16 cases, 22 refusals) is in the pr filter.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6147405317 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3843#pullrequestreview-6147405317). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-02T08:48:43Z. **Review:** APPROVED --- Reviewed `fa774fcb` (draft) by reading the diff; not built or run. **Verdict: approve.** The scheduled VCC and SCC tests are matched only when nothing in between can change what the branch reads, and the new then-arm forms take the exact-EXEC path. No MUST. - **SHOULD** Run a before/after `m86` census on `f365f125` for the real gain on the 84 + 77. The tests now match across independent work, and a mask copy no longer needs a nested child. Both widen accepted shapes, so the census would also show that no program changes to a different refusal. - **NIT** This conflicts with #3707 (ours) and #3806 in `lower_mesh`. #3707 adds the same 32-bit SALU list and `lane_free` for loops that `saveexec_scalar_tail` (`gfx1013_direct_mesh.inl:610`) now holds. Whichever merges second can reuse the other's list. I will do that on #3707 if this lands first. - Checked, no finding: - Scheduled test (`:812`): an instruction in between may not read the AND's destination, EXEC, VCCZ or EXECZ, nor write the destination or the mask pair. A VOPC writing VCC, SMEM, or a compare ends the scan, and `vcc_test` then refuses. Scalar ALU in between disables only the SCC form. At the AND (`:1674`), SCC is the proven uniform bit, which equals "AND nonempty" inside a nonempty arm, and the AND's destination is cleared. - Arm SCC compares (`:803`): forward within the arm. Where a proof is needed (after allocation or before an else arm), both inputs must be wave-uniform, and a forward edge into the span is refused. `group_flow` is cleared for every matched test. - `s_and_b64 sN, exec, x` and `s_cselect_b64 sN, exec, 0` set `needs_exact_exec` (`:866`), so the diamond computes exact masks instead of refusing. The `s_cselect_b64` fix keeps an unknown EXEC word empty instead of selecting it. - `find_restore` (`:660`) accepts only `saveexec_scalar_tail` ops before the restore, and records their writes in `gap_writes`. `diamond_joined` uses the same list as before. Tests: `native_mesh_saveexec_exec_vcc_ir` (16 cases, 22 refusals) is in the `pr` filter.
lukaslw-lab commented 2026-12-02 09:23:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T09:23:07Z.


Census follow-up for the SHOULD in my review: f365f125 + this PR alone, same capture and method as #3703 / #3814 (6,685 distinct mesh programs, 6,436 pixel stages). Counts only.

Build Mesh translated Lost vs main
f365f125 1,036 —
f365f125 + #3843 1,036 0

81 programs move off their first refusal: mesh SAVEEXEC VCC test requires an immediate VCC branch 77, unbound numeric SGPR s4 4. None of them reaches OK yet: each stops at a later wall. The 84 mesh SAVEEXEC then arm depends on EXEC programs do not move on this capture. No validation failures.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7340809261 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3843#issuecomment-7340809261). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-02T09:23:07Z. --- Census follow-up for the SHOULD in my review: `f365f125` + this PR alone, same capture and method as #3703 / #3814 (6,685 distinct mesh programs, 6,436 pixel stages). Counts only. | Build | Mesh translated | Lost vs main | |---|---:|---:| | `f365f125` | 1,036 | — | | `f365f125` + #3843 | 1,036 | 0 | 81 programs move off their first refusal: `mesh SAVEEXEC VCC test requires an immediate VCC branch` 77, `unbound numeric SGPR s4` 4. None of them reaches OK yet: each stops at a later wall. The 84 `mesh SAVEEXEC then arm depends on EXEC` programs do not move on this capture. No validation failures.
lukaslw-lab commented 2026-12-02 20:27:33 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T20:27:33Z.

Review: APPROVED


Re-review on b6c4f79b (rebased on 5770f14e: the 32-bit SALU list and lane_free hoisted for the two users, full_exec added to the exact-EXEC condition from main).

Verdict: approve.

Census, same capture and method as before (6,685 distinct mesh programs), main 5770f14e vs this head:

Programs
Translate, main / with this PR 1,047 / 1,047
Lost / gained 0 / 0
First refusal moved 81: SAVEEXEC VCC test requires an immediate VCC branch → SAVEEXEC then arm depends on EXEC 77; unbound numeric SGPR s4 → s2 4

Same 81 as the earlier head. The hoisted scalar_alu32 set is unchanged in content, and both users now share it.

Update: the first run was on a main that refused 257 programs early (my #3707, #3892; fixed by #3893). I reran main 5770f14e and this head, both with that fix: 81 moved, 0 lost, 0 gained. The numbers above are unchanged.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6158377798 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3843#pullrequestreview-6158377798). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-02T20:27:33Z. **Review:** APPROVED --- Re-review on `b6c4f79b` (rebased on `5770f14e`: the 32-bit SALU list and `lane_free` hoisted for the two users, `full_exec` added to the exact-EXEC condition from main). **Verdict: approve.** Census, same capture and method as before (6,685 distinct mesh programs), main `5770f14e` vs this head: | | Programs | |---|---:| | Translate, main / with this PR | 1,047 / 1,047 | | Lost / gained | 0 / 0 | | First refusal moved | 81: `SAVEEXEC VCC test requires an immediate VCC branch` → `SAVEEXEC then arm depends on EXEC` 77; `unbound numeric SGPR s4` → `s2` 4 | Same 81 as the earlier head. The hoisted `scalar_alu32` set is unchanged in content, and both users now share it. Update: the first run was on a main that refused 257 programs early (my #3707, #3892; fixed by #3893). I reran main `5770f14e` and this head, both with that fix: 81 moved, 0 lost, 0 gained. The numbers above are unchanged. AI-assisted.
timbot103 commented 2026-12-02 23:05:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T23:05:00Z.


Stacked on #3842, and through it on #3835. This branch includes their commits; please land them first.

  • 845d46f8 replaces the C++20 starts_with calls. native_compute_pack_refusal_check builds the frontend as C++17, which main CI compiles but PR CI does not, so this PR would otherwise have broken main's full build after merging.
  • b350ac6d fixes an interaction with #3842. An arm that both copies an EXEC mask and contains a broadcast could drop the exact SAVEEXEC region. The region is now kept, and a varying broadcast that would need a group barrier is refused. The mask-copy and mask-select controls pass in both configurations. Straight SAVEEXEC broadcasts still pass the WARP and RTX 5080 readbacks.

Tests, Windows 11 26200 with RTX 5080 and WARP. The mesh filter was native_direct_mesh|native_direct_container|native_mesh_ plus this PR's own tests. Every branch passed a full Debug build of every target, including the C++17 native_compute_pack_refusal_check.

  • Debug passed 20/20. Release passed 19/20, and the PR preset passed 1/1.
  • The Release failures are the existing asynchronous WARP allocation fixtures (accepted=1 refused=0). They also fail on a clean 67862ee4, and every one of them passed with X2W_SYNC_MESH_REQUESTS=1.

All six mesh PRs (#3832, #3835, #3838, #3842, #3843 and #3846) were also merged together onto 67862ee4. That combined tree passed 47/47 in Debug and 47/47 in Release, plus 8/8 under the PR preset. All 15 pairs merge cleanly.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7361541258 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3843#issuecomment-7361541258). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-02T23:05:00Z. --- **Stacked on #3842**, and through it on #3835. This branch includes their commits; please land them first. - `845d46f8` replaces the C++20 `starts_with` calls. `native_compute_pack_refusal_check` builds the frontend as C++17, which main CI compiles but PR CI does not, so this PR would otherwise have broken main's full build after merging. - `b350ac6d` fixes an interaction with #3842. An arm that both copies an EXEC mask and contains a broadcast could drop the exact SAVEEXEC region. The region is now kept, and a varying broadcast that would need a group barrier is refused. The mask-copy and mask-select controls pass in both configurations. Straight SAVEEXEC broadcasts still pass the WARP and RTX 5080 readbacks. Tests, Windows 11 26200 with RTX 5080 and WARP. The mesh filter was `native_direct_mesh|native_direct_container|native_mesh_` plus this PR's own tests. Every branch passed a full Debug build of every target, including the C++17 `native_compute_pack_refusal_check`. - Debug passed 20/20. Release passed 19/20, and the PR preset passed 1/1. - The Release failures are the existing asynchronous WARP allocation fixtures (`accepted=1 refused=0`). They also fail on a clean `67862ee4`, and every one of them passed with `X2W_SYNC_MESH_REQUESTS=1`. All six mesh PRs (#3832, #3835, #3838, #3842, #3843 and #3846) were also merged together onto `67862ee4`. That combined tree passed 47/47 in Debug and 47/47 in Release, plus 8/8 under the PR preset. All 15 pairs merge cleanly.
timbot103 commented 2026-12-02 23:59:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T23:59:45Z.


Merged the updated #3835 (705d91ab, its fixture now uses a reserved-bit control that does not depend on #3833) into this stacked branch. The merge was clean. On main c42b7ce3 the mesh filter passes in Debug, and in Release apart from the existing asynchronous WARP allocation fixtures, which also fail on clean main and pass with X2W_SYNC_MESH_REQUESTS=1.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7362672309 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3843#issuecomment-7362672309). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-02T23:59:45Z. --- Merged the updated #3835 (`705d91ab`, its fixture now uses a reserved-bit control that does not depend on #3833) into this stacked branch. The merge was clean. On main `c42b7ce3` the mesh filter passes in Debug, and in Release apart from the existing asynchronous WARP allocation fixtures, which also fail on clean main and pass with `X2W_SYNC_MESH_REQUESTS=1`.
timbot103 commented 2026-12-03 01:30:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-03T01:30:59Z.


Merged the updated #3842 (main f3ab02fe). The merge was clean, and the SAVEEXEC controls and inherited active-lane readbacks pass. This PR is still stacked on #3842 and #3835. The remaining failures also fail on clean main: native_mesh_entry_registers_ir (fix PR coming) and the asynchronous WARP allocation fixtures.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7364429217 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3843#issuecomment-7364429217). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-03T01:30:59Z. --- Merged the updated #3842 (main `f3ab02fe`). The merge was clean, and the SAVEEXEC controls and inherited active-lane readbacks pass. This PR is still stacked on #3842 and #3835. The remaining failures also fail on clean main: `native_mesh_entry_registers_ir` (fix PR coming) and the asynchronous WARP allocation fixtures.
timbot103 commented 2026-12-03 04:01:12 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-03T04:01:12Z.


Merged the updated #3842 (main 41a83a9a); the merge was clean. This PR is still stacked on #3842 only, since #3835 has merged. The mesh filter passed 22/22 in Debug. Release passed 19/22; the 3 failures are the existing asynchronous WARP fixtures. The PR preset passed 1/1.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7367177231 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3843#issuecomment-7367177231). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-03T04:01:12Z. --- Merged the updated #3842 (main `41a83a9a`); the merge was clean. This PR is still stacked on #3842 only, since #3835 has merged. The mesh filter passed 22/22 in Debug. Release passed 19/22; the 3 failures are the existing asynchronous WARP fixtures. The PR preset passed 1/1.
timbot103 commented 2026-12-03 04:17:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-03T04:17:23Z.


No longer stacked: #3842 has merged. Merged main (43055293) into this branch. The two conflicts keep this PR's exact-EXEC guard and its mask-copy and mask-select refusal controls. The diff against main now contains only this PR's SAVEEXEC changes, the C++17-compatible prefix check, and their fixtures. The mesh filter passed 22/22 in Debug. Release passed 19/22; the 3 failures are the existing asynchronous WARP allocation fixtures, which pass with X2W_SYNC_MESH_REQUESTS=1. The PR preset passed 1/1, and the RTX 5080 checks passed 5/5 in each configuration. Marked Ready for review, keeping within 5 non-draft PRs per #3514.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7367473554 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3843#issuecomment-7367473554). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-03T04:17:23Z. --- No longer stacked: #3842 has merged. Merged `main` (`43055293`) into this branch. The two conflicts keep this PR's exact-EXEC guard and its mask-copy and mask-select refusal controls. The diff against `main` now contains only this PR's SAVEEXEC changes, the C++17-compatible prefix check, and their fixtures. The mesh filter passed 22/22 in Debug. Release passed 19/22; the 3 failures are the existing asynchronous WARP allocation fixtures, which pass with `X2W_SYNC_MESH_REQUESTS=1`. The PR preset passed 1/1, and the RTX 5080 checks passed 5/5 in each configuration. Marked Ready for review, keeping within 5 non-draft PRs per #3514.
R0Y00 commented 2026-12-03 04:21:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T04:21:32Z.

Review: APPROVED


Independently reviewed 8974c077 after the #3842 merge. The clean trial merge onto main 0bb85d8f gives tree 098ff4149a5bb6e5d62526468728220c06a8b791, byte-for-byte the tree tested from this PR's three changes replayed onto that main. MSVC Debug ctest --preset dev --no-tests=error -j 1 --output-on-failure -R '^(native_mesh_saveexec_exec_vcc_ir|native_mesh_buffer_load_format_ir|native_mesh_readfirstlane_active_(controls|warp|hardware))$' passed 5/5. The inherited readbacks passed on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656, Windows build 26300, debug layer enabled, no skips. The new SAVEEXEC cases validate DXIL and the expected refusals. On the preceding source-equivalent SAVEEXEC revision c1076cc7, forcing the captured branch predicate to zero failed the scheduled-VCC DXIL assertion. The edit was local and restored.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6163640967 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3843#pullrequestreview-6163640967). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-03T04:21:32Z. **Review:** APPROVED --- Independently reviewed `8974c077` after the #3842 merge. The clean trial merge onto main `0bb85d8f` gives tree `098ff4149a5bb6e5d62526468728220c06a8b791`, byte-for-byte the tree tested from this PR's three changes replayed onto that main. MSVC Debug `ctest --preset dev --no-tests=error -j 1 --output-on-failure -R '^(native_mesh_saveexec_exec_vcc_ir|native_mesh_buffer_load_format_ir|native_mesh_readfirstlane_active_(controls|warp|hardware))$'` passed 5/5. The inherited readbacks passed on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656, Windows build 26300, debug layer enabled, no skips. The new SAVEEXEC cases validate DXIL and the expected refusals. On the preceding source-equivalent SAVEEXEC revision `c1076cc7`, forcing the captured branch predicate to zero failed the scheduled-VCC DXIL assertion. The edit was local and restored.
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!3843
No description provided.