[llvm-commits] CVS: llvm/lib/VMCore/Instructions.cpp

Chris Lattner lattner at cs.uiuc.edu
Fri Aug 5 08:37:42 PDT 2005



Changes in directory llvm/lib/VMCore:

Instructions.cpp updated: 1.25 -> 1.26
---
Log message:

PHINode::hasConstantValue should never return the PHI itself, even if the
PHI is its only operand.


---
Diffs of the changes:  (+5 -2)

 Instructions.cpp |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)


Index: llvm/lib/VMCore/Instructions.cpp
diff -u llvm/lib/VMCore/Instructions.cpp:1.25 llvm/lib/VMCore/Instructions.cpp:1.26
--- llvm/lib/VMCore/Instructions.cpp:1.25	Thu Aug  4 20:03:27 2005
+++ llvm/lib/VMCore/Instructions.cpp	Fri Aug  5 10:37:31 2005
@@ -138,8 +138,11 @@
 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.
   //






More information about the llvm-commits mailing list