-
Notifications
You must be signed in to change notification settings - Fork 12.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SLPVectorizer] minor tweaks around lambdas for compatibilty with older compilers #122348
base: main
Are you sure you want to change the base?
[SLPVectorizer] minor tweaks around lambdas for compatibilty with older compilers #122348
Conversation
…e older compilers
@llvm/pr-subscribers-vectorizers @llvm/pr-subscribers-llvm-transforms Author: Alex MacLean (AlexMaclean) ChangesOlder 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. Full diff: https://github.com/llvm/llvm-project/pull/122348.diff 1 Files Affected:
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 36fed8937aec28..8e361f505419df 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -6923,8 +6923,8 @@ void BoUpSLP::tryToVectorizeGatheredLoads(
Loads.size());
Align Alignment = computeCommonAlignment<LoadInst>(Values);
auto *Ty = getWidenedType(Loads.front()->getType(), Loads.size());
- return TTI->isLegalMaskedGather(Ty, Alignment) &&
- !TTI->forceScalarizeMaskedGather(Ty, Alignment);
+ return this->TTI->isLegalMaskedGather(Ty, Alignment) &&
+ !this->TTI->forceScalarizeMaskedGather(Ty, Alignment);
};
auto GetVectorizedRanges = [this](ArrayRef<LoadInst *> Loads,
@@ -7085,9 +7085,10 @@ void BoUpSLP::tryToVectorizeGatheredLoads(
}
SmallVector<std::pair<LoadInst *, int>> LocalLoadsDists(LoadsDists);
SmallVector<LoadInst *> OriginalLoads(LocalLoadsDists.size());
- transform(
- LoadsDists, OriginalLoads.begin(),
- [](const std::pair<LoadInst *, int> &L) { return L.first; });
+ transform(LoadsDists, OriginalLoads.begin(),
+ [](const std::pair<LoadInst *, int> &L) -> LoadInst * {
+ return L.first;
+ });
stable_sort(LocalLoadsDists, LoadSorter);
SmallVector<LoadInst *> 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<std::pair<LoadInst *, int>> LoadsDists) {
+ [](unsigned S,
+ ArrayRef<std::pair<LoadInst *, int>> LoadsDists) -> unsigned {
return S + LoadsDists.size();
}) != NonVectorized.size() &&
IsMaskedGatherSupported(NonVectorized)) {
@@ -17003,8 +17005,8 @@ void BoUpSLP::optimizeGatherSequence() {
// Check if the last undefs actually change the final number of used vector
// registers.
return SM1.size() - LastUndefsCnt > 1 &&
- TTI->getNumberOfParts(SI1->getType()) ==
- TTI->getNumberOfParts(
+ this->TTI->getNumberOfParts(SI1->getType()) ==
+ this->TTI->getNumberOfParts(
getWidenedType(SI1->getType()->getElementType(),
SM1.size() - LastUndefsCnt));
};
@@ -17784,8 +17786,8 @@ bool BoUpSLP::collectValuesToDemote(
const unsigned VF = E.Scalars.size();
Type *OrigScalarTy = E.Scalars.front()->getType();
if (UniqueBases.size() <= 2 ||
- TTI->getNumberOfParts(getWidenedType(OrigScalarTy, VF)) ==
- TTI->getNumberOfParts(getWidenedType(
+ this->TTI->getNumberOfParts(getWidenedType(OrigScalarTy, VF)) ==
+ this->TTI->getNumberOfParts(getWidenedType(
IntegerType::get(OrigScalarTy->getContext(), BitWidth), VF)))
ToDemote.push_back(E.Idx);
}
|
@@ -6923,8 +6923,8 @@ void BoUpSLP::tryToVectorizeGatheredLoads( | |||
Loads.size()); | |||
Align Alignment = computeCommonAlignment<LoadInst>(Values); | |||
auto *Ty = getWidenedType(Loads.front()->getType(), Loads.size()); | |||
return TTI->isLegalMaskedGather(Ty, Alignment) && | |||
!TTI->forceScalarizeMaskedGather(Ty, Alignment); | |||
return this->TTI->isLegalMaskedGather(Ty, Alignment) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest something like this instead:
auto IsMaskedGatherSupported = [&, TTI=TTI](ArrayRef<LoadInst *> Loads) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, fixed
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.