Closed
Description
Reproducer: https://godbolt.org/z/EjYovPK8e
; bin/opt -passes=loop-vectorize reduced.ll -S
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"
target triple = "x86_64-unknown-linux-gnu"
define i32 @main(i1 %cmp.i937.i.i, ptr %p) {
entry:
br label %sub_1
sub_1: ; preds = %entry
%0 = select i1 false, i32 -27, i32 0
%sub.i936.neg.i.i = add i32 0, 0
br label %lor.end281.i.i
lor.end281.i.i: ; preds = %cleanup293.thread.i.i, %sub_1
%storemerge900975.i.i = phi i32 [ 1, %sub_1 ], [ %inc302.i.i, %cleanup293.thread.i.i ]
br i1 %cmp.i937.i.i, label %cleanup293.thread.i.i, label %cond.false.i938.i.i
cond.false.i938.i.i: ; preds = %lor.end281.i.i
%rem.i939964965.i.i = urem i32 %sub.i936.neg.i.i, %0
%1 = and i32 %rem.i939964965.i.i, 0
br label %cleanup293.thread.i.i
cleanup293.thread.i.i: ; preds = %cond.false.i938.i.i, %lor.end281.i.i
%cond.i940.i.i = phi i32 [ %1, %cond.false.i938.i.i ], [ 0, %lor.end281.i.i ]
store i32 %cond.i940.i.i, ptr %p, align 4
%inc302.i.i = add i32 %storemerge900975.i.i, 1
%exitcond.not.i.i = icmp eq i32 %inc302.i.i, 0
br i1 %exitcond.not.i.i, label %cleanup441.i.i, label %lor.end281.i.i
cleanup441.i.i: ; preds = %cleanup293.thread.i.i
ret i32 0
}
opt: /root/llvm-project/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp:2886: virtual void llvm::VPPredInstPHIRecipe::execute(llvm::VPTransformState&): Assertion `isa<VPReplicateRecipe>(getOperand(0)) && "operand must be VPReplicateRecipe"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=loop-vectorize <source>
1. Running pass "function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)" on module "<source>"
2. Running pass "loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>" on function "main"
#0 0x0000000005603c18 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5603c18)
#1 0x00000000056015a4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#2 0x00007a581ee42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x00007a581ee969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#4 0x00007a581ee42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#5 0x00007a581ee287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#6 0x00007a581ee2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#7 0x00007a581ee39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#8 0x00000000035fbe13 llvm::VPPredInstPHIRecipe::execute(llvm::VPTransformState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x35fbe13)
#9 0x00000000035a9a8a llvm::VPBasicBlock::executeRecipes(llvm::VPTransformState*, llvm::BasicBlock*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x35a9a8a)
#10 0x00000000035bc70d llvm::VPBasicBlock::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x35bc70d)
#11 0x00000000035afb81 llvm::VPRegionBlock::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x35afb81)
#12 0x00000000035bf201 llvm::VPlan::execute(llvm::VPTransformState*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x35bf201)
#13 0x0000000003459b9b llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3459b9b)
#14 0x0000000003470889 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3470889)
#15 0x0000000003472670 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3472670)
#16 0x0000000003472cc3 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3472cc3)
#17 0x0000000002d824be llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2d824be)
#18 0x00000000053fa1f0 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x53fa1f0)
#19 0x0000000000e91dde 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+0xe91dde)
#20 0x00000000053fa703 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x53fa703)
#21 0x0000000000e90c2e 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+0xe90c2e)
#22 0x00000000053f8320 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x53f8320)
#23 0x00000000009519ea 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) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9519ea)
#24 0x00000000009451bc optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9451bc)
#25 0x00007a581ee29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#26 0x00007a581ee29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#27 0x000000000093cdf5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x93cdf5)
Program terminated with signal: SIGSEGV
Compiler returned: 139