-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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: Avoid rotating/splitting loop bodies during 3-opt layout #113101
base: main
Are you sure you want to change the base?
JIT: Avoid rotating/splitting loop bodies during 3-opt layout #113101
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
While triaging layout regressions in #113108, I noticed some instances (comment) where 3-opt decides to create fallthrough along loop backedges, ultimately rotating the loop shape such that it is top-tested. It makes sense that our cost model would incentivize this behavior, since there frequently is a large difference in weight between loop iteration edges and loop entry/exit edges, but this is a clear case where our cost model is too simple to reflect real performance characteristics. Restricting 3-opt from creating fallthrough along backedges out of test blocks helps keep loops bottom-tested. Here's a motivating example from
And with these changes:
|
On second thought, I don't think inhibiting 3-opt from converging to a locally-minimal solution is the right approach (comment). I'm going to try something more surgical, and separate from 3-opt. |
Part of #107749. My recent comparison of 3-opt to an external TSP optimizer (comment) revealed the former's tendency to leave loop bodies broken up if hot jump compaction decided to create fallthrough along one of the loop's exit paths. The initial layout should probably keep loop bodies compact on principle, and rely on 3-opt's profitability heuristics to decide when to break them up. As a motivating example, consider the following layout from
benchmarks.run_pgo
:Notice how the placement of
[BB03, BB08]
at the end of the method creates a bimodal distribution of code density. With this PR, this is fixed: