-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[LV] Strip unnecessary make_{pair,optional} (NFC) #141924
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-vectorizers @llvm/pr-subscribers-llvm-transforms Author: Ramkumar Ramachandra (artagnon) ChangesFull diff: https://github.com/llvm/llvm-project/pull/141924.diff 1 Files Affected:
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 05b5764ffcafc..d9b71f58f15ea 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1105,7 +1105,7 @@ class LoopVectorizationCostModel {
void setWideningDecision(Instruction *I, ElementCount VF, InstWidening W,
InstructionCost Cost) {
assert(VF.isVector() && "Expected VF >=2");
- WideningDecisions[std::make_pair(I, VF)] = std::make_pair(W, Cost);
+ WideningDecisions[{I, VF}] = {W, Cost};
}
/// Save vectorization decision \p W and \p Cost taken by the cost model for
@@ -1127,11 +1127,9 @@ class LoopVectorizationCostModel {
for (unsigned Idx = 0; Idx < Grp->getFactor(); ++Idx) {
if (auto *I = Grp->getMember(Idx)) {
if (Grp->getInsertPos() == I)
- WideningDecisions[std::make_pair(I, VF)] =
- std::make_pair(W, InsertPosCost);
+ WideningDecisions[{I, VF}] = {W, InsertPosCost};
else
- WideningDecisions[std::make_pair(I, VF)] =
- std::make_pair(W, OtherMemberCost);
+ WideningDecisions[{I, VF}] = {W, OtherMemberCost};
}
}
}
@@ -1145,7 +1143,7 @@ class LoopVectorizationCostModel {
TheLoop->isInnermost() &&
"cost-model should not be used for outer loops (in VPlan-native path)");
- std::pair<Instruction *, ElementCount> InstOnVF = std::make_pair(I, VF);
+ std::pair<Instruction *, ElementCount> InstOnVF(I, VF);
auto Itr = WideningDecisions.find(InstOnVF);
if (Itr == WideningDecisions.end())
return CM_Unknown;
@@ -1156,7 +1154,7 @@ class LoopVectorizationCostModel {
/// width \p VF.
InstructionCost getWideningCost(Instruction *I, ElementCount VF) {
assert(VF.isVector() && "Expected VF >=2");
- std::pair<Instruction *, ElementCount> InstOnVF = std::make_pair(I, VF);
+ std::pair<Instruction *, ElementCount> InstOnVF(I, VF);
assert(WideningDecisions.contains(InstOnVF) &&
"The cost is not calculated");
return WideningDecisions[InstOnVF].second;
@@ -1175,8 +1173,7 @@ class LoopVectorizationCostModel {
std::optional<unsigned> MaskPos,
InstructionCost Cost) {
assert(!VF.isScalar() && "Expected vector VF");
- CallWideningDecisions[std::make_pair(CI, VF)] = {Kind, Variant, IID,
- MaskPos, Cost};
+ CallWideningDecisions[{CI, VF}] = {Kind, Variant, IID, MaskPos, Cost};
}
CallWideningDecision getCallWideningDecision(CallInst *CI,
@@ -1373,21 +1370,20 @@ class LoopVectorizationCostModel {
void setTailFoldingStyles(bool IsScalableVF, unsigned UserIC) {
assert(!ChosenTailFoldingStyle && "Tail folding must not be selected yet.");
if (!Legal->canFoldTailByMasking()) {
- ChosenTailFoldingStyle =
- std::make_pair(TailFoldingStyle::None, TailFoldingStyle::None);
+ ChosenTailFoldingStyle = {TailFoldingStyle::None, TailFoldingStyle::None};
return;
}
if (!ForceTailFoldingStyle.getNumOccurrences()) {
- ChosenTailFoldingStyle = std::make_pair(
+ ChosenTailFoldingStyle = {
TTI.getPreferredTailFoldingStyle(/*IVUpdateMayOverflow=*/true),
- TTI.getPreferredTailFoldingStyle(/*IVUpdateMayOverflow=*/false));
+ TTI.getPreferredTailFoldingStyle(/*IVUpdateMayOverflow=*/false)};
return;
}
// Set styles when forced.
- ChosenTailFoldingStyle = std::make_pair(ForceTailFoldingStyle.getValue(),
- ForceTailFoldingStyle.getValue());
+ ChosenTailFoldingStyle = {ForceTailFoldingStyle.getValue(),
+ ForceTailFoldingStyle.getValue()};
if (ForceTailFoldingStyle != TailFoldingStyle::DataWithEVL)
return;
// Override forced styles if needed.
@@ -1400,9 +1396,8 @@ class LoopVectorizationCostModel {
// If for some reason EVL mode is unsupported, fallback to
// DataWithoutLaneMask to try to vectorize the loop with folded tail
// in a generic way.
- ChosenTailFoldingStyle =
- std::make_pair(TailFoldingStyle::DataWithoutLaneMask,
- TailFoldingStyle::DataWithoutLaneMask);
+ ChosenTailFoldingStyle = {TailFoldingStyle::DataWithoutLaneMask,
+ TailFoldingStyle::DataWithoutLaneMask};
LLVM_DEBUG(
dbgs()
<< "LV: Preference for VP intrinsics indicated. Will "
@@ -8491,7 +8486,7 @@ void VPRecipeBuilder::collectScaledReductions(VFRange &Range) {
PartialReductionChain Chain = Pair.first;
if (ExtendIsOnlyUsedByPartialReductions(Chain.ExtendA) &&
ExtendIsOnlyUsedByPartialReductions(Chain.ExtendB))
- ScaledReductionMap.insert(std::make_pair(Chain.Reduction, Pair.second));
+ ScaledReductionMap.emplace_or_assign(Chain.Reduction, Pair.second);
}
}
@@ -8563,12 +8558,11 @@ bool VPRecipeBuilder::getScaledReductions(
[&](ElementCount VF) {
InstructionCost Cost = TTI->getPartialReductionCost(
Update->getOpcode(), A->getType(), B->getType(), PHI->getType(),
- VF, OpAExtend, OpBExtend,
- std::make_optional(BinOp->getOpcode()));
+ VF, OpAExtend, OpBExtend, BinOp->getOpcode());
return Cost.isValid();
},
Range)) {
- Chains.push_back(std::make_pair(Chain, TargetScaleFactor));
+ Chains.emplace_back(Chain, TargetScaleFactor);
return true;
}
@@ -10418,9 +10412,9 @@ bool LoopVectorizePass::processLoop(Loop *L) {
bool VectorizeLoop = true, InterleaveLoop = true;
if (VF.Width.isScalar()) {
LLVM_DEBUG(dbgs() << "LV: Vectorization is possible but not beneficial.\n");
- VecDiagMsg = std::make_pair(
+ VecDiagMsg = {
"VectorizationNotBeneficial",
- "the cost-model indicates that vectorization is not beneficial");
+ "the cost-model indicates that vectorization is not beneficial"};
VectorizeLoop = false;
}
@@ -10429,16 +10423,15 @@ bool LoopVectorizePass::processLoop(Loop *L) {
// requested.
LLVM_DEBUG(dbgs() << "LV: Ignoring UserIC, because vectorization and "
"interleaving should be avoided up front\n");
- IntDiagMsg = std::make_pair(
- "InterleavingAvoided",
- "Ignoring UserIC, because interleaving was avoided up front");
+ IntDiagMsg = {"InterleavingAvoided",
+ "Ignoring UserIC, because interleaving was avoided up front"};
InterleaveLoop = false;
} else if (IC == 1 && UserIC <= 1) {
// Tell the user interleaving is not beneficial.
LLVM_DEBUG(dbgs() << "LV: Interleaving is not beneficial.\n");
- IntDiagMsg = std::make_pair(
+ IntDiagMsg = {
"InterleavingNotBeneficial",
- "the cost-model indicates that interleaving is not beneficial");
+ "the cost-model indicates that interleaving is not beneficial"};
InterleaveLoop = false;
if (UserIC == 1) {
IntDiagMsg.first = "InterleavingNotBeneficialAndDisabled";
@@ -10449,10 +10442,9 @@ bool LoopVectorizePass::processLoop(Loop *L) {
// Tell the user interleaving is beneficial, but it explicitly disabled.
LLVM_DEBUG(
dbgs() << "LV: Interleaving is beneficial but is explicitly disabled.");
- IntDiagMsg = std::make_pair(
- "InterleavingBeneficialButDisabled",
- "the cost-model indicates that interleaving is beneficial "
- "but is explicitly disabled or interleave count is set to 1");
+ IntDiagMsg = {"InterleavingBeneficialButDisabled",
+ "the cost-model indicates that interleaving is beneficial "
+ "but is explicitly disabled or interleave count is set to 1"};
InterleaveLoop = false;
}
@@ -10462,10 +10454,10 @@ bool LoopVectorizePass::processLoop(Loop *L) {
if (!VectorizeLoop && InterleaveLoop && LVL.hasHistograms()) {
LLVM_DEBUG(dbgs() << "LV: Not interleaving without vectorization due "
<< "to histogram operations.\n");
- IntDiagMsg = std::make_pair(
+ IntDiagMsg = {
"HistogramPreventsScalarInterleaving",
"Unable to interleave without vectorization due to constraints on "
- "the order of histogram operations");
+ "the order of histogram operations"};
InterleaveLoop = false;
}
|
Gentle ping. |
lukel97
reviewed
Jun 6, 2025
a9e8436
to
8e6b044
Compare
fhahn
approved these changes
Jun 16, 2025
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.
LGTM, thanks
akuhlens
pushed a commit
to akuhlens/llvm-project
that referenced
this pull request
Jun 24, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.