Skip to content

[Xtensa] Failure to select fp16_to_fp #207505

Description

@tgross35

IR:

target datalayout = "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32"
target triple = "xtensa-unknown-none-elf"

; Function Attrs: nounwind
define dso_local float @cvt(half %a) unnamed_addr #0 {
start:
  %_0 = fpext half %a to float
  ret float %_0
}

attributes #0 = { nounwind "target-cpu"="esp32" }

Output:

rustc-LLVM ERROR: Cannot select: 0x110e4c0e0: f32 = fp16_to_fp 0x110e4c070
  0x110e4c070: i32,ch = CopyFromReg 0x1110b0488, Register:i32 %0
In function: cvt

I don't have a standalone build of LLVM with xtensa handy so this was reproduced via rustc (LLVM 22.1.7):

$ rustc -Vv
rustc 1.98.0-nightly (f428d123a 2026-06-19)
binary: rustc
commit-hash: f428d123ab0ea5431ec4256ff8838b9342866446
commit-date: 2026-06-19
host: aarch64-apple-darwin
release: 1.98.0-nightly
LLVM version: 22.1.7

$ cat a.rs
#![feature(no_core, lang_items, f16)]
#![allow(unused, improper_ctypes_definitions, internal_features)]
#![no_std]
#![no_core]

#[lang = "pointee_sized"]
pub trait PointeeSized {}

#[lang = "meta_sized"]
pub trait MetaSized: PointeeSized {}

#[lang = "sized"]
pub trait Sized: MetaSized {}

#[lang = "copy"]
pub trait Copy: Sized {}

#[unsafe(no_mangle)]
pub fn cvt(a: f16) -> f32 {
    a as f32
}
$ rustc a.rs --crate-type=lib --target xtensa-esp32-espidf
rustc-LLVM ERROR: Cannot select: 0x110e4c0e0: f32 = fp16_to_fp 0x110e4c070
  0x110e4c070: i32,ch = CopyFromReg 0x1110b0488, Register:i32 %0
In function: cvt

$ rustc a.rs --crate-type=lib --target xtensa-esp32-espidf --emit=llvm-ir -o-
(above output)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions