Skip to content

Update GetRangeFromAssertions to handle constants that FitsIn<int32_t>#128935

Draft
tannergooding wants to merge 1 commit into
dotnet:mainfrom
tannergooding:better-rngchk3
Draft

Update GetRangeFromAssertions to handle constants that FitsIn<int32_t>#128935
tannergooding wants to merge 1 commit into
dotnet:mainfrom
tannergooding:better-rngchk3

Conversation

@tannergooding
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings June 3, 2026 04:49
@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 Jun 3, 2026
@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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 updates the JIT’s “range-from-assertions” helper to accept an explicit var_types and to better cope with VN constants that aren’t strictly TYP_INT (notably including integral constants whose value fits in int32_t). The change primarily affects how Assertion Prop queries and consumes inferred ranges.

Changes:

  • Extend RangeCheck::GetRangeFromAssertions / worker to take an explicit var_types type and thread it through recursive calls.
  • Adjust GetRangeFromAssertionsWorker to treat any VN constant specially (return a constant range if it can be represented as an int, otherwise return unknown).
  • Update Assertion Prop call sites to pass the relevant tree type and to tolerate non-constant ranges (instead of asserting constant-range unconditionally).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/coreclr/jit/rangecheck.h Updates the GetRangeFromAssertions* signatures to include an explicit var_types type.
src/coreclr/jit/rangecheck.cpp Implements the new signature, updates recursion call sites, and revises constant/type handling in the worker.
src/coreclr/jit/assertionprop.cpp Updates callers to pass types and makes range consumers resilient to non-constant results.

Comment on lines +1109 to +1113
if (!result.IsConstantRange())
{
assert(varTypeIsLong(vnType));
return Limit(Limit::keUnknown);
}
Comment on lines +709 to +713
#if TARGET_64BIT
return Limit(Limit::keUnknown);
#else
return GetRangeFromType(TYP_INT);
#endif
Comment on lines +692 to +693
// Start with the widest possible constant range.
return GetRangeFromType(type);
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.

2 participants