[llvm-commits] [llvm] r59409 - /llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp

Chris Lattner sabre at nondot.org
Sat Nov 15 23:17:51 PST 2008


Author: lattner
Date: Sun Nov 16 01:17:51 2008
New Revision: 59409

URL: http://llvm.org/viewvc/llvm-project?rev=59409&view=rev
Log:
eliminate some std::set's.

Modified:
    llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=59409&r1=59408&r2=59409&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Sun Nov 16 01:17:51 2008
@@ -53,6 +53,7 @@
 #include "llvm/Transforms/Utils/Local.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/Statistic.h"
 using namespace llvm;
 
@@ -87,12 +88,12 @@
   private:
 
     void EliminatePointerRecurrence(PHINode *PN, BasicBlock *Preheader,
-                                    std::set<Instruction*> &DeadInsts);
+                                    SmallPtrSet<Instruction*, 16> &DeadInsts);
     Instruction *LinearFunctionTestReplace(Loop *L, SCEV *IterationCount,
                                            SCEVExpander &RW);
     void RewriteLoopExitValues(Loop *L, SCEV *IterationCount);
 
-    void DeleteTriviallyDeadInstructions(std::set<Instruction*> &Insts);
+    void DeleteTriviallyDeadInstructions(SmallPtrSet<Instruction*, 16> &Insts);
 
     void OptimizeCanonicalIVType(Loop *L);
     void HandleFloatingPointIV(Loop *L);
@@ -111,10 +112,10 @@
 /// specified set are trivially dead, delete them and see if this makes any of
 /// their operands subsequently dead.
 void IndVarSimplify::
-DeleteTriviallyDeadInstructions(std::set<Instruction*> &Insts) {
+DeleteTriviallyDeadInstructions(SmallPtrSet<Instruction*, 16> &Insts) {
   while (!Insts.empty()) {
     Instruction *I = *Insts.begin();
-    Insts.erase(Insts.begin());
+    Insts.erase(I);
     if (isInstructionTriviallyDead(I)) {
       for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
         if (Instruction *U = dyn_cast<Instruction>(I->getOperand(i)))
@@ -133,7 +134,7 @@
 /// analysis by the SCEV routines.
 void IndVarSimplify::EliminatePointerRecurrence(PHINode *PN,
                                                 BasicBlock *Preheader,
-                                            std::set<Instruction*> &DeadInsts) {
+                                     SmallPtrSet<Instruction*, 16> &DeadInsts) {
   assert(PN->getNumIncomingValues() == 2 && "Noncanonicalized loop!");
   unsigned PreheaderIdx = PN->getBasicBlockIndex(Preheader);
   unsigned BackedgeIdx = PreheaderIdx^1;
@@ -326,7 +327,7 @@
 
   bool HasConstantItCount = isa<SCEVConstant>(IterationCount);
 
-  std::set<Instruction*> InstructionsToDelete;
+  SmallPtrSet<Instruction*, 16> InstructionsToDelete;
   std::map<Instruction*, Value*> ExitValues;
 
   // Find all values that are computed inside the loop, but used outside of it.
@@ -427,7 +428,7 @@
   BasicBlock *Preheader = L->getLoopPreheader();
   SE = &LPM.getAnalysis<ScalarEvolution>();
 
-  std::set<Instruction*> DeadInsts;
+  SmallPtrSet<Instruction*, 16> DeadInsts;
   for (BasicBlock::iterator I = Header->begin(); isa<PHINode>(I); ++I) {
     PHINode *PN = cast<PHINode>(I);
     if (isa<PointerType>(PN->getType()))
@@ -448,7 +449,7 @@
 
   Changed = false;
   BasicBlock *Header    = L->getHeader();
-  std::set<Instruction*> DeadInsts;
+  SmallPtrSet<Instruction*, 16> DeadInsts;
   
   // Verify the input to the pass in already in LCSSA form.
   assert(L->isLCSSAForm());
@@ -495,7 +496,7 @@
                                                      IterationCount->getType());
       if (Instruction *I = LinearFunctionTestReplace(L, IterationCount,
                                                      Rewriter)) {
-        std::set<Instruction*> InstructionsToDelete;
+        SmallPtrSet<Instruction*, 16> InstructionsToDelete;
         InstructionsToDelete.insert(I);
         DeleteTriviallyDeadInstructions(InstructionsToDelete);
       }





More information about the llvm-commits mailing list