Per-lane: a mask last written in a per-lane loop leaves the code behind it unguarded (lane_masks) #3440
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by throny on 2026-11-29T17:20:57Z.
Found while reviewing local work on the per-lane analysis (C56 on #3011). On
main0fe06eb0,gpu/recomp/lane_masks.rsleaves an instruction without its EXEC guard when the mask that narrows EXEC was last written inside a per-lane loop.Program (wave64, the encodings the module's tests use):
Console: after the loop VCC holds the compare of the last round only, so it has bits just for the lanes that were still in the loop in that round.
s_and_saveexecnarrows EXEC to those lanes, and thev_movruns only there.Per-lane form: every lane keeps its own last compare bit, and every lane left the loop with that bit set. The summary lists no guard for pc 28 (
guardedis empty), so thev_movruns in every lane, also in those the console leaves out.Test that shows it (add to
lane_masks.rsmod tests; fails onmainwithleft: []):Run here:
cargo test -p xcl --lib -- lane_masks, RTX 4080 16 GB, Windows 11: the assertion fails withleft: [].Effect: only with
XCL_PER_LANE=1(off by default). A program of this shape would write a register in lanes the console skips. Whether the retail title has such a program I have not checked.What I think the cause is (reading, not verified further): a mask written in a loop body where lanes leave one by one is treated after the loop as each lane's own bit, although on the console the register is one wave-wide value from the last round. Such a mask would have to be refused, or guarded as unknown, when it is read after the loop.
Not tested: a GPU run of this program in both forms; other shapes (a mask from one side of an if read after the join may have the same problem).
AI use: Claude Code; a Claude Opus 5.5 review found the shape, a Claude Fable 5.2 agent wrote and ran the test, Claude Fable 5.2 wrote this report.