[llvm] [LoopVectorize] Add support for vectorisation of more early exit loops (PR #88385)
Graham Hunter via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 2 04:10:24 PDT 2024
================
@@ -1439,6 +1496,103 @@ bool LoopVectorizationLegality::canVectorizeLoopNestCFG(
return Result;
}
+void LoopVectorizationLegality::recordExitingBlocks() {
+ SmallVector<BasicBlock *, 8> ExitingBlocks;
+ TheLoop->getExitingBlocks(ExitingBlocks);
+
+ SmallVector<BasicBlock *, 4> CountableExitingBBs;
+ PSE.getSE()->getCountableExitingBlocks(TheLoop, &CountableExitingBBs);
+
+ // There could be multiple exiting blocks with an exact exit-not-taken
+ // count. Find all of the uncountable early exit blocks, i.e. the ones with
+ // an unknown count.
+ SmallVector<BasicBlock *, 4> UncountableExitingBBs;
+ SmallVector<BasicBlock *, 4> UncountableExitBBs;
+ for (BasicBlock *BB1 : ExitingBlocks) {
+ if (!is_contained(CountableExitingBBs, BB1)) {
+ UncountableExitingBBs.push_back(BB1);
+
+ for (BasicBlock *BB2 : successors(BB1)) {
+ if (!TheLoop->contains(BB2)) {
+ UncountableExitBBs.push_back(BB2);
+ break;
+ }
+ }
+ }
+ }
+
+ CountableExitingBlocks = std::move(CountableExitingBBs);
----------------
huntergr-arm wrote:
No need to create temporaries and move the data, you can just add directly to the member vectors in LVL.
https://github.com/llvm/llvm-project/pull/88385
More information about the llvm-commits
mailing list