[llvm] [LV] Initial support for stores in early exit loops (PR #137774)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Fri May 9 07:29:50 PDT 2025
================
@@ -1656,6 +1688,21 @@ bool LoopVectorizationLegality::isVectorizableEarlyExitLoop() {
return false;
}
+ // For loops with stores.
+ // Record load for analysis by isDereferenceableAndAlignedInLoop
+ // and later by dependence analysis.
+ if (BranchInst *Br = dyn_cast<BranchInst>(BB->getTerminator())) {
+ // FIXME: Handle exit conditions with multiple users, more complex exit
+ // conditions than br(icmp(load, loop_inv)).
+ ICmpInst *Cmp = dyn_cast<ICmpInst>(Br->getCondition());
+ if (Cmp && Cmp->hasOneUse() &&
+ TheLoop->isLoopInvariant(Cmp->getOperand(1))) {
+ LoadInst *Load = dyn_cast<LoadInst>(Cmp->getOperand(0));
+ if (Load && Load->hasOneUse() && TheLoop->contains(Load))
----------------
david-arm wrote:
The store can also have a dependence with another load in the loop that doesn't contribute to the early exit condition.
https://github.com/llvm/llvm-project/pull/137774
More information about the llvm-commits
mailing list