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
This commit is contained in:
Dan Gohman
2009-09-03 15:34:35 +00:00
parent dd12de686c
commit bccfc24c4e
7 changed files with 49 additions and 37 deletions

View File

@ -494,17 +494,14 @@ void PromoteMem2Reg::run() {
PHINode *PN = I->second;
// If this PHI node merges one value and/or undefs, get the value.
if (Value *V = PN->hasConstantValue(true)) {
if (!isa<Instruction>(V) ||
properlyDominates(cast<Instruction>(V), PN)) {
if (AST && isa<PointerType>(PN->getType()))
AST->deleteValue(PN);
PN->replaceAllUsesWith(V);
PN->eraseFromParent();
NewPhiNodes.erase(I++);
EliminatedAPHI = true;
continue;
}
if (Value *V = PN->hasConstantValue(&DT)) {
if (AST && isa<PointerType>(PN->getType()))
AST->deleteValue(PN);
PN->replaceAllUsesWith(V);
PN->eraseFromParent();
NewPhiNodes.erase(I++);
EliminatedAPHI = true;
continue;
}
++I;
}