Misc improvements for rangecheck#129101
Merged
Merged
Conversation
- Fix unsound bounds in RangeOps::Or (could exclude reachable values); use max-based lower/upper bounds - Add UDIV constant-range support to GetRangeFromAssertionsWorker - Populate m_isVNNeverNegative on checked-bound / VN-relop assertions (and fix the operand used) - Restrict the never-negative O2K_VN_ADD_CNS range deduction to LT/LE relops (GT/GE were unsound) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refines CoreCLR JIT range analysis and assertion metadata to both fix identified unsound deductions and modestly extend the set of VN operations that can be range-evaluated from assertions.
Changes:
- Fix
RangeOps::Orto produce sound bounds for bitwise OR over non-negative constant ranges by usingmax-based lower bounds and a conservative “fill lower bits” upper bound. - Extend
RangeCheck::GetRangeFromAssertionsWorkerto compute constant ranges forVNF_UDIV(unsigned division) when both operands have suitable constant ranges. - Improve assertion metadata by propagating
m_isVNNeverNegativeforO2K_VN_ADD_CNSin checked-bound and VN-relop assertions, and restrict a previously-unsound range deduction fast path to LT/LE-style relops.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/coreclr/jit/rangecheck.h | Adjusts OR range computation to avoid excluding reachable values; adds constant-range support for unsigned division. |
| src/coreclr/jit/rangecheck.cpp | Enables VNF_UDIV range evaluation from assertions; restricts a never-negative O2K_VN_ADD_CNS fast path to sound relops. |
| src/coreclr/jit/compiler.h | Populates O2K_VN_ADD_CNS::m_isVNNeverNegative based on VN analysis for checked-bound and VN-relop assertions. |
Member
Author
|
PTAL @jakobbotsch @dotnet/jit-contrib a couple of improvements + 2 correctness fixes, diffs |
jakobbotsch
approved these changes
Jun 8, 2026
tannergooding
approved these changes
Jun 8, 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.
RangeOps::Or(could exclude reachable values); usemax-based lower/upper bounds[3..5] | [4..7] -> lo = 3|4 = 7, hi = 5|7 = 7 (claims [7..7])UDIVconstant-range support toGetRangeFromAssertionsWorkerm_isVNNeverNegativeon checked-bound / VN-relop assertionsO2K_VN_ADD_CNSrange deduction to LT/LE relops (GT/GE were unsound)Diffs