Skip to content

Commit 1e0e0e0

Browse files
authored
[VPlan] Improve style around container-inserts (NFC) (#155174)
1 parent c055678 commit 1e0e0e0

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

llvm/lib/Transforms/Vectorize/VPlan.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,15 +1473,15 @@ void VPSlotTracker::assignName(const VPValue *V) {
14731473
std::string BaseName = (Twine(Prefix) + Name + Twine(">")).str();
14741474

14751475
// First assign the base name for V.
1476-
const auto &[A, _] = VPValue2Name.insert({V, BaseName});
1476+
const auto &[A, _] = VPValue2Name.try_emplace(V, BaseName);
14771477
// Integer or FP constants with different types will result in he same string
14781478
// due to stripping types.
14791479
if (V->isLiveIn() && isa<ConstantInt, ConstantFP>(UV))
14801480
return;
14811481

14821482
// If it is already used by C > 0 other VPValues, increase the version counter
14831483
// C and use it for V.
1484-
const auto &[C, UseInserted] = BaseName2Version.insert({BaseName, 0});
1484+
const auto &[C, UseInserted] = BaseName2Version.try_emplace(BaseName, 0);
14851485
if (!UseInserted) {
14861486
C->second++;
14871487
A->second = (BaseName + Twine(".") + Twine(C->second)).str();

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ static bool sinkScalarOperands(VPlan &Plan) {
142142
for (VPValue *Op : Recipe.operands())
143143
if (auto *Def =
144144
dyn_cast_or_null<VPSingleDefRecipe>(Op->getDefiningRecipe()))
145-
WorkList.insert(std::make_pair(VPBB, Def));
145+
WorkList.insert({VPBB, Def});
146146
}
147147
}
148148

@@ -206,7 +206,7 @@ static bool sinkScalarOperands(VPlan &Plan) {
206206
for (VPValue *Op : SinkCandidate->operands())
207207
if (auto *Def =
208208
dyn_cast_or_null<VPSingleDefRecipe>(Op->getDefiningRecipe()))
209-
WorkList.insert(std::make_pair(SinkTo, Def));
209+
WorkList.insert({SinkTo, Def});
210210
Changed = true;
211211
}
212212
return Changed;
@@ -910,10 +910,10 @@ static void removeRedundantExpandSCEVRecipes(VPlan &Plan) {
910910
if (!ExpR)
911911
continue;
912912

913-
auto I = SCEV2VPV.insert({ExpR->getSCEV(), ExpR});
914-
if (I.second)
913+
const auto &[V, Inserted] = SCEV2VPV.try_emplace(ExpR->getSCEV(), ExpR);
914+
if (Inserted)
915915
continue;
916-
ExpR->replaceAllUsesWith(I.first->second);
916+
ExpR->replaceAllUsesWith(V->second);
917917
ExpR->eraseFromParent();
918918
}
919919
}

llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,18 @@ class UnrollState {
9292
void addRecipeForPart(VPRecipeBase *OrigR, VPRecipeBase *CopyR,
9393
unsigned Part) {
9494
for (const auto &[Idx, VPV] : enumerate(OrigR->definedValues())) {
95-
auto Ins = VPV2Parts.insert({VPV, {}});
96-
assert(Ins.first->second.size() == Part - 1 && "earlier parts not set");
97-
Ins.first->second.push_back(CopyR->getVPValue(Idx));
95+
const auto &[V, _] = VPV2Parts.try_emplace(VPV);
96+
assert(V->second.size() == Part - 1 && "earlier parts not set");
97+
V->second.push_back(CopyR->getVPValue(Idx));
9898
}
9999
}
100100

101101
/// Given a uniform recipe \p R, add it for all parts.
102102
void addUniformForAllParts(VPSingleDefRecipe *R) {
103-
auto Ins = VPV2Parts.insert({R, {}});
104-
assert(Ins.second && "uniform value already added");
103+
const auto &[V, Inserted] = VPV2Parts.try_emplace(R);
104+
assert(Inserted && "uniform value already added");
105105
for (unsigned Part = 0; Part != UF; ++Part)
106-
Ins.first->second.push_back(R);
106+
V->second.push_back(R);
107107
}
108108

109109
bool contains(VPValue *VPV) const { return VPV2Parts.contains(VPV); }

0 commit comments

Comments
 (0)