@@ -39,6 +39,7 @@ pub struct IeeeFloat<S> {
3939/// large to store the largest significands by itself.
4040type Limb = u128 ;
4141const LIMB_BITS : usize = 128 ;
42+ #[ inline( always) ]
4243fn limbs_for_bits ( bits : usize ) -> usize {
4344 ( bits + LIMB_BITS - 1 ) / LIMB_BITS
4445}
@@ -337,6 +338,7 @@ impl Semantics for X87DoubleExtendedS {
337338 /// exponent!=0 nor all 1's, integer bit 0 ("unnormal")
338339 /// exponent = 0, integer bit 1 ("pseudodenormal")
339340 /// At the moment, the first three are treated as NaNs, the last one as Normal.
341+ #[ inline]
340342 fn from_bits ( bits : u128 ) -> IeeeFloat < Self > {
341343 let sign = bits & ( 1 << ( Self :: BITS - 1 ) ) ;
342344 let exponent = ( ( bits & !sign) >> ( Self :: BITS - 1 - Self :: EXP_BITS ) ) & ( ( 1 << Self :: EXP_BITS ) - 1 ) ;
@@ -373,6 +375,7 @@ impl Semantics for X87DoubleExtendedS {
373375 r
374376 }
375377
378+ #[ inline]
376379 fn to_bits ( x : IeeeFloat < Self > ) -> u128 {
377380 // Get integer bit from significand.
378381 let integer_bit = sig:: get_bit ( & x. sig , Self :: PRECISION - 1 ) ;
@@ -2656,6 +2659,7 @@ impl<S: Semantics> IeeeFloat<S> {
26562659
26572660impl Loss {
26582661 /// Combine the effect of two lost fractions.
2662+ #[ inline]
26592663 fn combine ( self , less_significant : Loss ) -> Loss {
26602664 let mut more_significant = self ;
26612665 if less_significant != Loss :: ExactlyZero {
@@ -2671,6 +2675,7 @@ impl Loss {
26712675
26722676 /// Return the fraction lost were a bignum truncated losing the least
26732677 /// significant `bits` bits.
2678+ #[ inline]
26742679 fn through_truncation ( limbs : & [ Limb ] , bits : usize ) -> Loss {
26752680 if bits == 0 {
26762681 return Loss :: ExactlyZero ;
@@ -2703,11 +2708,13 @@ mod sig {
27032708 use core:: cmp:: Ordering ;
27042709 use core:: mem;
27052710
2711+ #[ inline]
27062712 pub ( super ) fn is_all_zeros ( limbs : & [ Limb ] ) -> bool {
27072713 limbs. iter ( ) . all ( |& l| l == 0 )
27082714 }
27092715
27102716 /// One, not zero, based LSB. That is, returns 0 for a zeroed significand.
2717+ #[ inline]
27112718 pub ( super ) fn olsb ( limbs : & [ Limb ] ) -> usize {
27122719 for i in 0 ..limbs. len ( ) {
27132720 if limbs[ i] != 0 {
@@ -2719,6 +2726,7 @@ mod sig {
27192726 }
27202727
27212728 /// One, not zero, based MSB. That is, returns 0 for a zeroed significand.
2729+ #[ inline]
27222730 pub ( super ) fn omsb ( limbs : & [ Limb ] ) -> usize {
27232731 for i in ( 0 ..limbs. len ( ) ) . rev ( ) {
27242732 if limbs[ i] != 0 {
@@ -2730,6 +2738,7 @@ mod sig {
27302738 }
27312739
27322740 /// Comparison (unsigned) of two significands.
2741+ #[ inline]
27332742 pub ( super ) fn cmp ( a : & [ Limb ] , b : & [ Limb ] ) -> Ordering {
27342743 assert_eq ! ( a. len( ) , b. len( ) ) ;
27352744 for ( a, b) in a. iter ( ) . zip ( b) . rev ( ) {
@@ -2743,16 +2752,19 @@ mod sig {
27432752 }
27442753
27452754 /// Extract the given bit.
2755+ #[ inline]
27462756 pub ( super ) fn get_bit ( limbs : & [ Limb ] , bit : usize ) -> bool {
27472757 limbs[ bit / LIMB_BITS ] & ( 1 << ( bit % LIMB_BITS ) ) != 0
27482758 }
27492759
27502760 /// Set the given bit.
2761+ #[ inline]
27512762 pub ( super ) fn set_bit ( limbs : & mut [ Limb ] , bit : usize ) {
27522763 limbs[ bit / LIMB_BITS ] |= 1 << ( bit % LIMB_BITS ) ;
27532764 }
27542765
27552766 /// Shift `dst` left `bits` bits, subtract `bits` from its exponent.
2767+ #[ inline]
27562768 pub ( super ) fn shift_left ( dst : & mut [ Limb ] , exp : & mut ExpInt , bits : usize ) {
27572769 if bits > 0 {
27582770 // Our exponent should not underflow.
@@ -2785,6 +2797,7 @@ mod sig {
27852797 }
27862798
27872799 /// Shift `dst` right `bits` bits noting lost fraction.
2800+ #[ inline]
27882801 pub ( super ) fn shift_right ( dst : & mut [ Limb ] , exp : & mut ExpInt , bits : usize ) -> Loss {
27892802 let loss = Loss :: through_truncation ( dst, bits) ;
27902803
@@ -2823,6 +2836,7 @@ mod sig {
28232836 /// Copy the bit vector of width `src_bits` from `src`, starting at bit SRC_LSB,
28242837 /// to `dst`, such that the bit SRC_LSB becomes the least significant bit of `dst`.
28252838 /// All high bits above `src_bits` in `dst` are zero-filled.
2839+ #[ inline]
28262840 pub ( super ) fn extract ( dst : & mut [ Limb ] , src : & [ Limb ] , src_bits : usize , src_lsb : usize ) {
28272841 if src_bits == 0 {
28282842 return ;
@@ -2856,6 +2870,7 @@ mod sig {
28562870
28572871 /// We want the most significant PRECISION bits of `src`. There may not
28582872 /// be that many; extract what we can.
2873+ #[ inline]
28592874 pub ( super ) fn from_limbs ( dst : & mut [ Limb ] , src : & [ Limb ] , precision : usize ) -> ( Loss , ExpInt ) {
28602875 let omsb = omsb ( src) ;
28612876
@@ -2871,6 +2886,7 @@ mod sig {
28712886 /// For every consecutive chunk of `bits` bits from `limbs`,
28722887 /// going from most significant to the least significant bits,
28732888 /// call `f` to transform those bits and store the result back.
2889+ #[ inline]
28742890 pub ( super ) fn each_chunk < F : FnMut ( Limb ) -> Limb > ( limbs : & mut [ Limb ] , bits : usize , mut f : F ) {
28752891 assert_eq ! ( LIMB_BITS % bits, 0 ) ;
28762892 for limb in limbs. iter_mut ( ) . rev ( ) {
@@ -2883,6 +2899,7 @@ mod sig {
28832899 }
28842900
28852901 /// Increment in-place, return the carry flag.
2902+ #[ inline]
28862903 pub ( super ) fn increment ( dst : & mut [ Limb ] ) -> Limb {
28872904 for x in dst {
28882905 * x = x. wrapping_add ( 1 ) ;
@@ -2895,6 +2912,7 @@ mod sig {
28952912 }
28962913
28972914 /// Decrement in-place, return the borrow flag.
2915+ #[ inline]
28982916 pub ( super ) fn decrement ( dst : & mut [ Limb ] ) -> Limb {
28992917 for x in dst {
29002918 * x = x. wrapping_sub ( 1 ) ;
@@ -2907,6 +2925,7 @@ mod sig {
29072925 }
29082926
29092927 /// `a += b + c` where `c` is zero or one. Returns the carry flag.
2928+ #[ inline]
29102929 pub ( super ) fn add ( a : & mut [ Limb ] , b : & [ Limb ] , mut c : Limb ) -> Limb {
29112930 assert ! ( c <= 1 ) ;
29122931
@@ -2921,6 +2940,7 @@ mod sig {
29212940 }
29222941
29232942 /// `a -= b + c` where `c` is zero or one. Returns the borrow flag.
2943+ #[ inline]
29242944 pub ( super ) fn sub ( a : & mut [ Limb ] , b : & [ Limb ] , mut c : Limb ) -> Limb {
29252945 assert ! ( c <= 1 ) ;
29262946
@@ -2935,6 +2955,7 @@ mod sig {
29352955 }
29362956
29372957 /// `a += b` or `a -= b`. Does not preserve `b`.
2958+ #[ inline]
29382959 pub ( super ) fn add_or_sub (
29392960 a_sig : & mut [ Limb ] ,
29402961 a_exp : & mut ExpInt ,
@@ -3000,6 +3021,7 @@ mod sig {
30003021 /// `(n - 1) * (n - 1) + 2 * (n - 1) == (n - 1) * (n + 1)`
30013022 ///
30023023 /// which is less than n^2.
3024+ #[ inline]
30033025 pub ( super ) fn widening_mul ( a : Limb , b : Limb ) -> [ Limb ; 2 ] {
30043026 let mut wide = [ 0 , 0 ] ;
30053027
@@ -3022,6 +3044,7 @@ mod sig {
30223044 }
30233045
30243046 /// `dst = a * b` (for normal `a` and `b`). Returns the lost fraction.
3047+ #[ inline]
30253048 pub ( super ) fn mul < ' a > (
30263049 dst : & mut [ Limb ] ,
30273050 exp : & mut ExpInt ,
@@ -3092,6 +3115,7 @@ mod sig {
30923115
30933116 /// `quotient = dividend / divisor`. Returns the lost fraction.
30943117 /// Does not preserve `dividend` or `divisor`.
3118+ #[ inline]
30953119 pub ( super ) fn div (
30963120 quotient : & mut [ Limb ] ,
30973121 exp : & mut ExpInt ,
0 commit comments