Skip to content

Commit 899ef22

Browse files
committed
eliminate some more code subsumed by r86264
llvm-svn: 86267
1 parent 2f6184f commit 899ef22

File tree

1 file changed

+4
-41
lines changed

1 file changed

+4
-41
lines changed

llvm/lib/Transforms/Scalar/JumpThreading.cpp

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,47 +1005,10 @@ bool JumpThreading::ProcessThreadableEdges(Instruction *CondInst,
10051005
bool JumpThreading::ProcessJumpOnPHI(PHINode *PN) {
10061006
BasicBlock *BB = PN->getParent();
10071007

1008-
// See if the phi node has any constant integer or undef values. If so, we
1009-
// can determine where the corresponding predecessor will branch.
1010-
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {
1011-
Value *PredVal = PN->getIncomingValue(i);
1012-
1013-
// Check to see if this input is a constant integer. If so, the direction
1014-
// of the branch is predictable.
1015-
if (ConstantInt *CI = dyn_cast<ConstantInt>(PredVal)) {
1016-
// Merge any common predecessors that will act the same.
1017-
BasicBlock *PredBB = FactorCommonPHIPreds(PN, CI);
1018-
1019-
BasicBlock *SuccBB;
1020-
if (BranchInst *BI = dyn_cast<BranchInst>(BB->getTerminator()))
1021-
SuccBB = BI->getSuccessor(CI->isZero());
1022-
else {
1023-
SwitchInst *SI = cast<SwitchInst>(BB->getTerminator());
1024-
SuccBB = SI->getSuccessor(SI->findCaseValue(CI));
1025-
}
1026-
1027-
// Ok, try to thread it!
1028-
return ThreadEdge(BB, PredBB, SuccBB);
1029-
}
1030-
1031-
// If the input is an undef, then it doesn't matter which way it will go.
1032-
// Pick an arbitrary dest and thread the edge.
1033-
if (UndefValue *UV = dyn_cast<UndefValue>(PredVal)) {
1034-
// Merge any common predecessors that will act the same.
1035-
BasicBlock *PredBB = FactorCommonPHIPreds(PN, UV);
1036-
BasicBlock *SuccBB =
1037-
BB->getTerminator()->getSuccessor(GetBestDestForJumpOnUndef(BB));
1038-
1039-
// Ok, try to thread it!
1040-
return ThreadEdge(BB, PredBB, SuccBB);
1041-
}
1042-
}
1043-
1044-
// If the incoming values are all variables, we don't know the destination of
1045-
// any predecessors. However, if any of the predecessor blocks end in an
1046-
// unconditional branch, we can *duplicate* the jump into that block in order
1047-
// to further encourage jump threading and to eliminate cases where we have
1048-
// branch on a phi of an icmp (branch on icmp is much better).
1008+
// If any of the predecessor blocks end in an unconditional branch, we can
1009+
// *duplicate* the jump into that block in order to further encourage jump
1010+
// threading and to eliminate cases where we have branch on a phi of an icmp
1011+
// (branch on icmp is much better).
10491012

10501013
// We don't want to do this tranformation for switches, because we don't
10511014
// really want to duplicate a switch.

0 commit comments

Comments
 (0)