aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/LoopSimplify.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-09-03 15:34:35 +0000
committerDan Gohman <gohman@apple.com>2009-09-03 15:34:35 +0000
commitbccfc24c4e8092e1ee18746dd4cee01247728faa (patch)
treebf1ea31f55e271210a43862a4fe5c64749b8c796 /lib/Transforms/Utils/LoopSimplify.cpp
parentdd12de686cb0a3bcff879ae895fe461caa6f7842 (diff)
Change PHINode::hasConstantValue to have a DominatorTree argument
instead of a bool argument, and to do the dominator check itself. This makes it eaiser to use when DominatorTree information is available. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80920 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/LoopSimplify.cpp')
-rw-r--r--lib/Transforms/Utils/LoopSimplify.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/Transforms/Utils/LoopSimplify.cpp b/lib/Transforms/Utils/LoopSimplify.cpp
index c981a014cb..56e5a46cb7 100644
--- a/lib/Transforms/Utils/LoopSimplify.cpp
+++ b/lib/Transforms/Utils/LoopSimplify.cpp
@@ -255,7 +255,7 @@ ReprocessLoop:
PHINode *PN;
for (BasicBlock::iterator I = L->getHeader()->begin();
(PN = dyn_cast<PHINode>(I++)); )
- if (Value *V = PN->hasConstantValue()) {
+ if (Value *V = PN->hasConstantValue(DT)) {
if (AA) AA->deleteValue(PN);
PN->replaceAllUsesWith(V);
PN->eraseFromParent();
@@ -417,14 +417,13 @@ static PHINode *FindPHIToPartitionLoops(Loop *L, DominatorTree *DT,
for (BasicBlock::iterator I = L->getHeader()->begin(); isa<PHINode>(I); ) {
PHINode *PN = cast<PHINode>(I);
++I;
- if (Value *V = PN->hasConstantValue())
- if (!isa<Instruction>(V) || DT->dominates(cast<Instruction>(V), PN)) {
- // This is a degenerate PHI already, don't modify it!
- PN->replaceAllUsesWith(V);
- if (AA) AA->deleteValue(PN);
- PN->eraseFromParent();
- continue;
- }
+ if (Value *V = PN->hasConstantValue(DT)) {
+ // This is a degenerate PHI already, don't modify it!
+ PN->replaceAllUsesWith(V);
+ if (AA) AA->deleteValue(PN);
+ PN->eraseFromParent();
+ continue;
+ }
// Scan this PHI node looking for a use of the PHI node by itself.
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)