Skip to content

Small TP improvement in assertprop #113360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 12, 2025
Merged

Conversation

EgorBo
Copy link
Member

@EgorBo EgorBo commented Mar 11, 2025

Diffs - they come from the GTF_EXCEPT change. the rest of the changes are just clean up. E.g. I removed various ValueNumStore::NoVN checks because optAddAssertion is already smart enough to ignore assertions with such vns.

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Mar 11, 2025
Copy link
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 March 11, 2025 10:52
@Copilot Copilot AI review requested due to automatic review settings March 11, 2025 10:52
Copy link
Contributor

@Copilot 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.

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

@EgorBo
Copy link
Member Author

EgorBo commented Mar 11, 2025

@dotnet/jit-contrib PTAL, simple change with diffs (size & TP).

The vast majority of all assertions are "lclvar != 0" (both local and global assert prop) created by GT_IND node (and GT_STOREIND), ignoring GTF_EXCEPT alone gives nice results, but there should be done something smarter to avoid creating redundant assertions.

@EgorBo
Copy link
Member Author

EgorBo commented Mar 11, 2025

Ah, actually, I should probably keep the "is address exposed" check for local prop, it might not check that

@EgorBo
Copy link
Member Author

EgorBo commented Mar 11, 2025

@jakobbotsch @AndyAyersMS does this look reasonable?

I plan to make LCLVAR local-prop only, remove op1.lcl.ssa field and use O1K_VN for global prop.

Another thing to experiment is to speed up "do we already have this assertion?" currently it's O(n) loop and it shows up in a profiler.

@@ -2370,7 +2337,11 @@ void Compiler::optAssertionGen(GenTree* tree)
case GT_ARR_LENGTH:
case GT_MDARR_LENGTH:
case GT_MDARR_LOWER_BOUND:
assertionInfo = optCreateAssertion(tree->GetIndirOrArrMetaDataAddr(), nullptr, OAK_NOT_EQUAL);
// These indirs (esp. GT_IND and GT_STOREIND) are the most popular sources of assertions.
if ((tree->gtFlags & GTF_EXCEPT) != 0)
Copy link
Member

Choose a reason for hiding this comment

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

Seems it might make more sense to use IndirMayFault() here, since this check conflates the exceptions thrown by operands with the indir itself.

Copy link
Member Author

@EgorBo EgorBo Mar 12, 2025

Choose a reason for hiding this comment

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

Good point, but looks like IndirMayFault may not be cheap. In this case it's just a heuristic to avoid creating too many assertions (and we do create too many)

Copy link
Member Author

Choose a reason for hiding this comment

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

Although, I'll check

Copy link
Member Author

Choose a reason for hiding this comment

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

Addressed

Copy link
Member

@jakobbotsch jakobbotsch left a comment

Choose a reason for hiding this comment

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

LGTM with a suggestion

@EgorBo
Copy link
Member Author

EgorBo commented Mar 12, 2025

LGTM with a suggestion

Would appreciate a green one 🙂

@jakobbotsch
Copy link
Member

Would appreciate a green one 🙂

Oops, sorry about that

@EgorBo EgorBo merged commit 43236f8 into dotnet:main Mar 12, 2025
110 of 113 checks passed
@EgorBo EgorBo deleted the small-tp-improvement branch March 12, 2025 19:34
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 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.

2 participants