Skip to content

Conversation

@eeckstein
Copy link
Contributor

  • Explanation: Fixes a bug in the loop-invariant-code-motion pass which causes a miscompile. The fix is to remove a small peephole optimization which tried to re-use existing instructions in a loop pre-header block when hoisting instructions out of the loop. This is wrong for load instructions because the loaded value could be overridden by another instruction in the pre-header block.
  • Risk: Low. The only change is to remove a small peephole optimization
  • Testing: Tested by a lit test.
  • Issue: rdar://164034503
  • Reviewer: @aidan-hall
  • Main branch PR: LoopInvariantCodeMotion: don't reuse existing instructions in the loop pre-header #85569

…p pre-header

This is wrong for hoisted load instructions because we don't check for aliasing in the pre-header.
And for side-effect-free instructions it's not really necessary, because that can cleanup CSE afterwards.

Fixes a miscompile
rdar://164034503
@eeckstein eeckstein requested a review from a team as a code owner November 21, 2025 06:58
@eeckstein
Copy link
Contributor Author

@swift-ci test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants