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: Use post order computed by SSA in VN #94623

Merged
merged 1 commit into from
Nov 13, 2023

Conversation

jakobbotsch
Copy link
Member

VN tries hard to dynamically compute a reverse post-order to visit the flow graph in. However, SSA has already computed such an order, so simply pass this along to VN instead.

A few positive diffs are expected. As Andy has pointed out recently the "dynamic RPO" VN was doing does not necessarily result in an actual RPO, so using SSA's order is expected to be a better order than what VN ends up with today.

VN tries hard to dynamically compute a reverse post-order to visit the
flow graph in. However, SSA has already computed such an order, so
simply pass this along to VN instead.

A few positive diffs are expected. As Andy has pointed out recently the
"dynamic RPO" VN was doing does not necessarily result in an actual RPO,
so using SSA's order is expected to be a better order than what VN ends
up with today.
@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 Nov 11, 2023
@ghost ghost assigned jakobbotsch Nov 11, 2023
@ghost
Copy link

ghost commented Nov 11, 2023

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Issue Details

VN tries hard to dynamically compute a reverse post-order to visit the flow graph in. However, SSA has already computed such an order, so simply pass this along to VN instead.

A few positive diffs are expected. As Andy has pointed out recently the "dynamic RPO" VN was doing does not necessarily result in an actual RPO, so using SSA's order is expected to be a better order than what VN ends up with today.

Author: jakobbotsch
Assignees: jakobbotsch
Labels:

area-CodeGen-coreclr

Milestone: -

@@ -769,7 +769,6 @@ bool Compiler::fgRemoveDeadBlocks()
// Notes:
// Each block's `bbPreorderNum` and `bbPostorderNum` is set.
// The `fgBBReversePostorder` array is filled in with the `BasicBlock*` in reverse post-order.
// This algorithm only pays attention to the actual blocks. It ignores any imaginary entry block.
Copy link
Member Author

Choose a reason for hiding this comment

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

I wasn't totally sure what this was referring to... but today we do ensure all blocks are visited below, so it seemed odd.

Copy link
Member

Choose a reason for hiding this comment

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

SSA creates a stack-allocated BB0 when it computes dominators, I suspect this is the "imaginary entry block."

Copy link
Member Author

@jakobbotsch jakobbotsch Nov 13, 2023

Choose a reason for hiding this comment

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

Hmm, might be. Still, not sure it is too relevant for this computation.

@jakobbotsch
Copy link
Member Author

/azp run runtime-coreclr jitstress, runtime-coreclr libraries-jitstress, Fuzzlyn

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jakobbotsch
Copy link
Member Author

cc @dotnet/jit-contrib PTAL @AndyAyersMS

Some minor positive diffs, both in codegen and TP.

Copy link
Member

@AndyAyersMS AndyAyersMS left a comment

Choose a reason for hiding this comment

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

Nice.

We should think about how to safeguard against flowgraph changes... doesn't have to be in this PR but maybe you could use the bracketing "is safe to add" stuff I used when doing something similar for morph.

@jakobbotsch
Copy link
Member Author

We should think about how to safeguard against flowgraph changes... doesn't have to be in this PR but maybe you could use the bracketing "is safe to add" stuff I used when doing something similar for morph.

Good idea, will think about how to reuse that.

@jakobbotsch jakobbotsch merged commit 8acb13b into dotnet:main Nov 13, 2023
@jakobbotsch jakobbotsch deleted the precomputed-rpo-in-vn branch November 13, 2023 21:36
@cincuranet
Copy link
Contributor

Possibly related improvement: dotnet/perf-autofiling-issues#24588.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 17, 2023
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