diff options
author | Chris Lattner <sabre@nondot.org> | 2009-12-31 07:33:14 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-12-31 07:33:14 +0000 |
commit | ec531233a16605756a84d175178e1ee0fac4791c (patch) | |
tree | ac6e7402df1808802f0c480f1f052717dc4c2146 /lib/Transforms/Scalar/Reassociate.cpp | |
parent | 1befe643b2a030f5e2433ce0034a27fb65b5f26b (diff) |
use more modern datastructures.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92344 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/Reassociate.cpp')
-rw-r--r-- | lib/Transforms/Scalar/Reassociate.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Transforms/Scalar/Reassociate.cpp b/lib/Transforms/Scalar/Reassociate.cpp index 79c59f374c..a6dd46321b 100644 --- a/lib/Transforms/Scalar/Reassociate.cpp +++ b/lib/Transforms/Scalar/Reassociate.cpp @@ -35,6 +35,7 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/ADT/PostOrderIterator.h" #include "llvm/ADT/Statistic.h" +#include "llvm/ADT/DenseMap.h" #include <algorithm> #include <map> using namespace llvm; @@ -600,7 +601,7 @@ Value *Reassociate::OptimizeExpression(BinaryOperator *I, } if (Ops.size() == 1) return Ops[0].Op; - // Handle destructive annihilation do to identities between elements in the + // Handle destructive annihilation due to identities between elements in the // argument list here. switch (Opcode) { default: break; @@ -688,7 +689,7 @@ Value *Reassociate::OptimizeExpression(BinaryOperator *I, // reassociate this to A*(A+B*C)+D, which reduces the number of multiplies. // To efficiently find this, we count the number of times a factor occurs // for any ADD operands that are MULs. - std::map<Value*, unsigned> FactorOccurrences; + DenseMap<Value*, unsigned> FactorOccurrences; unsigned MaxOcc = 0; Value *MaxOccVal = 0; for (unsigned i = 0, e = Ops.size(); i != e; ++i) { @@ -708,9 +709,9 @@ Value *Reassociate::OptimizeExpression(BinaryOperator *I, if (Occ > MaxOcc) { MaxOcc = Occ; MaxOccVal = Factors[1]; } } } else { - std::set<Value*> Duplicates; + SmallPtrSet<Value*, 4> Duplicates; for (unsigned i = 0, e = Factors.size(); i != e; ++i) { - if (Duplicates.insert(Factors[i]).second) { + if (Duplicates.insert(Factors[i])) { unsigned Occ = ++FactorOccurrences[Factors[i]]; if (Occ > MaxOcc) { MaxOcc = Occ; MaxOccVal = Factors[i]; } } |