[llvm] [VPlan] Improve style around container-inserts (NFC) (PR #155174)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 25 07:36:09 PDT 2025
================
@@ -92,18 +92,19 @@ 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, SmallVector<VPValue *>());
+ 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, SmallVector<VPValue *>());
+ assert(Inserted && "uniform value already added");
for (unsigned Part = 0; Part != UF; ++Part)
- Ins.first->second.push_back(R);
+ V->second.push_back(R);
----------------
lukel97 wrote:
If you do a build without assertions enabled, does the compiler complain about Inserted not being used? Not sure if it's possible to add a [[maybe_unused]] for part of a structured binding or not. But maybe this isn't a problem because it's a structured binding to begin with
https://github.com/llvm/llvm-project/pull/155174
More information about the llvm-commits
mailing list