Skip to content

Zero-diff part of "Use SSA-based ComputeRange" - #112853

Merged
EgorBo merged 11 commits into
dotnet:mainfrom
EgorBo:rngchk-2-nodiff
Feb 28, 2025
Merged

Zero-diff part of "Use SSA-based ComputeRange"#112853
EgorBo merged 11 commits into
dotnet:mainfrom
EgorBo:rngchk-2-nodiff

Conversation

@EgorBo

@EgorBo EgorBo commented Feb 24, 2025

Copy link
Copy Markdown
Member

Extracted from #112824 for simpler code review

@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Feb 24, 2025
@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.

@EgorBo
EgorBo marked this pull request as ready for review February 24, 2025 12:35
Copilot AI review requested due to automatic review settings February 24, 2025 12:35

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.

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

@EgorBo

EgorBo commented Feb 24, 2025

Copy link
Copy Markdown
Member Author

@jakobbotsch @AndyAyersMS @dotnet/jit-contrib PTAL, zero-diff change. Just preparations for using RangeCheck in assertprop (in #112824):

  1. Hid all maps under lazy-init getters (these maps are cleaned on every GetRange call, so the state is not shareable between phases).
  2. RangeCheck becomes a singleton instance - this helps to reduce TP impact and allocations when it's called from Assertprop
  3. Removed verbose SSA validation - it's quite ad-hoc and messy, also, it's an additional state that I had to reset between phases. RangeCheck used to be the last phase to use SSA, but it's not the case today so if we need it, we have to come up with some generic SSA validation and use it everywhere.
  4. Propagated block into various optAssertionProp_* that I'll need.

CI failures are unrelated.

@AndyAyersMS AndyAyersMS left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we're trying to economize by keeping the collection backbones around once we've allocated them.

Could we make it clearer which parts of the range check state are durable and which parts are not? Eg split out the more transient parts into a caller-supplied struct or something?

Or make it harder to accidentally call into the wrong part of range check?

Comment thread src/coreclr/jit/rangecheck.h
Comment thread src/coreclr/jit/rangecheck.cpp Outdated
@EgorBo

EgorBo commented Feb 27, 2025

Copy link
Copy Markdown
Member Author

@AndyAyersMS I have reworked everything and made all members in Rangecheck private except these three:

// Entry point for RangeCheck phase
bool OptimizeRangeChecks();

// GetRange for an arbitrary tree. Slow, is based on SSA.
// (perhaps, can be reworked someday to be purely VN-based)
// Resets all caches on entry.
bool TryGetRange(BasicBlock* block, GenTree* expr, Range* pRange);

// Cheaper version of TryGetRange that is based only on incoming assertions.
// Does not need any internal state - hence, static
static bool TryGetRangeFromAssertions(Compiler* comp, ValueNum num, ASSERT_VALARG_TP assertions, Range* pRange);

Also, addressed your feedback around clearing caches when we haven't created them yet by introducing Clear<map name>() methods.

DoesOverflow is merged into TryGetRange

@EgorBo
EgorBo merged commit 949ad0f into dotnet:main Feb 28, 2025
@EgorBo
EgorBo deleted the rngchk-2-nodiff branch February 28, 2025 18:00
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 31, 2025
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.

3 participants