]> granicus.if.org Git - llvm/commitdiff
Avoid duplicated map lookups. No functionality change intended.
authorBenjamin Kramer <benny.kra@googlemail.com>
Fri, 17 Jun 2016 18:59:41 +0000 (18:59 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Fri, 17 Jun 2016 18:59:41 +0000 (18:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273030 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/MemoryDependenceAnalysis.cpp
lib/CodeGen/LiveDebugValues.cpp
lib/Support/CommandLine.cpp
lib/Target/TargetRecip.cpp
lib/Transforms/Scalar/PlaceSafepoints.cpp
lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
lib/Transforms/Scalar/StructurizeCFG.cpp

index e23cd819f07bfb97e8458f5fc29429883a667404..9f96cbaf8a5294567ebe564bfeaa6661118f71fa 100644 (file)
@@ -365,9 +365,8 @@ MemoryDependenceResults::getInvariantGroupPointerDependency(LoadInst *LI,
       continue;
 
     if (auto *BCI = dyn_cast<BitCastInst>(Ptr)) {
-      if (!Seen.count(BCI->getOperand(0))) {
+      if (Seen.insert(BCI->getOperand(0)).second) {
         LoadOperandsQueue.push_back(BCI->getOperand(0));
-        Seen.insert(BCI->getOperand(0));
       }
     }
 
@@ -377,9 +376,8 @@ MemoryDependenceResults::getInvariantGroupPointerDependency(LoadInst *LI,
         continue;
 
       if (auto *BCI = dyn_cast<BitCastInst>(U)) {
-        if (!Seen.count(BCI)) {
+        if (Seen.insert(BCI).second) {
           LoadOperandsQueue.push_back(BCI);
-          Seen.insert(BCI);
         }
         continue;
       }
index 1297273ee5b591f3e2b83f99e07890ef0b7bd623..4ff88d528108cf33952bd4ba7a4d9b32ce13a710 100644 (file)
@@ -487,8 +487,7 @@ bool LiveDebugValues::ExtendRanges(MachineFunction &MF) {
         if (OLChanged) {
           OLChanged = false;
           for (auto s : MBB->successors())
-            if (!OnPending.count(s)) {
-              OnPending.insert(s);
+            if (OnPending.insert(s).second) {
               Pending.push(BBToOrder[s]);
             }
         }
index 9be0daada506fb9f7bdf334924834acf3c00df8b..5ada72f9f94e27a15243b342bae55086c806fa18 100644 (file)
@@ -1604,7 +1604,8 @@ protected:
              E = SortedCategories.end();
          Category != E; ++Category) {
       // Hide empty categories for -help, but show for -help-hidden.
-      bool IsEmptyCategory = CategorizedOptions[*Category].size() == 0;
+      const auto &CategoryOptions = CategorizedOptions[*Category];
+      bool IsEmptyCategory = CategoryOptions.empty();
       if (!ShowHidden && IsEmptyCategory)
         continue;
 
@@ -1625,11 +1626,8 @@ protected:
         continue;
       }
       // Loop over the options in the category and print.
-      for (std::vector<Option *>::const_iterator
-               Opt = CategorizedOptions[*Category].begin(),
-               E = CategorizedOptions[*Category].end();
-           Opt != E; ++Opt)
-        (*Opt)->printOptionInfo(MaxArgLen);
+      for (const Option *Opt : CategoryOptions)
+        Opt->printOptionInfo(MaxArgLen);
     }
   }
 };
index 97662f72afe849a78e923219510642998ddefb86..183fa5062eabacc39e5bc7c54a1f13aeabd1b7e0 100644 (file)
@@ -156,9 +156,10 @@ void TargetRecip::parseIndividualParams(const std::vector<std::string> &Args) {
     
     // If the precision was not specified, the double entry is also initialized.
     if (Val.back() != 'f' && Val.back() != 'd') {
-      RecipMap[Val.str() + 'd'].Enabled = !IsDisabled;
+      RecipParams &Params = RecipMap[Val.str() + 'd'];
+      Params.Enabled = !IsDisabled;
       if (!RefStepString.empty())
-        RecipMap[Val.str() + 'd'].RefinementSteps = RefSteps;
+        Params.RefinementSteps = RefSteps;
     }
   }
 }
index 1cadab625b0579a866c5cfefe4b996b105c54d11..029178388b78d454ce37274e91f0ea56a22f61fe 100644 (file)
@@ -277,9 +277,8 @@ static void scanOneBB(Instruction *Start, Instruction *End,
     if (BBI->isTerminator()) {
       BasicBlock *BB = BBI->getParent();
       for (BasicBlock *Succ : successors(BB)) {
-        if (Seen.count(Succ) == 0) {
+        if (Seen.insert(Succ).second) {
           Worklist.push_back(Succ);
-          Seen.insert(Succ);
         }
       }
     }
index 21c0c9d97ab775ef05a157e61203e0fafd6f3706..fe15d17212ca0f5b8bf20f066f9876332f139bc6 100644 (file)
@@ -2616,9 +2616,8 @@ static void recomputeLiveInValues(GCPtrLivenessData &RevisedLivenessData,
   // We may have base pointers which are now live that weren't before.  We need
   // to update the PointerToBase structure to reflect this.
   for (auto V : Updated)
-    if (!Info.PointerToBase.count(V)) {
+    if (Info.PointerToBase.insert(std::make_pair(V, V)).second) {
       assert(Bases.count(V) && "can't find base for unexpected live value");
-      Info.PointerToBase[V] = V;
       continue;
     }
 
index 675614dca954d80b61f1562220a8b9b42ff55323..802b3e476aadd8ca62c96501df5b03d739a9a340 100644 (file)
@@ -311,11 +311,7 @@ void StructurizeCFG::orderNodes() {
   for (RegionNode *RN : TempOrder) {
     BasicBlock *BB = RN->getEntry();
     Loop *Loop = LI->getLoopFor(BB);
-    if (!LoopBlocks.count(Loop)) {
-      LoopBlocks[Loop] = 1;
-      continue;
-    }
-    LoopBlocks[Loop]++;
+    ++LoopBlocks[Loop];
   }
 
   unsigned CurrentLoopDepth = 0;
@@ -333,11 +329,11 @@ void StructurizeCFG::orderNodes() {
       // the outer loop.
 
       RNVector::iterator LoopI = I;
-      while(LoopBlocks[CurrentLoop]) {
+      while (unsigned &BlockCount = LoopBlocks[CurrentLoop]) {
         LoopI++;
         BasicBlock *LoopBB = (*LoopI)->getEntry();
         if (LI->getLoopFor(LoopBB) == CurrentLoop) {
-          LoopBlocks[CurrentLoop]--;
+          --BlockCount;
           Order.push_back(*LoopI);
         }
       }