[llvm] [VPlan] Improve style around container-inserts (NFC) (PR #155174)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 25 19:18:07 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 *>());
----------------
lukel97 wrote:

Can we omit the SmallVector constructor and have try_emplace just use the default constructor?

It would be nice to use try_emplace since it also avoids a copy IIUC. 

https://github.com/llvm/llvm-project/pull/155174


More information about the llvm-commits mailing list