[llvm] [LoopVectorize] Add support for vectorisation of more early exit loops (PR #88385)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 24 02:06:41 PDT 2024


================
@@ -1439,6 +1498,74 @@ bool LoopVectorizationLegality::canVectorizeLoopNestCFG(
   return Result;
 }
 
+bool LoopVectorizationLegality::isVectorizableEarlyExitLoop() {
+  // At least one of the exiting blocks must be the latch.
+  BasicBlock *LatchBB = TheLoop->getLoopLatch();
+  if (!LatchBB) {
+    reportVectorizationFailure("Loop does not have a latch",
+                               "Cannot vectorize early exit loop",
+                               "NoLatchEarlyExit", ORE, TheLoop);
+    LLVM_DEBUG(dbgs() << "LV: Loop does not have a latch.\n");
+    return false;
+  }
+
+  if (!LAI)
+    LAI = &LAIs.getInfo(*TheLoop);
----------------
david-arm wrote:

It was needed because LAI in the current version of the patch sets up the countable and uncountable blocks. If we set up the blocks here then I won't need LAI for this logic.

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


More information about the llvm-commits mailing list