Skip to content

Commit a9e8436

Browse files
committed
[LV] Strip unnecessary make_{pair,optional} (NFC)
1 parent 29db305 commit a9e8436

File tree

1 file changed

+27
-35
lines changed

1 file changed

+27
-35
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@ class LoopVectorizationCostModel {
11051105
void setWideningDecision(Instruction *I, ElementCount VF, InstWidening W,
11061106
InstructionCost Cost) {
11071107
assert(VF.isVector() && "Expected VF >=2");
1108-
WideningDecisions[std::make_pair(I, VF)] = std::make_pair(W, Cost);
1108+
WideningDecisions[{I, VF}] = {W, Cost};
11091109
}
11101110

11111111
/// Save vectorization decision \p W and \p Cost taken by the cost model for
@@ -1127,11 +1127,9 @@ class LoopVectorizationCostModel {
11271127
for (unsigned Idx = 0; Idx < Grp->getFactor(); ++Idx) {
11281128
if (auto *I = Grp->getMember(Idx)) {
11291129
if (Grp->getInsertPos() == I)
1130-
WideningDecisions[std::make_pair(I, VF)] =
1131-
std::make_pair(W, InsertPosCost);
1130+
WideningDecisions[{I, VF}] = {W, InsertPosCost};
11321131
else
1133-
WideningDecisions[std::make_pair(I, VF)] =
1134-
std::make_pair(W, OtherMemberCost);
1132+
WideningDecisions[{I, VF}] = {W, OtherMemberCost};
11351133
}
11361134
}
11371135
}
@@ -1145,7 +1143,7 @@ class LoopVectorizationCostModel {
11451143
TheLoop->isInnermost() &&
11461144
"cost-model should not be used for outer loops (in VPlan-native path)");
11471145

1148-
std::pair<Instruction *, ElementCount> InstOnVF = std::make_pair(I, VF);
1146+
std::pair<Instruction *, ElementCount> InstOnVF(I, VF);
11491147
auto Itr = WideningDecisions.find(InstOnVF);
11501148
if (Itr == WideningDecisions.end())
11511149
return CM_Unknown;
@@ -1156,7 +1154,7 @@ class LoopVectorizationCostModel {
11561154
/// width \p VF.
11571155
InstructionCost getWideningCost(Instruction *I, ElementCount VF) {
11581156
assert(VF.isVector() && "Expected VF >=2");
1159-
std::pair<Instruction *, ElementCount> InstOnVF = std::make_pair(I, VF);
1157+
std::pair<Instruction *, ElementCount> InstOnVF(I, VF);
11601158
assert(WideningDecisions.contains(InstOnVF) &&
11611159
"The cost is not calculated");
11621160
return WideningDecisions[InstOnVF].second;
@@ -1175,8 +1173,7 @@ class LoopVectorizationCostModel {
11751173
std::optional<unsigned> MaskPos,
11761174
InstructionCost Cost) {
11771175
assert(!VF.isScalar() && "Expected vector VF");
1178-
CallWideningDecisions[std::make_pair(CI, VF)] = {Kind, Variant, IID,
1179-
MaskPos, Cost};
1176+
CallWideningDecisions[{CI, VF}] = {Kind, Variant, IID, MaskPos, Cost};
11801177
}
11811178

11821179
CallWideningDecision getCallWideningDecision(CallInst *CI,
@@ -1373,21 +1370,20 @@ class LoopVectorizationCostModel {
13731370
void setTailFoldingStyles(bool IsScalableVF, unsigned UserIC) {
13741371
assert(!ChosenTailFoldingStyle && "Tail folding must not be selected yet.");
13751372
if (!Legal->canFoldTailByMasking()) {
1376-
ChosenTailFoldingStyle =
1377-
std::make_pair(TailFoldingStyle::None, TailFoldingStyle::None);
1373+
ChosenTailFoldingStyle = {TailFoldingStyle::None, TailFoldingStyle::None};
13781374
return;
13791375
}
13801376

13811377
if (!ForceTailFoldingStyle.getNumOccurrences()) {
1382-
ChosenTailFoldingStyle = std::make_pair(
1378+
ChosenTailFoldingStyle = {
13831379
TTI.getPreferredTailFoldingStyle(/*IVUpdateMayOverflow=*/true),
1384-
TTI.getPreferredTailFoldingStyle(/*IVUpdateMayOverflow=*/false));
1380+
TTI.getPreferredTailFoldingStyle(/*IVUpdateMayOverflow=*/false)};
13851381
return;
13861382
}
13871383

13881384
// Set styles when forced.
1389-
ChosenTailFoldingStyle = std::make_pair(ForceTailFoldingStyle.getValue(),
1390-
ForceTailFoldingStyle.getValue());
1385+
ChosenTailFoldingStyle = {ForceTailFoldingStyle.getValue(),
1386+
ForceTailFoldingStyle.getValue()};
13911387
if (ForceTailFoldingStyle != TailFoldingStyle::DataWithEVL)
13921388
return;
13931389
// Override forced styles if needed.
@@ -1400,9 +1396,8 @@ class LoopVectorizationCostModel {
14001396
// If for some reason EVL mode is unsupported, fallback to
14011397
// DataWithoutLaneMask to try to vectorize the loop with folded tail
14021398
// in a generic way.
1403-
ChosenTailFoldingStyle =
1404-
std::make_pair(TailFoldingStyle::DataWithoutLaneMask,
1405-
TailFoldingStyle::DataWithoutLaneMask);
1399+
ChosenTailFoldingStyle = {TailFoldingStyle::DataWithoutLaneMask,
1400+
TailFoldingStyle::DataWithoutLaneMask};
14061401
LLVM_DEBUG(
14071402
dbgs()
14081403
<< "LV: Preference for VP intrinsics indicated. Will "
@@ -8491,7 +8486,7 @@ void VPRecipeBuilder::collectScaledReductions(VFRange &Range) {
84918486
PartialReductionChain Chain = Pair.first;
84928487
if (ExtendIsOnlyUsedByPartialReductions(Chain.ExtendA) &&
84938488
ExtendIsOnlyUsedByPartialReductions(Chain.ExtendB))
8494-
ScaledReductionMap.insert(std::make_pair(Chain.Reduction, Pair.second));
8489+
ScaledReductionMap.emplace_or_assign(Chain.Reduction, Pair.second);
84958490
}
84968491
}
84978492

@@ -8563,12 +8558,11 @@ bool VPRecipeBuilder::getScaledReductions(
85638558
[&](ElementCount VF) {
85648559
InstructionCost Cost = TTI->getPartialReductionCost(
85658560
Update->getOpcode(), A->getType(), B->getType(), PHI->getType(),
8566-
VF, OpAExtend, OpBExtend,
8567-
std::make_optional(BinOp->getOpcode()));
8561+
VF, OpAExtend, OpBExtend, BinOp->getOpcode());
85688562
return Cost.isValid();
85698563
},
85708564
Range)) {
8571-
Chains.push_back(std::make_pair(Chain, TargetScaleFactor));
8565+
Chains.emplace_back(Chain, TargetScaleFactor);
85728566
return true;
85738567
}
85748568

@@ -10418,9 +10412,9 @@ bool LoopVectorizePass::processLoop(Loop *L) {
1041810412
bool VectorizeLoop = true, InterleaveLoop = true;
1041910413
if (VF.Width.isScalar()) {
1042010414
LLVM_DEBUG(dbgs() << "LV: Vectorization is possible but not beneficial.\n");
10421-
VecDiagMsg = std::make_pair(
10415+
VecDiagMsg = {
1042210416
"VectorizationNotBeneficial",
10423-
"the cost-model indicates that vectorization is not beneficial");
10417+
"the cost-model indicates that vectorization is not beneficial"};
1042410418
VectorizeLoop = false;
1042510419
}
1042610420

@@ -10429,16 +10423,15 @@ bool LoopVectorizePass::processLoop(Loop *L) {
1042910423
// requested.
1043010424
LLVM_DEBUG(dbgs() << "LV: Ignoring UserIC, because vectorization and "
1043110425
"interleaving should be avoided up front\n");
10432-
IntDiagMsg = std::make_pair(
10433-
"InterleavingAvoided",
10434-
"Ignoring UserIC, because interleaving was avoided up front");
10426+
IntDiagMsg = {"InterleavingAvoided",
10427+
"Ignoring UserIC, because interleaving was avoided up front"};
1043510428
InterleaveLoop = false;
1043610429
} else if (IC == 1 && UserIC <= 1) {
1043710430
// Tell the user interleaving is not beneficial.
1043810431
LLVM_DEBUG(dbgs() << "LV: Interleaving is not beneficial.\n");
10439-
IntDiagMsg = std::make_pair(
10432+
IntDiagMsg = {
1044010433
"InterleavingNotBeneficial",
10441-
"the cost-model indicates that interleaving is not beneficial");
10434+
"the cost-model indicates that interleaving is not beneficial"};
1044210435
InterleaveLoop = false;
1044310436
if (UserIC == 1) {
1044410437
IntDiagMsg.first = "InterleavingNotBeneficialAndDisabled";
@@ -10449,10 +10442,9 @@ bool LoopVectorizePass::processLoop(Loop *L) {
1044910442
// Tell the user interleaving is beneficial, but it explicitly disabled.
1045010443
LLVM_DEBUG(
1045110444
dbgs() << "LV: Interleaving is beneficial but is explicitly disabled.");
10452-
IntDiagMsg = std::make_pair(
10453-
"InterleavingBeneficialButDisabled",
10454-
"the cost-model indicates that interleaving is beneficial "
10455-
"but is explicitly disabled or interleave count is set to 1");
10445+
IntDiagMsg = {"InterleavingBeneficialButDisabled",
10446+
"the cost-model indicates that interleaving is beneficial "
10447+
"but is explicitly disabled or interleave count is set to 1"};
1045610448
InterleaveLoop = false;
1045710449
}
1045810450

@@ -10462,10 +10454,10 @@ bool LoopVectorizePass::processLoop(Loop *L) {
1046210454
if (!VectorizeLoop && InterleaveLoop && LVL.hasHistograms()) {
1046310455
LLVM_DEBUG(dbgs() << "LV: Not interleaving without vectorization due "
1046410456
<< "to histogram operations.\n");
10465-
IntDiagMsg = std::make_pair(
10457+
IntDiagMsg = {
1046610458
"HistogramPreventsScalarInterleaving",
1046710459
"Unable to interleave without vectorization due to constraints on "
10468-
"the order of histogram operations");
10460+
"the order of histogram operations"};
1046910461
InterleaveLoop = false;
1047010462
}
1047110463

0 commit comments

Comments
 (0)