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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 27 08:33:51 PST 2025


================
@@ -950,6 +957,26 @@ void VPlan::prepareToExecute(Value *TripCountV, Value *VectorTripCountV,
   }
 }
 
+bool VPlan::isExitBlock(VPBlockBase *VPBB) {
+  if (!isa<VPIRBasicBlock>(VPBB) || VPBB->getNumSuccessors() ||
+      VPBB == getScalarHeader())
+    return false;
+
+  VPRegionBlock *RegionBlock = getVectorLoopRegion();
+  if (!RegionBlock)
+    return false;
+
+  // The block must be a successor of the region block.
+  if (llvm::is_contained(
+          vp_depth_first_shallow(RegionBlock->getSingleSuccessor()), VPBB)) {
----------------
fhahn wrote:

I am not sure I completely follow the logic here. We return true if `VPBB` is any block after the middle block, basically relying on the checks above to filter out all non-VPIRBBs or VPIRBBs with successors.

Simpler to `return isa<VPIRBasicBlock>(VPBB) && VPBB->getNumSuccessors() == 0;`

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


More information about the llvm-commits mailing list