Skip to content

[LoopVectorize][VPlan] Assertion `VF.Width == Width && "VPlan cost model and legacy cost model disagreed"' failed. #96328

Closed
@patrick-rivos

Description

@patrick-rivos

Reduced LLVM IR:

target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128"
target triple = "riscv64-unknown-linux-gnu"

define i32 @main(ptr %e) #0 {
entry:
  br label %for.body

for.body:                                       ; preds = %for.body, %entry
  %phi.0 = phi i64 [ %phi.0.next, %for.body ], [ 1, %entry ]
  %mul.0 = mul i64 %phi.0, 5
  %arr.idx = getelementptr [5 x i16], ptr %e, i64 0, i64 %mul.0
  %load.0 = load i16, ptr %arr.idx, align 2
  %phi.0.next = add i64 %phi.0, 1
  %exitcond = icmp ne i64 %phi.0.next, 24
  br i1 %exitcond, label %for.body, label %for.loopexit

for.loopexit:                      ; preds = %for.body
  ret i32 0
}

attributes #0 = { "target-features"="+64bit,+v,+zvl128b,+zvl256b" }

Command/backtrace:

> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize reduced.ll
WARNING: You're attempting to print out a bitcode file.
This is inadvisable as it may cause display problems. If
you REALLY want to taste LLVM bitcode first-hand, you
can force output with the `-f' option.

opt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10360: bool llvm::LoopVectorizePass::processLoop(llvm::Loop*): Assertion `VF.Width == Width && "VPlan cost model and legacy cost model disagreed"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize reduced.ll
 #0 0x0000600d4f81dd50 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e5fd50)
 #1 0x0000600d4f81b15f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e5d15f)
 #2 0x0000600d4f81b2b5 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f70a8a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f70a8a969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007f70a8a969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007f70a8a969fc pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007f70a8a42476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007f70a8a287f3 abort ./stdlib/abort.c:81:7
 #9 0x00007f70a8a2871b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007f70a8a39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x0000600d4e8538b6 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1e958b6)
#12 0x0000600d4e855e1e llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1e97e1e)
#13 0x0000600d4e856f40 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1e98f40)
#14 0x0000600d4d70e776 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xd50776)
#15 0x0000600d4f6399e1 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2c7b9e1)
#16 0x0000600d4d711906 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xd53906)
#17 0x0000600d4f6386eb llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2c7a6eb)
#18 0x0000600d4d70dfc6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xd4ffc6)
#19 0x0000600d4f636521 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2c78521)
#20 0x0000600d4cf652a6 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) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x5a72a6)
#21 0x0000600d4cf56f71 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x598f71)
#22 0x00007f70a8a29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#23 0x00007f70a8a29e40 call_init ./csu/../csu/libc-start.c:128:20
#24 0x00007f70a8a29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#25 0x0000600d4cf4cdb5 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x58edb5)
zsh: IOT instruction (core dumped)  /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt

Godbolt: https://godbolt.org/z/habqYfPxq

Found via fuzzer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashPrefer [crash-on-valid] or [crash-on-invalid]vectorizers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions