From 746139b736b9c567d1e62186b70b0d1c0ae03b29 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 1 Nov 2009 04:23:20 +0000 Subject: [PATCH] strengthen an assumption: RevectorBlockTo knows that PredBB ended in an uncond branch because the pass requires BreakCriticalEdges. However, BCE doesn't eliminate critical adges from indbrs. llvm-svn: 85707 --- llvm/lib/Transforms/Scalar/CondPropagate.cpp | 24 +++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/llvm/lib/Transforms/Scalar/CondPropagate.cpp b/llvm/lib/Transforms/Scalar/CondPropagate.cpp index 5b573f492cdc..8a6c5562eb9e 100644 --- a/llvm/lib/Transforms/Scalar/CondPropagate.cpp +++ b/llvm/lib/Transforms/Scalar/CondPropagate.cpp @@ -196,18 +196,20 @@ void CondProp::SimplifyPredecessors(SwitchInst *SI) { // possible, and to avoid invalidating "i". for (unsigned i = PN->getNumIncomingValues(); i != 0; --i) if (ConstantInt *CI = dyn_cast(PN->getIncomingValue(i-1))) { - // If we have a constant, forward the edge from its current to its - // ultimate destination. - unsigned DestCase = SI->findCaseValue(CI); - RevectorBlockTo(PN->getIncomingBlock(i-1), - SI->getSuccessor(DestCase)); - ++NumSwThread; + BasicBlock *PredBB = PN->getIncomingBlock(i-1); + if (isa(PredBB->getTerminator())) { + // If we have a constant, forward the edge from its current to its + // ultimate destination. + unsigned DestCase = SI->findCaseValue(CI); + RevectorBlockTo(PredBB, SI->getSuccessor(DestCase)); + ++NumSwThread; - // If there were two predecessors before this simplification, or if the - // PHI node contained all the same value except for the one we just - // substituted, the PHI node may be deleted. Don't iterate through it the - // last time. - if (SI->getCondition() != PN) return; + // If there were two predecessors before this simplification, or if the + // PHI node contained all the same value except for the one we just + // substituted, the PHI node may be deleted. Don't iterate through it the + // last time. + if (SI->getCondition() != PN) return; + } } }