<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/96180>96180</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
LLVM ERROR: Cannot select: 0x7729100: ch = store<(store (s16) into %ir.x), trunc to bf16> 0x76cd240, 0x7728ed0, 0x7728fb0, undef:i64
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
DigOrDog
</td>
</tr>
</table>
<pre>
# Description
The following IR causes a crash in version 18 of the backend, but does not cause the crash in version 17.
# Minimal Reproduction
https://godbolt.org/z/x79jGaxqj
## code
```
define i32 @f(double %LGV, ptr %x) {
BB:
%CastFPTrunc = fptrunc double %LGV to bfloat
store bfloat %CastFPTrunc, ptr %x, align 2
ret i32 0
}
```
## Stack Trace
```
LLVM ERROR: Cannot select: 0x7729100: ch = store<(store (s16) into %ir.x), trunc to bf16> 0x76cd240, 0x7728ed0, 0x7728fb0, undef:i64
0x7728ed0: f64,ch = CopyFromReg 0x76cd240, Register:f64 %0
0x7728e60: f64 = Register %0
0x7728fb0: i64,ch = CopyFromReg 0x76cd240, Register:i64 %1
0x7728f40: i64 = Register %1
0x7729170: 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 0x00007ac867042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x00007ac8670969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#4 0x00007ac867042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#5 0x00007ac8670287f3 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 0x00007ac867029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#21 0x00007ac867029e40 __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/eJzUmF1z2ywWxz8NvmHsEUjWy4UvFDvOeqbZZuxOZ_YqgxCSaRFoAbXOfvodkORYrp9t02YvnkziSIjzPz84hwMyMYbXkrEVWN6B5WZGOntUerXh9Ue9UfWsUOXLCuAQbpihmreWKwmCDQjyT0cGKyWE-s5lDXd7SElnmIEEUk3MEXIJvzFtuJIQpVBV0B4ZLAj9ymQJ8BoWnYWlYgZKZXtb3-NH42TROxw-cQgfueQNEXDPWq3Kjr5CHa1tDQhzgLcAb2tVFkrYhdI1wNv_ALw9JdmXB3L695crSadKVcmGhjgYfv1tySouGeQhhiAKKoDTUnWFYBDg5YeHz24wrdXu7gRwBkFy19vd3TkSfwnd0zUxdvv0SXeSQhBuYNVafz1Rg1bBohKK2NHSWKXZ0HYlM3W9hkTwWkI8WmpmPfUwDpBsbo5vGP_BEvoVftKE3p6GDx8-P8L7_f7jHoQ5XBPpAmeYYNS6huCUJDhDQeBu6NGP0KODcA1w2o_CXaDYzRKXVjlurhdu1hx9Pxt-_CgG4b2TjGmJo8A99fopKy9uqsLfdLJkFQhzHkfjyF87hzms4gjg9YC0Vu3LVqtmz-qp_p7V3FimQZhXceTQglHtrBePel5qtJj0fSULc8jf6pn3ntGgNohFo9gPbtHEbYaSSc9-YnyPnYRVJ_uV4obQtz59uM8P99B0RcMtJLDoaqhZq7R1YbhaTNweu2JBVQP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