llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[X86][GISel] clang crashed on empty function with vector argument at -O0

Open XChy opened this issue 1 year ago • 4 comments

Reproducer: https://godbolt.org/z/1W1aPsEsz Reduced C testcase:

#include <stdint.h>
#define BS_VEC(type, num) type __attribute__((vector_size(num * sizeof(type))))
int64_t backsmith_pure_2(BS_VEC(uint32_t, 2)) {}

clang output:

<source>:4:45: warning: omitting the parameter name in a function definition is a C23 extension [-Wc23-extensions]
    4 | int64_t backsmith_pure_2(BS_VEC(uint32_t, 2)) {}
      |                                             ^
<source>:4:48: warning: non-void function does not return a value [-Wreturn-type]
    4 | int64_t backsmith_pure_2(BS_VEC(uint32_t, 2)) {}
      |                                                ^
Unsupported register size.
UNREACHABLE executed at /root/llvm-project/llvm/lib/Target/X86/GISel/X86RegisterBankInfo.cpp:190!
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: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O0 -mllvm -global-isel -mllvm -global-isel-abort=2 <source>
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module '<source>'.
4.	Running pass 'RegBankSelect' on function '@backsmith_pure_2'
 #0 0x0000000004238d78 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4238d78)
 #1 0x00000000042361a4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x42361a4)
 #2 0x000000000417a418 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007d278b242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007d278b2969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x00007d278b242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007d278b2287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x0000000004185ffa (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4185ffa)
 #8 0x0000000002d82989 llvm::X86GenRegisterBankInfo::getPartialMappingIdx(llvm::MachineInstr const&, llvm::LLT const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x2d82989)
 #9 0x0000000002d82b42 llvm::X86RegisterBankInfo::getInstrPartialMappingIdxs(llvm::MachineInstr const&, llvm::MachineRegisterInfo const&, bool, llvm::SmallVectorImpl<llvm::X86GenRegisterBankInfo::PartialMappingIdx>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x2d82b42)
#10 0x0000000002d840cd llvm::X86RegisterBankInfo::getInstrMapping(llvm::MachineInstr const&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x2d840cd)
#11 0x0000000005648f57 llvm::RegBankSelect::assignInstr(llvm::MachineInstr&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5648f57)
#12 0x00000000056494f5 llvm::RegBankSelect::assignRegisterBanks(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x56494f5)
#13 0x0000000005649736 llvm::RegBankSelect::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5649736)
#14 0x00000000034ebb59 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#15 0x0000000003b350a6 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3b350a6)
#16 0x0000000003b35451 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3b35451)
#17 0x0000000003b35cbf llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3b35cbf)
#18 0x00000000044f97f6 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*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44f97f6)
#19 0x0000000004b83fa7 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4b83fa7)
#20 0x0000000006926d7c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6926d7c)
#21 0x0000000004b84408 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4b84408)
#22 0x0000000004e72255 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4e72255)
#23 0x0000000004df319e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4df319e)
#24 0x0000000004f6a9cd clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4f6a9cd)
#25 0x0000000000dcd1b0 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdcd1b0)
#26 0x0000000000dc3d2a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#27 0x0000000000dc3ead int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::'lambda'(llvm::SmallVectorImpl<char const*>&)>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#28 0x0000000004bedcb9 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
#29 0x000000000417a8b4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x417a8b4)
#30 0x0000000004bee2cf 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
#31 0x0000000004baf022 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4baf022)
#32 0x0000000004baffce clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4baffce)
#33 0x0000000004bb7725 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4bb7725)
#34 0x0000000000dc96d1 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdc96d1)
#35 0x0000000000c79094 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc79094)
#36 0x00007d278b229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#37 0x00007d278b229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#38 0x0000000000dc37c5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdc37c5)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134

XChy avatar Nov 05 '25 09:11 XChy

@llvm/issue-subscribers-backend-x86

Author: Hongyu Chen (XChy)

Reproducer: https://godbolt.org/z/1W1aPsEsz Reduced C testcase: ```c #include <stdint.h> #define BS_VEC(type, num) type __attribute__((vector_size(num * sizeof(type)))) int64_t backsmith_pure_2(BS_VEC(uint32_t, 2)) {} ```

clang output:

&lt;source&gt;:4:45: warning: omitting the parameter name in a function definition is a C23 extension [-Wc23-extensions]
    4 | int64_t backsmith_pure_2(BS_VEC(uint32_t, 2)) {}
      |                                             ^
&lt;source&gt;:4:48: warning: non-void function does not return a value [-Wreturn-type]
    4 | int64_t backsmith_pure_2(BS_VEC(uint32_t, 2)) {}
      |                                                ^
