From 33bf1cad759487f678f2b694866e2608c4b99aea Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Thu, 7 Jan 2021 20:29:34 -0800 Subject: [PATCH] [llvm] Use *Set::contains (NFC) --- llvm/lib/Transforms/IPO/FunctionAttrs.cpp | 4 ++-- llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp | 2 +- .../lib/Transforms/InstCombine/InstCombineCompares.cpp | 2 +- .../Instrumentation/ControlHeightReduction.cpp | 18 +++++++++--------- llvm/lib/Transforms/Scalar/JumpThreading.cpp | 2 +- llvm/lib/Transforms/Scalar/LoopRerollPass.cpp | 2 +- llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp | 2 +- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp index 62e3e5a..5cf5e94 100644 --- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp +++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp @@ -1244,7 +1244,7 @@ static bool InstrBreaksNonThrowing(Instruction &I, const SCCNodeSet &SCCNodes) { // I is a may-throw call to a function inside our SCC. This doesn't // invalidate our current working assumption that the SCC is no-throw; we // just have to scan that other function. - if (SCCNodes.count(Callee) > 0) + if (SCCNodes.contains(Callee)) return false; } } @@ -1264,7 +1264,7 @@ static bool InstrBreaksNoFree(Instruction &I, const SCCNodeSet &SCCNodes) { if (Callee->doesNotFreeMemory()) return false; - if (SCCNodes.count(Callee) > 0) + if (SCCNodes.contains(Callee)) return false; return true; diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp index 8750e83..a3d86e26 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -2523,7 +2523,7 @@ Instruction *InstCombinerImpl::optimizeBitCastFromPhi(CastInst &CI, if (BCI == &CI) RetVal = I; } else if (auto *PHI = dyn_cast(V)) { - assert(OldPhiNodes.count(PHI) > 0); + assert(OldPhiNodes.contains(PHI)); (void) PHI; } else { llvm_unreachable("all uses should be handled"); diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index 0887779..888166f 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -502,7 +502,7 @@ static bool canRewriteGEPAsOffset(Value *Start, Value *Base, Value *V = WorkList.back(); - if (Explored.count(V) != 0) { + if (Explored.contains(V)) { WorkList.pop_back(); continue; } diff --git a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp index d941607..927c341 100644 --- a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp +++ b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp @@ -731,7 +731,7 @@ static Instruction* getBranchInsertPoint(RegInfo &RI) { } } for (Instruction &I : *EntryBB) { - if (EntryBlockSelectSet.count(&I) > 0) { + if (EntryBlockSelectSet.contains(&I)) { assert(&I == HoistPoint && "HoistPoint must be the first one in Selects"); break; @@ -1304,17 +1304,17 @@ void CHR::classifyBiasedScopes(CHRScope *Scope, CHRScope *OutermostScope) { for (RegInfo &RI : Scope->RegInfos) { if (RI.HasBranch) { Region *R = RI.R; - if (TrueBiasedRegionsGlobal.count(R) > 0) + if (TrueBiasedRegionsGlobal.contains(R)) OutermostScope->TrueBiasedRegions.insert(R); - else if (FalseBiasedRegionsGlobal.count(R) > 0) + else if (FalseBiasedRegionsGlobal.contains(R)) OutermostScope->FalseBiasedRegions.insert(R); else llvm_unreachable("Must be biased"); } for (SelectInst *SI : RI.Selects) { - if (TrueBiasedSelectsGlobal.count(SI) > 0) + if (TrueBiasedSelectsGlobal.contains(SI)) OutermostScope->TrueBiasedSelects.insert(SI); - else if (FalseBiasedSelectsGlobal.count(SI) > 0) + else if (FalseBiasedSelectsGlobal.contains(SI)) OutermostScope->FalseBiasedSelects.insert(SI); else llvm_unreachable("Must be biased"); @@ -1397,8 +1397,8 @@ void CHR::setCHRRegions(CHRScope *Scope, CHRScope *OutermostScope) { DenseSet HoistStops; bool IsHoisted = false; if (RI.HasBranch) { - assert((OutermostScope->TrueBiasedRegions.count(R) > 0 || - OutermostScope->FalseBiasedRegions.count(R) > 0) && + assert((OutermostScope->TrueBiasedRegions.contains(R) || + OutermostScope->FalseBiasedRegions.contains(R)) && "Must be truthy or falsy"); auto *BI = cast(R->getEntry()->getTerminator()); // Note checkHoistValue fills in HoistStops. @@ -1410,8 +1410,8 @@ void CHR::setCHRRegions(CHRScope *Scope, CHRScope *OutermostScope) { IsHoisted = true; } for (SelectInst *SI : RI.Selects) { - assert((OutermostScope->TrueBiasedSelects.count(SI) > 0 || - OutermostScope->FalseBiasedSelects.count(SI) > 0) && + assert((OutermostScope->TrueBiasedSelects.contains(SI) || + OutermostScope->FalseBiasedSelects.contains(SI)) && "Must be true or false biased"); // Note checkHoistValue fills in HoistStops. DenseMap Visited; diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp index e8de6f4..96aef90 100644 --- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp +++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp @@ -1757,7 +1757,7 @@ bool JumpThreadingPass::processThreadableEdges(Value *Cond, BasicBlock *BB, // and we still want to process. erase_if(PredToDestList, [&](const std::pair &PredToDest) { - return LoopHeaders.count(PredToDest.second) != 0; + return LoopHeaders.contains(PredToDest.second); }); if (PredToDestList.empty()) diff --git a/llvm/lib/Transforms/Scalar/LoopRerollPass.cpp b/llvm/lib/Transforms/Scalar/LoopRerollPass.cpp index 2a04137..b3bae47 100644 --- a/llvm/lib/Transforms/Scalar/LoopRerollPass.cpp +++ b/llvm/lib/Transforms/Scalar/LoopRerollPass.cpp @@ -1096,7 +1096,7 @@ LoopReroll::DAGRootTracker::nextInstr(int Val, UsesTy &In, UsesTy::iterator *StartI) { UsesTy::iterator I = StartI ? *StartI : In.begin(); while (I != In.end() && (I->second.test(Val) == 0 || - Exclude.count(I->first) != 0)) + Exclude.contains(I->first))) ++I; return I; } diff --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp index d09f1ee..ef25963 100644 --- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp +++ b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp @@ -1371,7 +1371,7 @@ PreservedAnalyses LoopFullUnrollPass::run(Loop &L, LoopAnalysisManager &AM, } // Otherwise erase the loop from the list if it was in the old loops. - return OldLoops.count(SibLoop) != 0; + return OldLoops.contains(SibLoop); }); Updater.addSiblingLoops(SibLoops); diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index c8e5fdb..8c06e293 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -7586,7 +7586,7 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) { continue; // We may go through BB multiple times so skip the one we have checked. if (!VisitedInstrs.insert(&*it).second) { - if (it->use_empty() && KeyNodes.count(&*it) > 0 && + if (it->use_empty() && KeyNodes.contains(&*it) && vectorizeSimpleInstructions(PostProcessInstructions, BB, R)) { // We would like to start over since some instructions are deleted // and the iterator may become invalid value. -- 2.7.4