aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2007-06-01 17:34:47 +0000
committerOwen Anderson <resistor@mac.com>2007-06-01 17:34:47 +0000
commit8e21fb7df8530c239f7bd590ff940253ac928aa3 (patch)
treebfdb709feb03ac7d8623d9434d6a5088b679fdb4
parent144fd1ff0f1548ec9c4e835dec19ac2d5e46e902 (diff)
Fix Expression comparison, which in turn fixes a value numbering error.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37386 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/GVNPRE.cpp23
1 files changed, 11 insertions, 12 deletions
diff --git a/lib/Transforms/Scalar/GVNPRE.cpp b/lib/Transforms/Scalar/GVNPRE.cpp
index 287b845f69..f7040b03e1 100644
--- a/lib/Transforms/Scalar/GVNPRE.cpp
+++ b/lib/Transforms/Scalar/GVNPRE.cpp
@@ -60,19 +60,14 @@ namespace {
return false;
if (opcode == 0) {
- if (value < other.value)
- return true;
- else
- return false;
+ return value < other.value;
} else {
if (lhs < other.lhs)
return true;
else if (other.lhs < lhs)
- return true;
- else if (rhs < other.rhs)
- return true;
- else
return false;
+ else
+ return rhs < other.rhs;
}
}
@@ -214,7 +209,8 @@ GVNPRE::Expression GVNPRE::buildExpression(ValueTable& VN, Value* V) {
GVNPRE::Expression GVNPRE::add(ValueTable& VN, std::set<Expression>& MS,
Instruction* V) {
Expression e = buildExpression(VN, V);
- if (VN.insert(std::make_pair(e, nextValueNumber)).second)
+ std::pair<ValueTable::iterator, bool> ret = VN.insert(std::make_pair(e, nextValueNumber));
+ if (ret.second)
nextValueNumber++;
if (e.opcode != 0 || (e.opcode == 0 && isa<PHINode>(e.value)))
MS.insert(e);
@@ -391,9 +387,12 @@ void GVNPRE::dump(GVNPRE::ValueTable& VN, std::set<GVNPRE::Expression>& s) {
DOUT << VN[*I] << ": ";
DOUT << "( ";
DOUT << (char)(I->opcode+48);
- DOUT << ", "
- << (I->value == 0 ? "0" : I->value->getName().c_str())
- << ", value." << I->lhs << ", value." << I->rhs << " ) ";
+ DOUT << ", ";
+ if (I->value == 0)
+ DOUT << "0";
+ else
+ DEBUG(I->value->dump());
+ DOUT << ", value." << I->lhs << ", value." << I->rhs << " ) ";
}
DOUT << "}\n\n";
}