[bug] A loop-carried lane mask read after a divergent loop is the lane's last pass, not the wave's #257

Open
opened 2026-11-27 05:34:38 +00:00 by github-bot · 3 comments
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-27 05:31 UTC · original

What is wrong

When lanes leave a divergent loop on different passes, a lane that reads a loop-carried lane mask after the loop gets the value from its own last pass. On the console the mask is a wave-wide scalar, so the lane should read what the wave's last pass left.

Shown with a synthetic program on Metal: lane 0 reads 0 where the console gives 1. Main translates the shape without refusal.

What is known

  • It is independent of the skip-edge rules in fill_phis (mask_differs_on_edge, no_mask_lane_on_edge) and of the rules now on fix/loop-and-arm-masks.
  • It comes from treating a scalar lane mask as per-lane data across the loop exit: the lane functions the structure keeps hold only for lanes that reach a value's block.
  • How many shaders in the corpus have the shape is being measured now. No fix is written.

Help wanted

  • A sound rule for it: either carry the wave's value to lanes that already left (the lockstep path does something like this), or refuse the shape.
  • The same question for a closely related family: about 56 pixel shaders build a loop mask by OR-ing lanes in and then removing them, and are refused today because one value has two instances (the one at the pass the lane left, and later passes).

The area is crates/victory-shader/src/emit/lower.rs around fill_phis. A note on the shape is in docs/native-host.md.

**@⁠LakshanSivakumar** on GitHub · 2026-11-27 05:31 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/257) **What is wrong** When lanes leave a divergent loop on different passes, a lane that reads a loop-carried lane mask *after* the loop gets the value from its own last pass. On the console the mask is a wave-wide scalar, so the lane should read what the wave's last pass left. Shown with a synthetic program on Metal: lane 0 reads 0 where the console gives 1. Main translates the shape without refusal. **What is known** - It is independent of the skip-edge rules in `fill_phis` (`mask_differs_on_edge`, `no_mask_lane_on_edge`) and of the rules now on `fix/loop-and-arm-masks`. - It comes from treating a scalar lane mask as per-lane data across the loop exit: the lane functions the structure keeps hold only for lanes that reach a value's block. - How many shaders in the corpus have the shape is being measured now. No fix is written. **Help wanted** - A sound rule for it: either carry the wave's value to lanes that already left (the lockstep path does something like this), or refuse the shape. - The same question for a closely related family: about 56 pixel shaders build a loop mask by OR-ing lanes in and then removing them, and are refused today because one value has two instances (the one at the pass the lane left, and later passes). The area is `crates/victory-shader/src/emit/lower.rs` around `fill_phis`. A note on the shape is in `docs/native-host.md`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 05:34:39 +00:00
Author
Owner

@⁠gagarinyury on GitHub · 2026-11-27 10:30 UTC · original

/claim

**@⁠gagarinyury** on GitHub · 2026-11-27 10:30 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/257#issuecomment-7215967665) /claim
Author
Owner

@⁠gagarinyury on GitHub · 2026-11-27 10:31 UTC · original

/claim

**@⁠gagarinyury** on GitHub · 2026-11-27 10:31 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/257#issuecomment-7215981430) /claim
Author
Owner

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

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

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