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

    <tr>
        <th>Summary</th>
        <td>
            [WASM] Cannot select BUILD_VECTOR when enabling SIMD128
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          HazyFish
      </td>
    </tr>
</table>

<pre>
    ## Description

When feature `simd128` is on, the following code crashes the WebAssembly backend (both `wasm32` and `wasm64`) with error `Cannot select: v16i8 = BUILD_VECTOR`。

## Minimal Reproduction

https://godbolt.org/z/o71M96j4P

### Code

```ll
define <4 x i8> @f(<4 x i8> %0) {
BB:
  %V1 = or <4 x i8> <i8 255, i8 255, i8 255, i8 255>, %0
  %V2 = insertelement <4 x i8> %V1, i8 17, i32 1
  ret <4 x i8> %V2
}
```

### Stack Trace

```console
LLVM ERROR: Cannot select: t27: v16i8 = BUILD_VECTOR Constant:i32<255>, Constant:i32<17>, Constant:i32<255>, Constant:i32<255>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>
  t25: i32 = Constant<255>
  t22: i32 = Constant<17>
  t25: i32 = Constant<255>
  t25: i32 = Constant<255>
  t26: i32 = Constant<0>
  t26: i32 = Constant<0>
  t26: i32 = Constant<0>
  t26: i32 = Constant<0>
  t26: i32 = Constant<0>
  t26: i32 = Constant<0>
  t26: i32 = Constant<0>
  t26: i32 = Constant<0>
  t26: i32 = Constant<0>
  t26: i32 = Constant<0>
  t26: i32 = Constant<0>
  t26: i32 = Constant<0>
In function: f
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/llc -o /app/output.s -x86-asm-syntax=intel -mtriple=wasm64 -mattr=+simd128 <source>
1.      Running pass 'Function Pass Manager' on module '<source>'.
2.      Running pass 'WebAssembly Instruction Selection' on function '@f'
 #0 0x000055f974a9115f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x354b15f)
 #1 0x000055f974a8e8b4 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f5bd0016420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007f5bcfae300b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007f5bcfac2859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x000055f971d20a66 llvm::RISCVISAInfo::updateImplication() (.cold) RISCVISAInfo.cpp:0:0
 #6 0x000055f97484e02d llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x330802d)
 #7 0x000055f97484ff6a llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3309f6a)
 #8 0x000055f9730b8b1f (anonymous namespace)::WebAssemblyDAGToDAGISel::Select(llvm::SDNode*) WebAssemblyISelDAGToDAG.cpp:0:0
 #9 0x000055f97484a630 llvm::SelectionDAGISel::DoInstructionSelection() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3304630)
#10 0x000055f974857e44 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3311e44)
#11 0x000055f97485b4c8 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x33154c8)
#12 0x000055f97485d192 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#13 0x000055f973d306ce llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#14 0x000055f9742ca7f1 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2d847f1)
#15 0x000055f9742caa39 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2d84a39)
#16 0x000055f9742cb2b2 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2d852b2)
#17 0x000055f971ddd634 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#18 0x000055f971d25f06 main (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x7dff06)
#19 0x00007f5bcfac4083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#20 0x000055f971dd3a1e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x88da1e)
Program terminated with signal: SIGSEGV
Compiler returned: 139
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWEtv4zgS_jX0hbBBkXpQBx8cO84YSLaDuDeNPRmUSNmcpkiBpCbJ_PoFJTuR3E53ZjdYYIEB8pBZxY9fPVxVFHNO7rUQc5BcgWQ1Ya0_GDv_jf35spbuMCkMf5kDTAAmcCVcaWXjpdEArQBa9H-_HYSGlWC-tQKCFDlZ8whTkCIoHTQa4CX0BwEro5R5knoPS8MFLC1zB-E60TdRLJwTdaFeYMHK70JzCDAtjD8ExCfmaoIDIAuCfiGNQYoAzuGT9AcorDU2iJZMa-OhE0qUHpAF_CNKJYWArODVPze3q93j9fLrl4ew95oAigDFQ2OOpt5JLWum4INorOFteW7zwfvGAbIAeA3wem94YZSfGbsHeP0nwGuTRXd5-nt8_yN2gF8aLkaSFPU_SvULXFRSCwjIMobPUFJAriGIUQUwHa_hpPMByK76jVdXgVX3CIP0MepMD74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