Skip to content

Create ">=0" assertion for unpromoted Span.Length - #130326

Merged
EgorBo merged 2 commits into
dotnet:mainfrom
EgorBo:preferred-bound-2
Jul 8, 2026
Merged

EgorBo merged 2 commits into
dotnet:mainfrom
EgorBo:preferred-bound-2

Conversation

@EgorBo

@EgorBo EgorBo commented Jul 8, 2026

Copy link
Copy Markdown
Member

A simple improvement, -30kb diff on win-x64

Copilot AI review requested due to automatic review settings July 8, 2026 01:22
@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 Jul 8, 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 adjusts JIT range/AssertionProp reasoning around Span/array length “checked-bound” values so the compiler can more consistently treat an unpromoted Span.Length indirection as non-negative and as the preferred bounds-check length value.

Changes:

  • In RangeCheck::ComputeRange, if the computed VN matches the caller-provided preferredBoundVN, represent the value as an exact symbolic range [bound, bound].
  • In optAssertionGen, generate an IND >= 0 assertion for TYP_INT indirections proven non-negative by IntegralRange (targeting unpromoted Span.Length).

Reviewed changes

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

File Description
src/coreclr/jit/rangecheck.cpp Adds a preferred-bound fast path in range computation and simplifies GT_ARR_LENGTH handling.
src/coreclr/jit/assertionprop.cpp Adds IND >= 0 assertion generation for known-non-negative int indirections (notably unpromoted Span.Length).

Copilot AI review requested due to automatic review settings July 8, 2026 12:28
@EgorBo
EgorBo marked this pull request as ready for review July 8, 2026 12:28

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 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread src/coreclr/jit/assertionprop.cpp Resolved
@EgorBo

EgorBo commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

PTAL @dotnet/jit-contrib trivial change, a couple of diffs, mostly on win-x64.

@EgorBo
EgorBo requested a review from a team July 8, 2026 15:23
Comment thread src/coreclr/jit/assertionprop.cpp Resolved
@EgorBo
EgorBo enabled auto-merge (squash) July 8, 2026 18:16
@EgorBo
EgorBo merged commit 07f0abc into dotnet:main Jul 8, 2026
137 checks passed
@EgorBo
EgorBo deleted the preferred-bound-2 branch July 8, 2026 20:27
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jul 10, 2026
eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
A simple improvement, -30kb diff on win-x64
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 27, 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 reduce-unsafe

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants