From 2c2640b96638bc4d26a713f4f77f434c33ba20f6 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Wed, 23 Oct 2019 16:25:01 +0200 Subject: [PATCH 1/2] Always inline the cast_from_int in the non-SIMD impl This makes it more consistent with the SIMD implementation, and it usually requires very few machine instructions to convert from an unsigned integer to a floating-point value. --- src/distributions/utils.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/distributions/utils.rs b/src/distributions/utils.rs index 3af4e86fdec..8ccd0c66133 100644 --- a/src/distributions/utils.rs +++ b/src/distributions/utils.rs @@ -321,6 +321,7 @@ macro_rules! scalar_float_impl { <$ty>::from_bits(self.to_bits() - 1) } type UInt = $uty; + #[inline(always)] fn cast_from_int(i: Self::UInt) -> Self { i as $ty } } From 961aa13e1a15d678a324bd8897e471ff521d6335 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Wed, 23 Oct 2019 16:41:10 +0200 Subject: [PATCH 2/2] Use a simple inline instead of inline[always] --- src/distributions/utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/distributions/utils.rs b/src/distributions/utils.rs index 8ccd0c66133..f7ddecbb9cd 100644 --- a/src/distributions/utils.rs +++ b/src/distributions/utils.rs @@ -321,7 +321,7 @@ macro_rules! scalar_float_impl { <$ty>::from_bits(self.to_bits() - 1) } type UInt = $uty; - #[inline(always)] + #[inline] fn cast_from_int(i: Self::UInt) -> Self { i as $ty } }