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

Open
opened 2026-11-27 19:23:14 +00:00 by github-bot · 2 comments
Owner

@⁠Sheffy007 on GitHub · 2026-11-27 19:20 UTC · original

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** on GitHub · 2026-11-27 19:20 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/444) ## 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
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 19:23:14 +00:00
Author
Owner

@⁠Sheffy007 on GitHub · 2026-11-27 19:20 UTC · original

/claim

**@⁠Sheffy007** on GitHub · 2026-11-27 19:20 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/444#issuecomment-7226438789) /claim
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-27 19:21 UTC · original

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

**@⁠github-actions[bot]** on GitHub · 2026-11-27 19:21 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/444#issuecomment-7226441841) Claimed by @⁠Sheffy007. Open a draft pull request with `Refs #444` in its description within 24 hours, or the claim expires.
This discussion has been locked. Commenting is limited to contributors.
No description provided.