diff options
author | Nate Begeman <natebegeman@mac.com> | 2005-08-04 23:24:19 +0000 |
---|---|---|
committer | Nate Begeman <natebegeman@mac.com> | 2005-08-04 23:24:19 +0000 |
commit | b392321cae84aa9ac37966ce0d3f73a34bee8b11 (patch) | |
tree | 1dd95fa0d70c36c83a8b37e5f5dc4c77d15b8c56 /llvm/lib/VMCore/BasicBlock.cpp | |
parent | a75342d89f59426934ed634a15c6585197ff55cc (diff) | |
download | bcm5719-llvm-b392321cae84aa9ac37966ce0d3f73a34bee8b11.tar.gz bcm5719-llvm-b392321cae84aa9ac37966ce0d3f73a34bee8b11.zip |
Fix a fixme in CondPropagate.cpp by moving a PhiNode optimization into
BasicBlock's removePredecessor routine. This requires shuffling around
the definition and implementation of hasContantValue from Utils.h,cpp into
Instructions.h,cpp
llvm-svn: 22664
Diffstat (limited to 'llvm/lib/VMCore/BasicBlock.cpp')
-rw-r--r-- | llvm/lib/VMCore/BasicBlock.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/VMCore/BasicBlock.cpp b/llvm/lib/VMCore/BasicBlock.cpp index 98d12d8f138..407080cf68b 100644 --- a/llvm/lib/VMCore/BasicBlock.cpp +++ b/llvm/lib/VMCore/BasicBlock.cpp @@ -189,8 +189,16 @@ void BasicBlock::removePredecessor(BasicBlock *Pred, // Okay, now we know that we need to remove predecessor #pred_idx from all // PHI nodes. Iterate over each PHI node fixing them up PHINode *PN; - for (iterator II = begin(); (PN = dyn_cast<PHINode>(II)); ++II) + for (iterator II = begin(); (PN = dyn_cast<PHINode>(II)); ++II) { PN->removeIncomingValue(Pred, false); + // If all incoming values to the Phi are the same, we can replace the Phi + // with that value. + if (Value *PNV = PN->hasConstantValue()) + if (!isa<Instruction>(PNV)) { + PN->replaceAllUsesWith(PNV); + PN->eraseFromParent(); + } + } } } |