Issue 139879
Summary [AArch64] Failure to select 64-bit SLI intrinsics with immediate 0
Labels new issue
Assignees
Reporter ostannard
    The AArch64 backend hits a "cannot select" error for these two AArch64 AdvSIMD intrinsic calls:

```c
#include <arm_neon.h>

uint64_t foo(uint64_t c) { return vslid_n_u64(c, c, 0); }
uint64x1_t bar(uint64x1_t c) { return vsli_n_u64(c, c, 0); }
```

```
$ /work/llvm/build/bin/clang --target=aarch64-none-elf -S test.c -o - -O1
        .file   "test.c"
fatal error: error in backend: Cannot select: t17: v1i64 = AArch64ISD::VSLI t18, t18, Constant:i32<0>
 t18: v1i64 = scalar_to_vector t2
    t2: i64,ch = CopyFromReg t0, Register:i64 %0
      t1: i64 = Register %0
  t18: v1i64 = scalar_to_vector t2
    t2: i64,ch = CopyFromReg t0, Register:i64 %0
      t1: i64 = Register %0
  t7: i32 = Constant<0>
In function: foo
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: /work/llvm/build/bin/clang --target=aarch64-none-elf -S test.c -o - -O1
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'test.c'.
4.      Running pass 'AArch64 Instruction Selection' on function '@foo'
 #0 0x0000556cc8818207 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/work/llvm/build/bin/clang+0x87ae207)
 #1 0x0000556cc8815dfe llvm::sys::RunSignalHandlers() (/work/llvm/build/bin/clang+0x87abdfe)
 #2 0x0000556cc877e158 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) CrashRecoveryContext.cpp:0:0
 #3 0x0000556cc877e0ef llvm::CrashRecoveryContext::HandleExit(int) (/work/llvm/build/bin/clang+0x87140ef)
 #4 0x0000556cc88126a7 llvm::sys::Process::Exit(int, bool) (/work/llvm/build/bin/clang+0x87a86a7)
 #5 0x0000556cc5cd3605 (/work/llvm/build/bin/clang+0x5c69605)
 #6 0x0000556cc8786680 llvm::report_fatal_error(llvm::Twine const&, bool) (/work/llvm/build/bin/clang+0x871c680)
 #7 0x0000556cc9c75601 llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/work/llvm/build/bin/clang+0x9c0b601)
 #8 0x0000556cc9c745b2 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/work/llvm/build/bin/clang+0x9c0a5b2)
 #9 0x0000556cc5f90ab7 (anonymous namespace)::AArch64DAGToDAGISel::Select(llvm::SDNode*) AArch64ISelDAGToDAG.cpp:0:0
#10 0x0000556cc9c68e7d llvm::SelectionDAGISel::DoInstructionSelection() (/work/llvm/build/bin/clang+0x9bfee7d)
#11 0x0000556cc9c67e17 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/work/llvm/build/bin/clang+0x9bfde17)
#12 0x0000556cc9c65b2c llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/work/llvm/build/bin/clang+0x9bfbb2c)
#13 0x0000556cc9c62b01 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/work/llvm/build/bin/clang+0x9bf8b01)
#14 0x0000556cc9c60329 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/work/llvm/build/bin/clang+0x9bf6329)
#15 0x0000556cc7c49d18 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/work/llvm/build/bin/clang+0x7bdfd18)
#16 0x0000556cc81d250b llvm::FPPassManager::runOnFunction(llvm::Function&) (/work/llvm/build/bin/clang+0x816850b)
#17 0x0000556cc81da341 llvm::FPPassManager::runOnModule(llvm::Module&) (/work/llvm/build/bin/clang+0x8170341)
#18 0x0000556cc81d2f1f llvm::legacy::PassManagerImpl::run(llvm::Module&) (/work/llvm/build/bin/clang+0x8168f1f)
#19 0x0000556cc8fbc8de clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/work/llvm/build/bin/clang+0x8f528de)
#20 0x0000556cc8fd1520 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/work/llvm/build/bin/clang+0x8f67520)
#21 0x0000556ccaa7d717 clang::ParseAST(clang::Sema&, bool, bool) (/work/llvm/build/bin/clang+0xaa13717)
#22 0x0000556cc95e3ad6 clang::FrontendAction::Execute() (/work/llvm/build/bin/clang+0x9579ad6)
#23 0x0000556cc954e5af clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/work/llvm/build/bin/clang+0x94e45af)
#24 0x0000556cc96e4b20 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/work/llvm/build/bin/clang+0x967ab20)
#25 0x0000556cc5cd2dd0 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/work/llvm/build/bin/clang+0x5c68dd0)
#26 0x0000556cc5ccf091 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#27 0x0000556cc9395259 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::$_1>(long) Job.cpp:0:0
#28 0x0000556cc877e08b llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/work/llvm/build/bin/clang+0x871408b)
#29 0x0000556cc93947c0 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/work/llvm/build/bin/clang+0x932a7c0)
#30 0x0000556cc93512d3 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/work/llvm/build/bin/clang+0x92e72d3)
#31 0x0000556cc93515d7 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/work/llvm/build/bin/clang+0x92e75d7)
#32 0x0000556cc9370e09 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/work/llvm/build/bin/clang+0x9306e09)
#33 0x0000556cc5cce46f clang_main(int, char**, llvm::ToolContext const&) (/work/llvm/build/bin/clang+0x5c6446f)
#34 0x0000556cc5cdfb47 main (/work/llvm/build/bin/clang+0x5c75b47)
#35 0x00007f06f9c29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#36 0x00007f06f9c29e40 call_init ./csu/../csu/libc-start.c:128:20
#37 0x00007f06f9c29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#38 0x0000556cc5ccc8e5 _start (/work/llvm/build/bin/clang+0x5c628e5)
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 21.0.0git (g...@github.com:llvm/llvm-project.git c3ce5684a8b408220eed983d065edba0e6ed5016)
Target: aarch64-unknown-none-elf
Thread model: posix
InstalledDir: /work/llvm/build/bin
Build config: +assertions
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/test-65c08e.c
clang: note: diagnostic msg: /tmp/test-65c08e.sh
clang: note: diagnostic msg: 

********************
```

Zero is a valid immediate according to https://developer.arm.com/architectures/instruction-sets/intrinsics/vslid_n_u64, and is valid for the SLI instruction.

The signed versions of these intrinsics are also affected, but the `uint64x2_t` and `int64x2_t` versions are not.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to