Thanks Duncan for the idea
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159687
91177308-0d34-0410-b5e6-
96231b3b80d8
// 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);
// The case where the first value is this PHI.
ConstantValue = getIncomingValue(i);
}
+ if (ConstantValue == this)
+ return UndefValue::get(getType());
return ConstantValue;
}