PHINode::hasConstantValue(): return undef if the PHI is fully recursive.

Thanks Duncan for the idea

llvm-svn: 159687
This commit is contained in:
Nuno Lopes
2012-07-03 21:15:40 +00:00
parent c8a0ce0a7a
commit 0d44a50426
2 changed files with 3 additions and 1 deletions

View 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);

View 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;
}