[llvm] [LoopVectorize] Teach LoopVectorizationLegality about more early exits (PR #107004)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 13 01:47:15 PDT 2024


================
@@ -377,6 +377,24 @@ class LoopVectorizationLegality {
     return LAI->getDepChecker().getMaxSafeVectorWidthInBits();
   }
 
+  /// Returns true if the loop has a speculative early exit, i.e. an
+  /// uncountable exit that isn't the latch block.
+  bool hasSpeculativeEarlyExit() const { return HasSpeculativeEarlyExit; }
+
+  /// Returns the speculative early exiting block.
+  BasicBlock *getSpeculativeEarlyExitingBlock() const {
+    assert(getUncountableExitingBlocks().size() == 1 &&
+           "Expected only a single uncountable exiting block");
+    return getUncountableExitingBlocks()[0];
+  }
+
+  /// Returns the destination of a speculative early exiting block.
+  BasicBlock *getSpeculativeEarlyExitBlock() const {
+    assert(getUncountableExitBlocks().size() == 1 &&
----------------
fhahn wrote:

Both `getSpeculativeEarlyExitBloc` and `getUncountableExitingBlocks` assert that there's exactly one entry. Would it be simpler to store the pointers directly, rather than in a 1 element vector?

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


More information about the llvm-commits mailing list