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: Remove bbFallsThrough check in optFindLoopCompactionInsertionPoint #99827

Merged
merged 2 commits into from
Mar 19, 2024

Conversation

amanasifkhalid
Copy link
Member

Calling bbFallsThrough isn't all that helpful here, as it doesn't consider BBJ_ALWAYS blocks to the next block, BBJ_COND blocks that don't fall through for the false path, etc. I'm planning on getting rid of bbFallsThrough everywhere except in fgReorderBlocks (that removal will hopefully come when we replace our block layout algorithm altogether), but to still be able to short-circuit optFindLoopCompactionInsertionPoint, I added some manual checks for blocks that can "fall through."

cc @dotnet/jit-contrib, @jakobbotsch PTAL. The diffs weren't that big locally, but I'm open to different/more radical approaches here. Thanks!

@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 Mar 15, 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

Diffs

@AndyAyersMS
Copy link
Member

The more radical thing would be to stop doing loop compaction entirely. Now that we have a flow-based approach to finding loops, it should not matter what other blocks might appear between the lexically first and lexically last loop blocks.

Whether we can "fix" this later though is likely the big question. Once we get to layout we will want to make loop bodies compact.

@amanasifkhalid
Copy link
Member Author

The more radical thing would be to stop doing loop compaction entirely.

I tried this locally out of curiosity, and the size/PerfScore regressions suggest our current layout algorithm doesn't handle uncompacted loops all that well. I've added a note to #93020 to consider skipping loop compaction once have a new layout algorithm, assuming the new algorithm does a decent job of placing loop bodies' blocks contiguously -- if we start with a RPO traversal, I guess that would negate the need for compaction?

@AndyAyersMS
Copy link
Member

if we start with a RPO traversal, I guess that would negate the need for compaction?

I believe that's the case, yes.

@jakobbotsch
Copy link
Member

I don't think RPO will guarantee compactness of natural loops -- for example, the RPO can have outside-loop successors of the exiting blocks between the header and its inside-loop successors.

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.

Seems fine to me. I hope long term we remove the compaction entirely in favor of the block layout in the backend.

@amanasifkhalid amanasifkhalid merged commit 43a9236 into dotnet:main Mar 19, 2024
129 checks passed
@amanasifkhalid amanasifkhalid deleted the loopCompactionInsert branch March 19, 2024 14:36
@github-actions github-actions bot locked and limited conversation to collaborators Apr 19, 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.

3 participants