Skip to content

JIT: Factor SSA's dominator tree computation - #95507

Merged
jakobbotsch merged 4 commits into
dotnet:mainfrom
jakobbotsch:hoisting-rbo-dominators
Dec 2, 2023
Merged

jakobbotsch merged 4 commits into
dotnet:mainfrom
jakobbotsch:hoisting-rbo-dominators

Conversation

@jakobbotsch

@jakobbotsch jakobbotsch commented Dec 1, 2023 •

Copy link
Copy Markdown
Member

Factor the dominator tree computation out to a FlowGraphDominatorTree class. Compute preorder and postorder numbers for this tree. Switch RBO and hoisting from using fgDominate which is querying dominator information computed all the way back in loop finding to actually use the dominator tree computed by SSA.

Small number of diffs are expected from RBO now not rejecting some cases because of more precise treatment of EH constructs. TP may be regressed a bit due to now numbering SSA's dominator tree -- we can regain that TP once we remove the old dominator computation.

Factor the dominator tree computation out to a `FlowGraphDominatorTree`
class. Compute preorder and postorder numbers for this tree. Switch RBO
and hoisting from using `fgDominate` which is querying dominator
information computed all the way back in loop finding to actually use
the dominator tree computed by SSA.

Small number of diffs are expected from RBO now not rejecting some cases
because of more precise treatment of EH constructs now. TP may be
regressed a bit too due to now numbering SSA's dominator tree -- we can
regain that TP once we remove the old dominator computation.
@ghost ghost assigned jakobbotsch Dec 1, 2023
@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Dec 1, 2023
@ghost

ghost commented Dec 1, 2023

Copy link
Copy Markdown

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

Issue Details

Factor the dominator tree computation out to a FlowGraphDominatorTree class. Compute preorder and postorder numbers for this tree. Switch RBO and hoisting from using fgDominate which is querying dominator information computed all the way back in loop finding to actually use the dominator tree computed by SSA.

Small number of diffs are expected from RBO now not rejecting some cases because of more precise treatment of EH constructs. TP may be regressed a bit too due to now numbering SSA's dominator tree -- we can regain that TP once we remove the old dominator computation.

Author: jakobbotsch
Assignees: jakobbotsch
Labels:

area-CodeGen-coreclr

Milestone: -

@jakobbotsch

Copy link
Copy Markdown
Member Author

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

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@jakobbotsch
jakobbotsch marked this pull request as ready for review December 1, 2023 14:53
@jakobbotsch

Copy link
Copy Markdown
Member Author

cc @dotnet/jit-contrib PTAL @AndyAyersMS. Should be ready assuming CI passes, the current failure looks like some sort of infra issue, I see no error in the console log.

Diffs. Surprisingly a TP improvement; I suppose SSA's dominator computation is just better optimized than fgComputeDoms() is, even though it also takes proper EH flow into account.


// domTree[i].nextSibling = domTree[parent->bbPostorderNum].firstChild;
// domTree[parent->bbPostorderNum].firstChild = block;
//}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll submit a PR right after this one that replaces the above quirk with this code, so I left it here. It seems like it has some nice improvements.

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

Are there any users of the old DomTreeVisitor left?

@jakobbotsch

Copy link
Copy Markdown
Member Author

Are there any users of the old DomTreeVisitor left?

Yes, we still have fgNumberDomTree to compute the preorder/postorder numbers used by fgDominate. We're still using that for the old loop finding and for optFindAndScaleGeneralLoopBlocks. The latter is especially problematic since it makes use of both dominators and reachability, so I need to figure out what to do with it... Ideally I'd like to completely remove it, but will have to see the effects of that, particularly on prejit and NAOT where we don't have PGO. If I end up not being able to get rid of it I'll probably switch it to the new dominators added in this PR and compute the dense reachability sets only inside that particular pass.

@jakobbotsch
jakobbotsch merged commit a0891ab into dotnet:main Dec 2, 2023
@jakobbotsch
jakobbotsch deleted the hoisting-rbo-dominators branch December 2, 2023 19:39
@AndyAyersMS

Copy link
Copy Markdown
Member

The latter is especially problematic since it makes use of both dominators and reachability

If we're finding the same set of loops (or a superset) with the new logic, then the reachability checks can become loop membership, and the dominator checks can become DFST ancestry checks, so seems like neither reachability nor dominance is actually needed?

@jakobbotsch

Copy link
Copy Markdown
Member Author

If we're finding the same set of loops (or a superset) with the new logic, then the reachability checks can become loop membership, and the dominator checks can become DFST ancestry checks, so seems like neither reachability nor dominance is actually needed?

I haven't tried to understand what it is doing there, but from the function header/logic it seems like it might be more general than just natural loops. Not sure how much it matters... I'll try playing around with it when I get to that point.

@jakobbotsch jakobbotsch mentioned this pull request Dec 13, 2023
15 of 21 tasks
@github-actions github-actions Bot locked and limited conversation to collaborators Jan 2, 2024
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