Skip to content

Tracking issue for f32 and f64 methods in libcore #50145

Open
@SimonSapin

Description

@SimonSapin

#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: calls llvm.fabs.f32 or llvm.fabs.f64
  • signum: calls llvm.copysign.f32 or llvm.copysign.f64
  • powi: calls llvm.powi.f32 or llvm.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.)

CC @alexcrichton

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-floating-pointArea: Floating point numbers and arithmeticA-intrinsicsArea: IntrinsicsC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCLibs-TrackedLibs issues that are tracked on the team's project board.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions