[llvm] [LoopVectorize] Add support for vectorisation of more early exit loops (PR #88385)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 23 23:39:04 PDT 2024
================
@@ -2514,14 +2545,20 @@ bool LoopAccessInfo::analyzeLoop(AAResults *AA, LoopInfo *LI,
// Check if we see any stores. If there are no stores, then we don't
// care if the pointers are *restrict*.
+ bool CanVecMem = false;
if (!Stores.size()) {
LLVM_DEBUG(dbgs() << "LAA: Found a read-only loop!\n");
- return true;
+ // Don't return yet if there are uncountable exits because we also need to
+ // record all of the underlying objects for memory fault analysis.
+ if (!UncountableExitingBlocks.size())
+ return true;
----------------
fhahn wrote:
Relying on analyzeLoop to collect all underlying objects is fragile (it is easy to miss this invariant when a new exit is added) and adds additional complexity to LAA which isn't needed for its job. It may also have to iterate over the whole loop for users that don't support loops with uncountable exits.
We already iterate over the loop multiple times in LoopVectorizationLegality to collect information needed to decide whether to vectorize, so IMO it would make sense to move the logic there, instead adding complexity to LAA which isn't needed for dependence analysis/runtime check generation.
As mentioned earlier, we also already collect pointers we know won't fault across all iterations of the loop. Would be good to reuse/extend the existing logic
https://github.com/llvm/llvm-project/pull/88385
More information about the llvm-commits
mailing list