[llvm] [VPlan] Build initial VPlan 0 using HCFGBuilder for inner loops. (NFC) (PR #124432)

via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 3 01:01:42 PST 2025


================
@@ -9343,15 +9370,18 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
       // in the exit block, a uniform store recipe will be created for the final
       // invariant store of the reduction.
       StoreInst *SI;
-      if ((SI = dyn_cast<StoreInst>(&I)) &&
+      if ((SI = dyn_cast<StoreInst>(Instr)) &&
           Legal->isInvariantAddressOfReduction(SI->getPointerOperand())) {
         // Only create recipe for the final invariant store of the reduction.
-        if (!Legal->isInvariantStoreOfReduction(SI))
+        if (!Legal->isInvariantStoreOfReduction(SI)) {
+          R.eraseFromParent();
           continue;
+        }
         auto *Recipe = new VPReplicateRecipe(
             SI, RecipeBuilder.mapToVPValues(Instr->operands()),
             true /* IsUniform */);
         Recipe->insertBefore(*MiddleVPBB, MBIP);
----------------
ayalz wrote:

Perhaps simpler to do:
```suggestion
        if (Legal->isInvariantStoreOfReduction(SI)) {
          auto *Recipe = new VPReplicateRecipe(
              SI, RecipeBuilder.mapToVPValues(Instr->operands()),
              true /* IsUniform */);
          Recipe->insertBefore(*MiddleVPBB, MBIP);
        }
```

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


More information about the llvm-commits mailing list