diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp index 62e3e5ad0a52be..5cf5e9463b451c 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 8750e83623e6a1..a3d86e26fe2396 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 08877797c53abc..888166f1f53d75 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 d9416072793a82..927c34180db934 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 e8de6f425db6e8..96aef90c1c1a35 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 2a04137e5d2f52..b3bae47e96de24 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 d09f1ee22a752c..ef25963a997ad9 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 c8e5fdb458ffb9..8c06e29341adef 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.