[llvm] [VPlan] Dispatch to multiple exit blocks via middle blocks. (PR #112138)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 22 03:59:53 PDT 2024


================
@@ -2575,7 +2577,8 @@ void InnerLoopVectorizer::createVectorLoopSkeleton(StringRef Prefix) {
   LoopVectorPreHeader = OrigLoop->getLoopPreheader();
   assert(LoopVectorPreHeader && "Invalid loop structure");
   LoopExitBlock = OrigLoop->getUniqueExitBlock(); // may be nullptr
-  assert((LoopExitBlock || Cost->requiresScalarEpilogue(VF.isVector())) &&
+  assert((LoopExitBlock || Cost->requiresScalarEpilogue(VF.isVector()) ||
----------------
david-arm wrote:

I think we can completely remove the need for the `LoopExitBlock` variable - see https://github.com/llvm/llvm-project/pull/108231, since it's only ever used in one place. And even then what's actually meant by `LoopExitBlock` in `createEpilogueVectorizedLoopSkeleton` is the exit block from the latch.

Then in https://github.com/llvm/llvm-project/pull/88385 I think we can replace this assert with:

```
  assert((OrigLoop->getUniqueLatchExitBlock() ||
          Cost->requiresScalarEpilogue(VF.isVector())) &&
         "multiple exit loop without required epilogue?");
```

because even if `canVectorizeEarlyExit` returns true I think we still require an exit from the latch.

https://github.com/llvm/llvm-project/pull/112138


More information about the llvm-commits mailing list