<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/155183>155183</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [SLPVectorizer] Assertion `ScheduleEnd && "tried to vectorize a terminator?"' failed.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          TatyanaDoubts
      </td>
    </tr>
</table>

<pre>
    To reproduce run opt with the test below, -passes=slp-vectorizer
```
; ModuleID = './reduced.ll'
source_filename = "./reduced.ll"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2"
target triple = "x86_64-unknown-linux-gnu"

define void @wombat() gc "statepoint-example" personality ptr null {
bb:
  %add = add i32 0, 0
 %add1 = add i32 0, 0
  %invoke = invoke i32 null(ptr addrspace(1) null, i32 0, i32 0, i32 0)
          to label %bb2 unwind label %bb8

bb2: ; preds = %bb
  %add3 = add i32 %invoke, 0
  br label %bb4

bb4:                                              ; preds = %bb2
  %phi = phi i32 [ %add3, %bb2 ]
  %phi5 = phi i32 [ 0, %bb2 ]
  %phi6 = phi i32 [ %add, %bb2 ]
  %phi7 = phi i32 [ %add1, %bb2 ]
  ret void

bb8:                                              ; preds = %bb
 %landingpad = landingpad { ptr, i32 }
          cleanup
  ret void
}
```
Reproducer: https://godbolt.org/z/njq5sde1d

Stack dump:
```
0.      Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer <source>
1.      Running pass "function(slp-vectorizer)" on module "<source>"
2.      Running pass "slp-vectorizer" on function "wombat"
 #0 0x00000000056fd7a8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x56fd7a8)
 #1 0x00000000056fa654 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x0000727df8242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x0000727df82969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x0000727df8242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x0000727df82287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x0000727df822871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #7 0x0000727df8239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #8 0x00000000035a390b llvm::slpvectorizer::BoUpSLP::BlockScheduling::tryScheduleBundle(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP*, (anonymous namespace)::InstructionsState const&, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&) SLPVectorizer.cpp:0:0
 #9 0x00000000035e0d99 llvm::slpvectorizer::BoUpSLP::buildTreeRec(llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x35e0d99)
#10 0x00000000035e1e58 llvm::slpvectorizer::BoUpSLP::buildTreeRec(llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x35e1e58)
#11 0x00000000035e3601 llvm::slpvectorizer::BoUpSLP::buildTreeRec(llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x35e3601)
#12 0x00000000036119c1 llvm::SLPVectorizerPass::tryToVectorizeList(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x36119c1)
#13 0x000000000361695d bool tryToVectorizeSequence<llvm::Value>(llvm::SmallVectorImpl<llvm::Value*>&, llvm::function_ref<bool (llvm::Value*, llvm::Value*)>, llvm::function_ref<bool (llvm::Value*, llvm::Value*)>, llvm::function_ref<bool (llvm::ArrayRef<llvm::Value*>, bool)>, bool, llvm::slpvectorizer::BoUpSLP&) (.constprop.0) SLPVectorizer.cpp:0:0
#14 0x000000000361802a llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x361802a)
#15 0x000000000361fec6 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0
#16 0x0000000003620a1b llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3620a1b)
#17 0x0000000002e0752e llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2e0752e)
#18 0x00000000054eb8b1 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x54eb8b1)
#19 0x0000000000ed995e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xed995e)
#20 0x00000000054ebefa llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x54ebefa)
#21 0x000000000096d8fe llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x96d8fe)
#22 0x00000000054e9941 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x54e9941)
#23 0x0000000000977b9a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x977b9a)
#24 0x000000000096bc67 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x96bc67)
#25 0x0000727df8229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#26 0x0000727df8229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#27 0x0000000000962d85 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x962d85)
Program terminated with signal: SIGSEGV
Compiler returned: 139
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsWtty46gW_RryQtmF0P0hD44Tz0md7ppUnNOvKSSwzQSBBlAu_fWnQLJ1iTMdd6drprrGlVgSsBd7LxZbIJkYw7eSsXMQX4D48ow0dqf0-R2xL0SSS9UU1pw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