[llvm] [VPlan] Model branch cond to enter scalar epilogue in VPlan. (PR #92651)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 4 05:25:16 PDT 2024


================
@@ -815,6 +819,42 @@ VPlanPtr VPlan::createInitialVPlan(const SCEV *TripCount, ScalarEvolution &SE,
   VPBlockUtils::insertBlockAfter(TopRegion, VecPreheader);
   VPBasicBlock *MiddleVPBB = new VPBasicBlock("middle.block");
   VPBlockUtils::insertBlockAfter(MiddleVPBB, TopRegion);
+
+  // Add a check in the middle block to see if we have completed
+  // all of the iterations in the first vector loop.  Three cases:
+  // 1) If we require a scalar epilogue, there is no conditional branch as
+  //    we unconditionally branch to the scalar preheader.  Do nothing.
+  // 2) If (N - N%VF) == N, then we *don't* need to run the remainder.
+  //    Thus if tail is to be folded, we know we don't need to run the
+  //    remainder and we can use the previous value for the condition (true).
----------------
ayalz wrote:

```suggestion
  //    remainder and we can set the condition to true.
```
would be better to have an unconditional branch as in case 1.

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


More information about the llvm-commits mailing list