diff options
author | Evan Cheng <evan.cheng@apple.com> | 2009-04-15 00:43:54 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2009-04-15 00:43:54 +0000 |
commit | aa230a41dcfc44d3a711732866c07079ec9e2ba6 (patch) | |
tree | 892dc247e0f05c28541b5d473a311eb75b52d8b1 /lib | |
parent | 517576d6f96a0acde9bab79553d89f4ceba20cf6 (diff) |
Avoid making the transformation enabled by my last patch if the new destinations have phi nodes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69121 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Scalar/CondPropagate.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/CondPropagate.cpp b/lib/Transforms/Scalar/CondPropagate.cpp index 8df2b6c82f..c85d0317d6 100644 --- a/lib/Transforms/Scalar/CondPropagate.cpp +++ b/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<PHINode>(Succ0->begin())) + return false; + + BasicBlock *Succ1 = BI->getSuccessor(1); + if (isa<PHINode>(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); |