Repository navigation
[release/11.0] JIT: fix switch peeling stealing the wrong operand of its compare - #137375
Merged
JulieLeeMSFT merged 1 commit intoNov 13, 2026
Merged
Conversation
Backport dotnet#132395 to release/11.0. Co-authored-by: Copilot <[email protected]> Copilot-Session: 58a22678-35fa-4b52-8f7f-563e0c9e37ce
Member
Author
|
@dotnet/jit-contrib PTAL Fix that is in 10.0 and main, but missed being in 11.0. |
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded, although builds and tests were not run during this review.
No open issues 🎉
What changed in this PR
Backports #132395 to release/11.0, addressing #137330: profile-guided switch peeling could reuse the dominant-case constant instead of the actual switch value after comparison operands were swapped.
Changes:
- Reuses the switch value before sequencing the comparison and removes redundant rethreading.
- Adds a regression test covering switch dispatch in an unrolled loop.
- Runs the test in an isolated process with tiered compilation and profile-guided optimization enabled.
Builds and tests were not run during this review.
| File | Description |
|---|---|
src/tests/JIT/Regression/JitBlue/Runtime_132370/Runtime_132370.csproj |
Configures the isolated, priority-1 regression test and tiering settings. |
src/tests/JIT/Regression/JitBlue/Runtime_132370/Runtime_132370.cs |
Exercises dominant-case profiling and verifies correct switch results. |
src/coreclr/jit/fgopt.cpp |
Preserves the switch operand before comparison sequencing can swap operands. |
Review effort: Balanced
This was referenced Nov 11, 2026
dhartglassMSFT
approved these changes
Nov 11, 2026
Member
Author
|
fyi @JulieLeeMSFT |
Member
|
/ba-g known issues. |
This was referenced Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes Issue #137330
main PR #132395
Description
Backport of #132395 to release/11.0.
Reuse the switch value before sequencing the dominant-case comparison, which can swap its operands. The JIT change is identical to the main-branch fix; the regression test uses an isolated project with tiered compilation and PGO enabled.
Customer Impact
#137330 reports incorrect results on .NET 11.0.0: an unrolled switch can dispatch on the dominant case instead of the actual value. The report is on macOS ARM64; the issue also reproduces on Windows x64.
Regression
The issue remains in .NET 11 but was fixed in .NET 10.0.13 and later. The specific introducing change has not been established.
Testing
.\build.cmd clr+libs+host -c Checked -rc Checked -lc Release -hc Release— passed on the previous release tip; the subsequent release update changed only unrelated library tests..\src\tests\build.cmd -Test JIT\Regression\Regression_2.csproj x64 checked -Priority 1 -SkipNative /p:LibrariesConfiguration=Release /p:HostConfiguration=Release— passed, with one pre-existing IL warning inRuntime_74635..\build.cmd clr.jit -c Checked -rc Checked -lc Release -hc Releaseand.\src\tests\build.cmd -GenerateLayoutOnly x64 checked /p:LibrariesConfiguration=Release /p:HostConfiguration=Release— passed after updating to the latest release tip.CORE_ROOTset to the checked layout,& "$env:CORE_ROOT\..\..\JIT\Regression\JitBlue\Runtime_132370\Runtime_132370\Runtime_132370.cmd"failed as expected in 5/5 runs before the fix and passed 5/5 after it.& "$env:CORE_ROOT\..\..\JIT\Regression\Regression_2\Regression_2.cmd" 'DisplayName~Runtime_132370'— passed one out-of-process test after the update, with Tier1 compilation confirmed.The test was not run locally on macOS ARM64. Targeted JIT formatting and clang-tidy checks passed; the full
jitformat.pysweep was not run.Risk
Low: this is the same JIT change already in main and .NET 10, and it affects profile-guided switch peeling. The original PR reported no assembly diffs for its benchmark and library collections.
Resolves #137330
Note
This description was generated with GitHub Copilot.