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

    <tr>
        <th>Summary</th>
        <td>
             LLVM ERROR: Cannot select: 0x89658f0: ch = store<(store (s16) into `ptr undef`), trunc to bf16> 0x8965ea0, 0x8965dc0, undef:i64, undef:i64
        </td>
    </tr>

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

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

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

<pre>
    # Description
The following code generated by a Fuzzer tool causes crashes in LLVM Compiler (LLC) versions 17.0.1 and 18.1.0. The error message is as follows: "LLVM ERROR: Cannot select: 0x8d60da0: ch = store<(store (s16) into ptr undef), trunc to bf16> 0x8d61350, 0x8d61270, undef:i64, undef:i64."

# Minimal Reproduction
https://godbolt.org/z/K131ef86s

## code
```
; ModuleID = 'Fuzzer input'
source_filename = "M"

@G = global i1 true
@G.1 = global i2 1
@G.2 = global float 0x7FF8000000000000

define i32 @f() {
BB:
  %LGV = load i1, ptr @G, align 1
  %CastExt = zext i1 %LGV to i2
  %RP = alloca i32, align 4
  %Castaddrspacecast1 = addrspacecast ptr %RP to ptr addrspace(1)
 %L = load i8, ptr addrspace(1) %Castaddrspacecast1, align 1
  %0 = load i32, ptr %RP, align 4
  store ptr addrspace(1) %Castaddrspacecast1, ptr undef, align 8
  store i2 %CastExt, ptr @G.1, align 1
  %CastIToFP = uitofp i8 %L to float
  store float %CastIToFP, ptr @G.2, align 4
 %CastFPTrunc = fptrunc float %CastIToFP to bfloat
  store bfloat %CastFPTrunc, ptr undef, align 2
  ret i32 %0
}
```

## Stack Trace
```
LLVM ERROR: Cannot select: 0x8d60da0: ch = store<(store (s16) into `ptr undef`), trunc to bf16> 0x8d61350, 0x8d61270, undef:i64, undef:i64
  0x8d61270: f32 = uint_to_fp 0x8d61430
    0x8d61430: i32,ch = load<(dereferenceable load (s8) from %ir.Castaddrspacecast1, addrspace 1), zext from i8> 0x8d023a0, FrameIndex:i64<0>, undef:i64
      0x8d60f60: i64 = FrameIndex<0>
      0x8d60e10: i64 = undef
  0x8d60e10: i64 = undef
  0x8d60e10: i64 = undef
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-18.1.0/bin/llc -o /app/output.s -x86-asm-syntax=intel -mtriple aarch64 -global-isel -O0 <source>
1.      Running pass 'Function Pass Manager' on module '<source>'.
2.      Running pass 'AArch64 Instruction Selection' on function '@f'
 #0 0x00000000034ca4a8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-18.1.0/bin/llc+0x34ca4a8)
 #1 0x00000000034c7e1c SignalHandler(int) Signals.cpp:0:0
 #2 0x0000752347842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x00007523478969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x0000752347842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x00007523478287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x0000000000716f82 llvm::RISCVISAInfo::updateCombination() (.cold) RISCVISAInfo.cpp:0:0
 #7 0x00000000032a1bc4 llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/opt/compiler-explorer/clang-18.1.0/bin/llc+0x32a1bc4)
 #8 0x00000000032a7b85 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/opt/compiler-explorer/clang-18.1.0/bin/llc+0x32a7b85)
 #9 0x0000000000afc2cd (anonymous namespace)::AArch64DAGToDAGISel::Select(llvm::SDNode*) AArch64ISelDAGToDAG.cpp:0:0
#10 0x000000000329f147 llvm::SelectionDAGISel::DoInstructionSelection() (/opt/compiler-explorer/clang-18.1.0/bin/llc+0x329f147)
#11 0x00000000032ac465 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-18.1.0/bin/llc+0x32ac465)
#12 0x00000000032af12f llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-18.1.0/bin/llc+0x32af12f)
#13 0x00000000032b1819 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#14 0x000000000262f530 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#15 0x0000000002b425d2 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-18.1.0/bin/llc+0x2b425d2)
#16 0x0000000002b42751 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-18.1.0/bin/llc+0x2b42751)
#17 0x0000000002b443d0 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-18.1.0/bin/llc+0x2b443d0)
#18 0x00000000008126b4 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#19 0x0000000000728816 main (/opt/compiler-explorer/clang-18.1.0/bin/llc+0x728816)
#20 0x0000752347829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#21 0x0000752347829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#22 0x000000000080a31e _start (/opt/compiler-explorer/clang-18.1.0/bin/llc+0x80a31e)
Program terminated with signal: SIGSEGV
Compiler returned: 139
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0WF1v2zrS_jXKzcCCRH1f-MKx47zGm2yDpCiwVwElUTK3FCmQ1KnTX78gKTuS62xOTtOiSSSS88wzH5yhiJWiLSdk6SXXXrK5woPeC7nc0PaL3Ij2qhT1y9JDEWyIqiTtNRXcCzZesPq6J9AIxsQPyluoRE2gJZxIrEkN5Qtg2A4_fxIJWggGF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