From 8e21fb7df8530c239f7bd590ff940253ac928aa3 Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Fri, 1 Jun 2007 17:34:47 +0000 Subject: [PATCH] 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 --- lib/Transforms/Scalar/GVNPRE.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/Transforms/Scalar/GVNPRE.cpp b/lib/Transforms/Scalar/GVNPRE.cpp index 287b845f69f..f7040b03e17 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& MS, Instruction* V) { Expression e = buildExpression(VN, V); - if (VN.insert(std::make_pair(e, nextValueNumber)).second) + std::pair ret = VN.insert(std::make_pair(e, nextValueNumber)); + if (ret.second) nextValueNumber++; if (e.opcode != 0 || (e.opcode == 0 && isa(e.value))) MS.insert(e); @@ -391,9 +387,12 @@ void GVNPRE::dump(GVNPRE::ValueTable& VN, std::set& 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"; } -- 2.34.1