Repository navigation
Shaders: a lane mask's high dword is the pair's own, not a guess at the register next to the low one - #2836
Shaders: a lane mask's high dword is the pair's own, not a guess at the register next to the low one#2836kotekompotek wants to merge 2 commits into
Conversation
…he register next to the low one In wave64 a mask the structure pass cannot see into was kept as Atom::Opaque of the pair's low value alone, and lowering guessed the high dword from the register next to it (Marvisak#2780). A mask whose dwords are written apart — LLVM splits a 64-bit constant that is not inline into two s_mov_b32, and vcc_lo/vcc_hi are written apart the same way — got no guess, so lanes 32-63 tested the low dword's bits again; a high dword rewritten after a 64-bit write could be guessed stale. The opaque atom now names both dwords of the pair as they were read, and the emitter tests them directly (no guessing, so pair_high goes); two masks sharing a low dword with different high dwords are different masks. The atom's birth index is the later of the pair's, so forgetting masks when a region's values are redefined drops a pair the region assembled. A wave64 cndmask over s[12:13] written by halves now differs in DXIL for a high dword of -1 versus 0 (identical before), matching the console. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Independent Windows verification of exact head Rebase needed. The merge still conflicts in The diagnostics app build passed on this head, including the follow-up to the Fresh verification and review by Codex ( |
|
Reviewed and tested
|
bdadc5e to
5b737de
Compare
|
Automated triage for the maintainers. Verdict: proposed close (duplicate of #2783). The change is correct by my reading. If you see a case this PR handles that #2783 doesn't, please say so here, or add it to #2783. This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label. CI: passing ( Generated by Claude Code |
|
I built #3023 on this PR, with both of your commits kept as they are, rebased onto main 63bcca4. It adds the scalar-branch part from the triage on #2780: a VCC that is one of your |
Summary
Fixes #2780.
In a wave64 program that reads lanes the console's way, the structure pass kept a mask it cannot see into as
Atom::Opaque(lo)— the pair's low value alone — and lowering guessed the high dword withpair_high(the writing instruction's second destination, a matching input, or a same-block phi). A mask whose dwords are written separately — LLVM splits a non-inline 64-bit constant into twos_mov_b32, andvcc_lo/vcc_hiare written apart the same way — got no guess, so lanes 32-63 tested the low dword's bits again. A high dword rewritten after a 64-bit write could also be guessed stale.Atom::Opaquenow names both dwords of the pair as they were read, and the emitter tests them directly —pair_highis removed. Two masks sharing a low dword with different high dwords are distinct atoms (previously they were one atom sharing one guess). The atom's birth index is the later of the pair's, soforgetdrops a pair assembled inside a region when that region's values are redefined.Test plan
valu_tests::a_half_written_mask_tests_its_high_dword— the issue's reproducer shape (s_movhalves +v_mbcnt+v_cndmaskover the pair): fails on main (identical DXIL fors13of -1 vs 0), passes with the changecargo clippy -p victory-shader --all-targets --lockedcleancargo test -p victory-shader --lib— no new failures; the 80 pre-existing failures on this host are allno SM 6.6 deviceenvironment skipss_cbranch_vccz/vccnzpath sharesLanes::maskand is covered by the same fixGenerated with Devin