[llvm] [LoopVectorize] Use new getUniqueLatchExitBlock routine (PR #108231)
Graham Hunter via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 4 06:30:36 PST 2024
================
@@ -159,6 +159,16 @@ BlockT *LoopBase<BlockT, LoopT>::getUniqueExitBlock() const {
return getExitBlockHelper(this, true).first;
}
+template <class BlockT, class LoopT>
+BlockT *LoopBase<BlockT, LoopT>::getUniqueLatchExitBlock() const {
+ const BlockT *Latch = getLoopLatch();
+ assert(Latch && "Latch block must exists");
+ SmallVector<BlockT *, 4> ExitBlocks;
----------------
huntergr-arm wrote:
```suggestion
auto IsExitBlock = [&](BlockT *BB, bool AllowRepeats) -> BlockT * {
assert(!AllowRepeats && "Unexpected parameter value.");
return !contains(BB) ? BB : nullptr;
};
return find_singleton<BlockT>(children<BlockT *>(Latch), IsExitBlock);
```
Requires changing Latch to be a non-const pointer (since there isn't a version of `children` with const), but if we already have the Latch block there's no need to search for it again.
https://github.com/llvm/llvm-project/pull/108231
More information about the llvm-commits
mailing list