@@ -2795,33 +2795,28 @@ VPExpressionRecipe::VPExpressionRecipe(
27952795 // the expression. The original operands are added as operands of the
27962796 // VPExpressionRecipe itself.
27972797
2798- // This map caches the temporary placeholders so duplicates aren't created in
2799- // the case that recipes share operands.
28002798 SmallMapVector<VPValue *, VPValue *, 4 > OperandPlaceholders;
2801-
28022799 for (auto *R : ExpressionRecipes) {
28032800 for (const auto &[Idx, Op] : enumerate(R->operands ())) {
28042801 auto *Def = Op->getDefiningRecipe ();
28052802 if (Def && ExpressionRecipesAsSetOfUsers.contains (Def))
28062803 continue ;
28072804 addOperand (Op);
2808- if (OperandPlaceholders. find (Op) == OperandPlaceholders. end ())
2809- OperandPlaceholders[Op] = new VPValue () ;
2810- LiveInPlaceholders.push_back (OperandPlaceholders[Op] );
2805+ VPValue *Tmp = new VPValue ();
2806+ OperandPlaceholders[Op] = Tmp ;
2807+ LiveInPlaceholders.push_back (Tmp );
28112808 }
28122809 }
28132810
2814- for (auto *R : ExpressionRecipes) {
2815- for (const auto &[Idx, Op] : enumerate(R->operands ())) {
2816- auto *Entry = OperandPlaceholders.find (Op);
2817- if (Entry != OperandPlaceholders.end ())
2818- R->setOperand (Idx, Entry->second );
2819- }
2820- }
2811+ for (auto *R : ExpressionRecipes)
2812+ for (auto &Entry : OperandPlaceholders)
2813+ R->replaceUsesOfWith (Entry.first , Entry.second );
28212814}
28222815
28232816void VPExpressionRecipe::decompose () {
28242817 for (auto *R : ExpressionRecipes)
2818+ // Since the list could contain duplicates, make sure the recipe hasn't
2819+ // already been inserted.
28252820 if (!R->getParent ())
28262821 R->insertBefore (this );
28272822
0 commit comments