[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 02:08: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]);
----------------
david-arm wrote:
In one of my early implementations last year I actually kept the users on separate lists, a list for "normal" exits and a list of early exits. But then I think you restructured the code in collectUsersInExitBlocks and addUsersInExitBlocks to handle arbitrary numbers of exits (https://github.com/llvm/llvm-project/pull/115066), which is the direction it seemed you wanted this to go. If we go down the route of doing this in `handleUncountableEarlyExit` then we can should also clean up `collectUsersInExitBlocks` as it doesn't need to be so general anymore.
https://github.com/llvm/llvm-project/pull/120567
More information about the llvm-commits
mailing list