Skip to content

Commit 986f2ac

Browse files
authored
[SLPVectorizer] minor tweaks around lambdas for compatibility with older compilers (#122348)
Older version of msvc do not have great lambda support and are not able to handle uses of class data or lambdas with implicit return types in some cases. These minor changes improve the sources compatibility with older msvc and don't hurt readability either.
1 parent 59ced72 commit 986f2ac

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6908,7 +6908,7 @@ void BoUpSLP::tryToVectorizeGatheredLoads(
69086908
return L1.second > L2.second;
69096909
};
69106910

6911-
auto IsMaskedGatherSupported = [&](ArrayRef<LoadInst *> Loads) {
6911+
auto IsMaskedGatherSupported = [&, TTI = TTI](ArrayRef<LoadInst *> Loads) {
69126912
ArrayRef<Value *> Values(reinterpret_cast<Value *const *>(Loads.begin()),
69136913
Loads.size());
69146914
Align Alignment = computeCommonAlignment<LoadInst>(Values);
@@ -7075,9 +7075,10 @@ void BoUpSLP::tryToVectorizeGatheredLoads(
70757075
}
70767076
SmallVector<std::pair<LoadInst *, int>> LocalLoadsDists(LoadsDists);
70777077
SmallVector<LoadInst *> OriginalLoads(LocalLoadsDists.size());
7078-
transform(
7079-
LoadsDists, OriginalLoads.begin(),
7080-
[](const std::pair<LoadInst *, int> &L) { return L.first; });
7078+
transform(LoadsDists, OriginalLoads.begin(),
7079+
[](const std::pair<LoadInst *, int> &L) -> LoadInst * {
7080+
return L.first;
7081+
});
70817082
stable_sort(LocalLoadsDists, LoadSorter);
70827083
SmallVector<LoadInst *> Loads;
70837084
unsigned MaxConsecutiveDistance = 0;
@@ -7304,7 +7305,8 @@ void BoUpSLP::tryToVectorizeGatheredLoads(
73047305
if (!Ref.empty() && !NonVectorized.empty() &&
73057306
std::accumulate(
73067307
Ref.begin(), Ref.end(), 0u,
7307-
[](unsigned S, ArrayRef<std::pair<LoadInst *, int>> LoadsDists) {
7308+
[](unsigned S,
7309+
ArrayRef<std::pair<LoadInst *, int>> LoadsDists) -> unsigned {
73087310
return S + LoadsDists.size();
73097311
}) != NonVectorized.size() &&
73107312
IsMaskedGatherSupported(NonVectorized)) {
@@ -16979,8 +16981,9 @@ void BoUpSLP::optimizeGatherSequence() {
1697916981
// and its mask indeces are the same as in the first one or undefs. E.g.
1698016982
// shuffle %0, poison, <0, 0, 0, undef> is less defined than shuffle %0,
1698116983
// poison, <0, 0, 0, 0>.
16982-
auto &&IsIdenticalOrLessDefined = [this](Instruction *I1, Instruction *I2,
16983-
SmallVectorImpl<int> &NewMask) {
16984+
auto &&IsIdenticalOrLessDefined = [TTI = TTI](Instruction *I1,
16985+
Instruction *I2,
16986+
SmallVectorImpl<int> &NewMask) {
1698416987
if (I1->getType() != I2->getType())
1698516988
return false;
1698616989
auto *SI1 = dyn_cast<ShuffleVectorInst>(I1);
@@ -17774,7 +17777,7 @@ bool BoUpSLP::collectValuesToDemote(
1777417777
BitWidth = std::max(BitWidth, BitWidth1);
1777517778
return BitWidth > 0 && OrigBitWidth >= (BitWidth * 2);
1777617779
};
17777-
auto FinalAnalysis = [&]() {
17780+
auto FinalAnalysis = [&, TTI = TTI]() {
1777817781
if (!IsProfitableToDemote)
1777917782
return false;
1778017783
bool Res = all_of(

0 commit comments

Comments
 (0)