From: Paul Eggert Date: Sun, 1 Jun 2025 22:51:26 +0000 (-0700) Subject: factor: remove wide_int X-Git-Tag: v9.8~241 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=88cca5d5fca6e49654f88013018a7e29785b206e;p=thirdparty%2Fcoreutils.git factor: remove wide_int * src/factor.c (wide_int): Remove, since it gets in the way of using mp_limb_t for words. All uses removed. (submod2, HIGHBIT_TO_MASK, divexact_21): Rewrite without using wide_int. This shouldn't change the machine code these days, as compilers are pretty smart about isolating the top bit of an unsigned int. --- diff --git a/src/factor.c b/src/factor.c index cb0df9e096..8fec474c0e 100644 --- a/src/factor.c +++ b/src/factor.c @@ -125,11 +125,9 @@ use the widest hardware-supported type. */ #if USE_INT128 typedef unsigned __int128 wide_uint; -typedef __int128 wide_int; # define W_TYPE_SIZE 128 #else typedef uintmax_t wide_uint; -typedef intmax_t wide_int; # define W_TYPE_SIZE UINTMAX_WIDTH #endif #define WIDE_UINT_MAX ((wide_uint) -1) @@ -390,15 +388,11 @@ static void factor (wide_uint, wide_uint, struct factors *); #define submod2(r1, r0, a1, a0, b1, b0, n1, n0) \ do { \ sub_ddmmss ((r1), (r0), (a1), (a0), (b1), (b0)); \ - if ((wide_int) (r1) < 0) \ + if ((r1) >> (W_TYPE_SIZE - 1) != 0) \ add_ssaaaa ((r1), (r0), (r1), (r0), (n1), (n0)); \ } while (0) -#define HIGHBIT_TO_MASK(x) \ - (((wide_int)-1 >> 1) < 0 \ - ? (wide_uint)((wide_int)(x) >> (W_TYPE_SIZE - 1)) \ - : ((x) & ((wide_uint) 1 << (W_TYPE_SIZE - 1)) \ - ? WIDE_UINT_MAX : (wide_uint) 0)) +#define HIGHBIT_TO_MASK(x) (- ((wide_uint) (x) >> (W_TYPE_SIZE - 1))) /* Return r = a mod d, where a = , d = . Requires that d1 != 0. */ @@ -910,7 +904,7 @@ static const unsigned char binvert_table[128] = if ((u1) >= (d)) \ { \ wide_uint _p1; \ - MAYBE_UNUSED wide_int _p0; \ + MAYBE_UNUSED wide_uint _p0; \ umul_ppmm (_p1, _p0, _q0, d); \ (q1) = ((u1) - _p1) * _di; \ (q0) = _q0; \