Direct DXIL: Lw::top_vgpr() reads init.touched (empty outside Entry::Kernel and cleared in XCL_PER_LANE), truncating v_movrel* and v_swaprel_b32 #1890
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#1890
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 that direct DXIL'sv_movrel*andv_swaprel_b32lowering computes its VGPR index bound fromself.init.touched, which is only pre-populated forEntry::Kernel— and is explicitly emptied before every instruction inXCL_PER_LANE=1.Where
crates/xcl/src/gpu/dxil/lower_wide.rs:264-354(Lw::top_vgpr,Lw::movrel,Lw::swaprel)crates/xcl/src/gpu/dxil/kernel.rs:208-220(for d in cfg.insts.iter().filter(|_| kernel))crates/xcl/src/gpu/recomp/lower_dxil.rs:267-272(std::mem::take(&mut self.lw.init.touched)inDxilIr::foreign)Root cause
Lw::top_vgpr()returns the maximum VGPR present inself.init.touched(lower_wide.rs:264-266), andmovrel()/swaprel()clamp their select/write loops totop = self.top_vgpr().max(vdst).max(base).kernel.rs:208,lw.init.touchedis only pre-populated whenentry == Entry::Kernel. For all real shader stages (Entry::Compute,Entry::Vertex,Entry::Pixel,Entry::Mesh,Entry::Geometry),lw.init.touchedstarts empty and only accumulates VGPRs already lowered earlier in RPO order:v_movreld_b32 v0, s0writingv0 + m0beforev0 + m0has been referenced in an earlier block seestop == 0(or a lower VGPR index) and silently drops the write.v_movrels_b32 v0, v4orv_swaprel_b32readingv4 + m0where higher VGPRs are defined in a loop back-edge or initialized as stage inputs only referenced later silently reads0instead of the VGPR.XCL_PER_LANE=1,DxilIr::foreign()(lower_dxil.rs:267) swaps outself.lw.init.touchedwith an emptyBTreeSetbefore callingself.lw.inst_guarded(d, ...), sotop_vgpr()is always 0 (even inEntry::Kernel), silently dropping everym0 > 0write and returning0on everym0 > 0read. Additionally,Lower::bridge()(lower.rs:1624) only passesrdna2::vgpr_uses(d)(the base VGPR) intoinputs/outputs, sov_movrel*/v_swaprel_b32cannot safely bridge inXCL_PER_LANEunless refused or given the full VGPR range.Trigger
Any Compute/VS/PS/MS/GS shader translated through Direct DXIL (
XCL_DIRECT_DXIL=1/all) that executesv_movreld_b32 v0, v1withm0 = 2beforev2is directly named (e.g. dynamically indexing a VGPR array before readingv2out), or anyv_movrel*/v_swaprel_b32withm0 > 0underXCL_PER_LANE=1.Fix direction
instsinLw::new, matchingrecomp/emit.rs) in a dedicatedLw::max_vgpr: u64field instead of deriving it fromself.init.touched.v_movrel*/v_swaprel_b32inrecomp/lower.rs::bridge()(or pass/collect the full[base..=max_vgpr]VGPR range).AI use
main @ 689f2dband issue drafting.@WebIdentity1 on GitHub · 2026-11-24 23:41 UTC · original
I am investigating this with public synthetic compute-entry fixtures on native Windows/RTX 3090. I will check the program-wide VGPR bound separately from the per-lane bridge contract, and coordinate any fix here; the existing #1823 kernel tests do not exercise the same entry setup. I will leave the distinct swaprel destination-semantics change in #803 to its author.
AI use: Codex with GPT-6 Astra is doing the investigation and tests.