[llvm] [LV] Keep duplicate recipes in VPExpressionRecipe (PR #156976)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 1 01:03:00 PDT 2025


================
@@ -2801,21 +2800,31 @@ VPExpressionRecipe::VPExpressionRecipe(
   // create new temporary VPValues for all operands defined by a recipe outside
   // the expression. The original operands are added as operands of the
   // VPExpressionRecipe itself.
+
+  SmallMapVector<VPValue *, VPValue *, 4> OperandPlaceholders;
   for (auto *R : ExpressionRecipes) {
     for (const auto &[Idx, Op] : enumerate(R->operands())) {
       auto *Def = Op->getDefiningRecipe();
       if (Def && ExpressionRecipesAsSetOfUsers.contains(Def))
         continue;
       addOperand(Op);
-      LiveInPlaceholders.push_back(new VPValue());
-      R->setOperand(Idx, LiveInPlaceholders.back());
+      VPValue *Tmp = new VPValue();
+      OperandPlaceholders[Op] = Tmp;
+      LiveInPlaceholders.push_back(Tmp);
     }
   }
+
+  for (auto *R : ExpressionRecipes)
----------------
fhahn wrote:

I don't think it is a practical issue at the moment, but as mentioned in https://github.com/llvm/llvm-project/pull/156976#pullrequestreview-3283240979 it should at least be mentioned/documented.

Or perhaps even better also store a map of live-ins and their tmp values, instead of a vector and creating unused temporary values.

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


More information about the llvm-commits mailing list