JIT: Validate jump threading phi inputs - #134205
Open
AndyAyersMS wants to merge 2 commits into
Open
AndyAyersMS wants to merge 2 commits into
AndyAyersMS wants to merge 2 commits into
Conversation
Jump threading could remove a phi without accounting for all remaining predecessors, producing an invalid SSA rewrite. Require complete predecessor coverage before replacing phi uses. Fixes dotnet#133981 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 19e3976f-8f3e-4ab8-973d-d568620770c1
|
Azure Pipelines: Successfully started running 5 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Member
Author
|
@EgorBo PTAL A couple of SPMI diffs. |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A critical finding remains: count-only phi coverage can accept a missing current predecessor when stale phi arguments remain.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR hardens JIT jump-threading SSA replacement against incomplete phi inputs and adds regression coverage.
Changes:
- Adds predecessor-coverage checks for block and successor rewrites.
- Adds the
Phi_01regression test.
File summaries
| File | Summary |
|---|---|
src/tests/JIT/opt/RedundantBranch/JumpThreadPhi.cs |
Adds regression coverage for incorrect output. |
src/coreclr/jit/redundantbranchopts.cpp |
Adds phi predecessor coverage checks. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
EgorBo
approved these changes
Sep 18, 2026
Compare predecessor identities when validating threaded PHI replacements. This prevents stale PHI arguments from masking missing current predecessors. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 19e3976f-8f3e-4ab8-973d-d568620770c1
Member
Author
|
@EgorBo revised to a more exact check, ptal |
EgorBo
approved these changes
Sep 19, 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.

Jump threading can see an incomplete phi after an earlier flow edit. The SSA
replacement logic only checked the phi arguments that remained, so it could
remove the phi and rewrite uses without accounting for every predecessor.
Require the block and successor replacement paths to cover every expected
predecessor before accepting a common SSA definition. Otherwise, conservatively
skip the rewrite.
Add a regression case to
JumpThreadPhithat returned 101 instead of 200 beforethe fix.
Validation:
JumpThreadPhi: 2 passed; new test fails before the fix and passes after itfour affected collections, +82 bytes over about 1.86 million sequentially
replayed contexts
Resolves #133981
Note
This pull request description was generated with GitHub Copilot.