mirror of git://sourceware.org/git/glibc.git
Replace count_leading_zeros with stdc_leading_zeros
Checked on x86_64-linux-gnu and aarch64-linux-gnu. Reviewed-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Collin Funk <collin.funk1@gmail.com>
This commit is contained in:
parent
f91abbde02
commit
36b4c553e6
|
|
@ -25,6 +25,7 @@ along with the GNU MP Library; see the file COPYING.LIB. If not, see
|
|||
<https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <gmp.h>
|
||||
#include <stdbit.h>
|
||||
#include "gmp-impl.h"
|
||||
#include "longlong.h"
|
||||
|
||||
|
|
@ -62,9 +63,7 @@ mpn_divmod_1 (mp_ptr quot_ptr,
|
|||
if (UDIV_TIME > (2 * UMUL_TIME + 6)
|
||||
&& (UDIV_TIME - (2 * UMUL_TIME + 6)) * dividend_size > UDIV_TIME)
|
||||
{
|
||||
int normalization_steps;
|
||||
|
||||
count_leading_zeros (normalization_steps, divisor_limb);
|
||||
int normalization_steps = stdc_leading_zeros (divisor_limb);
|
||||
if (normalization_steps != 0)
|
||||
{
|
||||
mp_limb_t divisor_limb_inverted;
|
||||
|
|
@ -144,9 +143,7 @@ mpn_divmod_1 (mp_ptr quot_ptr,
|
|||
{
|
||||
if (UDIV_NEEDS_NORMALIZATION)
|
||||
{
|
||||
int normalization_steps;
|
||||
|
||||
count_leading_zeros (normalization_steps, divisor_limb);
|
||||
int normalization_steps = stdc_leading_zeros (divisor_limb);
|
||||
if (normalization_steps != 0)
|
||||
{
|
||||
divisor_limb <<= normalization_steps;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ along with the GNU MP Library; see the file COPYING.LIB. If not, see
|
|||
<https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <gmp.h>
|
||||
#include <stdbit.h>
|
||||
#include "gmp-impl.h"
|
||||
#include "longlong.h"
|
||||
|
||||
|
|
@ -58,9 +59,7 @@ mpn_mod_1 (mp_srcptr dividend_ptr, mp_size_t dividend_size,
|
|||
if (UDIV_TIME > (2 * UMUL_TIME + 6)
|
||||
&& (UDIV_TIME - (2 * UMUL_TIME + 6)) * dividend_size > UDIV_TIME)
|
||||
{
|
||||
int normalization_steps;
|
||||
|
||||
count_leading_zeros (normalization_steps, divisor_limb);
|
||||
int normalization_steps = stdc_leading_zeros (divisor_limb);
|
||||
if (normalization_steps != 0)
|
||||
{
|
||||
mp_limb_t divisor_limb_inverted;
|
||||
|
|
@ -137,9 +136,7 @@ mpn_mod_1 (mp_srcptr dividend_ptr, mp_size_t dividend_size,
|
|||
{
|
||||
if (UDIV_NEEDS_NORMALIZATION)
|
||||
{
|
||||
int normalization_steps;
|
||||
|
||||
count_leading_zeros (normalization_steps, divisor_limb);
|
||||
int normalization_steps = stdc_leading_zeros (divisor_limb);
|
||||
if (normalization_steps != 0)
|
||||
{
|
||||
divisor_limb <<= normalization_steps;
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ extern double ____strtod_l_internal (const char *, char **, int, locale_t);
|
|||
#include <stdint.h>
|
||||
#include <rounding-mode.h>
|
||||
#include <tininess.h>
|
||||
#include <stdbit.h>
|
||||
|
||||
/* The gmp headers need some configuration frobs. */
|
||||
#define HAVE_ALLOCA 1
|
||||
|
|
@ -1247,7 +1248,7 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
|
|||
}
|
||||
|
||||
/* Determine how many bits of the result we already have. */
|
||||
count_leading_zeros (bits, num[numsize - 1]);
|
||||
bits = stdc_leading_zeros (num[numsize - 1]);
|
||||
bits = numsize * BITS_PER_MP_LIMB - bits;
|
||||
|
||||
/* Now we know the exponent of the number in base two.
|
||||
|
|
@ -1465,7 +1466,8 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
|
|||
|--- n ---|
|
||||
*/
|
||||
|
||||
count_leading_zeros (cnt, den[densize - 1]);
|
||||
cnt = stdc_leading_zeros (den[densize - 1]);
|
||||
|
||||
|
||||
if (cnt > 0)
|
||||
{
|
||||
|
|
@ -1504,11 +1506,7 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
|
|||
#define got_limb \
|
||||
if (bits == 0) \
|
||||
{ \
|
||||
int cnt; \
|
||||
if (quot == 0) \
|
||||
cnt = BITS_PER_MP_LIMB; \
|
||||
else \
|
||||
count_leading_zeros (cnt, quot); \
|
||||
int cnt = stdc_leading_zeros (quot); \
|
||||
exponent -= cnt; \
|
||||
if (BITS_PER_MP_LIMB - cnt > MANT_DIG) \
|
||||
{ \
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#include <ieee754.h>
|
||||
#include <float.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbit.h>
|
||||
|
||||
/* Convert a `double' in IEEE754 standard double-precision format to a
|
||||
multi-precision integer representing the significand scaled up by its
|
||||
|
|
@ -68,7 +69,7 @@ __mpn_extract_double (mp_ptr res_ptr, mp_size_t size,
|
|||
|
||||
if (res_ptr[N - 1] != 0)
|
||||
{
|
||||
count_leading_zeros (cnt, res_ptr[N - 1]);
|
||||
cnt = stdc_leading_zeros (res_ptr[N - 1]);
|
||||
cnt -= NUM_LEADING_ZEROS;
|
||||
#if N == 2
|
||||
res_ptr[N - 1] = res_ptr[1] << cnt
|
||||
|
|
@ -82,7 +83,7 @@ __mpn_extract_double (mp_ptr res_ptr, mp_size_t size,
|
|||
}
|
||||
else
|
||||
{
|
||||
count_leading_zeros (cnt, res_ptr[0]);
|
||||
cnt = stdc_leading_zeros (res_ptr[0]);
|
||||
if (cnt >= NUM_LEADING_ZEROS)
|
||||
{
|
||||
res_ptr[N - 1] = res_ptr[0] << (cnt - NUM_LEADING_ZEROS);
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#include <math.h>
|
||||
#include <math_private.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbit.h>
|
||||
|
||||
/* Convert a `long double' in IEEE854 quad-precision format to a
|
||||
multi-precision integer representing the significand scaled up by its
|
||||
|
|
@ -76,7 +77,7 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
|
|||
#if N == 2
|
||||
if (res_ptr[N - 1] != 0)
|
||||
{
|
||||
count_leading_zeros (cnt, res_ptr[N - 1]);
|
||||
cnt = stdc_leading_zeros (res_ptr[N - 1]);
|
||||
cnt -= NUM_LEADING_ZEROS;
|
||||
res_ptr[N - 1] = res_ptr[N - 1] << cnt
|
||||
| (res_ptr[0] >> (BITS_PER_MP_LIMB - cnt));
|
||||
|
|
@ -85,7 +86,7 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
|
|||
}
|
||||
else
|
||||
{
|
||||
count_leading_zeros (cnt, res_ptr[0]);
|
||||
cnt = stdc_leading_zeros (res_ptr[0]);
|
||||
if (cnt >= NUM_LEADING_ZEROS)
|
||||
{
|
||||
res_ptr[N - 1] = res_ptr[0] << (cnt - NUM_LEADING_ZEROS);
|
||||
|
|
@ -106,7 +107,7 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
|
|||
if (res_ptr[j] != 0)
|
||||
break;
|
||||
|
||||
count_leading_zeros (cnt, res_ptr[j]);
|
||||
cnt = stdc_leading_zeros (res_ptr[j]);
|
||||
cnt -= NUM_LEADING_ZEROS;
|
||||
l = N - 1 - j;
|
||||
if (cnt < 0)
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbit.h>
|
||||
|
||||
/* Convert a `long double' in IBM extended format to a multi-precision
|
||||
integer representing the significand scaled up by its number of
|
||||
|
|
@ -133,7 +134,7 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
|
|||
#if N == 2
|
||||
if (res_ptr[N - 1] != 0)
|
||||
{
|
||||
count_leading_zeros (cnt, res_ptr[N - 1]);
|
||||
cnt = stdc_leading_zeros (res_ptr[N - 1]);
|
||||
cnt -= NUM_LEADING_ZEROS;
|
||||
res_ptr[N - 1] = res_ptr[N - 1] << cnt
|
||||
| (res_ptr[0] >> (BITS_PER_MP_LIMB - cnt));
|
||||
|
|
@ -142,7 +143,7 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
|
|||
}
|
||||
else
|
||||
{
|
||||
count_leading_zeros (cnt, res_ptr[0]);
|
||||
cnt = stdc_leading_zeros (res_ptr[0]);
|
||||
if (cnt >= NUM_LEADING_ZEROS)
|
||||
{
|
||||
res_ptr[N - 1] = res_ptr[0] << (cnt - NUM_LEADING_ZEROS);
|
||||
|
|
@ -163,7 +164,7 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
|
|||
if (res_ptr[j] != 0)
|
||||
break;
|
||||
|
||||
count_leading_zeros (cnt, res_ptr[j]);
|
||||
cnt = stdc_leading_zeros (res_ptr[j]);
|
||||
cnt -= NUM_LEADING_ZEROS;
|
||||
l = N - 1 - j;
|
||||
if (cnt < 0)
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbit.h>
|
||||
|
||||
/* Convert a `long double' in IEEE854 standard double-precision format to a
|
||||
multi-precision integer representing the significand scaled up by its
|
||||
|
|
@ -67,7 +68,7 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
|
|||
|
||||
if (res_ptr[N - 1] != 0)
|
||||
{
|
||||
count_leading_zeros (cnt, res_ptr[N - 1]);
|
||||
cnt = stdc_leading_zeros (res_ptr[N - 1]);
|
||||
if (cnt != 0)
|
||||
{
|
||||
#if N == 2
|
||||
|
|
@ -82,7 +83,7 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
|
|||
}
|
||||
else
|
||||
{
|
||||
count_leading_zeros (cnt, res_ptr[0]);
|
||||
cnt = stdc_leading_zeros (res_ptr[0]);
|
||||
res_ptr[N - 1] = res_ptr[0] << cnt;
|
||||
res_ptr[0] = 0;
|
||||
*expt = LDBL_MIN_EXP - 1 - BITS_PER_MP_LIMB - cnt;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
#include <endian.h>
|
||||
#include <stdlib.h>
|
||||
#include <bits/wordsize.h>
|
||||
#include <stdbit.h>
|
||||
|
||||
#if __WORDSIZE != 32
|
||||
#error This is for 32-bit targets only
|
||||
|
|
@ -113,7 +114,7 @@ __udivmoddi4 (UDWtype n, UDWtype d, UDWtype *rp)
|
|||
{
|
||||
/* 0q = nn / 0D */
|
||||
|
||||
count_leading_zeros (bm, d0);
|
||||
bm = stdc_leading_zeros (d0);
|
||||
|
||||
if (bm != 0)
|
||||
{
|
||||
|
|
@ -137,7 +138,7 @@ __udivmoddi4 (UDWtype n, UDWtype d, UDWtype *rp)
|
|||
if (d0 == 0)
|
||||
d0 = 1 / d0; /* Divide intentionally by zero. */
|
||||
|
||||
count_leading_zeros (bm, d0);
|
||||
bm = stdc_leading_zeros (d0);
|
||||
|
||||
if (bm == 0)
|
||||
{
|
||||
|
|
@ -202,7 +203,7 @@ __udivmoddi4 (UDWtype n, UDWtype d, UDWtype *rp)
|
|||
{
|
||||
/* 0q = NN / dd */
|
||||
|
||||
count_leading_zeros (bm, d1);
|
||||
bm = stdc_leading_zeros (d1);
|
||||
if (bm == 0)
|
||||
{
|
||||
/* From (n1 >= d1) /\ (the most significant bit of d1 is set),
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#include <ieee754.h>
|
||||
#include <float.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbit.h>
|
||||
|
||||
/* Convert a `long double' in IEEE854 standard double-precision format to a
|
||||
multi-precision integer representing the significand scaled up by its
|
||||
|
|
@ -73,7 +74,7 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
|
|||
|
||||
if (res_ptr[N - 1] != 0)
|
||||
{
|
||||
count_leading_zeros (cnt, res_ptr[N - 1]);
|
||||
cnt = stdc_leading_zeros (res_ptr[N - 1]);
|
||||
if (cnt != 0)
|
||||
{
|
||||
#if N == 2
|
||||
|
|
@ -88,7 +89,7 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
|
|||
}
|
||||
else if (res_ptr[0] != 0)
|
||||
{
|
||||
count_leading_zeros (cnt, res_ptr[0]);
|
||||
cnt = stdc_leading_zeros (res_ptr[0]);
|
||||
res_ptr[N - 1] = res_ptr[0] << cnt;
|
||||
res_ptr[0] = 0;
|
||||
*expt = LDBL_MIN_EXP - 1 - BITS_PER_MP_LIMB - cnt;
|
||||
|
|
|
|||
Loading…
Reference in New Issue