Skip to content

Register self loops in the loop forest - #1334

Open
Acture wants to merge 1 commit into
AliveToolkit:masterfrom
Acture:fix-nested-self-loop-unroll
Open

Register self loops in the loop forest#1334
Acture wants to merge 1 commit into
AliveToolkit:masterfrom
Acture:fix-nested-self-loop-unroll

Conversation

@Acture

@Acture Acture commented Aug 17, 2026

Copy link
Copy Markdown

Summary

  • Register every loop header as a key in forest. A header only got one as a side effect of some body block naming it as parent, so a loop whose body is just the header itself was missing from the forest.
  • Function::unroll descends into a child only when forest.count(child) holds, so a nested self loop was never unrolled and kept its backedge. State::addJump redirects that backedge to #sink, dropping the executions that run the inner loop more than once from the refinement query.
  • Add a regression test where src returns %n and tgt returns 3 * %n. alive-tv reports it correct without this patch.

Fixes #1305.

Testing

  • ninja check

Result: 1423 passed, 1 expected failure.

I could not build master locally as it needs a newer LLVM than I have, so this was run on 0dc2be5 with the same patch applied. The loop forest construction this changes is identical between that commit and master.

@Acture
Acture force-pushed the fix-nested-self-loop-unroll branch from 1d4dc3e to 6132b57 Compare August 17, 2026 12:05
@Acture Acture changed the title Register self loops in the loop forest so the unroller does not skip them register self loops in the loop forest Aug 17, 2026
@Acture
Acture force-pushed the fix-nested-self-loop-unroll branch from 6132b57 to 871ebab Compare August 17, 2026 12:52
@Acture Acture changed the title register self loops in the loop forest Register self loops in the loop forest Aug 17, 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.

Construction of forest in LoopAnalysis::run missing loop headers?

1 participant