Uh oh!
There was an error while loading. Please reload this page.
JIT: support SSA-aware PHI jump threading - #126812
Conversation
Teach redundant branch elimination to keep jump threading through PHI- based blocks when the PHI uses can be fully accounted for in the block and its immediate successors. Rewrite the affected successor SSA/VN uses, keep dominating-block threading conservative, and add focused regression coverage for the new PHI-based cases. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
Pull request overview
This PR extends CoreCLR JIT redundant branch optimization (jump threading) to support PHI-based threading when PHI definitions have non-local uses, by accounting for those uses within the threaded block and its immediate successors and rewriting successor SSA/VN uses accordingly. It also adds a focused JIT regression test to cover the new PHI-based scenario.
Changes:
- Add tracking of PHI SSA uses in the candidate block/successors and rewrite successor SSA/VN uses when threading bypasses the PHI block.
- Refine jump-thread eligibility checking to return a richer classification (including “needs PHI use resolution”).
- Add a new JIT test case (
JumpThreadPhi) to validate the new behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/jit/redundantbranchopts.cpp | Implements PHI-use discovery and successor SSA/VN rewriting; updates jump-thread check flow. |
| src/coreclr/jit/compiler.h | Introduces JumpThreadCheckResult and declares new helper methods for PHI-use analysis/rewriting. |
| src/coreclr/jit/compmemkind.h | Adds a dedicated allocator kind for redundant-branch/jump-threading data. |
| src/tests/JIT/opt/RedundantBranch/JumpThreadPhi.cs | Adds regression coverage for PHI-based jump threading through a PHI-producing pattern. |
| src/tests/JIT/opt/RedundantBranch/JumpThreadPhi.csproj | Adds the test project definition consistent with existing tests in the folder. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
AndyAyersMS
commented
Apr 12, 2026
Follow-on to #126711. If all the uses of a global phi in a jump-threading candidate block are in the block and its successors, we can (in most cases) allow jump threading and rewrite the successor uses to the appropriate new ssa def & vn. We avoid cases where the successors already have PHIs or would need to have new PHIs. These seem somewhat rare. @EgorBo PTAL |
Uh oh!
There was an error while loading. Please reload this page.
EgorBo
left a comment
There was a problem hiding this comment.
Thanks for filing a fix for this!
AndyAyersMS
commented
Apr 13, 2026
There are a couple of follow-ons coming that should let us actually fix #126703, but I think this is a good improvement on its own. |
AndyAyersMS
commented
Apr 13, 2026
Linux x64 is probably most representative, other os/arch seem to be missing some collections. |
AndyAyersMS
commented
Apr 13, 2026
/ba-g dead-letter mac catalyst |
Uh oh!
There was an error while loading. Please reload this page.
This reverts commit 578644c.
… global PHI use bug (#126976) Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/1507ea1a-6b49-4f3d-977a-83f9c781da83 Co-authored-by: mangod9 <61718172+mangod9@users.noreply.github.com>
Teach redundant branch elimination to keep jump threading through PHI-based blocks when the PHI uses can be fully accounted for in the block and its immediate successors. Rewrite the affected successor SSA/VN uses, keep dominating-block threading conservative, and add focused regression coverage for the new PHI-based cases. Fix included here that was not in dotnet#126812: ensure that field uses of locals get the proper VN updates. Fixesdotnet#126976.
Teach redundant branch elimination to keep jump threading through PHI-based blocks when the PHI uses can be fully accounted for in the block and its immediate successors. Rewrite the affected successor SSA/VN uses, keep dominating-block threading conservative, and add focused regression coverage for the new PHI-based cases. Fix included here that was not in dotnet#126812: ensure that field uses of locals get the proper VN updates. Fixesdotnet#126976.
Teach redundant branch elimination to keep jump threading through PHI-based blocks when the PHI uses can be fully accounted for in the block and its immediate successors. Rewrite the affected successor SSA/VN uses, keep dominating-block threading conservative, and add focused regression coverage for the new PHI-based cases. Fix included here that was not in #126812: ensure that field uses of locals get the proper VN updates. Fixes#126976.
Teach redundant branch elimination to keep jump threading through PHI- based blocks when the PHI uses can be fully accounted for in the block and its immediate successors. Rewrite the affected successor SSA/VN uses, keep dominating-block threading conservative, and add focused regression coverage for the new PHI-based cases.
Fixes#126703(not quite, yet)