* Convert InstWorkList to vector instead of set, because on big programs it
authorChris Lattner <sabre@nondot.org>
Tue, 7 May 2002 04:29:32 +0000 (04:29 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 7 May 2002 04:29:32 +0000 (04:29 +0000)
  is empirically faster by a noticable margin, even though duplicates can
  happen.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2511 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/SCCP.cpp

index 015c67a0d228ede9b08230b51d897f5c43109e06..54e5fc0f28e00a57c5cf945f06c1bbd1b7316538 100644 (file)
@@ -92,7 +92,7 @@ class SCCP : public FunctionPass, public InstVisitor<SCCP> {
   std::set<BasicBlock*>     BBExecutable;// The basic blocks that are executable
   std::map<Value*, InstVal> ValueState;  // The state each value is in...
 
-  std::set<Instruction*>    InstWorkList;// The instruction work list
+  std::vector<Instruction*> InstWorkList;// The instruction work list
   std::vector<BasicBlock*>  BBWorkList;  // The BasicBlock work list
 public:
 
@@ -124,7 +124,7 @@ private:
     DEBUG_SCCP(cerr << "markConstant: " << V << " = " << I);
 
     if (ValueState[I].markConstant(V)) {
-      InstWorkList.insert(I);
+      InstWorkList.push_back(I);
       return true;
     }
     return false;
@@ -138,7 +138,7 @@ private:
     if (ValueState[V].markOverdefined()) {
       if (Instruction *I = dyn_cast<Instruction>(V)) {
        DEBUG_SCCP(cerr << "markOverdefined: " << V);
-       InstWorkList.insert(I);  // Only instructions go on the work list
+       InstWorkList.push_back(I);  // Only instructions go on the work list
       }
       return true;
     }
@@ -251,8 +251,8 @@ bool SCCP::runOnFunction(Function *F) {
   while (!BBWorkList.empty() || !InstWorkList.empty()) {
     // Process the instruction work list...
     while (!InstWorkList.empty()) {
-      Instruction *I = *InstWorkList.begin();
-      InstWorkList.erase(InstWorkList.begin());
+      Instruction *I = InstWorkList.back();
+      InstWorkList.pop_back();
 
       DEBUG_SCCP(cerr << "\nPopped off I-WL: " << I);