[llvm] [LV] Strip unnecessary make_{pair, optional} (NFC) (PR #141924)
via llvm-commits
llvm-commits at lists.llvm.org
Thu May 29 03:30:54 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Ramkumar Ramachandra (artagnon)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/141924.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Vectorize/LoopVectorize.cpp (+27-35)
``````````diff
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;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/141924
More information about the llvm-commits
mailing list