<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/64266>64266</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [RISC-V] crash when using riscv_rvv_vector_bits attribute with `LMUL>1`, but works for fractional LMUL
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          camel-cdr
      </td>
    </tr>
</table>

<pre>
    It's seems like the `riscv_rvv_vector_bits` attribute results in a crash, when `LMUL>1`, but it works for fractional LMUL.

The code in question [[godbolt](https://godbolt.org/z/EK8jz495f)]:

```c
#include <riscv_vector.h>

typedef vuint8m4_t V128 __attribute__((riscv_rvv_vector_bits(512)));

V128 vadd8(V128 a, V128 b) {
    return __riscv_vadd_vv_u8m4(a, b, 16);
}
```

full report:

```
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-trunk/bin/clang -g -o /app/output.s -S -target riscv64-unknown-linux-gnu -march=rv64gc -mabi=lp64d --gcc-toolchain=/opt/compiler-explorer/riscv64/gcc-8.2.0/riscv64-unknown-linux-gnu --sysroot=/opt/compiler-explorer/riscv64/gcc-8.2.0/riscv64-unknown-linux-gnu/riscv64-unknown-linux-gnu/sysroot -fcolor-diagnostics -fno-crash-diagnostics -march=rv64gcv -O3 -mrvv-vector-bits=128 <source>
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module '<source>'.
4.      Running pass 'Live DEBUG_VALUE analysis' on function '@vadd8'
 #0 0x000000000336e3e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x336e3e8)
 #1 0x000000000336c514 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x336c514)
 #2 0x00000000032c0a58 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f2bdafbb420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x0000000002ad9591 (anonymous namespace)::VarLocBasedLDV::transferRegisterCopy(llvm::MachineInstr&, (anonymous namespace)::VarLocBasedLDV::OpenRangesSet&, (anonymous namespace)::VarLocBasedLDV::VarLocMap&, llvm::SmallVector<(anonymous namespace)::VarLocBasedLDV::TransferDebugPair, 4u>&) VarLocBasedImpl.cpp:0:0
 #5 0x0000000002adbdfc (anonymous namespace)::VarLocBasedLDV::ExtendRanges(llvm::MachineFunction&, llvm::MachineDominatorTree*, llvm::TargetPassConfig*, unsigned int, unsigned int) (.part.0) VarLocBasedImpl.cpp:0:0
 #6 0x0000000002834a60 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
 #7 0x0000000002d3bff2 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x2d3bff2)
 #8 0x0000000002d3c171 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x2d3c171)
 #9 0x0000000002d3dce0 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x2d3dce0)
#10 0x00000000035d39f0 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, 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>>) (/opt/compiler-explorer/clang-trunk/bin/clang+0x35d39f0)
#11 0x00000000045389bc clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x45389bc)
#12 0x00000000058f8329 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x58f8329)
#13 0x0000000004538045 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+0x4538045)
#14 0x0000000003df3971 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+0x3df3971)
#15 0x0000000003d78fab clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3d78fab)
#16 0x0000000003ed3803 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3ed3803)
#17 0x0000000000bd67f5 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+0xbd67f5)
#18 0x0000000000bcfb4d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#19 0x0000000003bc9ad9 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
#20 0x00000000032c0e83 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+0x32c0e83)
#21 0x0000000003bc9cf9 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
#22 0x0000000003b91cc7 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x3b91cc7)
#23 0x0000000003b9267d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x3b9267d)
#24 0x0000000003b9c5cc clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3b9c5cc)
#25 0x0000000000bd4451 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0xbd4451)
#26 0x0000000000ad0be1 main (/opt/compiler-explorer/clang-trunk/bin/clang+0xad0be1)
#27 0x00007f2bdaa5f083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#28 0x0000000000bcf34e _start (/opt/compiler-explorer/clang-trunk/bin/clang+0xbcf34e)
clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWV1zm7ga_jXKjQYPCGzji1w4drzbPek0E6e9ZYT0grUBiZWEk-yvPyPAMXKctttkz83ppLbRx6tHz_spRI0RpQS4RNMrNF1f0NbulL5ktIYqYFxf5Io_X36yiMwNNgC1wZV4AGx3gNEs1MKwfab3-2wPzCqd5cIaNAsxtVaLvLWANZi2sgYLiSlmmpodIiv8uAPpBNx8_nqD4usIzULXnLcWC4sflX4wuFAaF5oyK5SkFXZDJyhco3DZf97vADPFwYn-qwXjxuFuH1el4rmqLJquEUl31jYGxUtENohshq6J0iUim78R2Vz_J_3z72QxLRBZuBnxcryKQ9b9seGZxEKyquWAUbzqCeg3P9mh-Ho81T43wKHA-1ZIm9ZJZvG3iKQ4y17oyTJEUkTS80SSdBoRh6r_i6_G0jtRe8q5m989UEdh9ytHZIHRfBiPMcYabKslzrIBMeU82--zNq0TRNJuZu4-opm30nx9wsIYQdFWFdbQKG3fIq1_vL25Xm6vsWnzWlhMcd6WwzxsFT7Rj7C7Np8wVSOyqar94StotPoTmEVkI4xpwSCywVRyfNCGM8nOv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