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

    <tr>
        <th>Summary</th>
        <td>
            [x86_64] Cannot select `sint_to_fp` for `v8bf16` when targeting `sapphirerapids` / `znver4` CPU
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    ## Description

When casting `i16` vector to `bf16` vector using `uitofp` / `sitofp`, `x86_64` backend will crash with error `Cannot select: t17: v8bf16 = sint_to_fp t26` when targeting Intel `sapphirerapids` or AMD `znver4` CPU.

The problem doesn't exist when casting `i16` vector to `half` vector.
The problem doesn't exist when targeting `znver3`, `alderlake`, or `raptorlake` CPUs, or when CPU is not specified.

## Minimal Repoduction

https://godbolt.org/z/MKEb6rjns

### Code

```ll
define void @f(ptr %0, ptr %1) {
  %vi = load <4 x i16>, ptr %0
  %vf = uitofp <4 x i16> %vi to <4 x bfloat>
  store <4 x bfloat> %vf, ptr %1
  ret void
}
```

### Stack Trace

```console
LLVM ERROR: Cannot select: t17: v8bf16 = sint_to_fp t26
  t26: v8i32 = insert_subvector undef:v8i32, t14, Constant:i64<0>
    t25: v8i32 = undef
    t14: v4i32,ch = load<(load (s64) from %ir.0), zext from v4i16> t0, t2, undef:i64
      t2: i64,ch = CopyFromReg t0, Register:i64 %0
        t1: i64 = Register %0
      t6: i64 = undef
    t19: i64 = 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=x86_64 -mcpu=sapphirerapids <source>
1.      Running pass 'Function Pass Manager' on module '<source>'.
2.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@f'
 #0 0x0000000003398418 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3398418)
 #1 0x0000000003395d0c SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f51ad6d9420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007f51ad19c00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007f51ad17b859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x0000000000695331 (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x695331)
 #6 0x0000000003162a4d llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3162a4d)
 #7 0x0000000003164859 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3164859)
 #8 0x0000000001b7f921 (anonymous namespace)::X86DAGToDAGISel::Select(llvm::SDNode*) X86ISelDAGToDAG.cpp:0:0
 #9 0x000000000315f35f llvm::SelectionDAGISel::DoInstructionSelection() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x315f35f)
#10 0x000000000316c789 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x316c789)
#11 0x000000000316ff88 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x316ff88)
#12 0x0000000003171c82 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#13 0x0000000001b894bc (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) X86ISelDAGToDAG.cpp:0:0
#14 0x0000000002680049 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#15 0x0000000002bf8bb9 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2bf8bb9)
#16 0x0000000002bf8df1 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2bf8df1)
#17 0x0000000002bf9612 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2bf9612)
#18 0x000000000075e092 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#19 0x000000000069a7e6 main (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x69a7e6)
#20 0x00007f51ad17d083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#21 0x0000000000754a4e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x754a4e)
Program terminated with signal: SIGSEGV
Compiler returned: 139
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8WF9z4yry_TTkhbILof8PeXDsODf1m_xuKpl7d_bJhSRkcweBClDGmU-_1Uh2JMe7yZ117dQkdprW4XT3oUEwa8VWcX6N4hsUr65Y53baXP_Gfr6uhd1dFbp6vUY0RDTEK25LI1ontEJkhcii__2PHVe4ZNYJtcUoISJIUELwCy-dNthpsBX1xNjZwbcTTtctjCC6BoM9GBBdwt_7LNkkETgUrPzOVYV_CClxaZjd4R_C7TA3RhtwXTKltMOWS146FC6wC1L4eMlgdozCFbZCuY3Tm7rFjnpCP4C8Y2bLPf175bj0PFjb7oThhrWisuCpDV48rGDsp3rhxnNaPv4xH6fi647j1uhC8gZXmluFaOow3wvr-pk-SNOOyfrNOP8k6Bv9A7nwLYFMVtxI9p0Ppj5XhrVOH8wQhh3GPODy8Q8sLPbZbHkpasGrSZyDIB6EEg2T-Im3uurKU2HsnGstCheIrhFdb3VVaOnm2mwRXf9EdP3wf7dFYv5S9j00oC91xScjCen_S9kbKl4LxfGLFhVGEakR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