Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
patrick-rivos opened this issue Jun 21, 2024 · 2 comments
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] vectorizers

Comments

@patrick-rivos
Copy link
Contributor

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.

@EugeneZelenko EugeneZelenko added vectorizers crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Jun 21, 2024
@fhahn
Copy link
Contributor

fhahn commented Jun 25, 2024

This is caused by #92555 due to a dead load. I guesss to avoid issues with fuzzer generated test cases, we need to explicitly skip dead instructions in the legacy cost computation

fhahn added a commit that referenced this issue Jun 26, 2024
Add missing tests uncovered by
#92555.

Includes test for #96294 and
#96328
lravenclaw pushed a commit to lravenclaw/llvm-project that referenced this issue Jul 3, 2024
Add missing tests uncovered by
llvm#92555.

Includes test for llvm#96294 and
llvm#96328
@fhahn
Copy link
Contributor

fhahn commented Jul 5, 2024

Closing this as the patch has been reverted for now and a test case has been added in 8681bb8

@fhahn fhahn closed this as completed Jul 5, 2024
AlexisPerry pushed a commit to llvm-project-tlp/llvm-project that referenced this issue Jul 9, 2024
Add missing tests uncovered by
llvm#92555.

Includes test for llvm#96294 and
llvm#96328
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] vectorizers
Projects
None yet
Development

No branches or pull requests

3 participants