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

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 27 10:31:09 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)) {
----------------
david-arm wrote:

OK, that's fair enough. I wasn't sure if those two checks would always be enough, but it makes sense.

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


More information about the llvm-commits mailing list