Skip to content

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

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

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 Outdated
Comment thread src/coreclr/jit/rangecheck.cpp Outdated
Comment thread src/coreclr/jit/rangecheck.cpp Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 left a comment

Copy link
Copy Markdown
Contributor

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.

Copilot AI review requested due to automatic review settings June 4, 2026 00:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

@tannergooding

Copy link
Copy Markdown
Member Author

The difference between partial and full is around -400k bytes of codegen for a few dozen extra loc, better to just take the full thing

@github-actions github-actions Bot locked and limited conversation to collaborators Jul 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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