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

Thanks Duncan for the idea

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159687 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nuno Lopes 2012-07-03 21:15:40 +00:00
parent 86b032b2ab
commit 0fd518beb3
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;
}