[llvm] [LoopVectorize] Enable vectorisation of early exit loops with live-outs (PR #120567)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 22 08:29:27 PST 2025


================
@@ -9086,19 +9092,38 @@ addUsersInExitBlocks(VPlan &Plan,
       if (Op->isLiveIn())
         continue;
 
-      // Currently only live-ins can be used by exit values from blocks not
-      // exiting via the vector latch through to the middle block.
-      if (ExitIRI->getParent()->getSinglePredecessor() != MiddleVPBB)
-        return false;
-
       LLVMContext &Ctx = ExitIRI->getInstruction().getContext();
-      VPValue *Ext = B.createNaryOp(VPInstruction::ExtractFromEnd,
-                                    {Op, Plan.getOrAddLiveIn(ConstantInt::get(
-                                             IntegerType::get(Ctx, 32), 1))});
+      VPValue *Ext;
+      VPBasicBlock *PredVPBB =
+          cast<VPBasicBlock>(ExitIRI->getParent()->getPredecessors()[Idx]);
----------------
david-arm wrote:

To be honest I didn't base my latest changes off https://github.com/llvm/llvm-project/pull/123819. Ideally I'd prefer to get it all working in this PR so I can be absolutely sure that there are no test failures. At first glance it looks like https://github.com/llvm/llvm-project/pull/123819 will make things more difficult (and code more complicated) for the general case that I care about here. If you take a look at my version in this patch I split out handling of live-outs according to the incoming block which works for all cases (same or different exit blocks), whereas #123819 is trying to handle both the incoming values from the latch and the early exit in handleUncountableEarlyExit.

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


More information about the llvm-commits mailing list