aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorNuno Lopes <nunoplopes@sapo.pt>2012-07-03 21:15:40 +0000
committerNuno Lopes <nunoplopes@sapo.pt>2012-07-03 21:15:40 +0000
commit0fd518beb38568e58eeec86876bb597bab06b722 (patch)
treea0b18ec4e81ab9be8669c3442f61e28c3bda1845 /lib
parent86b032b2abcf8a66282241937861156fc432fa33 (diff)
downloadexternal_llvm-0fd518beb38568e58eeec86876bb597bab06b722.zip
external_llvm-0fd518beb38568e58eeec86876bb597bab06b722.tar.gz
external_llvm-0fd518beb38568e58eeec86876bb597bab06b722.tar.bz2
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
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/ValueTracking.cpp2
-rw-r--r--lib/VMCore/Instructions.cpp2
2 files changed, 3 insertions, 1 deletions
diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp
index d245783..cea34e1 100644
--- a/lib/Analysis/ValueTracking.cpp
+++ b/lib/Analysis/ValueTracking.cpp
@@ -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);
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp
index 5aef459..9af98e8 100644
--- a/lib/VMCore/Instructions.cpp
+++ b/lib/VMCore/Instructions.cpp
@@ -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;
}