Skip to content

Fix nested loop unroll exit value repair#1314

Merged
nunoplopes merged 3 commits intoAliveToolkit:masterfrom
cervoliu:fix/issue#1264-nested-unroll-ssa-user-patch
Apr 27, 2026
Merged

Fix nested loop unroll exit value repair#1314
nunoplopes merged 3 commits intoAliveToolkit:masterfrom
cervoliu:fix/issue#1264-nested-unroll-ssa-user-patch

Conversation

@cervoliu
Copy link
Copy Markdown
Contributor

Summary

  • Refresh loop unroll user and phi-predecessor snapshots per loop so outer-loop exit repair sees phis introduced while unrolling inner loops.
  • Add a regression test for the nested loop exit phi case from likely loop unroling bug #1264.

Fixes #1264.

Testing

  • ninja check

Result: 1428 passed, 1 expected failure.

Copilot AI review requested due to automatic review settings April 26, 2026 14:03
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a nested-loop unrolling correctness bug where outer-loop exit repair could miss PHIs introduced during inner-loop unrolling, and adds a regression test covering the reported miscompile from #1264.

Changes:

  • Refresh getUsers() and getPhiPredecessors() snapshots per loop during Function::unroll() so outer-loop exit repair sees PHIs introduced by inner-loop unrolling.
  • Add a new Alive-TV regression test for the nested loop exit-PHI case.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
ir/function.cpp Recomputes user/phi-predecessor snapshots per loop during unrolling to fix nested-loop exit value repair.
tests/alive-tv/loops/nested-exit-phi.srctgt.ll Adds a regression test reproducing the nested-loop exit-PHI mismatch and asserting the correct target result.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ir/function.cpp Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@nunoplopes nunoplopes merged commit 6c6aa1b into AliveToolkit:master Apr 27, 2026
16 checks passed
@cervoliu cervoliu deleted the fix/issue#1264-nested-unroll-ssa-user-patch branch April 27, 2026 11:41
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.

likely loop unroling bug

3 participants