shader: lower host-wave lane-mask joins and EXEC-masked skip reads on the host's lanes #444

Open
opened 2026-11-27 19:20:57 +00:00 by Sheffy007 · 2 comments
Sheffy007 commented 2026-11-27 19:20:57 +00:00 (Migrated from github.com)
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Sheffy007 on 2026-11-27T19:20:57Z.


Problem

In the #4 world-run refusal summary (18 distinct shaders: 17 graphics + 1 compute), pixel, vertex, mesh, and wave32 compute shaders running with !self.console_lanes fail at fill_phis (lower.rs:15069) with:

a lane-mask join of an untracked mask: data, on the host's lanes

Three gaps cause valid host-wave-safe lane-mask joins to hit HOST_LANES:

  1. pending_masks (lower.rs:14999-15070) does not lower MaskData::Host masks at host-uniform joins (and restricts mesh to non-loop two-predecessor forward branches):
    • While data_phis (lower.rs:14917) and Atom::Opaque (lower.rs:3692) accept proven host-wave-safe masks (is_host_wave_mask: s_bitset0(rem, s_ff1(rem)), rem & (rem - 1), 1 << s_ff1(rem), 0 - flag, s_ashr_i32 x, 31, quad-periodic masks, etc.), pending_masks sets number = self.console_lanes && uniform || mesh_number, which is false for all pixel and vertex shaders (and for uniform loops in mesh shaders).
    • Consequently, any waterfall/peeling loop or uniform branch in a pixel or vertex shader whose loop-carried or merged mask is read both as data and as a lane mask (or passes through s_wqm, excluded from st.other because Atom::Quad is a derivative shortcut) falls through to HOST_LANES.
    • Using st.bools.given(edge_cond, st.reach[b]) alongside uniform_join proves that every reachable edge into b is host-wave-uniform relative to b (rejecting multi-block per-lane if/else arms ending in unconditional jumps while accepting uniform loops and multi-block uniform branches).
  2. is_host_wave_mask and is_uniform_bitmask32 miss s_wqm_b32/s_wqm_b64, 1-bit sign-extending s_bfe_i32/s_bfe_i64, s_mul_i32 (flag * -1), and quad-periodic s_bitreplicate_b64_b32:
    • s_wqm expands aligned 4-lane quads identically on 32-lane and 64-lane host waves and is already lowered per-quad in MaskData::Host.
    • s_bfe_i32 / s_bfe_i64 with width 1 ((imm >> 16 & 0x7F) == 1) and s_mul_i32 by -1 of a 0/1 scalar flag produce uniform all-0 / all-1 masks across all lanes.
  3. unneeded_edges (keeps_exec_read, lower.rs:11308) misses v_cndmask_b32, s_*_saveexec_* / s_*_wrexec_*, s_nor_*, and src[0] == EXEC operand order:
    • In pixel and vertex shaders, a joined boolean SGPR mask whose s_cbranch_execz skip edge carries stale scalar data is frequently consumed directly by v_cndmask_b32 or s_and_saveexec_* under the narrowed EXEC (where none of the skipping lanes are active). Recognizing those EXEC-masked consumers marks the skip edge unneeded without requiring console lanes.

Refs #4, #258

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6653113536 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/444). Originally posted by [Sheffy007](https://github.com/Sheffy007) on 2026-11-27T19:20:57Z. --- ## Problem In the `#4` world-run refusal summary (`18` distinct shaders: `17` graphics + `1` compute), pixel, vertex, mesh, and wave32 compute shaders running with `!self.console_lanes` fail at `fill_phis` (`lower.rs:15069`) with: `a lane-mask join of an untracked mask: data, on the host's lanes` Three gaps cause valid host-wave-safe lane-mask joins to hit `HOST_LANES`: 1. **`pending_masks` (`lower.rs:14999-15070`) does not lower `MaskData::Host` masks at host-uniform joins (and restricts `mesh` to non-loop two-predecessor forward branches):** - While `data_phis` (`lower.rs:14917`) and `Atom::Opaque` (`lower.rs:3692`) accept proven host-wave-safe masks (`is_host_wave_mask`: `s_bitset0(rem, s_ff1(rem))`, `rem & (rem - 1)`, `1 << s_ff1(rem)`, `0 - flag`, `s_ashr_i32 x, 31`, quad-periodic masks, etc.), `pending_masks` sets `number = self.console_lanes && uniform || mesh_number`, which is `false` for all pixel and vertex shaders (and for uniform loops in mesh shaders). - Consequently, any waterfall/peeling loop or uniform branch in a pixel or vertex shader whose loop-carried or merged mask is read both as data and as a lane mask (or passes through `s_wqm`, excluded from `st.other` because `Atom::Quad` is a derivative shortcut) falls through to `HOST_LANES`. - Using `st.bools.given(edge_cond, st.reach[b])` alongside `uniform_join` proves that every reachable edge into `b` is host-wave-uniform relative to `b` (rejecting multi-block per-lane `if/else` arms ending in unconditional jumps while accepting uniform loops and multi-block uniform branches). 2. **`is_host_wave_mask` and `is_uniform_bitmask32` miss `s_wqm_b32`/`s_wqm_b64`, 1-bit sign-extending `s_bfe_i32`/`s_bfe_i64`, `s_mul_i32` (`flag * -1`), and quad-periodic `s_bitreplicate_b64_b32`:** - `s_wqm` expands aligned 4-lane quads identically on 32-lane and 64-lane host waves and is already lowered per-quad in `MaskData::Host`. - `s_bfe_i32` / `s_bfe_i64` with width `1` (`(imm >> 16 & 0x7F) == 1`) and `s_mul_i32` by `-1` of a `0/1` scalar flag produce uniform all-0 / all-1 masks across all lanes. 3. **`unneeded_edges` (`keeps_exec_read`, `lower.rs:11308`) misses `v_cndmask_b32`, `s_*_saveexec_*` / `s_*_wrexec_*`, `s_nor_*`, and `src[0] == EXEC` operand order:** - In pixel and vertex shaders, a joined boolean SGPR mask whose `s_cbranch_execz` skip edge carries stale scalar data is frequently consumed directly by `v_cndmask_b32` or `s_and_saveexec_*` under the narrowed `EXEC` (where none of the skipping lanes are active). Recognizing those `EXEC`-masked consumers marks the skip edge unneeded without requiring console lanes. Refs #4, #258
Sheffy007 commented 2026-11-27 19:20:58 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Sheffy007 on 2026-11-27T19:20:58Z.


/claim

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7226438789 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/444#issuecomment-7226438789). Originally posted by [Sheffy007](https://github.com/Sheffy007) on 2026-11-27T19:20:58Z. --- /claim
github-actions[bot] commented 2026-11-27 19:21:09 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-27T19:21:09Z.


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

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7226441841 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/444#issuecomment-7226441841). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-27T19:21:09Z. --- Claimed by @Sheffy007. Open a draft pull request with `Refs #444` in its description within 24 hours, or the claim expires.
Sign in to join this conversation.
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
LakshanSivakumar/Native-Victory-macOS#444
No description provided.