Skip to content

Commit 73ea4f0

Browse files
committed
Add __extendhfdf2
LLVM doesn't seem to emit this intrinsic but it probably should, in some cases it lowers f16->f64 conversions as f16->f32->f64 with two libcalls. GCC provides this intrinsic so it is good to have anyway. [1]: https://rust.godbolt.org/z/xezM9PEnz
1 parent f6a6911 commit 73ea4f0

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

src/float/extend.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ intrinsics! {
9696
extend(a)
9797
}
9898

99+
#[avr_skip]
100+
#[aapcs_on_arm]
101+
#[apple_f16_arg_abi]
102+
#[cfg(f16_enabled)]
103+
pub extern "C" fn __extendhfdf2(a: f16) -> f64 {
104+
extend(a)
105+
}
106+
99107
#[avr_skip]
100108
#[aapcs_on_arm]
101109
#[ppc_alias = __extendhfkf2]

testcrate/benches/float_extend.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,28 @@ float_bench! {
2828
],
2929
}
3030

31+
#[cfg(f16_enabled)]
32+
float_bench! {
33+
name: extend_f16_f64,
34+
sig: (a: f16) -> f64,
35+
crate_fn: extend::__extendhfdf2,
36+
sys_fn: __extendhfdf2,
37+
sys_available: not(feature = "no-sys-f16"),
38+
asm: [
39+
#[cfg(target_arch = "aarch64")] {
40+
let ret: f64;
41+
asm!(
42+
"fcvt {ret:d}, {a:h}",
43+
a = in(vreg) a,
44+
ret = lateout(vreg) ret,
45+
options(nomem, nostack, pure),
46+
);
47+
48+
ret
49+
};
50+
],
51+
}
52+
3153
#[cfg(all(f16_enabled, f128_enabled))]
3254
float_bench! {
3355
name: extend_f16_f128,
@@ -93,6 +115,7 @@ pub fn float_extend() {
93115
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
94116
{
95117
extend_f16_f32(&mut criterion);
118+
extend_f16_f64(&mut criterion);
96119

97120
#[cfg(f128_enabled)]
98121
extend_f16_f128(&mut criterion);

testcrate/tests/conv.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ mod extend {
311311
extend,
312312
f16 => f32, Half => Single, __extendhfsf2, not(feature = "no-sys-f16");
313313
f16 => f32, Half => Single, __gnu_h2f_ieee, not(feature = "no-sys-f16");
314+
f16 => f64, Half => Double, __extendhfdf2, not(feature = "no-sys-f16");
314315
f16 => f128, Half => Quad, __extendhftf2, not(feature = "no-sys-f16-f128-convert");
315316
f32 => f128, Single => Quad, __extendsftf2, not(feature = "no-sys-f128");
316317
f64 => f128, Double => Quad, __extenddftf2, not(feature = "no-sys-f128");

0 commit comments

Comments
 (0)