diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 9b5ad16589539..c4604782b3b64 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 InstOnVF = std::make_pair(I, VF); + std::pair 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 InstOnVF = std::make_pair(I, VF); + std::pair InstOnVF(I, VF); assert(WideningDecisions.contains(InstOnVF) && "The cost is not calculated"); return WideningDecisions[InstOnVF].second; @@ -1150,8 +1148,7 @@ class LoopVectorizationCostModel { std::optional 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 " @@ -8135,7 +8130,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); } } @@ -8207,12 +8202,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; } @@ -10105,9 +10099,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; } @@ -10116,16 +10110,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"; @@ -10136,10 +10129,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; } @@ -10149,10 +10141,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; }