From 682f8913a5e235bcddf971e889ed70fac25f3768 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Thu, 24 Dec 2020 09:08:36 -0800 Subject: [PATCH] [CodeGen, Transforms] Use llvm::any_of (NFC) --- lib/CodeGen/GlobalISel/LegalityPredicates.cpp | 9 ++-- lib/CodeGen/MultiHazardRecognizer.cpp | 7 ++-- .../ControlHeightReduction.cpp | 7 ++-- lib/Transforms/Utils/CodeMoverUtils.cpp | 41 +++++++++---------- lib/Transforms/Vectorize/SLPVectorizer.cpp | 6 +-- 5 files changed, 33 insertions(+), 37 deletions(-) diff --git a/lib/CodeGen/GlobalISel/LegalityPredicates.cpp b/lib/CodeGen/GlobalISel/LegalityPredicates.cpp index 9ca6d9a9a55..1993f603329 100644 --- a/lib/CodeGen/GlobalISel/LegalityPredicates.cpp +++ b/lib/CodeGen/GlobalISel/LegalityPredicates.cpp @@ -57,11 +57,10 @@ LegalityPredicate LegalityPredicates::typePairAndMemDescInSet( TypePairAndMemDesc Match = {Query.Types[TypeIdx0], Query.Types[TypeIdx1], Query.MMODescrs[MMOIdx].SizeInBits, Query.MMODescrs[MMOIdx].AlignInBits}; - return std::find_if( - TypesAndMemDesc.begin(), TypesAndMemDesc.end(), - [=](const TypePairAndMemDesc &Entry) ->bool { - return Match.isCompatible(Entry); - }) != TypesAndMemDesc.end(); + return llvm::any_of(TypesAndMemDesc, + [=](const TypePairAndMemDesc &Entry) -> bool { + return Match.isCompatible(Entry); + }); }; } diff --git a/lib/CodeGen/MultiHazardRecognizer.cpp b/lib/CodeGen/MultiHazardRecognizer.cpp index d66110ba3ac..e4cd92ac486 100644 --- a/lib/CodeGen/MultiHazardRecognizer.cpp +++ b/lib/CodeGen/MultiHazardRecognizer.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "llvm/CodeGen/MultiHazardRecognizer.h" +#include "llvm/ADT/STLExtras.h" #include #include #include @@ -25,8 +26,8 @@ void MultiHazardRecognizer::AddHazardRecognizer( } bool MultiHazardRecognizer::atIssueLimit() const { - return std::any_of(Recognizers.begin(), Recognizers.end(), - std::mem_fn(&ScheduleHazardRecognizer::atIssueLimit)); + return llvm::any_of(Recognizers, + std::mem_fn(&ScheduleHazardRecognizer::atIssueLimit)); } ScheduleHazardRecognizer::HazardType @@ -72,7 +73,7 @@ bool MultiHazardRecognizer::ShouldPreferAnother(SUnit *SU) { auto SPA = [=](std::unique_ptr &R) { return R->ShouldPreferAnother(SU); }; - return std::any_of(Recognizers.begin(), Recognizers.end(), SPA); + return llvm::any_of(Recognizers, SPA); } void MultiHazardRecognizer::AdvanceCycle() { diff --git a/lib/Transforms/Instrumentation/ControlHeightReduction.cpp b/lib/Transforms/Instrumentation/ControlHeightReduction.cpp index ab7e0ae9d4a..fd734df053c 100644 --- a/lib/Transforms/Instrumentation/ControlHeightReduction.cpp +++ b/lib/Transforms/Instrumentation/ControlHeightReduction.cpp @@ -260,10 +260,9 @@ class CHRScope { if (TailRegionSet.count(Parent)) return false; - assert(llvm::find_if(RegInfos, - [&Parent](const RegInfo &RI) { - return Parent == RI.R; - }) != RegInfos.end() && + assert(llvm::any_of( + RegInfos, + [&Parent](const RegInfo &RI) { return Parent == RI.R; }) && "Must be in head"); return true; }); diff --git a/lib/Transforms/Utils/CodeMoverUtils.cpp b/lib/Transforms/Utils/CodeMoverUtils.cpp index 08047dc0f96..ce982c7403a 100644 --- a/lib/Transforms/Utils/CodeMoverUtils.cpp +++ b/lib/Transforms/Utils/CodeMoverUtils.cpp @@ -355,35 +355,32 @@ bool llvm::isSafeToMoveBefore(Instruction &I, Instruction &InsertPoint, // Check if there exists instructions which may throw, may synchonize, or may // never return, from I to InsertPoint. if (!isSafeToSpeculativelyExecute(&I)) - if (std::any_of(InstsToCheck.begin(), InstsToCheck.end(), - [](Instruction *I) { - if (I->mayThrow()) - return true; + if (llvm::any_of(InstsToCheck, [](Instruction *I) { + if (I->mayThrow()) + return true; - const CallBase *CB = dyn_cast(I); - if (!CB) - return false; - if (!CB->hasFnAttr(Attribute::WillReturn)) - return true; - if (!CB->hasFnAttr(Attribute::NoSync)) - return true; + const CallBase *CB = dyn_cast(I); + if (!CB) + return false; + if (!CB->hasFnAttr(Attribute::WillReturn)) + return true; + if (!CB->hasFnAttr(Attribute::NoSync)) + return true; - return false; - })) { + return false; + })) { return reportInvalidCandidate(I, MayThrowException); } // Check if I has any output/flow/anti dependences with instructions from \p // StartInst to \p EndInst. - if (std::any_of(InstsToCheck.begin(), InstsToCheck.end(), - [&DI, &I](Instruction *CurInst) { - auto DepResult = DI->depends(&I, CurInst, true); - if (DepResult && - (DepResult->isOutput() || DepResult->isFlow() || - DepResult->isAnti())) - return true; - return false; - })) + if (llvm::any_of(InstsToCheck, [&DI, &I](Instruction *CurInst) { + auto DepResult = DI->depends(&I, CurInst, true); + if (DepResult && (DepResult->isOutput() || DepResult->isFlow() || + DepResult->isAnti())) + return true; + return false; + })) return reportInvalidCandidate(I, HasDependences); return true; diff --git a/lib/Transforms/Vectorize/SLPVectorizer.cpp b/lib/Transforms/Vectorize/SLPVectorizer.cpp index baa8ce2638a..f3a0baa0026 100644 --- a/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -2472,9 +2472,9 @@ template <> struct DOTGraphTraits : public DefaultDOTGraphTraits { } for (auto V : Entry->Scalars) { OS << *V; - if (std::any_of( - R->ExternalUses.begin(), R->ExternalUses.end(), - [&](const BoUpSLP::ExternalUser &EU) { return EU.Scalar == V; })) + if (llvm::any_of(R->ExternalUses, [&](const BoUpSLP::ExternalUser &EU) { + return EU.Scalar == V; + })) OS << " "; OS << "\n"; }