shader: follow constant/uniform v_cndmask terms, constant-mask selects, integer products, and v_readfirstlane in whole-wave sections #508

Open
opened 2026-11-27 22:48:24 +00:00 by Sheffy007 · 2 comments
Sheffy007 commented 2026-11-27 22:48:24 +00:00 (Migrated from github.com)
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Sheffy007 on 2026-11-27T22:48:24Z.


Summary

Several valid whole-wave reduction and prefix-scan shapes in crates/victory-shader/src/emit/wave.rs and lower.rs are currently refused as a whole-wave section step the simulation does not follow: a value that is no reduction or prefix (or VALU_SGPR / SCALAR):

  1. Constant or uniform active terms in v_cndmask_b32: WavePrefixSum(1), WaveActiveSum(k), WavePrefixSum(s_stride), and WavePrefixCountBits lowered via v_cndmask_b32 v_dst, 0, 1, s_saved (or v_cndmask_b32 v_dst, ident, s_uniform, s_saved) pass Sym::K or Sym::Uni as src1, which wave::simulate rejected as Sym::Unknown without setting why, refusing with a value that is no reduction or prefix.
  2. Constant lane-select masks in v_cndmask_b32 and s_mov_b64: Prefix scans that keep EXEC = -1 and mask rows/halves or lane 0 via s_mov_b32 / s_mov_b64 constant SGPRs into v_cndmask_b32 (or move a constant SGPR into EXEC) fell through to Sym::Unknown / SCALAR.
  3. Integer wave products (WaveActiveProduct / WavePrefixProduct): v_mul_lo_u32 and s_mul_i32 (Op::MulU, identity 1) were missing alongside Op::MulF.
  4. v_readfirstlane_b32 and inclusive-prefix total reads: v_readfirstlane_b32 inside a whole-wave section (reading exec.trailing_zeros(), e.g. lane 0 in place of the 8-byte v_readlane_b32 s, v, 0) hit VALU_SGPR; outside a section, v_readfirstlane_b32 on a section_uniform value or under a constant EXEC mask (s_mov_b64 exec, 1), as well as v_readlane_b32 of lane wave - 1 of an inclusive prefix, did not resolve through section_lanes.

Refs #4, #258

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6655663925 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/508). Originally posted by [Sheffy007](https://github.com/Sheffy007) on 2026-11-27T22:48:24Z. --- ## Summary Several valid whole-wave reduction and prefix-scan shapes in `crates/victory-shader/src/emit/wave.rs` and `lower.rs` are currently refused as `a whole-wave section step the simulation does not follow: a value that is no reduction or prefix` (or `VALU_SGPR` / `SCALAR`): 1. **Constant or uniform active terms in `v_cndmask_b32`**: `WavePrefixSum(1)`, `WaveActiveSum(k)`, `WavePrefixSum(s_stride)`, and `WavePrefixCountBits` lowered via `v_cndmask_b32 v_dst, 0, 1, s_saved` (or `v_cndmask_b32 v_dst, ident, s_uniform, s_saved`) pass `Sym::K` or `Sym::Uni` as `src1`, which `wave::simulate` rejected as `Sym::Unknown` without setting `why`, refusing with `a value that is no reduction or prefix`. 2. **Constant lane-select masks in `v_cndmask_b32` and `s_mov_b64`**: Prefix scans that keep `EXEC = -1` and mask rows/halves or lane 0 via `s_mov_b32` / `s_mov_b64` constant SGPRs into `v_cndmask_b32` (or move a constant SGPR into `EXEC`) fell through to `Sym::Unknown` / `SCALAR`. 3. **Integer wave products (`WaveActiveProduct` / `WavePrefixProduct`)**: `v_mul_lo_u32` and `s_mul_i32` (`Op::MulU`, identity `1`) were missing alongside `Op::MulF`. 4. **`v_readfirstlane_b32` and inclusive-prefix total reads**: `v_readfirstlane_b32` inside a whole-wave section (reading `exec.trailing_zeros()`, e.g. lane 0 in place of the 8-byte `v_readlane_b32 s, v, 0`) hit `VALU_SGPR`; outside a section, `v_readfirstlane_b32` on a `section_uniform` value or under a constant `EXEC` mask (`s_mov_b64 exec, 1`), as well as `v_readlane_b32` of lane `wave - 1` of an inclusive prefix, did not resolve through `section_lanes`. Refs #4, #258
Sheffy007 commented 2026-11-27 22:48:25 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Sheffy007 on 2026-11-27T22:48:25Z.


/claim

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7229632581 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/508#issuecomment-7229632581). Originally posted by [Sheffy007](https://github.com/Sheffy007) on 2026-11-27T22:48:25Z. --- /claim
github-actions[bot] commented 2026-11-27 22:48:36 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-27T22:48:36Z.


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

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7229635068 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/508#issuecomment-7229635068). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-27T22:48:36Z. --- Claimed by @Sheffy007. Open a draft pull request with `Refs #508` 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#508
No description provided.