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: Simplify block insertion logic during loop compaction #107403

Merged

Conversation

amanasifkhalid
Copy link
Member

Similar to #107371, don't worry about breaking up fallthrough when moving non-loop blocks out of loop bodies. We can rely on block layout to restore any fallthrough behavior worth keeping.

I expect this will incur diffs from optSetBlockWeights, since it still relies on the lexical ordering of blocks.

@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 Sep 5, 2024
Copy link
Contributor

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

@amanasifkhalid
Copy link
Member Author

Small diffs as expected; odd that TP didn't improve. I'm guessing we don't need to compact loops all that often, so pre-computing insertionPoint is often wasted.

@amanasifkhalid
Copy link
Member Author

cc @dotnet/jit-contrib, @AndyAyersMS PTAL. Thanks!

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.

Ultimately, we should not need to compact loops at all.

But that may be too radical a change to make right now.

@amanasifkhalid
Copy link
Member Author

Ultimately, we should not need to compact loops at all.

Yeah, once we replace optSetBlockWeights with something graph-based, I think it'll be easier to get rid of loop compaction. I'll give it a try once we're at that point.

@amanasifkhalid amanasifkhalid merged commit cf8cbe9 into dotnet:main Sep 6, 2024
106 of 108 checks passed
@amanasifkhalid amanasifkhalid deleted the loop-compaction-block-insertion branch September 6, 2024 15:50
@AndyAyersMS
Copy link
Member

Which reminds me -- I wonder if we should switch the layout RPO over to something like the "loop aware" RPO-inspired ordering that is now used in VN?

The main distinction being that that RPO may intermingle non-loop blocks with loop blocks, whereas the loop aware ordering takes care to visit all loop blocks before any blocks that may follow.

@AndyAyersMS
Copy link
Member

There's not yet a convenient abstraction for this order but it would not be too hard to make one that VN and something else could share.

@amanasifkhalid
Copy link
Member Author

amanasifkhalid commented Sep 6, 2024

Which reminds me -- I wonder if we should switch the layout RPO over to something like the "loop aware" RPO-inspired ordering that is now used in VN?

Interesting, I wasn't aware of this functionality. I'll take a look at it next. It would be nice if this could render fgMoveHotJumps mostly redundant: Aside from ensuring loops are compact, if the loop-aware RPO also ensures the loop head is at the top of the loop, then I think we shouldn't have to consider back edges in fgMoveHotJumps at all. Instead, fgMoveHotJumps will just be for moving blocks with multiple predecessors up to the hottest one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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