[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopUnroll.cpp LoopUnswitch.cpp

Chris Lattner sabre at nondot.org
Fri Feb 2 16:08:51 PST 2007



Changes in directory llvm/lib/Transforms/Scalar:

LoopUnroll.cpp updated: 1.34 -> 1.35
LoopUnswitch.cpp updated: 1.59 -> 1.60
---
Log message:

Switch inliner over to use DenseMap instead of std::map for ValueMap.  This
speeds up the inliner 16%.



---
Diffs of the changes:  (+13 -13)

 LoopUnroll.cpp   |   16 ++++++++--------
 LoopUnswitch.cpp |   10 +++++-----
 2 files changed, 13 insertions(+), 13 deletions(-)


Index: llvm/lib/Transforms/Scalar/LoopUnroll.cpp
diff -u llvm/lib/Transforms/Scalar/LoopUnroll.cpp:1.34 llvm/lib/Transforms/Scalar/LoopUnroll.cpp:1.35
--- llvm/lib/Transforms/Scalar/LoopUnroll.cpp:1.34	Tue Jan 30 17:46:24 2007
+++ llvm/lib/Transforms/Scalar/LoopUnroll.cpp	Fri Feb  2 18:08:31 2007
@@ -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 @@
 // 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 @@
 
   // 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 @@
     
     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 @@
 
       // 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 @@
  
   // 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))


Index: llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
diff -u llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.59 llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.60
--- llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.59	Tue Jan 30 17:46:24 2007
+++ llvm/lib/Transforms/Scalar/LoopUnswitch.cpp	Fri Feb  2 18:08:31 2007
@@ -445,10 +445,10 @@
 // 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);
   }
@@ -456,7 +456,7 @@
 
 /// CloneLoop - Recursively clone the specified loop and all of its children,
 /// mapping the blocks with the specified map.
-static Loop *CloneLoop(Loop *L, Loop *PL, std::map<const Value*, Value*> &VM,
+static Loop *CloneLoop(Loop *L, Loop *PL, DenseMap<const Value*, Value*> &VM,
                        LoopInfo *LI) {
   Loop *New = new Loop();
 
@@ -632,7 +632,7 @@
   // the instructions and blocks.
   std::vector<BasicBlock*> NewBlocks;
   NewBlocks.reserve(LoopBlocks.size());
-  std::map<const Value*, Value*> ValueMap;
+  DenseMap<const Value*, Value*> ValueMap;
   for (unsigned i = 0, e = LoopBlocks.size(); i != e; ++i) {
     BasicBlock *New = CloneBasicBlock(LoopBlocks[i], ValueMap, ".us", F);
     NewBlocks.push_back(New);
@@ -669,7 +669,7 @@
     for (BasicBlock::iterator I = ExitSucc->begin();
          (PN = dyn_cast<PHINode>(I)); ++I) {
       Value *V = PN->getIncomingValueForBlock(ExitBlocks[i]);
-      std::map<const Value *, Value*>::iterator It = ValueMap.find(V);
+      DenseMap<const Value *, Value*>::iterator It = ValueMap.find(V);
       if (It != ValueMap.end()) V = It->second;
       PN->addIncoming(V, NewExit);
     }






More information about the llvm-commits mailing list