[PATCH] D140580: [SLP]Do not emit many extractelements, reuse the single one emitted.
Alexey Bataev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 9 07:25:19 PST 2023
ABataev added a comment.
In D140580#4032808 <https://reviews.llvm.org/D140580#4032808>, @dyung wrote:
> Hi @ABataev, we are also seeing an internal test hit an assertion failure which I bisected back to your change and it is still currently failing with ToT (8304f6de94872cdcaba63039a61b8860fe367620 <https://reviews.llvm.org/rG8304f6de94872cdcaba63039a61b8860fe367620>).
>
> c++
> double *a, *f, *g, *h, *i;
> double b;
> long c, d, e, j;
> void k() {
> for (;;) {
> h = &b;
> i = &b + j;
> for (; c; c++) {
> d = f[c];
> e = i[c] - h[c];
> a[c] = g[c];
> a[j + c] = d;
> a[2 * j + c] = e;
> a[3 * j + c] = c;
> }
> }
> }
>
> Compile with "-O2 -mavx2" to show the crash:
>
> $ ~/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang -c -O2 -mavx2 test.cpp
> clang: /home/dyung/src/upstream/llvm_clean_git/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:8820: llvm::Value* llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int): Assertion `I->get()->isSame(VL) && "Expected same list of scalars."' failed.
> PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
> Stack dump:
> 0. Program arguments: /home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang -c -O2 -mavx2 test.cpp
> 1. <eof> parser at end of file
> 2. Optimizer
> #0 0x000056362caf68ff llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x3f968ff)
> #1 0x000056362caf489c llvm::sys::CleanupOnSignal(unsigned long) (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x3f9489c)
> #2 0x000056362ca43e78 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
> #3 0x00007f86cd094420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
> #4 0x00007f86ccb6100b raise /build/glibc-SzIz7B/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
> #5 0x00007f86ccb40859 abort /build/glibc-SzIz7B/glibc-2.31/stdlib/abort.c:81:7
> #6 0x00007f86ccb40729 get_sysdep_segment_value /build/glibc-SzIz7B/glibc-2.31/intl/loadmsgcat.c:509:8
> #7 0x00007f86ccb40729 _nl_load_domain /build/glibc-SzIz7B/glibc-2.31/intl/loadmsgcat.c:970:34
> #8 0x00007f86ccb51fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
> #9 0x000056362cdefcd1 llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int) (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x428fcd1)
> #10 0x000056362cdf2310 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*) (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x4292310)
> #11 0x000056362cdef071 llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int) (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x428f071)
> #12 0x000056362cdf0268 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*) (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x4290268)
> #13 0x000056362cdff568 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::MapVector<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>, llvm::DenseMap<llvm::Value*, unsigned int, llvm::DenseMapInfo<llvm::Value*, void>, llvm::detail::DenseMapPair<llvm::Value*, unsigned int>>, std::vector<std::pair<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>>, std::allocator<std::pair<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>>>>>&, llvm::Instruction*) (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x429f568)
> #14 0x000056362ce0e5c1 (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&) SLPVectorizer.cpp:0:0
> #15 0x000056362ce10664 llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Value*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x42b0664)
> #16 0x000056362ce14706 llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Value*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*) (.constprop.0) SLPVectorizer.cpp:0:0
> #17 0x000056362ce17e12 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x42b7e12)
> #18 0x000056362ce1ad77 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
> #19 0x000056362ce1bb6c llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x42bbb6c)
> #20 0x000056362dec7676 llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x5367676)
> #21 0x000056362a374cb4 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x1814cb4)
> #22 0x000056362c36bf7f llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x380bf7f)
> #23 0x000056362a35b2a6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x17fb2a6)
> #24 0x000056362c36a0aa llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x380a0aa)
> #25 0x000056362cef42d8 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&) BackendUtil.cpp:0:0
> #26 0x000056362cef7274 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) BackendUtil.cpp:0:0
> #27 0x000056362cef7db5 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x4397db5)
> #28 0x000056362de6b43b clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x530b43b)
> #29 0x000056362eddd275 clang::ParseAST(clang::Sema&, bool, bool) (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x627d275)
> #30 0x000056362de69eb8 clang::CodeGenAction::ExecuteAction() (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x5309eb8)
> #31 0x000056362d6e2579 clang::FrontendAction::Execute() (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x4b82579)
> #32 0x000056362d668d5e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x4b08d5e)
> #33 0x000056362d7c7fe3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x4c67fe3)
> #34 0x0000563629feca84 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x148ca84)
> #35 0x0000563629fe8bc7 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
> #36 0x000056362d4d2369 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
> #37 0x000056362ca4461a llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x3ee461a)
> #38 0x000056362d4d2c1f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
> #39 0x000056362d49bdac clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x493bdac)
> #40 0x000056362d49c82d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x493c82d)
> #41 0x000056362d4a5c6c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x4945c6c)
> #42 0x0000563629feb202 clang_main(int, char**) (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x148b202)
> #43 0x00007f86ccb42083 __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:342:3
> #44 0x0000563629fe38ce _start (/home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin/clang+0x14838ce)
> clang-16: error: clang frontend command failed with exit code 134 (use -v to see invocation)
> clang version 16.0.0 (https://github.com/llvm/llvm-project.git 8304f6de94872cdcaba63039a61b8860fe367620)
> Target: x86_64-unknown-linux-gnu
> Thread model: posix
> InstalledDir: /home/dyung/src/upstream/8304f6de94872cdcaba63039a61b8860fe367620-linux/bin
>
> Can you take a look?
Tried to reproduce but was unable to do it. Try to update the compiler, maybe it was fixed already
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D140580/new/
https://reviews.llvm.org/D140580
More information about the llvm-commits
mailing list