Description
#49896 removes from libcore (and moves to libstd) three methods of f32
and f64
(that were only usable through the unstable trait core::num::Float
) because they’re implemented by calling LLVM intrinsics, and it’s not clear whether those intrinsics are lowered on any platform to calls to C’s libm
or something else that requires runtime support that we don’t want in libcore:
abs
: callsllvm.fabs.f32
orllvm.fabs.f64
signum
: callsllvm.copysign.f32
orllvm.copysign.f64
powi
: callsllvm.powi.f32
orllvm.powi.f32
The first two seem like they’d be easy to implement in a small number of lower-level instructions (such as a couple lines with if
, or even bit twiddling based on IEEE 754). abs
in particular seems like a rather common operation, and it’s unfortunate not to have it in libcore.
The compiler-builtins
crate has Rust implementations of __powisf2
and __powidf2
, but in LLVM code those are only mentioned in lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
so I haven’t found evidence that llvm.powi.f32
and llvm.powi.f32
call those functions.
PR #27823 “Remove dependencies on libm functions from libcore” similarly moved a number of other f32
and f64
methods to libstd, but left these three behind specifically. (And unfortunately doesn’t discuss why.)
Maybe it’s fine to move them back in libcore? (As inherent methods, assuming #49896 lands.)