[llvm-commits] CVS: llvm/lib/Transforms/Scalar/GVNPRE.cpp
Owen Anderson
resistor at mac.com
Fri Jun 22 11:27:27 PDT 2007
Changes in directory llvm/lib/Transforms/Scalar:
GVNPRE.cpp updated: 1.53 -> 1.54
---
Log message:
Perform fewer set insertions while calculating ANTIC_IN. This reduces the amount of time to optimize 403.gcc from 21.9s to 18.2s.
---
Diffs of the changes: (+31 -40)
GVNPRE.cpp | 71 ++++++++++++++++++++++++++-----------------------------------
1 files changed, 31 insertions(+), 40 deletions(-)
Index: llvm/lib/Transforms/Scalar/GVNPRE.cpp
diff -u llvm/lib/Transforms/Scalar/GVNPRE.cpp:1.53 llvm/lib/Transforms/Scalar/GVNPRE.cpp:1.54
--- llvm/lib/Transforms/Scalar/GVNPRE.cpp:1.53 Fri Jun 22 12:04:40 2007
+++ llvm/lib/Transforms/Scalar/GVNPRE.cpp Fri Jun 22 13:27:04 2007
@@ -818,20 +818,20 @@
availNumbers.resize(VN.size());
if (isa<Instruction>(leftValue))
- if (!expNumbers.test(VN.lookup(leftValue)-1)) {
+ if (!expNumbers.test(VN.lookup(leftValue))) {
currExps.insert(leftValue);
- expNumbers.set(VN.lookup(leftValue)-1);
+ expNumbers.set(VN.lookup(leftValue));
}
if (isa<Instruction>(rightValue))
- if (!expNumbers.test(VN.lookup(rightValue)-1)) {
+ if (!expNumbers.test(VN.lookup(rightValue))) {
currExps.insert(rightValue);
- expNumbers.set(VN.lookup(rightValue)-1);
+ expNumbers.set(VN.lookup(rightValue));
}
- if (!expNumbers.test(VN.lookup(BO)-1)) {
+ if (!expNumbers.test(VN.lookup(BO))) {
currExps.insert(BO);
- expNumbers.set(num-1);
+ expNumbers.set(num);
}
// Handle cmp ops...
@@ -846,19 +846,19 @@
availNumbers.resize(VN.size());
if (isa<Instruction>(leftValue))
- if (!expNumbers.test(VN.lookup(leftValue)-1)) {
+ if (!expNumbers.test(VN.lookup(leftValue))) {
currExps.insert(leftValue);
- expNumbers.set(VN.lookup(leftValue)-1);
+ expNumbers.set(VN.lookup(leftValue));
}
if (isa<Instruction>(rightValue))
- if (!expNumbers.test(VN.lookup(rightValue)-1)) {
+ if (!expNumbers.test(VN.lookup(rightValue))) {
currExps.insert(rightValue);
- expNumbers.set(VN.lookup(rightValue)-1);
+ expNumbers.set(VN.lookup(rightValue));
}
- if (!expNumbers.test(VN.lookup(C)-1)) {
+ if (!expNumbers.test(VN.lookup(C))) {
currExps.insert(C);
- expNumbers.set(num-1);
+ expNumbers.set(num);
}
// Handle unsupported ops
@@ -871,9 +871,9 @@
}
if (!I->isTerminator())
- if (!availNumbers.test(VN.lookup(I)-1)) {
+ if (!availNumbers.test(VN.lookup(I))) {
currAvail.insert(I);
- availNumbers.set(VN.lookup(I)-1);
+ availNumbers.set(VN.lookup(I));
}
}
@@ -921,45 +921,36 @@
SmallPtrSet<Value*, 32>& currTemps,
std::set<BasicBlock*>& visited) {
SmallPtrSet<Value*, 32>& anticIn = anticipatedIn[BB];
- SmallPtrSet<Value*, 32> old (anticIn.begin(), anticIn.end());
+ unsigned old = anticIn.size();
bool defer = buildsets_anticout(BB, anticOut, visited);
if (defer)
return 0;
-
- SmallPtrSet<Value*, 32> S;
- for (SmallPtrSet<Value*, 32>::iterator I = anticOut.begin(),
- E = anticOut.end(); I != E; ++I)
- if (currTemps.count(*I) == 0)
- S.insert(*I);
anticIn.clear();
+ BitVector numbers(VN.size());
+ for (SmallPtrSet<Value*, 32>::iterator I = anticOut.begin(),
+ E = anticOut.end(); I != E; ++I) {
+ anticIn.insert(*I);
+ numbers.set(VN.lookup_or_add(*I));
+ }
for (SmallPtrSet<Value*, 32>::iterator I = currExps.begin(),
- E = currExps.end(); I != E; ++I)
- if (currTemps.count(*I) == 0)
+ E = currExps.end(); I != E; ++I) {
+ if (!numbers.test(VN.lookup_or_add(*I))) {
anticIn.insert(*I);
+ numbers.set(VN.lookup(*I));
+ }
+ }
+
+ for (SmallPtrSet<Value*, 32>::iterator I = currTemps.begin(),
+ E = currTemps.end(); I != E; ++I)
+ anticIn.erase(*I);
- BitVector numbers(VN.size());
- for (SmallPtrSet<Value*, 32>::iterator I = anticIn.begin(),
- E = anticIn.end(); I != E; ++I)
- numbers.set(VN.lookup(*I)-1);
- for (SmallPtrSet<Value*, 32>::iterator I = S.begin(), E = S.end();
- I != E; ++I) {
- // For non-opaque values, we should already have a value numbering.
- // However, for opaques, such as constants within PHI nodes, it is
- // possible that they have not yet received a number. Make sure they do
- // so now.
- if (!isa<BinaryOperator>(*I) && !isa<CmpInst>(*I))
- VN.lookup_or_add(*I);
- if (!numbers.test(VN.lookup(*I)-1))
- anticIn.insert(*I);
- }
-
clean(anticIn);
anticOut.clear();
- if (old.size() != anticIn.size())
+ if (old != anticIn.size())
return 2;
else
return 1;
More information about the llvm-commits
mailing list