[llvm] [VPlan] Update scalar induction resume values in VPlan. (PR #110577)

via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 1 05:07:43 PST 2024


================
@@ -7725,13 +7736,21 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
 
   BestVPlan.execute(&State);
 
-  // 2.5 Collect reduction resume values.
   auto *ExitVPBB = BestVPlan.getMiddleBlock();
-  if (VectorizingEpilogue)
+  // 2.5 When vectorizing the epilogue, fix reduction resume values and
+  // induction resume values from the bypass blocks.
+  if (VectorizingEpilogue) {
     for (VPRecipeBase &R : *ExitVPBB) {
       fixReductionScalarResumeWhenVectorizingEpilog(
           &R, State, State.CFG.VPBB2IRBB[ExitVPBB]);
     }
+    BasicBlock *PH = OrigLoop->getLoopPreheader();
+    for (const auto &[IVPhi, _] : Legal->getInductionVars()) {
+      auto *Inc = cast<PHINode>(IVPhi->getIncomingValueForBlock(PH));
+      const auto &[BB, V] = ILV.getInductionBypassValue(IVPhi);
----------------
ayalz wrote:

Note/assert that `BB` is the same for all IV's. Perhaps worth retrieving it once, say via `get "AdditionalBypassBlock()`, so that `getInductionAdditionalBypass()` can be `getInductionAdditionalBypassValue`, and also feeding it to `fixReductionScalarResumeWhenVectorizingEpilog()`.

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


More information about the llvm-commits mailing list