[llvm] 1e0e0e0 - [VPlan] Improve style around container-inserts (NFC) (#155174)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 26 06:13:02 PDT 2025
Author: Ramkumar Ramachandra
Date: 2025-08-26T14:12:59+01:00
New Revision: 1e0e0e0a56e66f5b3f687ec81a85785596913a7b
URL: https://github.com/llvm/llvm-project/commit/1e0e0e0a56e66f5b3f687ec81a85785596913a7b
DIFF: https://github.com/llvm/llvm-project/commit/1e0e0e0a56e66f5b3f687ec81a85785596913a7b.diff
LOG: [VPlan] Improve style around container-inserts (NFC) (#155174)
Added:
Modified:
llvm/lib/Transforms/Vectorize/VPlan.cpp
llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index f972efa07eb7e..1438dc366b55d 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -1473,7 +1473,7 @@ void VPSlotTracker::assignName(const VPValue *V) {
std::string BaseName = (Twine(Prefix) + Name + Twine(">")).str();
// First assign the base name for V.
- const auto &[A, _] = VPValue2Name.insert({V, BaseName});
+ const auto &[A, _] = VPValue2Name.try_emplace(V, BaseName);
// Integer or FP constants with
diff erent types will result in he same string
// due to stripping types.
if (V->isLiveIn() && isa<ConstantInt, ConstantFP>(UV))
@@ -1481,7 +1481,7 @@ void VPSlotTracker::assignName(const VPValue *V) {
// If it is already used by C > 0 other VPValues, increase the version counter
// C and use it for V.
- const auto &[C, UseInserted] = BaseName2Version.insert({BaseName, 0});
+ const auto &[C, UseInserted] = BaseName2Version.try_emplace(BaseName, 0);
if (!UseInserted) {
C->second++;
A->second = (BaseName + Twine(".") + Twine(C->second)).str();
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 2ffe668638e8b..556278e4c3dba 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -142,7 +142,7 @@ static bool sinkScalarOperands(VPlan &Plan) {
for (VPValue *Op : Recipe.operands())
if (auto *Def =
dyn_cast_or_null<VPSingleDefRecipe>(Op->getDefiningRecipe()))
- WorkList.insert(std::make_pair(VPBB, Def));
+ WorkList.insert({VPBB, Def});
}
}
@@ -206,7 +206,7 @@ static bool sinkScalarOperands(VPlan &Plan) {
for (VPValue *Op : SinkCandidate->operands())
if (auto *Def =
dyn_cast_or_null<VPSingleDefRecipe>(Op->getDefiningRecipe()))
- WorkList.insert(std::make_pair(SinkTo, Def));
+ WorkList.insert({SinkTo, Def});
Changed = true;
}
return Changed;
@@ -910,10 +910,10 @@ static void removeRedundantExpandSCEVRecipes(VPlan &Plan) {
if (!ExpR)
continue;
- auto I = SCEV2VPV.insert({ExpR->getSCEV(), ExpR});
- if (I.second)
+ const auto &[V, Inserted] = SCEV2VPV.try_emplace(ExpR->getSCEV(), ExpR);
+ if (Inserted)
continue;
- ExpR->replaceAllUsesWith(I.first->second);
+ ExpR->replaceAllUsesWith(V->second);
ExpR->eraseFromParent();
}
}
diff --git a/llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp b/llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp
index 4bcde8cd5d42a..7a63d20825a31 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp
@@ -92,18 +92,18 @@ class UnrollState {
void addRecipeForPart(VPRecipeBase *OrigR, VPRecipeBase *CopyR,
unsigned Part) {
for (const auto &[Idx, VPV] : enumerate(OrigR->definedValues())) {
- auto Ins = VPV2Parts.insert({VPV, {}});
- assert(Ins.first->second.size() == Part - 1 && "earlier parts not set");
- Ins.first->second.push_back(CopyR->getVPValue(Idx));
+ const auto &[V, _] = VPV2Parts.try_emplace(VPV);
+ assert(V->second.size() == Part - 1 && "earlier parts not set");
+ V->second.push_back(CopyR->getVPValue(Idx));
}
}
/// Given a uniform recipe \p R, add it for all parts.
void addUniformForAllParts(VPSingleDefRecipe *R) {
- auto Ins = VPV2Parts.insert({R, {}});
- assert(Ins.second && "uniform value already added");
+ const auto &[V, Inserted] = VPV2Parts.try_emplace(R);
+ assert(Inserted && "uniform value already added");
for (unsigned Part = 0; Part != UF; ++Part)
- Ins.first->second.push_back(R);
+ V->second.push_back(R);
}
bool contains(VPValue *VPV) const { return VPV2Parts.contains(VPV); }
More information about the llvm-commits
mailing list