[llvm] fbade95 - [LV] Strip unnecessary make_{pair, optional} (NFC) (#141924)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 16 00:55:49 PDT 2025
Author: Ramkumar Ramachandra
Date: 2025-06-16T08:55:46+01:00
New Revision: fbade95ebf2bc959fada5206e47f792a2090d72e
URL: https://github.com/llvm/llvm-project/commit/fbade95ebf2bc959fada5206e47f792a2090d72e
DIFF: https://github.com/llvm/llvm-project/commit/fbade95ebf2bc959fada5206e47f792a2090d72e.diff
LOG: [LV] Strip unnecessary make_{pair,optional} (NFC) (#141924)
Added:
Modified:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index eb04e2d5ca7b4..34f49a7721a30 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1080,7 +1080,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
@@ -1102,11 +1102,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};
}
}
}
@@ -1120,7 +1118,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;
@@ -1131,7 +1129,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;
@@ -1150,8 +1148,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,
@@ -1348,21 +1345,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.
@@ -1375,9 +1371,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 "
@@ -8138,7 +8133,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.try_emplace(Chain.Reduction, Pair.second);
}
}
@@ -8210,12 +8205,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;
}
@@ -10108,9 +10102,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;
}
@@ -10119,16 +10113,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";
@@ -10139,10 +10132,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;
}
@@ -10152,10 +10144,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;
}
More information about the llvm-commits
mailing list