[llvm] [LV] Add initial legality checks for ee loops with stores (PR #145663)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 11 04:10:32 PDT 2025
================
@@ -1793,6 +1814,110 @@ bool LoopVectorizationLegality::isVectorizableEarlyExitLoop() {
return true;
}
+bool LoopVectorizationLegality::canUncountedExitConditionLoadBeMoved(
+ BasicBlock *ExitingBlock) {
+ SmallVector<const SCEVPredicate *, 4> Predicates;
+ LoadInst *CriticalUncountedExitConditionLoad = nullptr;
+
+ // Try to find a load in the critical path for the uncounted exit condition.
+ // This is currently matching about the simplest form we can, expecting
+ // only one in-loop load, the result of which is directly compared against
+ // a loop-invariant value.
+ // FIXME: We're insisting on a single use for now, because otherwise we will
+ // need to make PHI nodes for other users. That can be done once the initial
+ // transform code lands.
+ if (BranchInst *Br = dyn_cast<BranchInst>(ExitingBlock->getTerminator())) {
----------------
david-arm wrote:
nit: How about bailing out early if it's not a branch to remove some indentation? For example,
```
auto *Br = dyn_cast<BranchInst>(ExitingBlock->getTerminator());
if (!Br) {
reportVectorizationFailure(
"Unsupported control flow in early exit loop with side effects",
"Cannot find branch instruction for uncounted exit in early exit loop "
"with side effects",
"UnsupportedUncountedExitTerminator", ORE, TheLoop);
return false;
}
// FIXME: Don't rely ...
```
https://github.com/llvm/llvm-project/pull/145663
More information about the llvm-commits
mailing list