Skip to content

Ensure that applicable intrinsics have their ranges tracked by vn/assertionprop/rngchk#128722

Open
tannergooding wants to merge 6 commits into
dotnet:mainfrom
tannergooding:intrinsic-intrng-fornode
Open

Ensure that applicable intrinsics have their ranges tracked by vn/assertionprop/rngchk#128722
tannergooding wants to merge 6 commits into
dotnet:mainfrom
tannergooding:intrinsic-intrng-fornode

Conversation

@tannergooding
Copy link
Copy Markdown
Member

Found some cases that were getting pessimized in #128677 because we didn't consistently handle different intrinsics across the various places that can produce range information.

Copilot AI review requested due to automatic review settings May 28, 2026 19:45
@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 May 28, 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 CoreCLR JIT range reasoning so that more intrinsic operations contribute consistent non-negative/range information across value numbering, assertion propagation, and range check elimination.

Changes:

  • Adds a ValueNumStore helper to extract SIMD size/base type from HW-intrinsic VN function apps.
  • Extends IsVNNeverNegative and RangeCheck’s VN-based range extraction to recognize additional HW-intrinsic VNFuncs and bit-counting VNFuncs.
  • Extends RangeCheck and AssertionProp tree-based range modeling for GT_INTRINSIC and GT_HWINTRINSIC bit-counting / extract-msb / element extraction patterns.

Reviewed changes

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

File Description
src/coreclr/jit/valuenum.h Declares new HW-intrinsic VN helper for SIMD size/base type extraction.
src/coreclr/jit/valuenum.cpp Uses new helper in IsVNNeverNegative and refactors HW-intrinsic VN decoding.
src/coreclr/jit/rangecheck.cpp Adds new intrinsic/HW-intrinsic range modeling in VN-based and tree-based range computation.
src/coreclr/jit/assertionprop.cpp Extends IntegralRange modeling for long constants, primitive intrinsics, and HW intrinsics.

Comment thread src/coreclr/jit/valuenum.cpp Outdated
Comment thread src/coreclr/jit/valuenum.cpp Outdated
Comment thread src/coreclr/jit/rangecheck.cpp Outdated
Copilot AI review requested due to automatic review settings May 29, 2026 01:16
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 4 out of 4 changed files in this pull request and generated 4 comments.

Comment thread src/coreclr/jit/valuenum.cpp
Comment thread src/coreclr/jit/rangecheck.cpp
Comment thread src/coreclr/jit/rangecheck.cpp Outdated
Comment thread src/coreclr/jit/rangecheck.cpp Outdated
@tannergooding tannergooding marked this pull request as ready for review May 29, 2026 13:13
Copilot AI review requested due to automatic review settings May 29, 2026 13:13
@tannergooding
Copy link
Copy Markdown
Member Author

tannergooding commented May 29, 2026

CC. @dotnet/jit-contrib, @EgorBo for review. Another PR around the various range/limit support we have.

Diffs are generally positive, with about half of the -2k bytes of improvements being in tests and the other half being in other collections.

The general improvements come from us being able to drop otherwise unnecessary casts and a few from redundant comparisons, some of which were found in #128677 and inspired this PR.

The ExtractMostSignificantBits helper is the new thing and is particularly prominent since we can know its never negative for any V64/V128 and almost any V256 (barring V256<byte> which has 32 elements).

For the rest, we had some handling already, and so this merges the Arm64/x64 code paths together to reduce duplication in those spots and is otherwise ensuring consistent handling across the locations that produce range/limit information, as we had a split of the handling before which could cause things to be missed.

There is no way for the JIT to determine this range information without us being explicit about it

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

Comment thread src/coreclr/jit/valuenum.cpp
Comment thread src/coreclr/jit/rangecheck.cpp
Copilot AI review requested due to automatic review settings May 29, 2026 18:09
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 4 out of 4 changed files in this pull request and generated 1 comment.

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