Shaders: a folded empty block keeps one phi entry per predecessor (#2621) #2692
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2692
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2692/head"
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?
@Calvix2k on GitHub · 2026-11-25 18:18 UTC · original
Calvix2k:codex/shader-folded-phi-entry→main· +71 −1 · 1 files · 1 commits · closed without mergingFixes #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.@Calvix2k on GitHub · 2026-11-25 18:34 UTC · original
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