diff options
author | Chris Lattner <sabre@nondot.org> | 2009-11-06 23:19:58 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-11-06 23:19:58 +0000 |
commit | eb690feaef157369edf12b1562da33877e62bb7d (patch) | |
tree | 6036e2caeb95a741838a6170e936b78a97a3907c /llvm/lib/Transforms/Scalar/JumpThreading.cpp | |
parent | db42ca663b1e66291471b1fd2fde5d8455b77caa (diff) | |
download | bcm5719-llvm-eb690feaef157369edf12b1562da33877e62bb7d.tar.gz bcm5719-llvm-eb690feaef157369edf12b1562da33877e62bb7d.zip |
Fix a bug where we'd call SplitBlockPredecessors with a pred in the
set only once even if it has multiple edges to BB.
llvm-svn: 86299
Diffstat (limited to 'llvm/lib/Transforms/Scalar/JumpThreading.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/JumpThreading.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp index 62f7d51ff8c..4bbde1397c8 100644 --- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp +++ b/llvm/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) |