Skip to content

Commit 0e814c2

Browse files
committed
[LV] Strip unnecessary make_{pair,optional} (NFC)
1 parent 89f692a commit 0e814c2

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
@@ -1080,7 +1080,7 @@ class LoopVectorizationCostModel {
10801080
void setWideningDecision(Instruction *I, ElementCount VF, InstWidening W,
10811081
InstructionCost Cost) {
10821082
assert(VF.isVector() && "Expected VF >=2");
1083-
WideningDecisions[std::make_pair(I, VF)] = std::make_pair(W, Cost);
1083+
WideningDecisions[{I, VF}] = {W, Cost};
10841084
}
10851085

10861086
/// Save vectorization decision \p W and \p Cost taken by the cost model for
@@ -1102,11 +1102,9 @@ class LoopVectorizationCostModel {
11021102
for (unsigned Idx = 0; Idx < Grp->getFactor(); ++Idx) {
11031103
if (auto *I = Grp->getMember(Idx)) {
11041104
if (Grp->getInsertPos() == I)
1105-
WideningDecisions[std::make_pair(I, VF)] =
1106-
std::make_pair(W, InsertPosCost);
1105+
WideningDecisions[{I, VF}] = {W, InsertPosCost};
11071106
else
1108-
WideningDecisions[std::make_pair(I, VF)] =
1109-
std::make_pair(W, OtherMemberCost);
1107+
WideningDecisions[{I, VF}] = {W, OtherMemberCost};
11101108
}
11111109
}
11121110
}
@@ -1120,7 +1118,7 @@ class LoopVectorizationCostModel {
11201118
TheLoop->isInnermost() &&
11211119
"cost-model should not be used for outer loops (in VPlan-native path)");
11221120

1123-
std::pair<Instruction *, ElementCount> InstOnVF = std::make_pair(I, VF);
1121+
std::pair<Instruction *, ElementCount> InstOnVF(I, VF);
11241122
auto Itr = WideningDecisions.find(InstOnVF);
11251123
if (Itr == WideningDecisions.end())
11261124
return CM_Unknown;
@@ -1131,7 +1129,7 @@ class LoopVectorizationCostModel {
11311129
/// width \p VF.
11321130
InstructionCost getWideningCost(Instruction *I, ElementCount VF) {
11331131
assert(VF.isVector() && "Expected VF >=2");
1134-
std::pair<Instruction *, ElementCount> InstOnVF = std::make_pair(I, VF);
1132+
std::pair<Instruction *, ElementCount> InstOnVF(I, VF);
11351133
assert(WideningDecisions.contains(InstOnVF) &&
11361134
"The cost is not calculated");
11371135
return WideningDecisions[InstOnVF].second;
@@ -1150,8 +1148,7 @@ class LoopVectorizationCostModel {
11501148
std::optional<unsigned> MaskPos,
11511149
InstructionCost Cost) {
11521150
assert(!VF.isScalar() && "Expected vector VF");
1153-
CallWideningDecisions[std::make_pair(CI, VF)] = {Kind, Variant, IID,
1154-
MaskPos, Cost};
1151+
CallWideningDecisions[{CI, VF}] = {Kind, Variant, IID, MaskPos, Cost};
11551152
}
11561153

11571154
CallWideningDecision getCallWideningDecision(CallInst *CI,
@@ -1348,21 +1345,20 @@ class LoopVectorizationCostModel {
13481345
void setTailFoldingStyles(bool IsScalableVF, unsigned UserIC) {
13491346
assert(!ChosenTailFoldingStyle && "Tail folding must not be selected yet.");
13501347
if (!Legal->canFoldTailByMasking()) {
1351-
ChosenTailFoldingStyle =
1352-
std::make_pair(TailFoldingStyle::None, TailFoldingStyle::None);
1348+
ChosenTailFoldingStyle = {TailFoldingStyle::None, TailFoldingStyle::None};
13531349
return;
13541350
}
13551351

13561352
if (!ForceTailFoldingStyle.getNumOccurrences()) {
1357-
ChosenTailFoldingStyle = std::make_pair(
1353+
ChosenTailFoldingStyle = {
13581354
TTI.getPreferredTailFoldingStyle(/*IVUpdateMayOverflow=*/true),
1359-
TTI.getPreferredTailFoldingStyle(/*IVUpdateMayOverflow=*/false));
1355+
TTI.getPreferredTailFoldingStyle(/*IVUpdateMayOverflow=*/false)};
13601356
return;
13611357
}
13621358

13631359
// Set styles when forced.
1364-
ChosenTailFoldingStyle = std::make_pair(ForceTailFoldingStyle.getValue(),
1365-
ForceTailFoldingStyle.getValue());
1360+
ChosenTailFoldingStyle = {ForceTailFoldingStyle.getValue(),
1361+
ForceTailFoldingStyle.getValue()};
13661362
if (ForceTailFoldingStyle != TailFoldingStyle::DataWithEVL)
13671363
return;
13681364
// Override forced styles if needed.
@@ -1375,9 +1371,8 @@ class LoopVectorizationCostModel {
13751371
// If for some reason EVL mode is unsupported, fallback to
13761372
// DataWithoutLaneMask to try to vectorize the loop with folded tail
13771373
// in a generic way.
1378-
ChosenTailFoldingStyle =
1379-
std::make_pair(TailFoldingStyle::DataWithoutLaneMask,
1380-
TailFoldingStyle::DataWithoutLaneMask);
1374+
ChosenTailFoldingStyle = {TailFoldingStyle::DataWithoutLaneMask,
1375+
TailFoldingStyle::DataWithoutLaneMask};
13811376
LLVM_DEBUG(
13821377
dbgs()
13831378
<< "LV: Preference for VP intrinsics indicated. Will "
@@ -8135,7 +8130,7 @@ void VPRecipeBuilder::collectScaledReductions(VFRange &Range) {
81358130
PartialReductionChain Chain = Pair.first;
81368131
if (ExtendIsOnlyUsedByPartialReductions(Chain.ExtendA) &&
81378132
ExtendIsOnlyUsedByPartialReductions(Chain.ExtendB))
8138-
ScaledReductionMap.insert(std::make_pair(Chain.Reduction, Pair.second));
8133+
ScaledReductionMap.emplace_or_assign(Chain.Reduction, Pair.second);
81398134
}
81408135
}
81418136

@@ -8207,12 +8202,11 @@ bool VPRecipeBuilder::getScaledReductions(
82078202
[&](ElementCount VF) {
82088203
InstructionCost Cost = TTI->getPartialReductionCost(
82098204
Update->getOpcode(), A->getType(), B->getType(), PHI->getType(),
8210-
VF, OpAExtend, OpBExtend,
8211-
std::make_optional(BinOp->getOpcode()));
8205+
VF, OpAExtend, OpBExtend, BinOp->getOpcode());
82128206
return Cost.isValid();
82138207
},
82148208
Range)) {
8215-
Chains.push_back(std::make_pair(Chain, TargetScaleFactor));
8209+
Chains.emplace_back(Chain, TargetScaleFactor);
82168210
return true;
82178211
}
82188212

@@ -10105,9 +10099,9 @@ bool LoopVectorizePass::processLoop(Loop *L) {
1010510099
bool VectorizeLoop = true, InterleaveLoop = true;
1010610100
if (VF.Width.isScalar()) {
1010710101
LLVM_DEBUG(dbgs() << "LV: Vectorization is possible but not beneficial.\n");
10108-
VecDiagMsg = std::make_pair(
10102+
VecDiagMsg = {
1010910103
"VectorizationNotBeneficial",
10110-
"the cost-model indicates that vectorization is not beneficial");
10104+
"the cost-model indicates that vectorization is not beneficial"};
1011110105
VectorizeLoop = false;
1011210106
}
1011310107

@@ -10116,16 +10110,15 @@ bool LoopVectorizePass::processLoop(Loop *L) {
1011610110
// requested.
1011710111
LLVM_DEBUG(dbgs() << "LV: Ignoring UserIC, because vectorization and "
1011810112
"interleaving should be avoided up front\n");
10119-
IntDiagMsg = std::make_pair(
10120-
"InterleavingAvoided",
10121-
"Ignoring UserIC, because interleaving was avoided up front");
10113+
IntDiagMsg = {"InterleavingAvoided",
10114+
"Ignoring UserIC, because interleaving was avoided up front"};
1012210115
InterleaveLoop = false;
1012310116
} else if (IC == 1 && UserIC <= 1) {
1012410117
// Tell the user interleaving is not beneficial.
1012510118
LLVM_DEBUG(dbgs() << "LV: Interleaving is not beneficial.\n");
10126-
IntDiagMsg = std::make_pair(
10119+
IntDiagMsg = {
1012710120
"InterleavingNotBeneficial",
10128-
"the cost-model indicates that interleaving is not beneficial");
10121+
"the cost-model indicates that interleaving is not beneficial"};
1012910122
InterleaveLoop = false;
1013010123
if (UserIC == 1) {
1013110124
IntDiagMsg.first = "InterleavingNotBeneficialAndDisabled";
@@ -10136,10 +10129,9 @@ bool LoopVectorizePass::processLoop(Loop *L) {
1013610129
// Tell the user interleaving is beneficial, but it explicitly disabled.
1013710130
LLVM_DEBUG(
1013810131
dbgs() << "LV: Interleaving is beneficial but is explicitly disabled.");
10139-
IntDiagMsg = std::make_pair(
10140-
"InterleavingBeneficialButDisabled",
10141-
"the cost-model indicates that interleaving is beneficial "
10142-
"but is explicitly disabled or interleave count is set to 1");
10132+
IntDiagMsg = {"InterleavingBeneficialButDisabled",
10133+
"the cost-model indicates that interleaving is beneficial "
10134+
"but is explicitly disabled or interleave count is set to 1"};
1014310135
InterleaveLoop = false;
1014410136
}
1014510137

@@ -10149,10 +10141,10 @@ bool LoopVectorizePass::processLoop(Loop *L) {
1014910141
if (!VectorizeLoop && InterleaveLoop && LVL.hasHistograms()) {
1015010142
LLVM_DEBUG(dbgs() << "LV: Not interleaving without vectorization due "
1015110143
<< "to histogram operations.\n");
10152-
IntDiagMsg = std::make_pair(
10144+
IntDiagMsg = {
1015310145
"HistogramPreventsScalarInterleaving",
1015410146
"Unable to interleave without vectorization due to constraints on "
10155-
"the order of histogram operations");
10147+
"the order of histogram operations"};
1015610148
InterleaveLoop = false;
1015710149
}
1015810150

0 commit comments

Comments
 (0)