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

    <tr>
        <th>Summary</th>
        <td>
            [WASM] Vector Multiplication Crash for 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

The following code targeting `wasm32` or `wasm64` with `simd128` feature crashes LLC with assertion error `(LaneBits == 64 || Val >= -(1ll << (LaneBits - 1))) && "Unexpected out of bounds negative value"` failed.

## Minimal Repoduction

https://godbolt.org/z/fdvE7jqcd

### Code

```ll
define void @f(ptr %0, ptr %pr) {
BB:
  %v0 = load <4 x i32>, ptr %0
  %v1 = icmp ugt <4 x i32> %v0, <i32 0, i32 1, i32 2, i32 3>
  %v2 = zext <4 x i1> %v1 to <4 x i8>
  %v3 = ashr <4 x i8> <i8 16, i8 16, i8 16, i8 16>, %v2
  %v4 = mul <4 x i8> %v3, %v3
  store <4 x i8> %v4, ptr %pr
  ret void
}
```

### Stack Trace

```console
llc: /home/henry/IRFuzzer/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp:2151: llvm::SDValue llvm::WebAssemblyTargetLowering::LowerBUILD_VECTOR(llvm::SDValue, llvm::SelectionDAG &) const: Assertion `(LaneBits == 64 || Val >= -(1ll << (LaneBits - 1))) && "Unexpected out of bounds negative value"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: ./llvm-project/build-debug/bin/llc --mtriple=wasm32 --mattr=+simd128 ./tmp/crash-reports/2.ll
1.      Running pass 'Function Pass Manager' on module './tmp/crash-reports/2.ll'.
2.      Running pass 'WebAssembly Instruction Selection' on function '@f'
 #0 0x00007ffb3e69969d llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/henry/IRFuzzer/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:11
 #1 0x00007ffb3e699b2b PrintStackTraceSignalHandler(void*) /home/henry/IRFuzzer/llvm-project/llvm/lib/Support/Unix/Signals.inc:639:1
 #2 0x00007ffb3e697db6 llvm::sys::RunSignalHandlers() /home/henry/IRFuzzer/llvm-project/llvm/lib/Support/Signals.cpp:104:5
 #3 0x00007ffb3e69a345 SignalHandler(int) /home/henry/IRFuzzer/llvm-project/llvm/lib/Support/Unix/Signals.inc:410:1
 #4 0x00007ffb3de98520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #5 0x00007ffb3deeca7c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x96a7c)
 #6 0x00007ffb3de98476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #7 0x00007ffb3de7e7f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #8 0x00007ffb3de7e71b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #9 0x00007ffb3de8fe96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#10 0x00007ffb46a443a0 llvm::WebAssemblyTargetLowering::LowerBUILD_VECTOR(llvm::SDValue, llvm::SelectionDAG&) const /home/henry/IRFuzzer/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp:2152:13
#11 0x00007ffb46a406a8 llvm::WebAssemblyTargetLowering::LowerOperation(llvm::SDValue, llvm::SelectionDAG&) const /home/henry/IRFuzzer/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp:1427:12
#12 0x00007ffb42d924ad (anonymous namespace)::SelectionDAGLegalize::LegalizeOp(llvm::SDNode*) /home/henry/IRFuzzer/llvm-project/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1294:29
#13 0x00007ffb42d90ba4 llvm::SelectionDAG::Legalize() /home/henry/IRFuzzer/llvm-project/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:5130:13
#14 0x00007ffb43001a75 llvm::SelectionDAGISel::CodeGenAndEmitDAG() /home/henry/IRFuzzer/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:904:3
#15 0x00007ffb430008fd llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, bool&) /home/henry/IRFuzzer/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:700:1
#16 0x00007ffb4300038e llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) /home/henry/IRFuzzer/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1638:11
#17 0x00007ffb42ffd8c0 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) /home/henry/IRFuzzer/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:480:3
#18 0x00007ffb46a302ca (anonymous namespace)::WebAssemblyDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) /home/henry/IRFuzzer/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp:60:5
#19 0x00007ffb41f5d9c5 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /home/henry/IRFuzzer/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:91:8
#20 0x00007ffb3f0e4486 llvm::FPPassManager::runOnFunction(llvm::Function&) /home/henry/IRFuzzer/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1430:23
#21 0x00007ffb3f0e92b2 llvm::FPPassManager::runOnModule(llvm::Module&) /home/henry/IRFuzzer/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1476:16
#22 0x00007ffb3f0e4d59 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /home/henry/IRFuzzer/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1545:23
#23 0x00007ffb3f0e48cd llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/henry/IRFuzzer/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:535:16
#24 0x00007ffb3f0e9591 llvm::legacy::PassManager::run(llvm::Module&) /home/henry/IRFuzzer/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1672:3
#25 0x000055d527591650 compileModule(char**, llvm::LLVMContext&) /home/henry/IRFuzzer/llvm-project/llvm/tools/llc/llc.cpp:736:41
#26 0x000055d52758fa2d main /home/henry/IRFuzzer/llvm-project/llvm/tools/llc/llc.cpp:420:13
#27 0x00007ffb3de7fd90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#28 0x00007ffb3de7fe40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#29 0x000055d52758f205 _start (./llvm-project/build-debug/bin/llc+0x19205)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUWd1u27gSfhrmhohBDfV7kQvHjrsBktMi6XYvA0qibG4pUYek8vf0B6TkWFJSpNm22R7AsCmK_Ga-meEMSTNjxLbh_ARFpyhaH7HO7pQ--YM9PmyE2R3lqnw4QUARULzmptCitUI1iKwRWfbfn3ccV0pKdSeaLS5UybFlesute0QxuWOmpoBigpXeP8ehe74Tdud6jKjLAFLXVXFmO81xoZnZcYMvLlb9MGYM10405lr3QAjSC9bwU2ENRnSN6BrHIUbJCiUr_IVJjOiZ6zxGkAbSPa4QXeHxtGMcIMj6D0YQI4gxAviz4fctLywvseosVhXOVdeUBjd8y6y45fiWyY4j8LQqJiQvF2ObDBa7FI2omcRXvFVlV8wtt7O2NYguEWwQbLaqzJW0C6W3CDaPCDZVeXuW_P3fonwO7dBXquSTNzHpP1L2HSWvRMPxrRIlRiGpEKSt1RhBRBCs8NButSefnPaTTk-dRr6J3etb4oyLpWKls2CI77Gg4Ex7gCDj8YEfL4q6xd3WTuf0gG4moitBAfu2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