Skip to content

Propagate NeverNegative flag during CSE#125272

Draft
EgorBo wants to merge 3 commits intodotnet:mainfrom
EgorBo:propagate-nevernegative-flag
Draft

Propagate NeverNegative flag during CSE#125272
EgorBo wants to merge 3 commits intodotnet:mainfrom
EgorBo:propagate-nevernegative-flag

Conversation

@EgorBo
Copy link
Member

@EgorBo EgorBo commented Mar 6, 2026

Closes #116073 (removes the bound check)

Also, add metrics to track global assertions (only the local ones were tracked before).

Copilot AI review requested due to automatic review settings March 6, 2026 15:11
@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 Mar 6, 2026
Copy link
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 CoreCLR JIT to preserve “never negative” range information through CSE temps (enabling later range-check elimination), and adds new JIT metrics to track global assertion table usage (in addition to existing local assertion metrics).

Changes:

  • Propagate IsNeverNegative from a CSE candidate expression onto the newly-created CSE temp local.
  • Add GlobalAssertionCount / GlobalAssertionOverflow metrics and record them during global assertion propagation.
  • Change optAssertionOverflow type in Compiler (currently from unsigned to int).

Reviewed changes

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

File Description
src/coreclr/jit/optcse.cpp Propagates IsNeverNegative onto CSE temps to preserve non-negativity info for later bounds-check elimination.
src/coreclr/jit/jitmetadatalist.h Adds new global-assertion metrics to the JIT metadata list.
src/coreclr/jit/compiler.h Changes the type of optAssertionOverflow (used for assertion table overflow counting).
src/coreclr/jit/assertionprop.cpp Records the new global-assertion metrics at the end of assertion discovery.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 6, 2026 15:27
Copy link
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.

Regression: Unnecessary bounds check generated for Span/ReadOnlySpan

2 participants