native: accept execz-skipped SGPR pair masked by EXEC at the join #3522

Manually merged
github merged 1 commit from github-bot/gh-3520 into gh-pr/3520/base 2026-11-30 08:44:42 +00:00 AGit
Owner

@⁠Leyukaka on GitHub · 2026-11-29 21:32 UTC · original
Leyukaka:native-compute-execz-join-mask → main · +240 −2 · 4 files · 1 commits · merged 2026-11-30 08:44 UTC

Refs #3226 (part 2 of our claim). Draft, under our open-PR cap (#3516).

Shape

An SGPR pair is defined only inside a block that s_cbranch_execz skips, and the first instruction at the join reads it as s_and_b64 pair, EXEC. Native direct compute refused this as unbound numeric SGPR, because the pair is unbound on the skip edge. This is the native counterpart of the gfx2hlsl join refusal released in #2645.

Acceptance rule

execz_join_mask_source (src/gfx1013_direct_compute.inl:5132) accepts the instruction at a join only if all of the following hold:

  • It is s_and_b64 with an even destination (at most s106, or EXEC), and its sources are EXEC and an even SGPR pair at most s104, in either order.
  • The join has exactly two incoming edges. branch_predecessors (:5227) drops any target reached by more than one branch, the join is not the entry, and the previous instruction is a non-branch, non-s_endpgm that falls through to it.
  • One edge is a forward taken s_cbranch_execz on which both pair words are unbound and both EXEC words are proven zero. In wave64 the branch tests both words. Otherwise it tests EXEC_LO only and the analysis must already know EXEC_HI is zero (:5152).
  • The other edge is the skipped block's fallthrough, on which both pair words are numeric (:5156).

On the skip edge EXEC is 0:0, so the AND and SCC are 0 whatever the pair holds. lower_execz_join_mask (:5160, called at :5314) loads the pair only when EXEC is nonzero, writes 0 to both result words otherwise, and derives SCC from both result words.

EXEC_HI tracking is State::exec_hi_zero in src/gfx1013_compute_native.cpp:

  • :530 the flag;
  • :696 recomputed on every write to s127;
  • :838 set by a narrow wave64 V_CMPX to EXEC, where the ballot write clears the upper half;
  • :996 merged as an AND at joins;
  • :1880 seeded true for direct DXIL when not wave64.

Still refused

The proof applies to that one instruction. The merged pair stays unbound for every other reader, so these keep the existing diagnostic:

  • s_or_b64, or an AND whose other source is not EXEC;
  • an unaligned source or destination;
  • a skip through s_cbranch_scc1 or s_cbranch_execnz;
  • a join with an extra incoming branch;
  • a pair word that is bound on the skip edge, or a high word that is not numeric on fallthrough;
  • EXEC_HI not proven zero when the branch tests EXEC_LO only;
  • a later raw read of the pair after the masked read;
  • an AND placed after EXEC is restored rather than at the branch target.

Tests

  • native_execz_join_mask_controls: passed. 12 refusal controls, each at the expected pc and register.
  • native_execz_join_mask_hardware: passed. Both groups matched on four profiles: wave64/64, wave64/64 with only high EXEC bits active, wave32/32, and narrow wave64/32. The readback checks active lanes, both mask words, SCC and buffer guards.
  • native_execz_join_mask_warp: skipped on this host (exit 77, requires shader model 6.6 with wave32).
  • Regressions, ctest -R '^(native_compute_|native_global_|native_execz|native_s_not_b64_exec_|native_wave64_exec_salu_)' -j 4: 20 tests, 17 passed, 0 failed, 3 skipped. The skips are native_compute_implicit_lod_warp, native_execz_join_mask_warp and native_global_srv_heap_replay_warp.
  • Mutations: 16 applied one at a time, each rebuilt, all caught. 14 fail the controls, covering each clause of the rule, the call site and the narrow wave64 V_CMPX flag. The other 2 fail only the hardware readback: hi replaced by lo in the high-word AND, and the skip-edge phi changed from 0 to 1.

Host: NVIDIA GeForce RTX 5080, driver 32.0.16.2101, Windows 10.0.26300, Debug build, X2W_WITH_OPUS=OFF. These tests do not enable the debug layer.

Not covered

  • WARP readback: the WARP test skips on this host.
**@⁠Leyukaka** on GitHub · 2026-11-29 21:32 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3520) `Leyukaka:native-compute-execz-join-mask` → `main` · +240 −2 · 4 files · 1 commits · merged 2026-11-30 08:44 UTC Refs #3226 (part 2 of our claim). Draft, under our open-PR cap (#3516). ## Shape An SGPR pair is defined only inside a block that `s_cbranch_execz` skips, and the first instruction at the join reads it as `s_and_b64 pair, EXEC`. Native direct compute refused this as `unbound numeric SGPR`, because the pair is unbound on the skip edge. This is the native counterpart of the gfx2hlsl join refusal released in #2645. ## Acceptance rule `execz_join_mask_source` (`src/gfx1013_direct_compute.inl:5132`) accepts the instruction at a join only if all of the following hold: - It is `s_and_b64` with an even destination (at most s106, or EXEC), and its sources are EXEC and an even SGPR pair at most s104, in either order. - The join has exactly two incoming edges. `branch_predecessors` (`:5227`) drops any target reached by more than one branch, the join is not the entry, and the previous instruction is a non-branch, non-`s_endpgm` that falls through to it. - One edge is a forward taken `s_cbranch_execz` on which both pair words are unbound and both EXEC words are proven zero. In wave64 the branch tests both words. Otherwise it tests EXEC_LO only and the analysis must already know EXEC_HI is zero (`:5152`). - The other edge is the skipped block's fallthrough, on which both pair words are numeric (`:5156`). On the skip edge EXEC is 0:0, so the AND and SCC are 0 whatever the pair holds. `lower_execz_join_mask` (`:5160`, called at `:5314`) loads the pair only when EXEC is nonzero, writes 0 to both result words otherwise, and derives SCC from both result words. EXEC_HI tracking is `State::exec_hi_zero` in `src/gfx1013_compute_native.cpp`: - `:530` the flag; - `:696` recomputed on every write to s127; - `:838` set by a narrow wave64 `V_CMPX` to EXEC, where the ballot write clears the upper half; - `:996` merged as an AND at joins; - `:1880` seeded true for direct DXIL when not wave64. ## Still refused The proof applies to that one instruction. The merged pair stays unbound for every other reader, so these keep the existing diagnostic: - `s_or_b64`, or an AND whose other source is not EXEC; - an unaligned source or destination; - a skip through `s_cbranch_scc1` or `s_cbranch_execnz`; - a join with an extra incoming branch; - a pair word that is bound on the skip edge, or a high word that is not numeric on fallthrough; - EXEC_HI not proven zero when the branch tests EXEC_LO only; - a later raw read of the pair after the masked read; - an AND placed after EXEC is restored rather than at the branch target. ## Tests - `native_execz_join_mask_controls`: passed. 12 refusal controls, each at the expected pc and register. - `native_execz_join_mask_hardware`: passed. Both groups matched on four profiles: wave64/64, wave64/64 with only high EXEC bits active, wave32/32, and narrow wave64/32. The readback checks active lanes, both mask words, SCC and buffer guards. - `native_execz_join_mask_warp`: skipped on this host (exit 77, requires shader model 6.6 with wave32). - Regressions, `ctest -R '^(native_compute_|native_global_|native_execz|native_s_not_b64_exec_|native_wave64_exec_salu_)' -j 4`: 20 tests, 17 passed, 0 failed, 3 skipped. The skips are `native_compute_implicit_lod_warp`, `native_execz_join_mask_warp` and `native_global_srv_heap_replay_warp`. - Mutations: 16 applied one at a time, each rebuilt, all caught. 14 fail the controls, covering each clause of the rule, the call site and the narrow wave64 `V_CMPX` flag. The other 2 fail only the hardware readback: `hi` replaced by `lo` in the high-word AND, and the skip-edge phi changed from 0 to 1. Host: NVIDIA GeForce RTX 5080, driver 32.0.16.2101, Windows 10.0.26300, Debug build, `X2W_WITH_OPUS=OFF`. These tests do not enable the debug layer. ## Not covered - WARP readback: the WARP test skips on this host.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 21:33:25 +00:00
Author
Owner

@⁠lukaslw-lab on GitHub · 2026-11-30 07:46 UTC · original · approved these changes

Reviewed da410f2e by reading the diff; not built or run.

Verdict: approve. The proof is sound for this one instruction. With exactly two incoming edges, the taken EXECZ edge proven to have both EXEC words zero, and the pair numeric on fallthrough, runtime EXEC != 0 at the join implies the fallthrough edge. So lower_execz_join_mask loads the pair only where it is defined, and the zero arm is exactly what s_and_b64 gives on the skip edge. No MUST.

  • NIT lower_execz_join_mask names its blocks after i.pc (execzMask<pc>, src/gfx1013_direct_compute.inl:5163). The rest of the file uses label_number++. If a later change ever lowers the same pc twice, this would emit duplicate labels; DXC would refuse that, so it cannot produce wrong output.
  • Checked, no finding:
    • exec_hi_zero only goes from true to false at merges (src/gfx1013_compute_native.cpp:996), so loops converge.
    • Every set() of s127 recomputes it, and the 64-bit set(i.dst + 1, {}) clears it.
    • The seed direct_dxil && !wave64 matches initialize().
    • In full wave64 the flag is never consulted, because the branch tests both words.
    • The fallthrough check reruns transfer with the same flags as the analysis (src/gfx1013_direct_compute.inl:5155).
    • branch_predecessors clears a target that two branches reach, and the fallthrough clauses rule out a second non-branch edge.
    • The destination stays an ordinary SALU result for the analysis, so later readers behave as before.

Tests: native_execz_join_mask_controls reaches each acceptance clause through its 12 refusals. _hardware checks active lanes, both mask words, SCC and guards on wave64, high-only EXEC, wave32 and narrow wave64. Together with the 16 mutations, that covers the rule and the two lowering details (hi word, skip-edge zero). CI ran none of them (native_execz_join_mask_* is not in the Windows pr filter, not even _controls), so the results are the author's RTX 5080 run only. WARP readback is still open, as stated.

**@⁠lukaslw-lab** on GitHub · 2026-11-30 07:46 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3520#pullrequestreview-6108453257) · **approved these changes** Reviewed `da410f2e` by reading the diff; not built or run. **Verdict: approve.** The proof is sound for this one instruction. With exactly two incoming edges, the taken EXECZ edge proven to have both EXEC words zero, and the pair numeric on fallthrough, runtime `EXEC != 0` at the join implies the fallthrough edge. So `lower_execz_join_mask` loads the pair only where it is defined, and the zero arm is exactly what `s_and_b64` gives on the skip edge. No MUST. - **NIT** `lower_execz_join_mask` names its blocks after `i.pc` (`execzMask<pc>`, `src/gfx1013_direct_compute.inl:5163`). The rest of the file uses `label_number++`. If a later change ever lowers the same pc twice, this would emit duplicate labels; DXC would refuse that, so it cannot produce wrong output. - Checked, no finding: - `exec_hi_zero` only goes from true to false at merges (`src/gfx1013_compute_native.cpp:996`), so loops converge. - Every `set()` of s127 recomputes it, and the 64-bit `set(i.dst + 1, {})` clears it. - The seed `direct_dxil && !wave64` matches `initialize()`. - In full wave64 the flag is never consulted, because the branch tests both words. - The fallthrough check reruns `transfer` with the same flags as the analysis (`src/gfx1013_direct_compute.inl:5155`). - `branch_predecessors` clears a target that two branches reach, and the fallthrough clauses rule out a second non-branch edge. - The destination stays an ordinary SALU result for the analysis, so later readers behave as before. Tests: `native_execz_join_mask_controls` reaches each acceptance clause through its 12 refusals. `_hardware` checks active lanes, both mask words, SCC and guards on wave64, high-only EXEC, wave32 and narrow wave64. Together with the 16 mutations, that covers the rule and the two lowering details (hi word, skip-edge zero). CI ran none of them (`native_execz_join_mask_*` is not in the Windows `pr` filter, not even `_controls`), so the results are the author's RTX 5080 run only. WARP readback is still open, as stated.
github-bot changed target branch from main to gh-pr/3520/base 2026-11-30 08:44:39 +00:00
github manually merged commit da410f2e7f into gh-pr/3520/base 2026-11-30 08:44:42 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.