shader: lower lane-mask phis and wave32 s_movk/s_cmovk masks read as data #528
Labels
No labels
accessibility
bug
claimed
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
tester report
urgent
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LakshanSivakumar--Native-Victory-macOS#528
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?
@Sheffy007 on GitHub · 2026-11-28 00:31 UTC · original
Problem
In world runs on
86cefd22(#525), 32 shader refusals fail with:"a lane mask holding lanes elsewhere read as data: a program input"and 5 fail with:
"a lane mask holding lanes elsewhere read as data: written by a scalar instruction of the other width".Root causes in
crates/victory-shader/src/emit/lower.rsandcrates/victory-shader/src/structure.rs:Phinodes misclassified asINPUTinLower::mask_number: When a lane-maskPhiloat blockbis not inst.activeandbis not auniform_join(sofill_phismoveslointobad), readingloas data (s_bcnt1,v_mbcnt,s_andn2SCC, etc.) callsmask_number(lo), which looks uploinp.blocks[b].instsand fails withINPUT("a program input") becauselois defined byp.blocks[b].phis[i].s_mov,xored_backswaps,restoredspills around a loop) hold the single dominating leaf mask's number on every iteration.once_blocks/wave_blocks/lockstep, such as loop-exit and post-branch reconvergence blocks), every lane of the wave is present with its exact per-laneAtom::Phibit inst.masks[&lo], sowide_ballotatbreconstructs the exact console scalar mask.fill_phiscan carry thei32mask number across the back-edge.Lanes::exec_copies_at_joinsonly checked one-steps_movfromEXECor_wrexec_, missing copy chains / swaps /s_mov exec, sand nested loopEXECshadow phis.s_movk_i32/s_cmovk_i32inmask_number:Lanes::soptrackss_movk_i32ands_cmovk_i32inst.masksfor wave32, whileLower::mask_numberstripped only_b32/_b64and rejected them withWIDTH.Proposed Fix
exec_copies_at_joinsto follow copy/swap/spill chains on both operands and coinductive nested loopEXECshadow phis.wide_ballots, and single-preheader/single-latch loop-internaldata_phis(reporting"a divergent join"rather than"a program input"if a phi genuinely diverges inside a loop).s_movk_i32ands_cmovk_i32inLower::mask_number(limitingMaskData::Hostto0/-1).Refs #4, #258, #525
@Sheffy007 on GitHub · 2026-11-28 00:32 UTC · original
/claim
@github-actions[bot] on GitHub · 2026-11-28 00:32 UTC · original
Claimed by @Sheffy007. Open a draft pull request with
Refs #524in its description within 24 hours, or the claim expires.@AnastasisKon on GitHub · 2026-11-28 13:56 UTC · original
Evidence for the class, measured on the GPU (fork
AnastasisKon/Native-Victory-macOSmain): a lane-mask join already answers per wave in lockstep's paired form (VICTORY_PAIRED_WAVES=1), so the refusal may not need a fast-path lowering at all.New test
victory-gpusplit_wave_tests::a_lane_mask_join_read_as_data_answers_per_wave_in_the_paired_formruns one of the join programs the fast path refuses (a_mask_join_read_by_an_or_with_exec_is_not_taken_as_anded_off: a mask loaded intos[8:9]under one EXEC, av_cmpinto it under another, thens_or_b64ands_and_b64with EXEC) in a group of two console waves, 128 threads:s[8:9] | execis lanes 0..19,s[8:9] & execlanes 0..2, so the or'dv_cndmasks store 3 in lanes 0..2, 1 in 3..19, 0 above - the console's answer;n > v0for n ≤ 50) is empty, so both joins stay empty through the branches it takes and it stores 0 in all its lanes.That is per wave, not per lane: the fast path's per-lane answer would spread the same bits over both halves. It also means the class needs the paired form rather than if-conversion in the fast path, which is the recourse
docs/native-host.mdanddocs/ROADMAP.mdnow name.Nothing here changes the fast path, so it does not conflict with the phi/
s_movkwork this issue is about; it is the measurement that says how much of the class is still open once the paired form is on. For reference,VICTORY_PAIRED_WAVES=1 cargo test -p victory-gpumakes twelve refusal pins insplit_wave_teststranslate instead (they assert today's default), which is the size of the class in the test suite.