Skip to content

loongarch64 half (f16) failure to select with +f and +d #93894

Description

@tgross35
define half @half_add(half %a, half %b) unnamed_addr #0 {
start:
  %_0 = fadd half %a, %b
  ret half %_0
}

With -mtriple=loongarch64-unknown-linux-gnu -mattr=+f,+d:

LLVM ERROR: Cannot select: t23: f32 = fp16_to_fp t21
  t21: i64 = fp_to_fp16 t4
    t4: f32,ch = CopyFromReg t0, Register:f32 %1
      t3: f32 = Register %1
In function: half_add
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=loongarch64-unknown-linux-gnu -mattr=+f,+d <source>
1.	Running pass 'Function Pass Manager' on module '<source>'.
2.	Running pass 'LoongArch DAG->DAG Pattern Instruction Selection' on function '@half_add'
 #0 0x00000000039e9678 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x39e9678)
 #1 0x00000000039e6dbc SignalHandler(int) Signals.cpp:0:0
 #2 0x00007e2b90a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x00007e2b90a969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x00007e2b90a42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x00007e2b90a287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x0000000000720e07 (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x720e07)
 #7 0x000000000379ccad llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x379ccad)
 #8 0x00000000037a1c9a llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x37a1c9a)
 #9 0x00000000016a2837 llvm::LoongArchDAGToDAGISel::Select(llvm::SDNode*) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x16a2837)
#10 0x0000000003799aee llvm::SelectionDAGISel::DoInstructionSelection() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3799aee)
#11 0x00000000037a7db6 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x37a7db6)
#12 0x00000000037ab0bd llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x37ab0bd)
#13 0x00000000037acaff llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#14 0x00000000029e6721 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#15 0x0000000002fad603 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2fad603)
#16 0x0000000002fad841 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2fad841)
#17 0x0000000002fae0a5 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2fae0a5)
#18 0x000000000083129c compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#19 0x0000000000728536 main (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x728536)
#20 0x00007e2b90a29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#21 0x00007e2b90a29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#22 0x000000000082804e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x82804e)
Program terminated with signal: SIGSEGV
Compiler returned: 139

There is no error if the -mattr flag is omitted

Reproduction: https://llvm.godbolt.org/z/faenafnzh

Activity

  1. tgross35 commented on Jun 4, 2024

    @tgross35
    ContributorAuthor

    The other variants of this fail here as well, e.g. i64 = fp_to_fp16, rust-lang/rust#125016 (comment)

  2. andrewrk commented on Jun 5, 2024

    @andrewrk
    Member

    Zig blocker too ziglang/zig#20193

  3. added a commit that references this issue on Jun 5, 2024
    bbb1854
  4. added a commit that references this issue on Jun 6, 2024
    d075b7b
  5. added a commit that references this issue on Aug 22, 2024
  6. added 2 commits that reference this issue on Oct 7, 2026
    0d45f81
    714c8f0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend:loongarchcrashPrefer [crash-on-valid] or [crash-on-invalid]

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions