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

Graham Hunter via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 21 03:47:52 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]);
----------------
huntergr-arm wrote:

I'm not keen on having the predecessors being looked up like this -- I know the operands to the exit phi recipe are added by walking the blocks in `collectUsersInExitBlocks`, but it feels fragile. I won't hold it up for that though, maybe this is something to improve in the future when we add support for additional uncounted exits.

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


More information about the llvm-commits mailing list