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: Revise DFS RPO computation #82752

Merged
merged 1 commit into from
Feb 28, 2023
Merged

Conversation

AndyAyersMS
Copy link
Member

Give block postorder numbers their customary meaning: the block's position in the postorder, not in the reverse postorder.

Rename "InvPostOrder" to the more customary ReversePostorder. Also, compute preorder numbers.

Preparatory work for running DFS RPO earlier to classify edges.

Give block postorder numbers their customary meaning: the block's position
in the postorder, not in the reverse postorder.

Rename "InvPostOrder" to the more customary ReversePostorder. Also, compute
preorder numbers.

Preparatory work for running DFS RPO earlier to classify edges.
@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 Feb 28, 2023
@ghost ghost assigned AndyAyersMS Feb 28, 2023
@ghost
Copy link

ghost commented Feb 28, 2023

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

Issue Details

Give block postorder numbers their customary meaning: the block's position in the postorder, not in the reverse postorder.

Rename "InvPostOrder" to the more customary ReversePostorder. Also, compute preorder numbers.

Preparatory work for running DFS RPO earlier to classify edges.

Author: AndyAyersMS
Assignees: AndyAyersMS
Labels:

area-CodeGen-coreclr

Milestone: -

@AndyAyersMS
Copy link
Member Author

@jakobbotsch PTAL
cc @dotnet/jit-contrib

@@ -1279,11 +1293,11 @@ BasicBlock* Compiler::fgIntersectDom(BasicBlock* a, BasicBlock* b)
BasicBlock* finger2 = b;
while (finger1 != finger2)
{
while (finger1->bbPostOrderNum > finger2->bbPostOrderNum)
while (finger1->bbPostorderNum < finger2->bbPostorderNum)
Copy link
Member Author

Choose a reason for hiding this comment

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

Note this method is now very similar to the SSA builder's IntersectDom -- the main difference being how nodes with no predecessors are handled.

@@ -961,12 +975,12 @@ void Compiler::fgComputeDoms()
bbRoot.bbPreds = nullptr;
bbRoot.bbNum = 0;
bbRoot.bbIDom = &bbRoot;
bbRoot.bbPostOrderNum = 0;
bbRoot.bbPostorderNum = fgBBNumMax + 1;
Copy link
Member Author

Choose a reason for hiding this comment

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

This is one subtle part I got wrong initially -- the fake "root" BB must now have a postnumber larger than the maximum possible postnumber instead of a reverse postnumber smaller than the the minimum possible reverse postnumber.

@AndyAyersMS
Copy link
Member Author

As hinted at above, the SSA builder's DFS numbering was already using postnumbers this way, so now the two uses are similar. There are still other differences between the two dominance computations. We really ought to just have one.

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

@AndyAyersMS
Copy link
Member Author

Runtime failure is very likely unrelated, opened #82771.

@AndyAyersMS AndyAyersMS merged commit 99547ae into dotnet:main Feb 28, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Mar 30, 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.

2 participants