[llvm-commits] CVS: llvm/lib/Transforms/Utils/Local.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sun Oct 17 14:23:37 PDT 2004
Changes in directory llvm/lib/Transforms/Utils:
Local.cpp updated: 1.34 -> 1.35
---
Log message:
Enhance hasConstantValue to ignore undef values in phi nodes. This allows it
to think that PHI[4, undef] == 4.
---
Diffs of the changes: (+3 -2)
Index: llvm/lib/Transforms/Utils/Local.cpp
diff -u llvm/lib/Transforms/Utils/Local.cpp:1.34 llvm/lib/Transforms/Utils/Local.cpp:1.35
--- llvm/lib/Transforms/Utils/Local.cpp:1.34 Wed Sep 1 17:55:36 2004
+++ llvm/lib/Transforms/Utils/Local.cpp Sun Oct 17 16:23:26 2004
@@ -353,7 +353,8 @@
//
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 @@
// 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;
More information about the llvm-commits
mailing list