summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-10-17 21:23:26 +0000
committerChris Lattner <sabre@nondot.org>2004-10-17 21:23:26 +0000
commit96db59e48a76e95d33404e84e3b6b60984a35982 (patch)
treee05bbba42ccc6127e70468c3d7d241bbe4a3cbc7 /llvm/lib/Transforms/Utils/Local.cpp
parente29d634a94d7e748abd7294b4024c3f6b7ee1def (diff)
downloadbcm5719-llvm-96db59e48a76e95d33404e84e3b6b60984a35982.tar.gz
bcm5719-llvm-96db59e48a76e95d33404e84e3b6b60984a35982.zip
Enhance hasConstantValue to ignore undef values in phi nodes. This allows it
to think that PHI[4, undef] == 4. llvm-svn: 17096
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index fe27f308cf0..b188884a405 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/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;
OpenPOWER on IntegriCloud