Skip to content

Use SSA-based TryGetRange to fold conditions#129354

Draft
EgorBo wants to merge 2 commits into
dotnet:mainfrom
EgorBo:ssa-based-relop
Draft

Use SSA-based TryGetRange to fold conditions#129354
EgorBo wants to merge 2 commits into
dotnet:mainfrom
EgorBo:ssa-based-relop

Conversation

@EgorBo

@EgorBo EgorBo commented Jun 12, 2026

Copy link
Copy Markdown
Member

Huge diffs locally (~ -1.2Mb on linux-x64)

Copilot AI review requested due to automatic review settings June 12, 2026 22:52
@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 12, 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 extends JIT assertion propagation to opportunistically fold ordered integer relational operators (<, <=, >, >=) to constant true/false using the SSA-based RangeCheck::TryGetRange analysis, and adds a small constant fast-path in TryGetRange itself to make such queries cheaper.

Changes:

  • Add a constant fast-path to RangeCheck::TryGetRange for int/nint constants that fit in int32.
  • In optAssertionPropGlobal_RelOp, when assertion-based range evaluation can’t prove a relop constant, attempt SSA-based operand range discovery via TryGetRange and fold when the relop becomes provably constant.

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 fast-path for constant expressions in RangeCheck::TryGetRange.
src/coreclr/jit/assertionprop.cpp Adds SSA-based range evaluation to fold certain ordered relops during global assertion propagation.

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