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

Sam Tebbs via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 26 03:42:05 PDT 2025


================
@@ -3013,10 +3014,16 @@ class VPExpressionRecipe : public VPSingleDefRecipe {
                            {Ext0, Ext1, Mul, Red}) {}
 
   ~VPExpressionRecipe() override {
-    for (auto *R : reverse(ExpressionRecipes))
-      delete R;
-    for (VPValue *T : LiveInPlaceholders)
-      delete T;
+    SmallSet<VPSingleDefRecipe *, 4> ExpressionRecipesSeen;
+    for (auto *R : reverse(ExpressionRecipes)) {
+      if (ExpressionRecipesSeen.insert(R).second)
+        delete R;
+    }
+    SmallSet<VPValue *, 4> PlaceholdersSeen;
+    for (VPValue *T : LiveInPlaceholders) {
+      if (PlaceholdersSeen.insert(T).second)
----------------
SamTebbs33 wrote:

Currently I'm caching the placeholder for each operand so that duplicate operands share the same placeholder, so we do need to care about duplicates here to avoid deleting placeholders that have already been deleted. But I've changed it so that the same operands don't share a placeholder.

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


More information about the llvm-commits mailing list