[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:31:45 +00:00 by LakshanSivakumar · 3 comments
LakshanSivakumar commented 2026-11-27 05:31:45 +00:00 (Migrated from github.com)
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T05:31:45Z.


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.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6640629401 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/257). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-27T05:31:45Z. --- **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`.
gagarinyury commented 2026-11-27 10:30:33 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by gagarinyury on 2026-11-27T10:30:33Z.


/claim

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7215967665 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/257#issuecomment-7215967665). Originally posted by [gagarinyury](https://github.com/gagarinyury) on 2026-11-27T10:30:33Z. --- /claim
gagarinyury commented 2026-11-27 10:31:14 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by gagarinyury on 2026-11-27T10:31:14Z.


/claim

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7215981430 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/257#issuecomment-7215981430). Originally posted by [gagarinyury](https://github.com/gagarinyury) on 2026-11-27T10:31:14Z. --- /claim
github-actions[bot] commented 2026-11-27 10:31:26 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-27T10:31:26Z.


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

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