[llvm] [VPlan] Explicitly replicate VPInstructions by VF. (PR #155102)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 12 01:16:10 PDT 2025


================
@@ -501,11 +502,24 @@ cloneForLane(VPlan &Plan, VPBuilder &Builder, Type *IdxTy,
     NewOps.push_back(Ext);
   }
 
-  auto *New =
-      new VPReplicateRecipe(RepR->getUnderlyingInstr(), NewOps,
-                            /*IsSingleScalar=*/true, /*Mask=*/nullptr, *RepR);
-  New->transferFlags(*RepR);
-  New->insertBefore(RepR);
+  VPRecipeWithIRFlags *New;
+  if (auto *RepR = dyn_cast<VPReplicateRecipe>(DefR)) {
+    // TODO: have cloning of replicate recipes also provide the desired result
+    // coupled with setting its operands to NewOps (deriving IsSingleScalar and
+    // Mask from the operands?)
+    New =
+        new VPReplicateRecipe(RepR->getUnderlyingInstr(), NewOps,
+                              /*IsSingleScalar=*/true, /*Mask=*/nullptr, *RepR);
+  } else {
+    assert(isa<VPInstruction>(DefR) &&
+           "DefR must either be a VPReplicateRecipe or VPInstruction");
----------------
ayalz wrote:

```suggestion
           "DefR must be a VPReplicateRecipe or VPInstruction");
```


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


More information about the llvm-commits mailing list