diff options
author | Chris Lattner <sabre@nondot.org> | 2009-09-21 22:27:34 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-09-21 22:27:34 +0000 |
commit | 7d08da6b2afa96f3c1ea63907f5e34d11e80cce9 (patch) | |
tree | 02f885b3ba34eeeb21f9fd5e7e2246a8b48d6b4e /llvm/lib/VMCore/Instructions.cpp | |
parent | e3ce1e2a37170dc2d2430d52b804b1f74b21ff18 (diff) | |
download | bcm5719-llvm-7d08da6b2afa96f3c1ea63907f5e34d11e80cce9.tar.gz bcm5719-llvm-7d08da6b2afa96f3c1ea63907f5e34d11e80cce9.zip |
tidy up
llvm-svn: 82489
Diffstat (limited to 'llvm/lib/VMCore/Instructions.cpp')
-rw-r--r-- | llvm/lib/VMCore/Instructions.cpp | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp index d479d9ac99c..8250ec009db 100644 --- a/llvm/lib/VMCore/Instructions.cpp +++ b/llvm/lib/VMCore/Instructions.cpp @@ -234,12 +234,11 @@ void PHINode::resizeOperands(unsigned NumOps) { /// otherwise use DT to test for dominance. /// Value *PHINode::hasConstantValue(DominatorTree *DT) const { - // If the PHI node only has one incoming value, eliminate the PHI node... + // If the PHI node only has one incoming value, eliminate the PHI node. if (getNumIncomingValues() == 1) { if (getIncomingValue(0) != this) // not X = phi X return getIncomingValue(0); - else - return UndefValue::get(getType()); // Self cycle is dead. + return UndefValue::get(getType()); // Self cycle is dead. } // Otherwise if all of the incoming values are the same for the PHI, replace @@ -253,8 +252,7 @@ Value *PHINode::hasConstantValue(DominatorTree *DT) const { } else if (getIncomingValue(i) != this) { // Not the PHI node itself... if (InVal && getIncomingValue(i) != InVal) return 0; // Not the same, bail out. - else - InVal = getIncomingValue(i); + InVal = getIncomingValue(i); } // The only case that could cause InVal to be null is if we have a PHI node @@ -267,19 +265,20 @@ Value *PHINode::hasConstantValue(DominatorTree *DT) const { // instruction, we cannot always return X as the result of the PHI node. Only // do this if X is not an instruction (thus it must dominate the PHI block), // or if the client is prepared to deal with this possibility. - if (HasUndefInput) - if (Instruction *IV = dyn_cast<Instruction>(InVal)) { - if (DT) { - // We have a DominatorTree. Do a precise test. - if (!DT->dominates(IV, this)) - return 0; - } else { - // If it's in the entry block, it dominates everything. - if (IV->getParent() != &IV->getParent()->getParent()->getEntryBlock() || - isa<InvokeInst>(IV)) - return 0; // Cannot guarantee that InVal dominates this PHINode. - } - } + if (!HasUndefInput || !isa<Instruction>(InVal)) + return InVal; + + Instruction *IV = cast<Instruction>(InVal); + if (DT) { + // We have a DominatorTree. Do a precise test. + if (!DT->dominates(IV, this)) + return 0; + } else { + // If it is in the entry block, it obviously dominates everything. + if (IV->getParent() != &IV->getParent()->getParent()->getEntryBlock() || + isa<InvokeInst>(IV)) + return 0; // Cannot guarantee that InVal dominates this PHINode. + } // All of the incoming values are the same, return the value now. return InVal; |