This code can handle non-dominating instructions

llvm-svn: 22667
This commit is contained in:
Chris Lattner 2005-08-05 00:57:45 +00:00
parent 1d8b24878f
commit 257efb2ad3
2 changed files with 2 additions and 2 deletions

View File

@ -256,7 +256,7 @@ BasicBlock *LoopSimplify::SplitBlockPredecessors(BasicBlock *BB,
PN->addIncoming(InVal, NewBB); PN->addIncoming(InVal, NewBB);
// Can we eliminate this phi node now? // Can we eliminate this phi node now?
if (Value *V = PN->hasConstantValue()) { if (Value *V = PN->hasConstantValue(true)) {
if (!isa<Instruction>(V) || if (!isa<Instruction>(V) ||
getAnalysis<DominatorSet>().dominates(cast<Instruction>(V), PN)) { getAnalysis<DominatorSet>().dominates(cast<Instruction>(V), PN)) {
PN->replaceAllUsesWith(V); PN->replaceAllUsesWith(V);

View File

@ -347,7 +347,7 @@ void PromoteMem2Reg::run() {
PHINode *SomePHI = 0; PHINode *SomePHI = 0;
for (unsigned i = 0, e = PNs.size(); i != e; ++i) for (unsigned i = 0, e = PNs.size(); i != e; ++i)
if (PNs[i]) { if (PNs[i]) {
if (Value *V = PNs[i]->hasConstantValue()) { if (Value *V = PNs[i]->hasConstantValue(true)) {
if (!isa<Instruction>(V) || dominates(cast<Instruction>(V), PNs[i])) { if (!isa<Instruction>(V) || dominates(cast<Instruction>(V), PNs[i])) {
if (AST && isa<PointerType>(PNs[i]->getType())) if (AST && isa<PointerType>(PNs[i]->getType()))
AST->deleteValue(PNs[i]); AST->deleteValue(PNs[i]);