104: add more #[inline] r=japaric a=erikdesjardins

Some of these are pretty big so they may not get inlined in practice, but we might as well make them consistent with the rest.

Co-authored-by: Erik <erikdesjardins@users.noreply.github.com>
This commit is contained in:
bors[bot] 2018-07-14 20:57:09 +00:00
commit 61d958fb2d
12 changed files with 12 additions and 0 deletions

View File

@ -1,5 +1,6 @@
use core::f32;
#[inline]
pub fn ceilf(x: f32) -> f32 {
let mut ui = x.to_bits();
let e = (((ui >> 23) & 0xff) - 0x7f) as i32;

View File

@ -318,6 +318,7 @@ static TBL: [u64; TBLSIZE * 2] = [
//
// Gal, S. and Bachelis, B. An Accurate Elementary Mathematical Library
// for the IEEE Floating Point Standard. TOMS 17(1), 26-46 (1991).
#[inline]
pub fn exp2(mut x: f64) -> f64 {
let redux = f64::from_bits(0x4338000000000000) / TBLSIZE as f64;
let p1 = f64::from_bits(0x3fe62e42fefa39ef);

View File

@ -69,6 +69,7 @@ static EXP2FT: [u64; TBLSIZE] = [
//
// Tang, P. Table-driven Implementation of the Exponential Function
// in IEEE Floating-Point Arithmetic. TOMS 15(2), 144-157 (1989).
#[inline]
pub fn exp2f(mut x: f32) -> f32 {
let redux = f32::from_bits(0x4b400000) / TBLSIZE as f32;
let p1 = f32::from_bits(0x3f317218);

View File

@ -1,5 +1,6 @@
use core::f64;
#[inline]
pub fn fdim(x: f64, y: f64) -> f64 {
if x.is_nan() {
x

View File

@ -1,5 +1,6 @@
use core::f32;
#[inline]
pub fn fdimf(x: f32, y: f32) -> f32 {
if x.is_nan() {
x

View File

@ -4,6 +4,7 @@ use super::sqrt;
const SPLIT: f64 = 134217728. + 1.; // 0x1p27 + 1 === (2 ^ 27) + 1
#[inline]
fn sq(x: f64) -> (f64, f64) {
let xh: f64;
let xl: f64;

View File

@ -65,6 +65,7 @@ const LG5: f64 = 1.818357216161805012e-01; /* 3FC74664 96CB03DE */
const LG6: f64 = 1.531383769920937332e-01; /* 3FC39A09 D078C69F */
const LG7: f64 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
#[inline]
pub fn log1p(x: f64) -> f64 {
let mut ui: u64 = x.to_bits();
let hfsq: f64;

View File

@ -20,6 +20,7 @@ const LG2: f32 = 0.40000972152; /* 0xccce13.0p-25 */
const LG3: f32 = 0.28498786688; /* 0x91e9ee.0p-25 */
const LG4: f32 = 0.24279078841; /* 0xf89e26.0p-26 */
#[inline]
pub fn log1pf(x: f32) -> f32 {
let mut ui: u32 = x.to_bits();
let hfsq: f32;

View File

@ -29,6 +29,7 @@ const LG5: f64 = 1.818357216161805012e-01; /* 3FC74664 96CB03DE */
const LG6: f64 = 1.531383769920937332e-01; /* 3FC39A09 D078C69F */
const LG7: f64 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
#[inline]
pub fn log2(mut x: f64) -> f64 {
let x1p54 = f64::from_bits(0x4350000000000000); // 0x1p54 === 2 ^ 54

View File

@ -23,6 +23,7 @@ const LG2: f32 = 0.40000972152; /* 0xccce13.0p-25 */
const LG3: f32 = 0.28498786688; /* 0x91e9ee.0p-25 */
const LG4: f32 = 0.24279078841; /* 0xf89e26.0p-26 */
#[inline]
pub fn log2f(mut x: f32) -> f32 {
let x1p25f = f32::from_bits(0x4c000000); // 0x1p25f === 2 ^ 25

View File

@ -2,6 +2,7 @@ use core::f64;
const TOINT: f64 = 1.0 / f64::EPSILON;
#[inline]
pub fn round(mut x: f64) -> f64 {
let (f, i) = (x, x.to_bits());
let e: u64 = i >> 52 & 0x7ff;

View File

@ -2,6 +2,7 @@ use core::f32;
const TOINT: f32 = 1.0 / f32::EPSILON;
#[inline]
pub fn roundf(mut x: f32) -> f32 {
let i = x.to_bits();
let e: u32 = i >> 23 & 0xff;