Shaders: a folded empty block keeps one phi entry per predecessor (#2621) #2690
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2692"
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 Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T18:18:52Z.
Fixes #2621.
Since
286a00ethe writer takes a constant branch's one edge, drops phi entries of edges that are gone, and folds an empty block with one predecessor into it.Plan::edgekept an entry frombwhen any ofb's successors, through folded targets, landed in the phi's block. Afterentry: CondBr(true, empty, join)foldsemptyintoentry -> join, the folded block's own entry stays (written fromentry), but the untaken direct edgeentry -> joinwas still counted: the phi got two entries for its one predecessor, which the validator and drivers reject.A successor folded from
bis the edgebitself leaves on and no longer counts as another way into the phi: the folded block's entry is the one that stays, written fromsrc(b). A successor that was not folded is an edge of its own, even when it isbitself: a self-looping header keeps its back-edge entry (found by the synthetic tests, whose validator rejected the first version of this change).The first test is the issue's
entry/empty/joinshape: the phi keeps the entry fromempty(written fromentry) and loses the direct one; it fails on the oldPlan::edgeat the second assertion. The second keeps a self-loop's back edge.Tests:
cargo test -p victory-shader --lib emit::bitcode::passes (14). With the test-binaries' Agility opt-in (#486) merged locally, the fullcargo test -p victory-shader --lib --lockedalso passes on an AMD Radeon RX 7800 XT (Windows 10 19045, driver 32.0.32029.2010): 272 passed, 0 failed, 3 ignored, with the synthetic and waterfall modules validating on hardware. Clippy clean.Imported from Marvisak/VIctory. Originally posted by necrobytes on 2026-11-25T18:28:49Z.
Review: COMMENTED
I ran both new bitcode tests against this head (
1f3b25a), the shared base (13f91ca), and the earlier fix for #2621 in #2622 (1fcd4d4). On the base, the folded-branch phi test fails and the self-loop passes. Both tests pass unchanged on both PRs. I used Rust 1.98.1 on Linux for the device-free writer tests.Could we carry
a_self_looping_header_keeps_its_back_edgeover to #2622 and consolidate there? That keeps the extra loop coverage alongside the simpler successor check. Validator and WARP readback on #2622AI-assisted review (Codex).
Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T18:34:35Z.
Consolidating on #2622, which is earlier, green and simpler:
successors(m.term(b)).contains(&x)covers the same cases without thesrccomparison (a folded block's own terminator still hasxas its successor, and an untaken constant-branch edge does not). I verified the validator/WARP point too; nothing in #2622 conflicts with the self-loop case.The one thing worth carrying there is
a_self_looping_header_keeps_its_back_edge, since that is the case a first, more eager folded-successor check broke (it dropped a header's own back edge and the validator rejected the phi). It passes on the base as well, so it is a guard rather than a regression test, but it is cheap:Closing this one in favour of #2622 so the queue has one fix per issue. Happy to send the test as a separate PR if you would rather not touch #2622.
Pull request closed