Improve RangeOps::Merge#129390
Open
EgorBo wants to merge 2 commits into
Open
Conversation
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tweaks RangeOps::Merge in the CoreCLR JIT range analysis to broaden when certain symbolic/constant merge rules apply, aiming to improve SPMI code size by producing tighter (or more frequently-applicable) merged ranges.
Changes:
- Relaxes the “widen upper limit” heuristic when merging a constant upper bound with a
$bnd + cnsupper bound. - Generalizes the “binop-array lower bound + constant lower bound” merge rule by removing the prior
cns <= 0gating and updating the accompanying rationale comment.
Drop the redundant `k >= 0` guard on the upper-limit widening rule Max(k, ($bnd + n)) => ($bnd + n): since $bnd >= 0 and n >= k, the result ($bnd + n) is already >= k for any sign of k, and it stays symbolic so a possible overflow is preserved. The lower-limit rule keeps its cns <= 0 guard: for cns > 0, ($bnd + cns) can overflow (e.g. a Span length is bounded by INT_MAX), so collapsing it to a constant would be an unsound (too-high) lower bound. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
a147003 to
afa9a93
Compare
Member
Author
|
PTAL @AndyAyersMS @dotnet/jit-contrib |
AndyAyersMS
approved these changes
Jun 15, 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.
Fold more bound checks with up to -110k diffs
RangeOps::Merge is typically used when we merge ranges from PHI args, e,g,
[0..1] U [10..10]becomes[0..10]Note
This PR was authored with assistance from GitHub Copilot CLI (AI). The change was validated locally via SuperPMI asmdiffs.