aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/JumpThreading.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-11-06 23:19:58 +0000
committerChris Lattner <sabre@nondot.org>2009-11-06 23:19:58 +0000
commit79f0332c203b33c4afc0fb6ad946fbe041164e6e (patch)
tree1b7775eccd3420ae6feed24298bb9c56ad14b5f7 /lib/Transforms/Scalar/JumpThreading.cpp
parentd51722a7e35ecd4e89eee0eeee9d8a718d99433b (diff)
Fix a bug where we'd call SplitBlockPredecessors with a pred in the
set only once even if it has multiple edges to BB. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86299 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/JumpThreading.cpp')
-rw-r--r--lib/Transforms/Scalar/JumpThreading.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/JumpThreading.cpp b/lib/Transforms/Scalar/JumpThreading.cpp
index 62f7d51ff8..4bbde1397c 100644
--- a/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/lib/Transforms/Scalar/JumpThreading.cpp
@@ -940,8 +940,17 @@ bool JumpThreading::ProcessThreadableEdges(Instruction *CondInst,
// predecessors that will jump to it into a single predecessor.
SmallVector<BasicBlock*, 16> PredsToFactor;
for (unsigned i = 0, e = PredToDestList.size(); i != e; ++i)
- if (PredToDestList[i].second == MostPopularDest)
- PredsToFactor.push_back(PredToDestList[i].first);
+ if (PredToDestList[i].second == MostPopularDest) {
+ BasicBlock *Pred = PredToDestList[i].first;
+
+ // This predecessor may be a switch or something else that has multiple
+ // edges to the block. Factor each of these edges by listing them
+ // according to # occurrences in PredsToFactor.
+ TerminatorInst *PredTI = Pred->getTerminator();
+ for (unsigned i = 0, e = PredTI->getNumSuccessors(); i != e; ++i)
+ if (PredTI->getSuccessor(i) == BB)
+ PredsToFactor.push_back(Pred);
+ }
BasicBlock *PredToThread;
if (PredsToFactor.size() == 1)