Skip to content

Remove the libm dependency and inline the functions we use? #147

@valadaptive

Description

@valadaptive

Right now, we depend on the libm crate to implement floating-point math operations like floor, ceil, and sqrt that are implemented as intrinsics in practice but are still not exposed in core.

There are various reasons we might not want libm.

It has its own architecture-specific implementations for some operations, but per-architecture support is patchy--some operations are missing even though they are supported by the underlying architecture. They are also implemented using inline assembly instead of intrinsics, which inhibits potential optimizations. This is apparently done to avoid recursion when using the libm crate as the libm implementation for Rust itself, but that doesn't apply when using it here.

It also performs its own feature detection, which is pure overhead and completely redundant with the feature detection we perform here.

I think there's room for a slimmer version of the libm crate that implements only the operations from the core_float_math feature. It shouldn't perform any runtime feature detection, and should use intrinsics when possible and inline assembly if the architecture's intrinsics are not stabilized.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions