diff options
author | Chris Lattner <sabre@nondot.org> | 2004-10-17 21:23:26 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-10-17 21:23:26 +0000 |
commit | 8143c2bc0de4f39bef0432a25d9a111be4767fa1 (patch) | |
tree | 7d2b206a7d7fead5814639ba25c8ca63e1f23f75 /lib | |
parent | c30bda7540de573c887e00bb76ac78d85f56acd4 (diff) |
Enhance hasConstantValue to ignore undef values in phi nodes. This allows it
to think that PHI[4, undef] == 4.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17096 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Utils/Local.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp index fe27f308cf..b188884a40 100644 --- a/lib/Transforms/Utils/Local.cpp +++ b/lib/Transforms/Utils/Local.cpp @@ -353,7 +353,8 @@ Value *llvm::hasConstantValue(PHINode *PN) { // Value *InVal = 0; for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) - if (PN->getIncomingValue(i) != PN) // Not the PHI node itself... + if (PN->getIncomingValue(i) != PN && // Not the PHI node itself... + !isa<UndefValue>(PN->getIncomingValue(i))) if (InVal && PN->getIncomingValue(i) != InVal) return 0; // Not the same, bail out. else @@ -363,7 +364,7 @@ Value *llvm::hasConstantValue(PHINode *PN) { // that only has entries for itself. In this case, there is no entry into the // loop, so kill the PHI. // - if (InVal == 0) InVal = Constant::getNullValue(PN->getType()); + if (InVal == 0) InVal = UndefValue::get(PN->getType()); // All of the incoming values are the same, return the value now. return InVal; |