Per-lane: DxilIr::ballot and DxilIr::read_lane do not update self.tails after spin_exchange, emitting invalid DXIL PHI predecessors #1889
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl#1889
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?
@microwave805 on GitHub · 2026-11-24 22:37 UTC · original
Static audit on
main @ 689f2dbfound thatDxilIr::ballotandDxilIr::read_lanedo not updateself.tails[self.cur]after callingLwsplit-wave64 helpers that create basic blocks viaspin_exchange.Where
crates/xcl/src/gpu/recomp/lower_dxil.rs:229-237(DxilIr::ballot)crates/xcl/src/gpu/recomp/lower_dxil.rs:281-288(DxilIr::read_lane)crates/xcl/src/gpu/recomp/lower_dxil.rs:277-278(DxilIr::foreign, which doesself.tails[self.cur] = self.lw.cur();)crates/xcl/src/gpu/dxil/lanes.rs:271-368(Lw::spin_exchange)Root cause
DxilIrtracks eachIrblock's starting DXIL block (self.blocks[b]) and current tail DXIL block (self.tails[b]) soDxilIr::incoming()(lower_dxil.rs:138) wires PHI predecessors toself.tails[pred]andDxilIr::at()(lower_dxil.rs:161) resumes emission atself.tails[block].In split wave64 compute shaders with more than 64 threads per group (
Partner::Spin),self.lw.ballot(c)andself.lw.read_lane_uniform(v, lane)both callself.lw.exchange(m)→self.lw.spin_exchange(...), which creates multiple new DXIL basic blocks (guarded(go, ...)→guarded(first, ...)→ spin looplp/ex/ joins) and advancesself.lw.cur()to the final join block.Because neither
DxilIr::ballotnorDxilIr::read_laneupdatesself.tails[self.cur] = self.lw.cur():br/br_ifterminates the post-spin_exchangejoin block, whileDxilIr::incoming()records the pre-exchangeself.tails[pred]as the PHI predecessor in successor blocks, producing malformed DXIL (PHI node entries do not match predecessors!).DxilIr::at(cur)would position the builder back in the already-terminated pre-exchange block.Trigger
Any wave64 compute shader lowered via
lower_dxil::compute_split(XCL_DIRECT_DXIL=1 XCL_PER_LANE=1on a wave32 GPU) withthreads > 64(e.g.[128, 1, 1]) that performs a whole-wave ballot (e.g.s_bcnt1_i32_b64,s_ff1_i32_b64, mask-to-number read) orv_readlane_b32/v_readfirstlane_b32in a block feeding a PHI at a successor block.Fix direction
Update
self.tails[self.cur] = self.lw.cur();in bothDxilIr::ballotandDxilIr::read_lanewheneverself.lw.splitis true (matchingDxilIr::foreign), and add a unit test compiling a[128, 1, 1]split wave64 compute shader withv_readlane_b32/s_bcnt1_i32_b64feeding a successor PHI through DXIL validation.AI use
main @ 689f2dband issue drafting.@oni-swr on GitHub · 2026-11-25 11:15 UTC · original
Taking #1889: update self.tails after spin_exchange in DxilIr::ballot and DxilIr::read_lane and add regression coverage proving valid DXIL PHI predecessors.
@oni-swr on GitHub · 2026-11-25 12:02 UTC · original
Releasing our claim on #1889: open PR #1928 already covers this.