Skip to content

JIT: recompute exit weight in loop inversion#131362

Open
AndyAyersMS wants to merge 1 commit into
dotnet:mainfrom
AndyAyersMS:fix-131329
Open

JIT: recompute exit weight in loop inversion#131362
AndyAyersMS wants to merge 1 commit into
dotnet:mainfrom
AndyAyersMS:fix-131329

Conversation

@AndyAyersMS

Copy link
Copy Markdown
Member

Avoids amplifying pre-existing small profile inconsistencies once the loop-exit flow is scaled down.

Fixes #131329.

Avoids amplifying pre-existing small profile inconsistencies once the
loop-exit flow is scaled down.

Fixes dotnet#131329.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 25, 2026 01:42
@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 Jul 25, 2026
@AndyAyersMS
AndyAyersMS requested a review from jakobbotsch July 25, 2026 01:42
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 pipeline(s).
11 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adjusts how loop inversion updates profile weights in optTryInvertWhileLoop to avoid profile self-consistency failures after the transformation.

Changes:

  • Stops adjusting the loop-exit block weight via subtraction of the newly introduced edge weight.
  • Recomputes the loop-exit block weight from its incoming edges after the duplicated blocks’ weights are updated.

Comment on lines +2276 to +2280
// Recompute exit's weight from its (now updated) incoming edges.
// Using computeIncomingWeight here (rather than decreasing by the newly
// introduced preheader-to-exit edge weight) avoids amplifying small
// pre-existing inconsistencies once the loop-exit flow is scaled down.
exit->setBBProfileWeight(exit->computeIncomingWeight());
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.

Assertion failed '!"Inconsistent profile data"' in 'System.Number:DiyFp128Exp(byref):System.Number+DiyFp128' during 'Invert loops'

2 participants