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

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 1 14:48:31 PDT 2025


================
@@ -530,41 +538,46 @@ void VPlanTransforms::replicateByVF(VPlan &Plan, ElementCount VF) {
   SmallVector<VPRecipeBase *> ToRemove;
   for (VPBasicBlock *VPBB : VPBBsToUnroll) {
     for (VPRecipeBase &R : make_early_inc_range(*VPBB)) {
-      auto *RepR = dyn_cast<VPReplicateRecipe>(&R);
-      if (!RepR || RepR->isSingleScalar())
+      auto *DefR = dyn_cast<VPRecipeWithIRFlags>(&R);
+      if (!DefR || !isa<VPInstruction, VPReplicateRecipe>(DefR))
+        continue;
+      if ((isa<VPReplicateRecipe>(DefR) &&
+           cast<VPReplicateRecipe>(DefR)->isSingleScalar()) ||
+          (isa<VPInstruction>(DefR) &&
+           !cast<VPInstruction>(DefR)->doesGeneratePerAllLanes()))
         continue;
 
----------------
ayalz wrote:

```suggestion
      if (!isa<VPInstruction, VPReplicateRecipe>(&R)) ||
          (isa<VPReplicateRecipe>(&R) &&
           cast<VPReplicateRecipe>(&R)->isSingleScalar()) ||
          (isa<VPInstruction>(&R) &&
           !cast<VPInstruction>(&R)->doesGeneratePerAllLanes()))
        continue;

      auto *DefR = cast<VPRecipeWithIRFlags>(&R);
```

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


More information about the llvm-commits mailing list