Skip to content

JIT: Remove most loop-related hoisting quirks - #95734

Merged
jakobbotsch merged 1 commit into
dotnet:mainfrom
jakobbotsch:hoisting-remove-loop-quirks
Dec 8, 2023
Merged

jakobbotsch merged 1 commit into
dotnet:mainfrom
jakobbotsch:hoisting-remove-loop-quirks

Conversation

@jakobbotsch

Copy link
Copy Markdown
Member

We still keep the quirk that we only hoist in loops also recognized by the old loop finding. Before we can hoist in new loops we need to implement creation of preheaders, but that requires incrementally keeping the old loop table up to date, which I'd like to avoid. So my next goal is to switch everything to only have the "recognized by old loop finding" quirk so that we can remove the old loop validity requirements.

A few minor diffs are expected because the new loop iteration order is not exactly the same as the old one. In particular child loop sibling links are stored in rever postorder (the old loop table has them in postorder), which means we end up hoisting them in postorder (the old one did them in reverse postorder). I initially added an ArrayStack::Reverse method to make it the same as previously, but the diffs were so small and just constituted some reordering, so the complication did not seem worth it.

We still keep the quirk that we only hoist in loops also recognized by
the old loop finding. Before we can hoist in new loops we need to
implement creation of preheaders, but that requires incrementally
keeping the old loop table up to date, which I'd like to avoid. So my
next goal is to switch everything to only have the "recognized by old
loop finding" quirk so that we can remove the old loop validity
requirements.

A few minor diffs are expected because the new loop iteration order is
not exactly the same as the old one. In particular child loop sibling
links are stored in rever postorder (the old loop table has them in
postorder), which means we end up hoisting them in postorder (the old
one did them in reverse postorder). I initially added an
`ArrayStack::Reverse` method to make it the same as previously, but the
diffs were so small and just constituted some reordering, so the
complication did not seem worth it.
@ghost ghost assigned jakobbotsch Dec 7, 2023
@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Dec 7, 2023
@ghost

ghost commented Dec 7, 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

We still keep the quirk that we only hoist in loops also recognized by the old loop finding. Before we can hoist in new loops we need to implement creation of preheaders, but that requires incrementally keeping the old loop table up to date, which I'd like to avoid. So my next goal is to switch everything to only have the "recognized by old loop finding" quirk so that we can remove the old loop validity requirements.

A few minor diffs are expected because the new loop iteration order is not exactly the same as the old one. In particular child loop sibling links are stored in rever postorder (the old loop table has them in postorder), which means we end up hoisting them in postorder (the old one did them in reverse postorder). I initially added an ArrayStack::Reverse method to make it the same as previously, but the diffs were so small and just constituted some reordering, so the complication did not seem worth it.

Author: jakobbotsch
Assignees: jakobbotsch
Labels:

area-CodeGen-coreclr

Milestone: -

@jakobbotsch
jakobbotsch marked this pull request as ready for review December 7, 2023 15:49
@jakobbotsch

Copy link
Copy Markdown
Member Author

cc @dotnet/jit-contrib PTAL @BruceForstall

Diffs

Comment on lines 6585 to 6587
// TODO-Quirk: Switch this to postorder over the loops, instead of this
// loop tree based thing. It is not the exact same order, but it will still
// process child loops before parent loops.

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.

Ugh, forgot to remove this. Will remove it as part of a future PR.


assert(childLoop->EntryEdges().size() == 1);
BasicBlock* childPreHead = childLoop->EntryEdge(0)->getSourceBlock();
BasicBlock* childPreHead = childLoop->EntryEdges()[0]->getSourceBlock();

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.

...and will also fix this bad merge as part of a future PR.

@jakobbotsch
jakobbotsch merged commit 41dbe9c into dotnet:main Dec 8, 2023
@jakobbotsch
jakobbotsch deleted the hoisting-remove-loop-quirks branch December 8, 2023 12:12
@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 8, 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