PHINode::hasConstantValue(): return undef if the PHI is fully recursive.
authorNuno Lopes <nunoplopes@sapo.pt>
Tue, 3 Jul 2012 21:15:40 +0000 (21:15 +0000)
committerNuno Lopes <nunoplopes@sapo.pt>
Tue, 3 Jul 2012 21:15:40 +0000 (21:15 +0000)
Thanks Duncan for the idea

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159687 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ValueTracking.cpp
lib/VMCore/Instructions.cpp

index d245783ec6529b75095eef4e166f844ee50c8626..cea34e16e7bf4527e883b0dc192e6da1b98a7af8 100644 (file)
@@ -694,7 +694,7 @@ void llvm::ComputeMaskedBits(Value *V, APInt &KnownZero, APInt &KnownOne,
     // taking conservative care to avoid excessive recursion.
     if (Depth < MaxDepth - 1 && !KnownZero && !KnownOne) {
       // Skip if every incoming value references to ourself.
-      if (P->hasConstantValue() == P)
+      if (dyn_cast_or_null<UndefValue>(P->hasConstantValue()))
         break;
 
       KnownZero = APInt::getAllOnesValue(BitWidth);
index 5aef45925016800734005972beb968ee19ae2721..9af98e8a9b3d139c248f8de23c3b3f7c8aec656c 100644 (file)
@@ -167,6 +167,8 @@ Value *PHINode::hasConstantValue() const {
        // The case where the first value is this PHI.
       ConstantValue = getIncomingValue(i);
     }
+  if (ConstantValue == this)
+    return UndefValue::get(getType());
   return ConstantValue;
 }