Unsupported register size.
UNREACHABLE executed at /root/llvm-project/llvm/lib/Target/X86/GISel/X86RegisterBankInfo.cpp:190!
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: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O0 -mllvm -global-isel -mllvm -global-isel-abort=2 &lt;source&gt;
1.	&lt;eof&gt; parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module '&lt;source&gt;'.
4.	Running pass 'RegBankSelect' on function '@<!-- -->backsmith_pure_2'
 #<!-- -->0 0x0000000004238d78 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4238d78)
 #<!-- -->1 0x00000000042361a4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x42361a4)
 #<!-- -->2 0x000000000417a418 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #<!-- -->3 0x00007d278b242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #<!-- -->4 0x00007d278b2969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #<!-- -->5 0x00007d278b242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #<!-- -->6 0x00007d278b2287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #<!-- -->7 0x0000000004185ffa (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4185ffa)
 #<!-- -->8 0x0000000002d82989 llvm::X86GenRegisterBankInfo::getPartialMappingIdx(llvm::MachineInstr const&amp;, llvm::LLT const&amp;, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x2d82989)
 #<!-- -->9 0x0000000002d82b42 llvm::X86RegisterBankInfo::getInstrPartialMappingIdxs(llvm::MachineInstr const&amp;, llvm::MachineRegisterInfo const&amp;, bool, llvm::SmallVectorImpl&lt;llvm::X86GenRegisterBankInfo::PartialMappingIdx&gt;&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x2d82b42)
#<!-- -->10 0x0000000002d840cd llvm::X86RegisterBankInfo::getInstrMapping(llvm::MachineInstr const&amp;) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x2d840cd)
#<!-- -->11 0x0000000005648f57 llvm::RegBankSelect::assignInstr(llvm::MachineInstr&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5648f57)
#<!-- -->12 0x00000000056494f5 llvm::RegBankSelect::assignRegisterBanks(llvm::MachineFunction&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x56494f5)
#<!-- -->13 0x0000000005649736 llvm::RegBankSelect::runOnMachineFunction(llvm::MachineFunction&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5649736)
#<!-- -->14 0x00000000034ebb59 llvm::MachineFunctionPass::runOnFunction(llvm::Function&amp;) (.part.0) MachineFunctionPass.cpp:0:0
#<!-- -->15 0x0000000003b350a6 llvm::FPPassManager::runOnFunction(llvm::Function&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3b350a6)
#<!-- -->16 0x0000000003b35451 llvm::FPPassManager::runOnModule(llvm::Module&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3b35451)
#<!-- -->17 0x0000000003b35cbf llvm::legacy::PassManagerImpl::run(llvm::Module&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3b35cbf)
#<!-- -->18 0x00000000044f97f6 clang::emitBackendOutput(clang::CompilerInstance&amp;, clang::CodeGenOptions&amp;, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr&lt;llvm::vfs::FileSystem&gt;, std::unique_ptr&lt;llvm::raw_pwrite_stream, std::default_delete&lt;llvm::raw_pwrite_stream&gt;&gt;, clang::BackendConsumer*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44f97f6)
#<!-- -->19 0x0000000004b83fa7 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4b83fa7)
#<!-- -->20 0x0000000006926d7c clang::ParseAST(clang::Sema&amp;, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6926d7c)
#<!-- -->21 0x0000000004b84408 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4b84408)
#<!-- -->22 0x0000000004e72255 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4e72255)
#<!-- -->23 0x0000000004df319e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4df319e)
#<!-- -->24 0x0000000004f6a9cd clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4f6a9cd)
#<!-- -->25 0x0000000000dcd1b0 cc1_main(llvm::ArrayRef&lt;char const*&gt;, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdcd1b0)
#<!-- -->26 0x0000000000dc3d2a ExecuteCC1Tool(llvm::SmallVectorImpl&lt;char const*&gt;&amp;, llvm::ToolContext const&amp;, llvm::IntrusiveRefCntPtr&lt;llvm::vfs::FileSystem&gt;) driver.cpp:0:0
#<!-- -->27 0x0000000000dc3ead int llvm::function_ref&lt;int (llvm::SmallVectorImpl&lt;char const*&gt;&amp;)&gt;::callback_fn&lt;clang_main(int, char**, llvm::ToolContext const&amp;)::'lambda'(llvm::SmallVectorImpl&lt;char const*&gt;&amp;)&gt;(long, llvm::SmallVectorImpl&lt;char const*&gt;&amp;) driver.cpp:0:0
#<!-- -->28 0x0000000004bedcb9 void llvm::function_ref&lt;void ()&gt;::callback_fn&lt;clang::driver::CC1Command::Execute(llvm::ArrayRef&lt;std::optional&lt;llvm::StringRef&gt;&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;*, bool*) const::'lambda'()&gt;(long) Job.cpp:0:0
#<!-- -->29 0x000000000417a8b4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref&lt;void ()&gt;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x417a8b4)
#<!-- -->30 0x0000000004bee2cf clang::driver::CC1Command::Execute(llvm::ArrayRef&lt;std::optional&lt;llvm::StringRef&gt;&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;*, bool*) const (.part.0) Job.cpp:0:0
#<!-- -->31 0x0000000004baf022 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&amp;, clang::driver::Command const*&amp;, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4baf022)
#<!-- -->32 0x0000000004baffce clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4baffce)
#<!-- -->33 0x0000000004bb7725 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4bb7725)
#<!-- -->34 0x0000000000dc96d1 clang_main(int, char**, llvm::ToolContext const&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdc96d1)
#<!-- -->35 0x0000000000c79094 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc79094)
#<!-- -->36 0x00007d278b229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#<!-- -->37 0x00007d278b229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#<!-- -->38 0x0000000000dc37c5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xdc37c5)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134

