diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 36fed8937aec2..e3cea4da17549 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -6918,7 +6918,7 @@ void BoUpSLP::tryToVectorizeGatheredLoads( return L1.second > L2.second; }; - auto IsMaskedGatherSupported = [&](ArrayRef Loads) { + auto IsMaskedGatherSupported = [&, TTI = TTI](ArrayRef Loads) { ArrayRef Values(reinterpret_cast(Loads.begin()), Loads.size()); Align Alignment = computeCommonAlignment(Values); @@ -7085,9 +7085,10 @@ void BoUpSLP::tryToVectorizeGatheredLoads( } SmallVector> LocalLoadsDists(LoadsDists); SmallVector OriginalLoads(LocalLoadsDists.size()); - transform( - LoadsDists, OriginalLoads.begin(), - [](const std::pair &L) { return L.first; }); + transform(LoadsDists, OriginalLoads.begin(), + [](const std::pair &L) -> LoadInst * { + return L.first; + }); stable_sort(LocalLoadsDists, LoadSorter); SmallVector Loads; unsigned MaxConsecutiveDistance = 0; @@ -7314,7 +7315,8 @@ void BoUpSLP::tryToVectorizeGatheredLoads( if (!Ref.empty() && !NonVectorized.empty() && std::accumulate( Ref.begin(), Ref.end(), 0u, - [](unsigned S, ArrayRef> LoadsDists) { + [](unsigned S, + ArrayRef> LoadsDists) -> unsigned { return S + LoadsDists.size(); }) != NonVectorized.size() && IsMaskedGatherSupported(NonVectorized)) { @@ -16970,8 +16972,9 @@ void BoUpSLP::optimizeGatherSequence() { // and its mask indeces are the same as in the first one or undefs. E.g. // shuffle %0, poison, <0, 0, 0, undef> is less defined than shuffle %0, // poison, <0, 0, 0, 0>. - auto &&IsIdenticalOrLessDefined = [this](Instruction *I1, Instruction *I2, - SmallVectorImpl &NewMask) { + auto &&IsIdenticalOrLessDefined = [TTI = TTI](Instruction *I1, + Instruction *I2, + SmallVectorImpl &NewMask) { if (I1->getType() != I2->getType()) return false; auto *SI1 = dyn_cast(I1); @@ -17765,7 +17768,7 @@ bool BoUpSLP::collectValuesToDemote( BitWidth = std::max(BitWidth, BitWidth1); return BitWidth > 0 && OrigBitWidth >= (BitWidth * 2); }; - auto FinalAnalysis = [&]() { + auto FinalAnalysis = [&, TTI = TTI]() { if (!IsProfitableToDemote) return false; bool Res = all_of(