Repository navigation
JIT: Don't peel the constant off an overflow-checked loop limit - #137705
Merged
Merged
Conversation
Fixes dotnet#137677 `FlowGraphNaturalLoop::MatchLimit` peels `base + cns` off the loop limit into `LimitBase`/`LimitOffset` and loop cloning derives its conditions from the wrapped sum. For a `checked(limit + cns)` limit that overflows, the loop test throws instead (here, swallowed by a `catch` that re-enters the loop), so the conditions don't describe the loop and the fast clone without bounds checks was selected: ```cs sum += a[i]; try { i++; if (i >= checked(limit + (int.MinValue + 5))) break; } catch (OverflowException) { ... } ``` Don't peel overflow-checked `ADD`/`SUB` limits. Co-authored-by: Copilot <[email protected]> Copilot-Session: f6e7f97d-0dd3-45a4-84b3-0276864afd0c
|
Azure Pipelines: Successfully started running 5 pipeline(s). 10 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 |
This was referenced Nov 17, 2026
Member
Author
|
PTAL @AndyAyersMS @dotnet/jit-contrib |
AndyAyersMS
approved these changes
Nov 17, 2026
Member
Author
|
/ba-g timeouts |
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 #137677
FlowGraphNaturalLoop::MatchLimitpeelsbase + cnsoff the loop limit intoLimitBase/LimitOffsetand loop cloning derives its conditions from the wrapped sum. For achecked(limit + cns)limit that overflows, the loop test throws instead (here, swallowed by acatchthat re-enters the loop), so the conditions don't describe the loop and the fast clone without bounds checks was selected:Don't peel overflow-checked
ADD/SUBlimits.