JIT: Use normalized block for comparison in RBO dominator walk#127434
Merged
AndyAyersMS merged 1 commit intodotnet:mainfrom Apr 26, 2026
Merged
JIT: Use normalized block for comparison in RBO dominator walk#127434AndyAyersMS merged 1 commit intodotnet:mainfrom
AndyAyersMS merged 1 commit intodotnet:mainfrom
Conversation
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes an RBO dominator-walk edge case in optRedundantDominatingBranch where the walk can bail out after prior folding creates an empty BBJ_ALWAYS chain, by ensuring comparisons are done against the normalized (side-effect-free-skipped) “current” block.
Changes:
- Normalize
currentBlockviaskipSideEffectFreeBlocksbefore comparing it against dominator successors in the RBO dominator walk. - Add a new dominating-branch test case (
Dom_05) to exercise the reported control-flow shape.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/coreclr/jit/redundantbranchopts.cpp | Normalizes the block being compared in the dominator walk to avoid mismatches caused by empty BBJ_ALWAYS chains. |
| src/tests/JIT/opt/RedundantBranch/RedundantBranchDominating.cs | Adds a new nested-dominating-branch scenario (Dom_05) and a corresponding test. |
Contributor
Author
AndyAyersMS
approved these changes
Apr 26, 2026
Member
AndyAyersMS
left a comment
There was a problem hiding this comment.
Thanks for spotting this.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes an issue where we bail out early in the RBO dominator walk due to comparing a successor that was skipped through empty
BBJ_ALWAYSblocks against the current block.The jit dump was like
after
BB03is folded into an emptyBBJ_ALWAYStoBB04, we continue walking to the next dominatorBB02, but when checkingBB02, we skipped side effect free blocks on its successors so that we end up comparingBB04againstBB03.Codegen diff:
G_M29168_IG01: ;; offset=0x0000 sub rsp, 40 ;; size=4 bbWeight=0.50 PerfScore 0.12 G_M29168_IG02: ;; offset=0x0004 - cmp ecx, 2 - jle SHORT G_M29168_IG03 cmp ecx, 8 jle SHORT G_M29168_IG03 mov ecx, 1 call [System.Console:WriteLine(int)] - ;; size=21 bbWeight=0.50 PerfScore 2.88 + ;; size=16 bbWeight=0.50 PerfScore 2.25 -G_M29168_IG03: ;; offset=0x0019 +G_M29168_IG03: ;; offset=0x0014 nop ;; size=1 bbWeight=1 PerfScore 0.25 -G_M29168_IG04: ;; offset=0x001A +G_M29168_IG04: ;; offset=0x0015 add rsp, 40 ret ;; size=5 bbWeight=1 PerfScore 1.25Fixes #127432
/cc: @AndyAyersMS