-
Notifications
You must be signed in to change notification settings - Fork 5.3k
JIT: Detect degenerate switches in switch recognition #122865
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
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
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 addresses issue #121691 by detecting degenerate switches in the JIT's switch recognition phase. A degenerate switch occurs when all test paths lead to the same target block, meaning there's only one unique successor instead of two.
Key Changes:
- Dynamically calculates the number of unique successors based on whether
blockIfTrueequalsblockIfFalse - Updates the
BBswtDescconstructor call to use the computednumSuccsvalue instead of a hardcoded2
|
cc @dotnet/jit-contrib PTAL @EgorBo |
EgorBo
left a comment
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.
presumably if all successors target the same block we can remove the switch entirely, but I guess here it's just some stress artifact
No, this actually happens in real code. But we have a later flowgraph optimization that removes the switch, so I didn't bother doing anything more complicated here. |
|
/ba-g iOS deadletter |
Fix #121691