diff --git a/src/math/fma.rs b/src/math/fma.rs index 789b0836..e0b3347a 100644 --- a/src/math/fma.rs +++ b/src/math/fma.rs @@ -29,6 +29,7 @@ pub fn fmaf128(x: f128, y: f128, z: f128) -> f128 { /// Fused multiply-add that works when there is not a larger float size available. Computes /// `(x * y) + z`. +#[inline] pub fn fma_round(x: F, y: F, z: F, _round: Round) -> FpResult where F: Float, diff --git a/src/math/fma_wide.rs b/src/math/fma_wide.rs index 8e908a14..08b78b02 100644 --- a/src/math/fma_wide.rs +++ b/src/math/fma_wide.rs @@ -28,6 +28,7 @@ pub fn fmaf(x: f32, y: f32, z: f32) -> f32 { /// Fma implementation when a hardware-backed larger float type is available. For `f32` and `f64`, /// `f64` has enough precision to represent the `f32` in its entirety, except for double rounding. +#[inline] pub fn fma_wide_round(x: F, y: F, z: F, round: Round) -> FpResult where F: Float + HFloat, diff --git a/src/math/generic/ceil.rs b/src/math/generic/ceil.rs index bf7e1d8e..5c5bb476 100644 --- a/src/math/generic/ceil.rs +++ b/src/math/generic/ceil.rs @@ -10,10 +10,12 @@ use super::super::support::{FpResult, Status}; use super::super::{Float, Int, IntTy, MinInt}; +#[inline] pub fn ceil(x: F) -> F { ceil_status(x).val } +#[inline] pub fn ceil_status(x: F) -> FpResult { let zero = IntTy::::ZERO; diff --git a/src/math/generic/copysign.rs b/src/math/generic/copysign.rs index 04864a35..a61af22f 100644 --- a/src/math/generic/copysign.rs +++ b/src/math/generic/copysign.rs @@ -1,6 +1,7 @@ use super::super::Float; /// Copy the sign of `y` to `x`. +#[inline] pub fn copysign(x: F, y: F) -> F { let mut ux = x.to_bits(); let uy = y.to_bits(); diff --git a/src/math/generic/fabs.rs b/src/math/generic/fabs.rs index 75b47310..0fa0edf9 100644 --- a/src/math/generic/fabs.rs +++ b/src/math/generic/fabs.rs @@ -1,6 +1,7 @@ use super::super::Float; /// Absolute value. +#[inline] pub fn fabs(x: F) -> F { let abs_mask = !F::SIGN_MASK; F::from_bits(x.to_bits() & abs_mask) diff --git a/src/math/generic/fdim.rs b/src/math/generic/fdim.rs index bf971cd7..a63007b1 100644 --- a/src/math/generic/fdim.rs +++ b/src/math/generic/fdim.rs @@ -1,5 +1,6 @@ use super::super::Float; +#[inline] pub fn fdim(x: F, y: F) -> F { if x <= y { F::ZERO } else { x - y } } diff --git a/src/math/generic/floor.rs b/src/math/generic/floor.rs index 77995516..24380462 100644 --- a/src/math/generic/floor.rs +++ b/src/math/generic/floor.rs @@ -10,10 +10,12 @@ use super::super::support::{FpResult, Status}; use super::super::{Float, Int, IntTy, MinInt}; +#[inline] pub fn floor(x: F) -> F { floor_status(x).val } +#[inline] pub fn floor_status(x: F) -> FpResult { let zero = IntTy::::ZERO; diff --git a/src/math/generic/fmax.rs b/src/math/generic/fmax.rs index 29a03110..bf3f847e 100644 --- a/src/math/generic/fmax.rs +++ b/src/math/generic/fmax.rs @@ -16,7 +16,7 @@ use super::super::Float; -#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] +#[inline] pub fn fmax(x: F, y: F) -> F { let res = if x.is_nan() || x < y { y } else { x }; // Canonicalize diff --git a/src/math/generic/fmaximum.rs b/src/math/generic/fmaximum.rs index 9e8d1739..387055af 100644 --- a/src/math/generic/fmaximum.rs +++ b/src/math/generic/fmaximum.rs @@ -11,6 +11,7 @@ use super::super::Float; +#[inline] pub fn fmaximum(x: F, y: F) -> F { let res = if x.is_nan() { x diff --git a/src/math/generic/fmaximum_num.rs b/src/math/generic/fmaximum_num.rs index 756ef5d9..f7efdde8 100644 --- a/src/math/generic/fmaximum_num.rs +++ b/src/math/generic/fmaximum_num.rs @@ -13,6 +13,7 @@ use super::super::Float; +#[inline] pub fn fmaximum_num(x: F, y: F) -> F { let res = if x.is_nan() || x < y || (x.to_bits() == F::NEG_ZERO.to_bits() && y.is_sign_positive()) { diff --git a/src/math/generic/fmin.rs b/src/math/generic/fmin.rs index 69fbf85a..cd3caeee 100644 --- a/src/math/generic/fmin.rs +++ b/src/math/generic/fmin.rs @@ -16,6 +16,7 @@ use super::super::Float; +#[inline] pub fn fmin(x: F, y: F) -> F { let res = if y.is_nan() || x < y { x } else { y }; // Canonicalize diff --git a/src/math/generic/fminimum.rs b/src/math/generic/fminimum.rs index ee549388..4ddb3645 100644 --- a/src/math/generic/fminimum.rs +++ b/src/math/generic/fminimum.rs @@ -11,6 +11,7 @@ use super::super::Float; +#[inline] pub fn fminimum(x: F, y: F) -> F { let res = if x.is_nan() { x diff --git a/src/math/generic/fminimum_num.rs b/src/math/generic/fminimum_num.rs index 96661832..441c204a 100644 --- a/src/math/generic/fminimum_num.rs +++ b/src/math/generic/fminimum_num.rs @@ -13,6 +13,7 @@ use super::super::Float; +#[inline] pub fn fminimum_num(x: F, y: F) -> F { let res = if y.is_nan() || x < y || (x.to_bits() == F::NEG_ZERO.to_bits() && y.is_sign_positive()) { diff --git a/src/math/generic/fmod.rs b/src/math/generic/fmod.rs index cd23350e..6414bbd2 100644 --- a/src/math/generic/fmod.rs +++ b/src/math/generic/fmod.rs @@ -3,7 +3,7 @@ use super::super::{CastFrom, Float, Int, MinInt}; -#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] +#[inline] pub fn fmod(x: F, y: F) -> F { let zero = F::Int::ZERO; let one = F::Int::ONE; diff --git a/src/math/generic/mod.rs b/src/math/generic/mod.rs index 9be185f8..35846351 100644 --- a/src/math/generic/mod.rs +++ b/src/math/generic/mod.rs @@ -1,3 +1,6 @@ +// Note: generic functions are marked `#[inline]` because, even though generic functions are +// typically inlined, this does not seem to always be the case. + mod ceil; mod copysign; mod fabs; diff --git a/src/math/generic/rint.rs b/src/math/generic/rint.rs index 45d2f313..9cdeb118 100644 --- a/src/math/generic/rint.rs +++ b/src/math/generic/rint.rs @@ -6,6 +6,7 @@ use super::super::support::{FpResult, Round}; /// IEEE 754-2019 `roundToIntegralExact`, which respects rounding mode and raises inexact if /// applicable. +#[inline] pub fn rint_round(x: F, _round: Round) -> FpResult { let toint = F::ONE / F::EPSILON; let e = x.ex(); diff --git a/src/math/generic/round.rs b/src/math/generic/round.rs index 8b513818..01314ac7 100644 --- a/src/math/generic/round.rs +++ b/src/math/generic/round.rs @@ -1,6 +1,7 @@ use super::super::{Float, MinInt}; use super::{copysign, trunc}; +#[inline] pub fn round(x: F) -> F { let f0p5 = F::from_parts(false, F::EXP_BIAS - 1, F::Int::ZERO); // 0.5 let f0p25 = F::from_parts(false, F::EXP_BIAS - 2, F::Int::ZERO); // 0.25 diff --git a/src/math/generic/scalbn.rs b/src/math/generic/scalbn.rs index b2696e5c..a45db1b4 100644 --- a/src/math/generic/scalbn.rs +++ b/src/math/generic/scalbn.rs @@ -16,6 +16,7 @@ use super::super::{CastFrom, CastInto, Float, IntTy, MinInt}; /// > /// > If the calculation does not overflow or underflow, the returned value is exact and /// > independent of the current rounding direction mode. +#[inline] pub fn scalbn(mut x: F, mut n: i32) -> F where u32: CastInto, diff --git a/src/math/generic/sqrt.rs b/src/math/generic/sqrt.rs index 5918025b..ec9ff22d 100644 --- a/src/math/generic/sqrt.rs +++ b/src/math/generic/sqrt.rs @@ -44,6 +44,7 @@ use super::super::support::{FpResult, IntTy, Round, Status, cold_path}; use super::super::{CastFrom, CastInto, DInt, Float, HInt, Int, MinInt}; +#[inline] pub fn sqrt(x: F) -> F where F: Float + SqrtHelper, @@ -57,6 +58,7 @@ where sqrt_round(x, Round::Nearest).val } +#[inline] pub fn sqrt_round(x: F, _round: Round) -> FpResult where F: Float + SqrtHelper, diff --git a/src/math/generic/trunc.rs b/src/math/generic/trunc.rs index 0fb3fa5a..25414ecf 100644 --- a/src/math/generic/trunc.rs +++ b/src/math/generic/trunc.rs @@ -4,10 +4,12 @@ use super::super::support::{FpResult, Status}; use super::super::{Float, Int, IntTy, MinInt}; +#[inline] pub fn trunc(x: F) -> F { trunc_status(x).val } +#[inline] pub fn trunc_status(x: F) -> FpResult { let mut xi: F::Int = x.to_bits(); let e: i32 = x.exp_unbiased(); diff --git a/src/math/roundeven.rs b/src/math/roundeven.rs index ec173828..6e621d76 100644 --- a/src/math/roundeven.rs +++ b/src/math/roundeven.rs @@ -30,6 +30,7 @@ pub fn roundevenf128(x: f128) -> f128 { roundeven_impl(x) } +#[inline] pub fn roundeven_impl(x: F) -> F { super::generic::rint_round(x, Round::Nearest).val }