[llvm] [LoopVectorize] Enable vectorisation of early exit loops with live-outs (PR #120567)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 21 07:37:59 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:
I also share your concerns, but at a previous vectoriser call in November @fhahn explained this was quite normal in VPlan that assumptions are made regarding the ordering of successors and predecessors. We already do this when setting up the middle block, etc. It was definitely a problem until I fixed up some code that replaced the VPBasicBlock middle block with a VPIRBasicBlock and maintained the ordering. As we support more exits it may become harder to maintain the ordering during VPlan optimisations.
https://github.com/llvm/llvm-project/pull/120567
More information about the llvm-commits
mailing list