Skip to content

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

Draft
tannergooding wants to merge 5 commits into
dotnet:mainfrom
tannergooding:better-rngchk3
Draft

Update GetRangeFromAssertions to handle constants that FitsIn<int32_t>#128935
tannergooding wants to merge 5 commits 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 thread src/coreclr/jit/rangecheck.cpp
Comment thread src/coreclr/jit/rangecheck.cpp
Comment thread src/coreclr/jit/rangecheck.cpp
Copilot AI review requested due to automatic review settings June 3, 2026 15:21
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

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

Comment thread src/coreclr/jit/assertionprop.cpp
Comment on lines +5534 to +5538
GenTreeBoundsChk* arrBndsChk = tree->AsBoundsChk();
GenTree* arrBndsChkIdx = arrBndsChk->GetIndex();
GenTree* arrBndsChkLen = arrBndsChk->GetArrayLength();
ValueNum vnCurIdx = vnStore->VNConservativeNormalValue(arrBndsChk->GetIndex()->gtVNPair);
ValueNum vnCurLen = vnStore->VNConservativeNormalValue(arrBndsChk->GetArrayLength()->gtVNPair);
Copilot AI review requested due to automatic review settings June 3, 2026 20:59
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

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

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