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

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 25 13:35:58 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 *>());
----------------
artagnon wrote:

To be honest, I found this inelegant too and wondered if the insert might not be that bad: there seems to be no way around it, unfortunately.

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


More information about the llvm-commits mailing list