[llvm-commits] CVS: llvm/lib/Transforms/Scalar/GVNPRE.cpp
Owen Anderson
resistor at mac.com
Mon Jun 4 16:28:55 PDT 2007
Changes in directory llvm/lib/Transforms/Scalar:
GVNPRE.cpp updated: 1.16 -> 1.17
---
Log message:
Fix a bunch of small bugs, and improve the debugging output significantly.
---
Diffs of the changes: (+44 -26)
GVNPRE.cpp | 70 ++++++++++++++++++++++++++++++++++++++-----------------------
1 files changed, 44 insertions(+), 26 deletions(-)
Index: llvm/lib/Transforms/Scalar/GVNPRE.cpp
diff -u llvm/lib/Transforms/Scalar/GVNPRE.cpp:1.16 llvm/lib/Transforms/Scalar/GVNPRE.cpp:1.17
--- llvm/lib/Transforms/Scalar/GVNPRE.cpp:1.16 Mon Jun 4 13:05:26 2007
+++ llvm/lib/Transforms/Scalar/GVNPRE.cpp Mon Jun 4 18:28:33 2007
@@ -138,15 +138,19 @@
return 0;
if (BinaryOperator* BO = dyn_cast<BinaryOperator>(V)) {
- Value* newOp1 = phi_translate(VN, MS, set,
+ Value* newOp1 = isa<Instruction>(BO->getOperand(0))
+ ? phi_translate(VN, MS, set,
find_leader(VN, set, VN[BO->getOperand(0)]),
- pred);
+ pred)
+ : BO->getOperand(0);
if (newOp1 == 0)
return 0;
- Value* newOp2 = phi_translate(VN, MS, set,
- find_leader(VN, set, VN[BO->getOperand(1)]),
- pred);
+ Value* newOp2 = isa<Instruction>(BO->getOperand(1))
+ ? phi_translate(VN, MS, set,
+ find_leader(VN, set, VN[BO->getOperand(0)]),
+ pred)
+ : BO->getOperand(1);
if (newOp2 == 0)
return 0;
@@ -303,8 +307,10 @@
add(VN, MS, BO);
- currExps.insert(leftValue);
- currExps.insert(rightValue);
+ if (isa<Instruction>(leftValue))
+ currExps.insert(leftValue);
+ if (isa<Instruction>(rightValue))
+ currExps.insert(rightValue);
currExps.insert(BO);
currTemps.insert(BO);
@@ -365,7 +371,13 @@
df_begin(PDT.getRootNode()), E = df_end(DT.getRootNode());
PDI != E; ++PDI) {
BasicBlock* BB = PDI->getBlock();
-
+ DOUT << "Block: " << BB->getName() << "\n";
+ DOUT << "TMP_GEN: ";
+ dump(VN, generatedTemporaries[BB]);
+ DOUT << "\n";
+
+ DOUT << "EXP_GEN: ";
+ dump_unique(VN, generatedExpressions[BB]);
visited.insert(BB);
std::set<Value*, ExprLT>& anticIn = anticipatedIn[BB];
@@ -373,31 +385,33 @@
if (BB->getTerminator()->getNumSuccessors() == 1) {
if (visited.find(BB) == visited.end())
- phi_translate_set(VN, maximalSet, anticIn, BB, anticOut);
+ phi_translate_set(VN, maximalSet, maximalSet, BB, anticOut);
else
- phi_translate_set(VN, anticIn, anticIn, BB, anticOut);
+ phi_translate_set(VN, maximalSet, anticipatedIn[BB->getTerminator()->getSuccessor(0)], BB, anticOut);
} else if (BB->getTerminator()->getNumSuccessors() > 1) {
- for (unsigned i = 0; i < BB->getTerminator()->getNumSuccessors(); ++i) {
+ BasicBlock* first = BB->getTerminator()->getSuccessor(0);
+ anticOut.insert(anticipatedIn[first].begin(),
+ anticipatedIn[first].end());
+ for (unsigned i = 1; i < BB->getTerminator()->getNumSuccessors(); ++i) {
BasicBlock* currSucc = BB->getTerminator()->getSuccessor(i);
+ std::set<Value*, ExprLT>& succAnticIn = anticipatedIn[currSucc];
+
std::set<Value*, ExprLT> temp;
- if (visited.find(currSucc) == visited.end())
- temp.insert(maximalSet.begin(), maximalSet.end());
- else
- temp.insert(anticIn.begin(), anticIn.end());
-
- anticIn.clear();
- std::insert_iterator<std::set<Value*, ExprLT> > ai_ins(anticIn,
- anticIn.begin());
-
- std::set_difference(anticipatedIn[currSucc].begin(),
- anticipatedIn[currSucc].end(),
- temp.begin(),
- temp.end(),
- ai_ins,
- ExprLT());
+ std::insert_iterator<std::set<Value*, ExprLT> > temp_ins(temp,
+ temp.begin());
+ std::set_intersection(anticOut.begin(), anticOut.end(),
+ succAnticIn.begin(), succAnticIn.end(),
+ temp_ins, ExprLT());
+
+ anticOut.clear();
+ anticOut.insert(temp.begin(), temp.end());
}
}
+ DOUT << "ANTIC_OUT: ";
+ dump_unique(VN, anticOut);
+ DOUT << "\n";
+
std::set<Value*, ExprLT> S;
std::insert_iterator<std::set<Value*, ExprLT> > s_ins(S, S.begin());
std::set_union(anticOut.begin(), anticOut.end(),
@@ -416,6 +430,10 @@
clean(VN, anticIn);
+ DOUT << "ANTIC_IN: ";
+ dump_unique(VN, anticIn);
+ DOUT << "\n";
+
if (old != anticIn)
changed = true;
More information about the llvm-commits
mailing list