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: Use binary search in FlowGraphNaturalLoops::GetLoopByHeader #108739

Merged
merged 3 commits into from
Oct 11, 2024

Conversation

amanasifkhalid
Copy link
Member

Follow-up to #108086. Since loops are stored in reverse post-order in FlowGraphNaturalLoops::m_loops, loop headers' post-order numbers are stored in descending order. Thus, we can use binary search, and since we plan to use loop-aware RPOs in more places, we should probably take advantage of this.

@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 Oct 10, 2024
Copy link
Contributor

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

amanasifkhalid and others added 2 commits October 10, 2024 10:16
Co-authored-by: Jakob Botsch Nielsen <Jakob.botsch.nielsen@gmail.com>
@amanasifkhalid
Copy link
Member Author

Diffs show some small TP regressions, presumably from most methods having too few loops to overcome the overhead of binary search. I think this cost is acceptable if it helps us avoid excessive runtime for extreme cases, though for cases with fewer than N loops, should we fall back to linear search, or is that overkill? @jakobbotsch

@jakobbotsch
Copy link
Member

Diffs show some small TP regressions, presumably from most methods having too few loops to overcome the overhead of binary search. I think this cost is acceptable if it helps us avoid excessive runtime for extreme cases, though for cases with fewer than N loops, should we fall back to linear search, or is that overkill? @jakobbotsch

I think it's fine to take the small regression.

@amanasifkhalid amanasifkhalid merged commit 3bcf39d into dotnet:main Oct 11, 2024
106 of 108 checks passed
@amanasifkhalid amanasifkhalid deleted the binary-search-loops branch October 11, 2024 14:45
@github-actions github-actions bot locked and limited conversation to collaborators Nov 11, 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