Skip to content

JIT: Improve side effect detection in loop hoisting #118463

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

amanasifkhalid
Copy link
Member

Addresses some of the regressions in #116486 and #116754. Hoisting's traversal of the loop body was previously not sensitive to execution flow, so it was overly conservative in its side effect detection, operating under the assumption that every block after the loop header could execute after the first global side effect. Now that hoisting visits loop blocks in RPO, we can propagate side effect state through the side-effecting paths of the loop.

@Copilot Copilot AI review requested due to automatic review settings August 6, 2025 20:55
@github-actions github-actions bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Aug 6, 2025
Copy link
Contributor

@Copilot 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

This PR improves side effect detection during loop hoisting by making the traversal more flow-sensitive. Previously, the JIT was overly conservative, assuming every block after the loop header could execute after the first global side effect. The new approach propagates side effect state through the control flow paths of the loop, enabling more precise hoisting decisions.

Key changes:

  • Replaced global m_beforeSideEffect flag with per-block side effect tracking using m_sideEffectBlocks BitVec
  • Modified side effect detection to propagate through control flow rather than assuming worst-case after first block
  • Updated comments to reflect the new flow-sensitive approach

Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant