JIT: Detect degenerate switches in switch recognition#122865
JIT: Detect degenerate switches in switch recognition#122865jakobbotsch merged 1 commit intodotnet:mainfrom
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
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.
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