[llvm] [VPlan] Verify plan before optimizations. NFC (PR #122678)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 13 02:20:56 PST 2025


================
@@ -9672,10 +9676,11 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
           CM.useOrderedReductions(RdxDesc), CurrentLinkI->getDebugLoc());
       // Append the recipe to the end of the VPBasicBlock because we need to
       // ensure that it comes after all of it's inputs, including CondOp.
-      // Note that this transformation may leave over dead recipes (including
-      // CurrentLink), which will be cleaned by a later VPlan transform.
+      // Delete CurrentLink as it will be invalid if its operand is replaced
+      // with a reduction defined at the bottom of the block in the next link.
       LinkVPBB->appendRecipe(RedRecipe);
       CurrentLink->replaceAllUsesWith(RedRecipe);
+      ToDelete.push_back(CurrentLink);
----------------
lukel97 wrote:

Yeah, it doesn't play well with the `for (VPRecipeBase &R : Header->phis())` iterator. And we can't use make_early_inc_range either since we're deleting an instruction that's not the current iterator

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


More information about the llvm-commits mailing list