Skip to content

Commit 578644c

Browse files
AndyAyersMSCopilot
andauthored
JIT: support SSA-aware PHI jump threading (#126812)
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>
1 parent 33be435 commit 578644c

File tree

5 files changed

+431
-28
lines changed

5 files changed

+431
-28
lines changed

src/coreclr/jit/compiler.h

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7857,14 +7857,23 @@ class Compiler
78577857

78587858
// Redundant branch opts
78597859
//
7860-
PhaseStatus optRedundantBranches();
7861-
bool optRedundantRelop(BasicBlock* const block);
7862-
bool optRedundantDominatingBranch(BasicBlock* const block);
7863-
bool optRedundantBranch(BasicBlock* const block);
7864-
bool optJumpThreadDom(BasicBlock* const block, BasicBlock* const domBlock, bool domIsSameRelop);
7865-
bool optJumpThreadPhi(BasicBlock* const block, GenTree* tree, ValueNum treeNormVN);
7866-
bool optJumpThreadCheck(BasicBlock* const block, BasicBlock* const domBlock);
7867-
bool optJumpThreadCore(JumpThreadInfo& jti);
7860+
enum class JumpThreadCheckResult
7861+
{
7862+
CannotThread,
7863+
CanThread,
7864+
NeedsPhiUseResolution,
7865+
};
7866+
7867+
PhaseStatus optRedundantBranches();
7868+
bool optRedundantRelop(BasicBlock* const block);
7869+
bool optRedundantDominatingBranch(BasicBlock* const block);
7870+
bool optRedundantBranch(BasicBlock* const block);
7871+
bool optJumpThreadDom(BasicBlock* const block, BasicBlock* const domBlock, bool domIsSameRelop);
7872+
bool optJumpThreadPhi(BasicBlock* const block, GenTree* tree, ValueNum treeNormVN);
7873+
JumpThreadCheckResult optJumpThreadCheck(BasicBlock* const block, BasicBlock* const domBlock);
7874+
bool optFindPhiUsesInBlockAndSuccessors(BasicBlock* block, GenTreeLclVar* phiDef, JumpThreadInfo& jti);
7875+
bool optCanRewritePhiUses(JumpThreadInfo& jti);
7876+
bool optJumpThreadCore(JumpThreadInfo& jti);
78687877

78697878
enum class ReachabilityResult
78707879
{

src/coreclr/jit/compmemkind.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ CompMemKindMacro(LSRA)
2828
CompMemKindMacro(LSRA_Interval)
2929
CompMemKindMacro(LSRA_RefPosition)
3030
CompMemKindMacro(Reachability)
31+
CompMemKindMacro(RedundantBranch)
3132
CompMemKindMacro(SSA)
3233
CompMemKindMacro(ValueNumber)
3334
CompMemKindMacro(LvaTable)

0 commit comments

Comments
 (0)