[llvm] r273030 - Avoid duplicated map lookups. No functionality change intended.
Benjamin Kramer via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 17 11:59:42 PDT 2016
Author: d0k
Date: Fri Jun 17 13:59:41 2016
New Revision: 273030
URL: http://llvm.org/viewvc/llvm-project?rev=273030&view=rev
Log:
Avoid duplicated map lookups. No functionality change intended.
Modified:
llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp
llvm/trunk/lib/CodeGen/LiveDebugValues.cpp
llvm/trunk/lib/Support/CommandLine.cpp
llvm/trunk/lib/Target/TargetRecip.cpp
llvm/trunk/lib/Transforms/Scalar/PlaceSafepoints.cpp
llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
llvm/trunk/lib/Transforms/Scalar/StructurizeCFG.cpp
Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=273030&r1=273029&r2=273030&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Fri Jun 17 13:59:41 2016
@@ -365,9 +365,8 @@ MemoryDependenceResults::getInvariantGro
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::getInvariantGro
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;
}
Modified: llvm/trunk/lib/CodeGen/LiveDebugValues.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveDebugValues.cpp?rev=273030&r1=273029&r2=273030&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LiveDebugValues.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveDebugValues.cpp Fri Jun 17 13:59:41 2016
@@ -487,8 +487,7 @@ bool LiveDebugValues::ExtendRanges(Machi
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]);
}
}
Modified: llvm/trunk/lib/Support/CommandLine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?rev=273030&r1=273029&r2=273030&view=diff
==============================================================================
--- llvm/trunk/lib/Support/CommandLine.cpp (original)
+++ llvm/trunk/lib/Support/CommandLine.cpp Fri Jun 17 13:59:41 2016
@@ -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);
}
}
};
Modified: llvm/trunk/lib/Target/TargetRecip.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetRecip.cpp?rev=273030&r1=273029&r2=273030&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetRecip.cpp (original)
+++ llvm/trunk/lib/Target/TargetRecip.cpp Fri Jun 17 13:59:41 2016
@@ -156,9 +156,10 @@ void TargetRecip::parseIndividualParams(
// 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;
}
}
}
Modified: llvm/trunk/lib/Transforms/Scalar/PlaceSafepoints.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/PlaceSafepoints.cpp?rev=273030&r1=273029&r2=273030&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/PlaceSafepoints.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/PlaceSafepoints.cpp Fri Jun 17 13:59:41 2016
@@ -277,9 +277,8 @@ static void scanOneBB(Instruction *Start
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);
}
}
}
Modified: llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp?rev=273030&r1=273029&r2=273030&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp Fri Jun 17 13:59:41 2016
@@ -2616,9 +2616,8 @@ static void recomputeLiveInValues(GCPtrL
// 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;
}
Modified: llvm/trunk/lib/Transforms/Scalar/StructurizeCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/StructurizeCFG.cpp?rev=273030&r1=273029&r2=273030&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/StructurizeCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/StructurizeCFG.cpp Fri Jun 17 13:59:41 2016
@@ -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);
}
}
More information about the llvm-commits
mailing list