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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 22 13:10:31 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]);
----------------
fhahn wrote:

Ah I see, instead of handling everything in `handleUncountableEarlyExit` here it requires running the collection early. 

The smallish additional complexity in  `handleUncountableEarlyExit` in https://github.com/llvm/llvm-project/pull/123819 for early exits has the advantage of not having this ordering requirement, but I don't have a strong preference. 

The main benefit from https://github.com/llvm/llvm-project/pull/123819 IMO would be to separately move where we update the currently supported exit users and test/defend the removal of the code in collectUser../addUsers.. independently before adding support for new exit values.

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


More information about the llvm-commits mailing list