[llvm] [LV] Add initial legality checks for ee loops with stores (PR #145663)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 18 03:26:39 PDT 2025
================
@@ -515,20 +523,87 @@ class LoopVectorizationLegality {
/// Returns true if this is an early exit loop that can be vectorized.
/// Currently, a loop with an uncountable early exit is considered
/// vectorizable if:
- /// 1. There are no writes to memory in the loop.
+ /// 1. Writes to memory do not form a dependence with any load used as
+ /// part of the uncounted exit condition.
/// 2. The loop has only one early uncountable exit
/// 3. The early exit block dominates the latch block.
/// 4. The latch block has an exact exit count.
/// 5. The loop does not contain reductions or recurrences.
/// 6. We can prove at compile-time that loops will not contain faulting
- /// loads.
+ /// loads, or that any faulting loads would also occur in a purely
+ /// scalar loop.
/// 7. It is safe to speculatively execute instructions such as divide or
- /// call instructions.
+ /// call instructions.
/// The list above is not based on theoretical limitations of vectorization,
/// but simply a statement that more work is needed to support these
/// additional cases safely.
bool isVectorizableEarlyExitLoop();
+ /// When vectorizing an early exit loop containing side effects, we need to
+ /// determine whether an uncounted exit will be taken before any operation
----------------
fhahn wrote:
```suggestion
/// determine whether an uncountable exit will be taken before any operation
```
https://github.com/llvm/llvm-project/pull/145663
More information about the llvm-commits
mailing list