aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Scalar/CondPropagate.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-12-03 19:44:02 +0000
committerChris Lattner <sabre@nondot.org>2008-12-03 19:44:02 +0000
commit29874e0dc6c4e55bc384611273343bb358982cc3 (patch)
treeff01073ac8df137035c562888c7cd0f61b60d29f /lib/Transforms/Scalar/CondPropagate.cpp
parente96cc775e496260b7a42dbd6148dffb0575d1304 (diff)
downloadexternal_llvm-29874e0dc6c4e55bc384611273343bb358982cc3.tar.gz
external_llvm-29874e0dc6c4e55bc384611273343bb358982cc3.tar.bz2
external_llvm-29874e0dc6c4e55bc384611273343bb358982cc3.zip
Factor some code into a new FoldSingleEntryPHINodes method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60501 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/CondPropagate.cpp')
-rw-r--r--lib/Transforms/Scalar/CondPropagate.cpp19
1 files changed, 6 insertions, 13 deletions
diff --git a/lib/Transforms/Scalar/CondPropagate.cpp b/lib/Transforms/Scalar/CondPropagate.cpp
index 126e13e453..2e89943290 100644
--- a/lib/Transforms/Scalar/CondPropagate.cpp
+++ b/lib/Transforms/Scalar/CondPropagate.cpp
@@ -14,12 +14,13 @@
#define DEBUG_TYPE "condprop"
#include "llvm/Transforms/Scalar.h"
-#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Constants.h"
#include "llvm/Function.h"
#include "llvm/Instructions.h"
#include "llvm/Pass.h"
#include "llvm/Type.h"
+#include "llvm/Transforms/Utils/BasicBlockUtils.h"
+#include "llvm/Transforms/Utils/Local.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Support/Compiler.h"
@@ -95,13 +96,9 @@ void CondProp::SimplifyBlock(BasicBlock *BB) {
BB != BI->getSuccessor(0)) {
BasicBlock *Succ = BI->getSuccessor(0);
- // If Succ has any PHI nodes, they are all single-entry PHI's.
- while (PHINode *PN = dyn_cast<PHINode>(Succ->begin())) {
- assert(PN->getNumIncomingValues() == 1 &&
- "PHI doesn't match parent block");
- PN->replaceAllUsesWith(PN->getIncomingValue(0));
- PN->eraseFromParent();
- }
+ // If Succ has any PHI nodes, they are all single-entry PHI's. Eliminate
+ // them.
+ FoldSingleEntryPHINodes(Succ);
// Remove BI.
BI->eraseFromParent();
@@ -205,11 +202,7 @@ void CondProp::RevectorBlockTo(BasicBlock *FromBB, BasicBlock *ToBB) {
// OldSucc had multiple successors. If ToBB has multiple predecessors, then
// the edge between them would be critical, which we already took care of.
// If ToBB has single operand PHI node then take care of it here.
- while (PHINode *PN = dyn_cast<PHINode>(ToBB->begin())) {
- assert(PN->getNumIncomingValues() == 1 && "Critical Edge Found!");
- PN->replaceAllUsesWith(PN->getIncomingValue(0));
- PN->eraseFromParent();
- }
+ FoldSingleEntryPHINodes(ToBB);
// Update PHI nodes in OldSucc to know that FromBB no longer branches to it.
OldSucc->removePredecessor(FromBB);