diff options
author | Chris Lattner <sabre@nondot.org> | 2007-02-03 00:08:31 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-02-03 00:08:31 +0000 |
commit | 5e665f559419c7f58a4fd9360cd488f065505c44 (patch) | |
tree | b0b885dc43015823c992923bd3a03b0cb4defa7b /lib/Transforms/Scalar/LoopUnroll.cpp | |
parent | 4642ca6589d3002861963744a157169f15d1ee90 (diff) |
Switch inliner over to use DenseMap instead of std::map for ValueMap. This
speeds up the inliner 16%.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33801 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopUnroll.cpp')
-rw-r--r-- | lib/Transforms/Scalar/LoopUnroll.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/Transforms/Scalar/LoopUnroll.cpp b/lib/Transforms/Scalar/LoopUnroll.cpp index 655ddc4179..c6d8853831 100644 --- a/lib/Transforms/Scalar/LoopUnroll.cpp +++ b/lib/Transforms/Scalar/LoopUnroll.cpp @@ -31,9 +31,9 @@ #include "llvm/Support/Debug.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/SmallPtrSet.h" #include "llvm/IntrinsicInst.h" #include <cstdio> -#include <set> #include <algorithm> using namespace llvm; @@ -111,10 +111,10 @@ static unsigned ApproximateLoopSize(const Loop *L) { // current values into those specified by ValueMap. // static inline void RemapInstruction(Instruction *I, - std::map<const Value *, Value*> &ValueMap) { + DenseMap<const Value *, Value*> &ValueMap) { for (unsigned op = 0, E = I->getNumOperands(); op != E; ++op) { Value *Op = I->getOperand(op); - std::map<const Value *, Value*>::iterator It = ValueMap.find(Op); + DenseMap<const Value *, Value*>::iterator It = ValueMap.find(Op); if (It != ValueMap.end()) Op = It->second; I->setOperand(op, Op); } @@ -212,7 +212,7 @@ bool LoopUnroll::visitLoop(Loop *L) { // For the first iteration of the loop, we should use the precloned values for // PHI nodes. Insert associations now. - std::map<const Value*, Value*> LastValueMap; + DenseMap<const Value*, Value*> LastValueMap; std::vector<PHINode*> OrigPHINode; for (BasicBlock::iterator I = Header->begin(); isa<PHINode>(I); ++I) { PHINode *PN = cast<PHINode>(I); @@ -240,7 +240,7 @@ bool LoopUnroll::visitLoop(Loop *L) { for (std::vector<BasicBlock*>::iterator BB = LoopBlocks.begin(), E = LoopBlocks.end(); BB != E; ++BB) { - std::map<const Value*, Value*> ValueMap; + DenseMap<const Value*, Value*> ValueMap; BasicBlock *New = CloneBasicBlock(*BB, ValueMap, SuffixBuffer); Header->getParent()->getBasicBlockList().push_back(New); @@ -259,7 +259,7 @@ bool LoopUnroll::visitLoop(Loop *L) { // Update our running map of newest clones LastValueMap[*BB] = New; - for (std::map<const Value*, Value*>::iterator VI = ValueMap.begin(), + for (DenseMap<const Value*, Value*>::iterator VI = ValueMap.begin(), VE = ValueMap.end(); VI != VE; ++VI) LastValueMap[VI->first] = VI->second; @@ -303,13 +303,13 @@ bool LoopUnroll::visitLoop(Loop *L) { // Update PHI nodes that reference the final latch block if (TripCount > 1) { - std::set<PHINode*> Users; + SmallPtrSet<PHINode*, 8> Users; for (Value::use_iterator UI = LatchBlock->use_begin(), UE = LatchBlock->use_end(); UI != UE; ++UI) if (PHINode* phi = dyn_cast<PHINode>(*UI)) Users.insert(phi); - for (std::set<PHINode*>::iterator SI = Users.begin(), SE = Users.end(); + for (SmallPtrSet<PHINode*,8>::iterator SI = Users.begin(), SE = Users.end(); SI != SE; ++SI) { Value* InVal = (*SI)->getIncomingValueForBlock(LatchBlock); if (isa<Instruction>(InVal)) |