From ffb83a155e4866979b60cb33ecb8a33b66db3549 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Wed, 15 Apr 2009 00:43:54 +0000 Subject: Avoid making the transformation enabled by my last patch if the new destinations have phi nodes. llvm-svn: 69121 --- llvm/lib/Transforms/Scalar/CondPropagate.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/Scalar/CondPropagate.cpp b/llvm/lib/Transforms/Scalar/CondPropagate.cpp index 8df2b6c82f6..c85d0317d65 100644 --- a/llvm/lib/Transforms/Scalar/CondPropagate.cpp +++ b/llvm/lib/Transforms/Scalar/CondPropagate.cpp @@ -267,11 +267,21 @@ bool CondProp::RevectorBlockTo(BasicBlock *FromBB, Value *Cond, BranchInst *BI){ // Change FromBr to branch to the new destination. FromBr->setSuccessor(0, ToBB); } else { + BasicBlock *Succ0 = BI->getSuccessor(0); + // Do not perform transform if the new destination has PHI nodes. The + // transform will add new preds to the PHI's. + if (isa(Succ0->begin())) + return false; + + BasicBlock *Succ1 = BI->getSuccessor(1); + if (isa(Succ1->begin())) + return false; + // Insert the new conditional branch. - BranchInst::Create(BI->getSuccessor(0), BI->getSuccessor(1), Cond, FromBr); + BranchInst::Create(Succ0, Succ1, Cond, FromBr); - FoldSingleEntryPHINodes(BI->getSuccessor(0)); - FoldSingleEntryPHINodes(BI->getSuccessor(1)); + FoldSingleEntryPHINodes(Succ0); + FoldSingleEntryPHINodes(Succ1); // Update PHI nodes in OldSucc to know that FromBB no longer branches to it. OldSucc->removePredecessor(FromBB); -- cgit v1.2.3