Skip to content

ssair: fix phi edge cleanup for current block#60697

Merged
KristofferC merged 3 commits intomasterfrom
kc/phi_edge_cleanup
Jan 29, 2026
Merged

ssair: fix phi edge cleanup for current block#60697
KristofferC merged 3 commits intomasterfrom
kc/phi_edge_cleanup

Conversation

@KristofferC
Copy link
Copy Markdown
Member

@KristofferC KristofferC commented Jan 15, 2026

🤖: When removing an edge during compaction, phi pruning treated only blocks with to < active_bb as already compacted. If the edge was removed into the current block, its phi nodes had already been rewritten with renamed predecessors, but the cleanup path still searched using the old predecessor ID in the pre-compact IR. This left a live block with a phi edge from a dead predecessor and broke IR verification. Treat to == active_bb as already compacted so phi edges are removed from the result stream with renamed predecessor IDs.

AI fix (take 2) of #60660. Putting up for consideration.

The test only reproduces on 1.13 but figured I might as well add it in for potential backport.

@KristofferC KristofferC requested a review from Keno January 15, 2026 11:04
@KristofferC KristofferC changed the title Update left-over reference to Core.GlobalMethods (#59976) ssair: fix phi edge cleanup for current block Jan 15, 2026
@Keno
Copy link
Copy Markdown
Member

Keno commented Jan 15, 2026

Fix looks plausible, but I'll need to take a deeper look. It'd be nice to get an ir-level test also in addition to the regression test.

@KristofferC KristofferC added the backport 1.13 Change should be backported to release-1.13 label Jan 15, 2026
@Keno
Copy link
Copy Markdown
Member

Keno commented Jan 22, 2026

So I think the identification of the issue is correct, but i don't think the fix quite works, because the statement range in result_bbs will not be correct for the active_bb. Instead the already compacted range for the current bb should be computed as StmtRange(first(bb.stmts), compact.result_idx-1) as it would be when finishing the bb (can pull this out into a helper). Thus if to == active_bb, this needs to be special cased. We are also making the assumption that all phi block statements have already been processed here. This is true, but should be documented and perhaps encoded in the name of the function, e.g. kill_edge_terminator! (only the version that has the active_bb arg of course). Plus needs an IR level test as mentioned.

(If you paste this into your claude session it'll probably give you correct code).

@KristofferC
Copy link
Copy Markdown
Member Author

updated

@KristofferC KristofferC mentioned this pull request Jan 26, 2026
43 tasks
@KristofferC KristofferC added the merge me PR is reviewed. Merge when all tests are passing label Jan 26, 2026
When removing an edge during compaction, phi pruning treated only blocks\nwith to < active_bb as already compacted. If the edge was removed into\nthe current block, its phi nodes had already been rewritten with renamed\npredecessors, but the cleanup path still searched using the old\npredecessor ID in the pre-compact IR. This left a live block with a phi\nedge from a dead predecessor and broke IR verification.\n\nTreat to == active_bb as already compacted so phi edges are removed from\nthe result stream with renamed predecessor IDs.
@KristofferC KristofferC merged commit 1fe82a0 into master Jan 29, 2026
8 checks passed
@KristofferC KristofferC deleted the kc/phi_edge_cleanup branch January 29, 2026 11:23
@aviatesk aviatesk mentioned this pull request Jan 29, 2026
40 tasks
@aviatesk aviatesk removed the backport 1.13 Change should be backported to release-1.13 label Jan 29, 2026
@inkydragon inkydragon removed the merge me PR is reviewed. Merge when all tests are passing label Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants