diff options
author | Chris Lattner <sabre@nondot.org> | 2005-08-05 15:37:31 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-08-05 15:37:31 +0000 |
commit | d7231ac523eb8d5c6a6b09e223e957cb99f9d446 (patch) | |
tree | 3b7de1a92d1a959fea83bf19f56dec875ea3a5e9 /lib/VMCore/Instructions.cpp | |
parent | 80f4d88a97e1b925c2ea67f932dd9c3ce1df1f8d (diff) |
PHINode::hasConstantValue should never return the PHI itself, even if the
PHI is its only operand.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22676 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Instructions.cpp')
-rw-r--r-- | lib/VMCore/Instructions.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index d9c20872f8..7de5602f08 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -138,8 +138,11 @@ void PHINode::resizeOperands(unsigned NumOps) { Value *PHINode::hasConstantValue(bool AllowNonDominatingInstruction) const { // If the PHI node only has one incoming value, eliminate the PHI node... if (getNumIncomingValues() == 1) - return getIncomingValue(0); - + if (getIncomingValue(0) != this) // not X = phi X + return getIncomingValue(0); + else + return UndefValue::get(getType()); // Self cycle is dead. + // Otherwise if all of the incoming values are the same for the PHI, replace // the PHI node with the incoming value. // |