-
Notifications
You must be signed in to change notification settings - Fork 5.1k
JIT: Consider conditionally executed loop statements for hoisting #117829
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: Consider conditionally executed loop statements for hoisting #117829
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.
Pull Request Overview
This PR optimizes the JIT loop hoisting algorithm to address a significant performance regression by considering conditionally executed loop statements for hoisting. The change switches from processing only definitely executed blocks to evaluating all loop blocks and applying cost-based heuristics for hoisting expensive statements from conditionally executed blocks.
Key changes:
- Modified loop hoisting to iterate through all loop blocks rather than just definitely executed ones
- Added cost-based filtering for conditionally executed statements using an
(IND_COST_EX * 16)
threshold - Changed data structures from ArrayStack to BitVec for tracking definitely executed blocks
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/coreclr/jit/optimizer.cpp | Main implementation changes for loop hoisting algorithm including data structure changes and cost-based heuristics |
src/coreclr/jit/compiler.h | Updated method signatures to support new BitVec-based approach and defExecuted parameter |
Comments suppressed due to low confidence (1)
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Diffs are small locally: FullOpts (-278 bytes)
|
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.
LGTM. Feel free to address my comments later if you like.
Fixes the roughly 10x regression in #116486. This quirks loop hoisting to iterate all loop blocks, and consider hoisting expensive statements even if they don't execute every iteration. The
(IND_COST_EX * 16)
cutoff was chosen to minimize churn, while still solving the above regression.