Open
Description
Feature gate: #![feature(float_algebraic)]
This is a tracking issue for exposing core::intrinsics::f*_algebraic
in stable Rust, including in const.
Public API
// core::num::f16
impl f16 {
pub const fn algebraic_add(self, rhs: f16) -> f16;
pub const fn algebraic_sub(self, rhs: f16) -> f16;
pub const fn algebraic_mul(self, rhs: f16) -> f16;
pub const fn algebraic_div(self, rhs: f16) -> f16;
pub const fn algebraic_rem(self, rhs: f16) -> f16;
}
// core::num::f32
impl f32 {
pub const fn algebraic_add(self, rhs: f32) -> f32;
pub const fn algebraic_sub(self, rhs: f32) -> f32;
pub const fn algebraic_mul(self, rhs: f32) -> f32;
pub const fn algebraic_div(self, rhs: f32) -> f32;
pub const fn algebraic_rem(self, rhs: f32) -> f32;
}
// core::num::f64
impl f64 {
pub const fn algebraic_add(self, rhs: f64) -> f64;
pub const fn algebraic_sub(self, rhs: f64) -> f64;
pub const fn algebraic_mul(self, rhs: f64) -> f64;
pub const fn algebraic_div(self, rhs: f64) -> f64;
pub const fn algebraic_rem(self, rhs: f64) -> f64;
}
// core::num::f128
impl f128 {
pub const fn algebraic_add(self, rhs: f128) -> f128;
pub const fn algebraic_sub(self, rhs: f128) -> f128;
pub const fn algebraic_mul(self, rhs: f128) -> f128;
pub const fn algebraic_div(self, rhs: f128) -> f128;
pub const fn algebraic_rem(self, rhs: f128) -> f128;
}
Steps / History
- ACP: ACP: Expose algebraic floating point intrinsics libs-team#532
- Implementation:
- Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- How does this interact (if at all) with the optional-fused-multiply-add intrinsics added in intrinsics fmuladdf{32,64}: expose llvm.fmuladd.* semantics #124874? Do we even still need those?
- Naming: "algebraic" is not very descriptive of what this does since the operations themselves are algebraic.
References
- Imprecise floating point operations (fast-math) #21690
- ACP: Expose algebraic floating point intrinsics libs-team#532
- Expose algebraic floating point intrinsics #136457
- https://github.com/calder/dot-bench
- https://www.felixcloutier.com/x86/vfmadd132ps:vfmadd213ps:vfmadd231ps
cc @rust-lang/lang @rust-lang/libs-api