| Issue |
63816
|
| Summary |
[RISCV] `fpext` crashes on `half` type
|
| Labels |
|
| Assignees |
|
| Reporter |
HazyFish
|
## Description
When `d` (Standard Extension for Double-Precision Floating-Point) feature is on, the following code crashes RISCV backend with assertion error `VT.isInteger() == MemVT.isInteger() && "Cannot convert from FP to Int or Int -> FP!"`.
## Cause
https://github.com/llvm/llvm-project/blob/b10899d869954e1426684cbc20a43d7303075d49/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp#L8210-L8229
The param `VT` is `i64` type and `MemVT` is `f16`, which caused the assertion to fail.
## Minimal Reproduction
https://godbolt.org/z/EK698bYWv
### Code
```ll
define void @test(ptr %0, ptr %1) {
%V1 = load <8 x half>, ptr %0
%V2 = fpext <8 x half> %V1 to <8 x double>
store <8 x double> %V2, ptr %1
ret void
}
```
### Stack Trace
```console
llc: /root/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:8222: llvm::SDValue llvm::SelectionDAG::getLoad(llvm::ISD::MemIndexedMode, llvm::ISD::LoadExtType, llvm::EVT, const llvm::SDLoc&, llvm::SDValue, llvm::SDValue, llvm::SDValue, llvm::EVT, llvm::MachineMemOperand*): Assertion `VT.isInteger() == MemVT.isInteger() && "Cannot convert from FP to Int or Int -> FP!"' failed.
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=riscv64 -mattr=+d <source>
1. Running pass 'Function Pass Manager' on module '<source>'.
2. Running pass 'RISC-V DAG->DAG Pattern Instruction Selection' on function '@test'
#0 0x0000557e3ad2b15f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x354b15f)
#1 0x0000557e3ad288b4 SignalHandler(int) Signals.cpp:0:0
#2 0x00007f11c56f2420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#3 0x00007f11c51bf00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#4 0x00007f11c519e859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#5 0x00007f11c519e729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#6 0x00007f11c51affd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#7 0x0000557e3aa9739a (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x32b739a)
#8 0x0000557e3aa9e6ed llvm::SelectionDAG::getExtLoad(llvm::ISD::LoadExtType, llvm::SDLoc const&, llvm::EVT, llvm::SDValue, llvm::SDValue, llvm::EVT, llvm::MachineMemOperand*) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x32be6ed)
#9 0x0000557e3a9c31b8 (anonymous namespace)::SelectionDAGLegalize::LegalizeLoadOps(llvm::SDNode*) LegalizeDAG.cpp:0:0
#10 0x0000557e3a9e2765 (anonymous namespace)::SelectionDAGLegalize::LegalizeOp(llvm::SDNode*) (.part.0) LegalizeDAG.cpp:0:0
#11 0x0000557e3a9e630c llvm::SelectionDAG::Legalize() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x320630c)
#12 0x0000557e3aaf1cec llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3311cec)
#13 0x0000557e3aaf54c8 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x33154c8)
#14 0x0000557e3aaf7192 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#15 0x0000557e39fca6ce llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#16 0x0000557e3a5647f1 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2d847f1)
#17 0x0000557e3a564a39 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2d84a39)
#18 0x0000557e3a5652b2 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2d852b2)
#19 0x0000557e38077634 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#20 0x0000557e37fbff06 main (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x7dff06)
#21 0x00007f11c51a0083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#22 0x0000557e3806da1e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x88da1e)
Program terminated with signal: SIGSEGV
Compiler returned: 139
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs