Skip to content
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

JIT: account for newly unreachable blocks in morph #109394

Merged
merged 4 commits into from
Nov 1, 2024

Conversation

AndyAyersMS
Copy link
Member

Morph can alter control flow, if (for instance) it can prove a block's conditional branch must go a certain way.

Take advantage of this to improve morph's cross-block assertion prop, by not considering unreachable predecessors when computing the incoming assertion state. This is similar to something we already do in value numbering, but there control flow isn't being altered.

Also, when we can prove that a block has become unreachable, remove the block IR and alter its jump kind, so we are not spending time morphing IR we'll subsequently just throw away.

Morph can alter control flow, if (for instance) it can prove a block's
conditional branch must go a certain way.

Take advantage of this to improve morph's cross-block assertion prop,
by not considering unreachable predecessors when computing the incoming
assertion state. This is similar to something we already do in value
numbering, but there control flow isn't being altered.

Also, when we can prove that a block has become unreachable, remove
the block IR and alter its jump kind, so we are not spending time
morphing IR we'll subsequently just throw away.
@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 Oct 30, 2024
@AndyAyersMS
Copy link
Member Author

We might want something like this in local morph too... see eg this comment in #104250.

// We will track which blocks become unreachable during morph
//
EnsureBasicBlockEpoch();
BlockSet unreachable = BlockSetOps::MakeEmpty(this);
Copy link
Member

Choose a reason for hiding this comment

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

This can use post-order number based bit vectors.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point.

I was actually thinking I could possibly just rely on edge removal, though there are some odd cases where we artificially bump up ref counts to keep blocks from being considered unreachable.

SPMI results are way more variable across ABI/ISA than I'd expect. Not sure if this is missing collections or something more fundamental...

@AndyAyersMS
Copy link
Member Author

Still vexed by BBJ_CALLFINALLY issues.

@AndyAyersMS
Copy link
Member Author

Diffs -- both size and TP wins.

@AndyAyersMS AndyAyersMS marked this pull request as ready for review November 1, 2024 01:00
@AndyAyersMS
Copy link
Member Author

@jakobbotsch PTAL
cc @dotnet/jit-contrib

Diffs -- good size and TP wins.

Haven't looked at regressions extensively, but saw one case where morph copy-propped a normal local into uses of a "is never negative" local and so we lost the "is never negative" aspect, and this caused us to miss an RBO because of signed/unsigned differences in VN.

Will fire up some stress...

@AndyAyersMS
Copy link
Member Author

/azp run runtime-coreclr jitstress

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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