llvmbot avatar Nov 05 '25 09:11 llvmbot

More explicit examples are:

define hidden void @foo(ptr %args, ptr %sunkaddr420)  {
  %5 = load <2 x i32>, ptr %args, align 4
  store <2 x i32> %5, ptr %sunkaddr420, align 4
  ret void
}
define hidden void @bar(ptr %args, ptr %sunkaddr420)  {
  %5 = load <4 x i8>, ptr %args, align 4
  store <4 x i8> %5, ptr %sunkaddr420, align 4
  ret void
}

Such vectors on GPRs are poorly supported now.

e-kud avatar Nov 18 '25 17:11 e-kud

Confirming on upstream/main faba310ff3e76fb8fd9d279d01d7af98943ef044 (LLVM 24.0.0git, assertions on), with one piece of narrowing that may help whoever picks this up: the abort is about the width of the vector that reaches RegBankSelect, not about vectors in general, and it reproduces without a function argument.

Minimal form

define void @s1(<2 x i32> %v, ptr %p) {
  store <2 x i32> %v, ptr %p
  ret void
}
$ llc -mtriple=x86_64-unknown-linux-gnu -global-isel -O0 repro.ll -o /dev/null
Unsupported register size.
UNREACHABLE executed at .../X86RegisterBankInfo.cpp:190!

The legalizer leaves the value as a 64-bit vector (G_UNMERGE_VALUES of the incoming <4 x s32>), and getPartialMappingIdx falls into the final else scalar/FP branch of X86RegisterBankInfo::getPartialMappingIdx, whose vector arm only knows 128/256/512. A 64-bit vector therefore has no partial mapping at all.

Observed widths

stored value result
<2 x i64> (128-bit) rc=0
<4 x i32> (128-bit) rc=0
<2 x i32> (64-bit) 134, X86RegisterBankInfo.cpp:190
<4 x i8> (32-bit) 134, X86RegisterBankInfo.cpp:190
<2 x i16> (32-bit) 1, cannot select: %10:gr16(s16), ...
<4 x i16> (64-bit) 1, cannot select: %14:gr16(s16), ...

So the 32/64-bit vectors fail in two different places depending on where the legalizer put them, which matches e-kud's note that "such vectors on GPRs are poorly supported now".

Related

The same 64-bit shape also livelocks the legalizer earlier in the pipeline when a <2 x i32> G_BUILD_VECTOR has to be legalized — I filed that separately as #236649, since the symptom and the fix are different.

nodecoda avatar Oct 29 '26 04:10 nodecoda

Confirming on upstream/main 05c41f574638 (LLVM 24.0.0git, assertions on), and adding the missing link between the two tables: the reason a 64-bit vector survives all the way to RegBankSelect is that the legalizer explicitly declares it legal.

llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp:349-357:

Action.legalForTypesWithMemDesc({{s8, p0, s8, 1},
                                 ...
                                 {v4s8, p0, v4s8, 1}});   // 32-bit vector
if (Is64Bit)
  Action.legalForTypesWithMemDesc(
      {{s64, p0, s64, 1}, {v2s32, p0, v2s32, 1}});        // 64-bit vector

With -debug-only=legalizer both instructions are reported as untouched:

Legalizing: G_STORE %2:_(<2 x s32>), %1:_(p0) :: (store (<2 x s32>) into %ir.q)
.. Already legal
Legalizing: %2:_(<2 x s32>) = G_LOAD %0:_(p0) :: (load (<2 x s32>) from %ir.p)
.. Already legal
Unsupported register size.

X86RegisterBankInfo.cpp:181-190 then has no arm for these widths:

} else {
  switch (Ty.getSizeInBits()) {
  case 128: return PMI_VEC128;
  case 256: return PMI_VEC256;
  case 512: return PMI_VEC512;
  default:  llvm_unreachable("Unsupported register size.");
  }
}

So the two tables disagree: the legalizer says <2 x s32> / <4 x s8> memory operands are legal, RegBankSelect says no 32/64-bit vector mapping exists. Minimal repro (llc -O0, x86-64):

define void @f(ptr %p, ptr %q) {
  %a = load <2 x i32>, ptr %p
  store <2 x i32> %a, ptr %q
  ret void
}

-global-isel-abort=2 cannot recover here, because the abort happens in RegBankSelect, after the legalizer has already accepted the type.

Fix direction is therefore one of: drop the v2s32/v4s8 legal memory declarations so these values get split/scalarized (and reach SDAG fallback), or teach getPartialMappingIdx about 32/64-bit vectors so the two tables agree.

nodecoda avatar Nov 04 '26 07:11 nodecoda