[llvm] [LoopVectorize] Add support for vectorisation of simple early exit loops (PR #88385)
Graham Hunter via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 11 06:29:14 PDT 2024
================
@@ -8592,6 +8595,66 @@ ScalarEvolution::BackedgeTakenInfo::getExact(const Loop *L, ScalarEvolution *SE,
return SE->getUMinFromMismatchedTypes(Ops, /* Sequential */ true);
}
+void ScalarEvolution::BackedgeTakenInfo::getExactExitingBlocks(
+ const Loop *L, ScalarEvolution *SE,
+ SmallVector<BasicBlock *, 4> *Blocks) const {
+ // All exiting blocks we have collected must dominate the only backedge.
+ const BasicBlock *Latch = L->getLoopLatch();
+ if (!Latch || !hasAnyInfo())
+ return;
+
+ for (const auto &ENT : ExitNotTaken) {
+ const SCEV *BECount = ENT.ExactNotTaken;
+ if (BECount == SE->getCouldNotCompute())
+ continue;
+ Blocks->push_back(ENT.ExitingBlock);
+ }
+
+ return;
+}
+
+const SCEV *ScalarEvolution::BackedgeTakenInfo::getSpeculative(
+ const Loop *L, ScalarEvolution *SE,
+ SmallVector<const SCEVPredicate *, 4> *Preds) const {
+ // All exiting blocks we have collected must dominate the only backedge.
+ const BasicBlock *Latch = L->getLoopLatch();
+ if (!Latch)
+ return SE->getCouldNotCompute();
+
+ if (!hasAnyInfo())
----------------
huntergr-arm wrote:
You can combine this with the above '!Latch' check.
https://github.com/llvm/llvm-project/pull/88385
More information about the llvm-commits
mailing list