diff --git a/llvm/lib/Target/AMDGPU/AMDGPUIGroupLP.cpp b/llvm/lib/Target/AMDGPU/AMDGPUIGroupLP.cpp --- a/llvm/lib/Target/AMDGPU/AMDGPUIGroupLP.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUIGroupLP.cpp @@ -593,11 +593,10 @@ for (; I != E; ++I) { std::vector> AddedEdges; int CandSGID = *I; - SchedGroup *Match; - for (auto &SG : SyncPipeline) { - if (SG.getSGID() == CandSGID) - Match = &SG; - } + SchedGroup *Match = llvm::find_if(SyncPipeline, [CandSGID](SchedGroup &SG) { + return SG.getSGID() == CandSGID; + }); + assert(Match); if (UseCostHeur) { if (Match->isFull()) { @@ -739,11 +738,10 @@ for (; I != E; ++I) { std::vector> AddedEdges; int CandSGID = *I; - SchedGroup *Match; - for (auto &SG : SyncPipeline) { - if (SG.getSGID() == CandSGID) - Match = &SG; - } + SchedGroup *Match = llvm::find_if(SyncPipeline, [CandSGID](SchedGroup &SG) { + return SG.getSGID() == CandSGID; + }); + assert(Match); LLVM_DEBUG(dbgs() << "Trying SGID # " << CandSGID << " with Mask " << (int)Match->getMask() << "\n");