[llvm] [VPlan] Improve style around container-inserts (NFC) (PR #155174)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 25 07:44:53 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);
----------------
artagnon wrote:
I think the standards committee is still undecided on allowing attributes in structured bindings. As such, neither clang nor gcc complain about an unused value: https://godbolt.org/z/vss5and8h.
https://github.com/llvm/llvm-project/pull/155174
More information about the llvm-commits
mailing list