[llvm] [LV] Allow loops with multiple early exits in legality checks. (PR #176403)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 16 07:37:22 PST 2026


================
@@ -1434,13 +1435,10 @@ bool LoopVectorizationLegality::isFixedOrderRecurrence(
 bool LoopVectorizationLegality::blockNeedsPredication(
     const BasicBlock *BB) const {
   // When vectorizing early exits, create predicates for the latch block only.
-  // The early exiting block must be a direct predecessor of the latch at the
-  // moment.
+  // For a single early exit, it must be a direct predecessor of the latch.
+  // For multiple early exits, they form a chain leading to the latch.
----------------
david-arm wrote:

I don't know what the correct terminology is here, but is it worth being a bit more specific about the type of chain? For example, something like 'they form a dominating chain' or `they form a chain where each exiting block dominates all subsequent blocks up to the latch`?

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


More information about the llvm-commits mailing list