[llvm] [LV] Only require a scalar epilogue for interleave groups actually widened as interleave accesses (PR #213904)

Mel Chen via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 19 02:00:59 PDT 2026


================
@@ -1275,6 +1284,15 @@ bool VPlanTransforms::handleEarlyExits(VPlan &Plan, UncountableExitStyle Style,
                                        TheLoop, PSE, DT, AC, Style);
   }
 
+  // A scalar epilogue is required if vectorized loop includes countable early
+  // exits.
+  if (MiddleVPBB->getNumSuccessors() == 2) {
----------------
Mel-Chen wrote:

> Do we need to handle this early here or could the code in tryToBuildVPlan also handle this?

I gave it a try. If we want to defer scalar epilogue handling, the only option seems to be recording whether the loop has countable early exits as a flag in LoopVectorizationPlanner prior to calling handleEarlyExits. IIUC, once handleEarlyExits finishes, the countable early exit edges are disconnected, making them unable to trace afterwards.

Another option was updating getCountableExitingBlocks(). However, currently only isVectorizableEarlyExitLoop() populates this container, so it can't be used to solve our current issue.

Also, I'm questioning the necessity of deferring this handling to tryToBuildVPlan. Since this is legality and is independent of the selected VF, handling it earlier seems reasonable. Is there any rationale for delaying this to tryToBuildVPlan that I might have overlooked?


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


More information about the llvm-commits mailing list