JIT: refine SSA info in ambiguously threaded blocks#126907
Merged
AndyAyersMS merged 6 commits intodotnet:mainfrom Apr 21, 2026
Merged
JIT: refine SSA info in ambiguously threaded blocks#126907AndyAyersMS merged 6 commits intodotnet:mainfrom
AndyAyersMS merged 6 commits intodotnet:mainfrom
Conversation
If we partially jump-thread a block with PHIs, the remaining preds that target block may all bring in the same SSA def for some of the PHIs. If so, remove the PHIs and update the SSA/VN for the PHI uses in the block. In particular there may just be one ambiguous pred. Also: enhance AP slightly to handle non-negative cases. Fixes dotnet#126703. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Contributor
There was a problem hiding this comment.
Pull request overview
Refines CoreCLR JIT optimizations around jump-threading through PHI-containing blocks by improving SSA/VN rewriting when only ambiguously-threaded predecessors remain, and adds a small assertion propagation enhancement to fold comparisons against negative constants when the compared value is proven non-negative.
Changes:
- Track and remove redundant PHI-def statements in partially jump-threaded blocks when remaining incoming paths agree on the same SSA def, and rewrite SSA/VN for affected uses.
- Adjust successor SSA replacement computation to reflect post-threading reaching paths.
- Enhance assertion propagation to fold
==/!=against negative constants when the value is known non-negative; add a regression test with disasm CHECKs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/tests/JIT/opt/RedundantBranch/JumpThreadPhi.cs | Adds disasm CHECK expectations to validate improved codegen for the repro pattern. |
| src/coreclr/jit/redundantbranchopts.cpp | Implements PHI-use rewriting + optional PHI removal when ambiguous preds converge on a single SSA def after partial threading. |
| src/coreclr/jit/assertionprop.cpp | Adds folding for X ==/!= (negative const) when X is proven never-negative. |
Member
Author
EgorBo
reviewed
Apr 14, 2026
EgorBo
approved these changes
Apr 14, 2026
This was referenced Apr 15, 2026
This was referenced Apr 20, 2026
Open
This was referenced Apr 21, 2026
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.




If we partially jump-thread a block with PHIs, the remaining preds that target block may all bring in the same SSA def for some of the PHIs. If so, remove the PHIs and update the SSA/VN for the PHI uses in the block.
In particular there may just be one ambiguous pred.
Fixes #126703.