Skip to content

Commit fbade95

Browse files
authored
[LV] Strip unnecessary make_{pair,optional} (NFC) (#141924)
1 parent e614050 commit fbade95

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 "
@@ -8138,7 +8133,7 @@ void VPRecipeBuilder::collectScaledReductions(VFRange &Range) {
81388133
PartialReductionChain Chain = Pair.first;
81398134
if (ExtendIsOnlyUsedByPartialReductions(Chain.ExtendA) &&
81408135
ExtendIsOnlyUsedByPartialReductions(Chain.ExtendB))
8141-
ScaledReductionMap.insert(std::make_pair(Chain.Reduction, Pair.second));
8136+
ScaledReductionMap.try_emplace(Chain.Reduction, Pair.second);
81428137
}
81438138
}
81448139

@@ -8210,12 +8205,11 @@ bool VPRecipeBuilder::getScaledReductions(
82108205
[&](ElementCount VF) {
82118206
InstructionCost Cost = TTI->getPartialReductionCost(
82128207
Update->getOpcode(), A->getType(), B->getType(), PHI->getType(),
8213-
VF, OpAExtend, OpBExtend,
8214-
std::make_optional(BinOp->getOpcode()));
8208+
VF, OpAExtend, OpBExtend, BinOp->getOpcode());
82158209
return Cost.isValid();
82168210
},
82178211
Range)) {
8218-
Chains.push_back(std::make_pair(Chain, TargetScaleFactor));
8212+
Chains.emplace_back(Chain, TargetScaleFactor);
82198213
return true;
82208214
}
82218215

@@ -10108,9 +10102,9 @@ bool LoopVectorizePass::processLoop(Loop *L) {
1010810102
bool VectorizeLoop = true, InterleaveLoop = true;
1010910103
if (VF.Width.isScalar()) {
1011010104
LLVM_DEBUG(dbgs() << "LV: Vectorization is possible but not beneficial.\n");
10111-
VecDiagMsg = std::make_pair(
10105+
VecDiagMsg = {
1011210106
"VectorizationNotBeneficial",
10113-
"the cost-model indicates that vectorization is not beneficial");
10107+
"the cost-model indicates that vectorization is not beneficial"};
1011410108
VectorizeLoop = false;
1011510109
}
1011610110

@@ -10119,16 +10113,15 @@ bool LoopVectorizePass::processLoop(Loop *L) {
1011910113
// requested.
1012010114
LLVM_DEBUG(dbgs() << "LV: Ignoring UserIC, because vectorization and "
1012110115
"interleaving should be avoided up front\n");
10122-
IntDiagMsg = std::make_pair(
10123-
"InterleavingAvoided",
10124-
"Ignoring UserIC, because interleaving was avoided up front");
10116+
IntDiagMsg = {"InterleavingAvoided",
10117+
"Ignoring UserIC, because interleaving was avoided up front"};
1012510118
InterleaveLoop = false;
1012610119
} else if (IC == 1 && UserIC <= 1) {
1012710120
// Tell the user interleaving is not beneficial.
1012810121
LLVM_DEBUG(dbgs() << "LV: Interleaving is not beneficial.\n");
10129-
IntDiagMsg = std::make_pair(
10122+
IntDiagMsg = {
1013010123
"InterleavingNotBeneficial",
10131-
"the cost-model indicates that interleaving is not beneficial");
10124+
"the cost-model indicates that interleaving is not beneficial"};
1013210125
InterleaveLoop = false;
1013310126
if (UserIC == 1) {
1013410127
IntDiagMsg.first = "InterleavingNotBeneficialAndDisabled";
@@ -10139,10 +10132,9 @@ bool LoopVectorizePass::processLoop(Loop *L) {
1013910132
// Tell the user interleaving is beneficial, but it explicitly disabled.
1014010133
LLVM_DEBUG(
1014110134
dbgs() << "LV: Interleaving is beneficial but is explicitly disabled.");
10142-
IntDiagMsg = std::make_pair(
10143-
"InterleavingBeneficialButDisabled",
10144-
"the cost-model indicates that interleaving is beneficial "
10145-
"but is explicitly disabled or interleave count is set to 1");
10135+
IntDiagMsg = {"InterleavingBeneficialButDisabled",
10136+
"the cost-model indicates that interleaving is beneficial "
10137+
"but is explicitly disabled or interleave count is set to 1"};
1014610138
InterleaveLoop = false;
1014710139
}
1014810140

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

0 commit comments

Comments
 (0)