ni...@lysator.liu.se (Niels Möller) writes: > Pushed now.
And below, a patch to delete all mention of COUNT_LEADING_ZEROS_0, except for tune/many.pl, which I'm not familiar with. What do you think? Regards, /Niels diff -Nprc2 gmp.0e10f8f34eb4/longlong.h gmp/longlong.h *** gmp.0e10f8f34eb4/longlong.h 2017-12-27 17:23:38.383996985 +0100 --- gmp/longlong.h 2017-12-27 17:23:38.399997013 +0100 *************** see https://www.gnu.org/licenses/. */ *** 88,93 **** 5) count_leading_zeros(count, x) counts the number of zero-bits from the msb to the first non-zero bit in the UWtype X. This is the number of ! steps X needs to be shifted left to set the msb. Undefined for X == 0, ! unless the symbol COUNT_LEADING_ZEROS_0 is defined to some value. 6) count_trailing_zeros(count, x) like count_leading_zeros, but counts --- 88,92 ---- 5) count_leading_zeros(count, x) counts the number of zero-bits from the msb to the first non-zero bit in the UWtype X. This is the number of ! steps X needs to be shifted left to set the msb. Undefined for X == 0. 6) count_trailing_zeros(count, x) like count_leading_zeros, but counts *************** long __MPN(count_leading_zeros) (UDItype *** 411,415 **** : "=r" (count) \ : "r" (x)) - #define COUNT_LEADING_ZEROS_0 32 #endif /* __a29k__ */ --- 410,413 ---- *************** extern UWtype __MPN(udiv_qrnnd) (UWtype *** 947,951 **** } while (0) #define COUNT_LEADING_ZEROS_NEED_CLZ_TAB - #define COUNT_LEADING_ZEROS_0 31 /* n==0 indistinguishable from n==1 */ #else /* ! pentiummmx || LONGLONG_STANDALONE */ --- 945,948 ---- *************** extern UWtype __MPN(udiv_qrnnd) (UWtype *** 966,970 **** (c) = 0x3FF + 31 - (__u.a[1] >> 20); \ } while (0) - #define COUNT_LEADING_ZEROS_0 (0x3FF + 31) #endif /* pentiummx */ --- 963,966 ---- *************** extern UWtype __MPN(udiv_qrnnd) (UWtype *** 1106,1110 **** (count) = __cbtmp ^ 31; \ } while (0) - #define COUNT_LEADING_ZEROS_0 (-32) /* sic */ #if defined (__i960mx) /* what is the proper symbol to test??? */ #define rshift_rhlc(r,h,l,c) \ --- 1102,1105 ---- *************** extern UWtype __MPN(udiv_qrnnd) (UWtype *** 1193,1197 **** : "=d" (count) \ : "od" ((USItype) (x)), "n" (0)) - #define COUNT_LEADING_ZEROS_0 32 #endif #endif /* mc68000 */ --- 1188,1191 ---- *************** extern UWtype __MPN(udiv_qrnnd) (UWtype *** 1212,1216 **** (count) = __cbtmp ^ 31; \ } while (0) - #define COUNT_LEADING_ZEROS_0 63 /* sic */ #if defined (__m88110__) #define umul_ppmm(wh, wl, u, v) \ --- 1206,1209 ---- *************** extern UWtype __MPN(udiv_qrnnd) (UWtype *** 1370,1374 **** #define count_leading_zeros(count, x) \ __asm__ ("cntlzw %0,%1" : "=r" (count) : "r" (x)) - #define COUNT_LEADING_ZEROS_0 32 #if HAVE_HOST_CPU_FAMILY_powerpc #if __GMP_GNUC_PREREQ (4,4) --- 1363,1366 ---- *************** extern UWtype __MPN(udiv_qrnnd) (UWtype *** 1487,1491 **** #define count_leading_zeros(count, x) \ __asm__ ("cntlzd %0,%1" : "=r" (count) : "r" (x)) - #define COUNT_LEADING_ZEROS_0 64 #if __GMP_GNUC_PREREQ (4,8) #define umul_ppmm(w1, w0, u, v) \ --- 1479,1482 ---- *************** extern UWtype __MPN(udiv_qrnnd) (UWtype *** 1711,1716 **** __asm__ ("scan %1,1,%0" : "=r" (count) : "r" (x)) /* Early sparclites return 63 for an argument of 0, but they warn that future ! implementations might change this. Therefore, leave COUNT_LEADING_ZEROS_0 ! undefined. */ #endif /* __sparclite__ */ #endif /* __sparc_v8__ */ --- 1702,1706 ---- __asm__ ("scan %1,1,%0" : "=r" (count) : "r" (x)) /* Early sparclites return 63 for an argument of 0, but they warn that future ! implementations might change this. */ #endif /* __sparclite__ */ #endif /* __sparc_v8__ */ *************** __GMP_DECLSPEC UWtype __MPN(udiv_w_sdiv) *** 2145,2149 **** } while (0) /* This version gives a well-defined value for zero. */ - #define COUNT_LEADING_ZEROS_0 (W_TYPE_SIZE - 1) #define COUNT_LEADING_ZEROS_NEED_CLZ_TAB #define COUNT_LEADING_ZEROS_SLOW --- 2135,2138 ---- diff -Nprc2 gmp.0e10f8f34eb4/tests/t-count_zeros.c gmp/tests/t-count_zeros.c *** gmp.0e10f8f34eb4/tests/t-count_zeros.c 2017-12-27 17:23:38.383996985 +0100 --- gmp/tests/t-count_zeros.c 2017-12-27 17:23:38.399997013 +0100 *************** check_various (void) *** 59,66 **** int i; - #ifdef COUNT_LEADING_ZEROS_0 - check_clz (COUNT_LEADING_ZEROS_0, CNST_LIMB(0)); - #endif - for (i=0; i < GMP_LIMB_BITS; i++) { --- 59,62 ---- diff -Nprc2 gmp.0e10f8f34eb4/tune/common.c gmp/tune/common.c *** gmp.0e10f8f34eb4/tune/common.c 2017-12-27 17:23:38.387996993 +0100 --- gmp/tune/common.c 2017-12-27 17:23:38.399997013 +0100 *************** speed_operator_mod (struct speed_params *** 2595,2599 **** int speed_routine_count_zeros_setup (struct speed_params *s, ! mp_ptr xp, int leading, int zero) { int i, c; --- 2595,2599 ---- int speed_routine_count_zeros_setup (struct speed_params *s, ! mp_ptr xp, int leading) { int i, c; *************** speed_routine_count_zeros_setup (struct *** 2605,2612 **** it to 1 for leading, or 0x800..00 for trailing. */ MPN_COPY (xp, s->xp_block, SPEED_BLOCK_SIZE); ! if (! zero) ! for (i = 0; i < SPEED_BLOCK_SIZE; i++) ! if (xp[i] == 0) ! xp[i] = leading ? 1 : GMP_LIMB_HIGHBIT; } else if (s->r == 1) --- 2605,2611 ---- it to 1 for leading, or 0x800..00 for trailing. */ MPN_COPY (xp, s->xp_block, SPEED_BLOCK_SIZE); ! for (i = 0; i < SPEED_BLOCK_SIZE; i++) ! if (xp[i] == 0) ! xp[i] = leading ? 1 : GMP_LIMB_HIGHBIT; } else if (s->r == 1) *************** double *** 2648,2658 **** speed_count_leading_zeros (struct speed_params *s) { ! #ifdef COUNT_LEADING_ZEROS_0 ! #define COUNT_LEADING_ZEROS_0_ALLOWED 1 ! #else ! #define COUNT_LEADING_ZEROS_0_ALLOWED 0 ! #endif ! ! SPEED_ROUTINE_COUNT_ZEROS_A (1, COUNT_LEADING_ZEROS_0_ALLOWED); count_leading_zeros (c, n); SPEED_ROUTINE_COUNT_ZEROS_B (); --- 2647,2651 ---- speed_count_leading_zeros (struct speed_params *s) { ! SPEED_ROUTINE_COUNT_ZEROS_A (1); count_leading_zeros (c, n); SPEED_ROUTINE_COUNT_ZEROS_B (); *************** double *** 2661,2665 **** speed_count_trailing_zeros (struct speed_params *s) { ! SPEED_ROUTINE_COUNT_ZEROS_A (0, 0); count_trailing_zeros (c, n); SPEED_ROUTINE_COUNT_ZEROS_B (); --- 2654,2658 ---- speed_count_trailing_zeros (struct speed_params *s) { ! SPEED_ROUTINE_COUNT_ZEROS_A (0); count_trailing_zeros (c, n); SPEED_ROUTINE_COUNT_ZEROS_B (); diff -Nprc2 gmp.0e10f8f34eb4/tune/speed.h gmp/tune/speed.h *** gmp.0e10f8f34eb4/tune/speed.h 2017-12-27 17:23:38.391996999 +0100 --- gmp/tune/speed.h 2017-12-27 17:23:38.399997013 +0100 *************** void mpz_powm_mod (mpz_ptr, mpz_srcptr, *** 513,517 **** void mpz_powm_redc (mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr); ! int speed_routine_count_zeros_setup (struct speed_params *, mp_ptr, int, int); --- 513,517 ---- void mpz_powm_redc (mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr); ! int speed_routine_count_zeros_setup (struct speed_params *, mp_ptr, int); *************** int speed_routine_count_zeros_setup (str *** 3513,3517 **** Give zero=1 if n=0 is allowed in the call, zero=0 if not. */ ! #define SPEED_ROUTINE_COUNT_ZEROS_A(leading, zero) \ { \ mp_ptr xp; \ --- 3513,3517 ---- Give zero=1 if n=0 is allowed in the call, zero=0 if not. */ ! #define SPEED_ROUTINE_COUNT_ZEROS_A(leading) \ { \ mp_ptr xp; \ *************** int speed_routine_count_zeros_setup (str *** 3525,3529 **** SPEED_TMP_ALLOC_LIMBS (xp, SPEED_BLOCK_SIZE, s->align_xp); \ \ ! if (! speed_routine_count_zeros_setup (s, xp, leading, zero)) \ return -1.0; \ speed_operand_src (s, xp, SPEED_BLOCK_SIZE); \ --- 3525,3529 ---- SPEED_TMP_ALLOC_LIMBS (xp, SPEED_BLOCK_SIZE, s->align_xp); \ \ ! if (! speed_routine_count_zeros_setup (s, xp, leading)) \ return -1.0; \ speed_operand_src (s, xp, SPEED_BLOCK_SIZE); \ *************** int speed_routine_count_zeros_setup (str *** 3553,3572 **** } \ ! #define SPEED_ROUTINE_COUNT_ZEROS_C(call, leading, zero) \ do { \ ! SPEED_ROUTINE_COUNT_ZEROS_A (leading, zero); \ call; \ SPEED_ROUTINE_COUNT_ZEROS_B (); \ } while (0) \ ! #define SPEED_ROUTINE_COUNT_LEADING_ZEROS_C(call,zero) \ ! SPEED_ROUTINE_COUNT_ZEROS_C (call, 1, zero) #define SPEED_ROUTINE_COUNT_LEADING_ZEROS(fun) \ ! SPEED_ROUTINE_COUNT_ZEROS_C (fun (c, n), 1, 0) ! #define SPEED_ROUTINE_COUNT_TRAILING_ZEROS_C(call,zero) \ ! SPEED_ROUTINE_COUNT_ZEROS_C (call, 0, zero) #define SPEED_ROUTINE_COUNT_TRAILING_ZEROS(call) \ ! SPEED_ROUTINE_COUNT_ZEROS_C (fun (c, n), 0, 0) --- 3553,3572 ---- } \ ! #define SPEED_ROUTINE_COUNT_ZEROS_C(call, leading) \ do { \ ! SPEED_ROUTINE_COUNT_ZEROS_A (leading); \ call; \ SPEED_ROUTINE_COUNT_ZEROS_B (); \ } while (0) \ ! #define SPEED_ROUTINE_COUNT_LEADING_ZEROS_C(call) \ ! SPEED_ROUTINE_COUNT_ZEROS_C (call, 1) #define SPEED_ROUTINE_COUNT_LEADING_ZEROS(fun) \ ! SPEED_ROUTINE_COUNT_ZEROS_C (fun (c, n), 1) ! #define SPEED_ROUTINE_COUNT_TRAILING_ZEROS_C(call) \ ! SPEED_ROUTINE_COUNT_ZEROS_C (call, 0) #define SPEED_ROUTINE_COUNT_TRAILING_ZEROS(call) \ ! SPEED_ROUTINE_COUNT_ZEROS_C (fun (c, n), 0) -- Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677. Internet email is subject to wholesale government surveillance. _______________________________________________ gmp-bugs mailing list gmp-bugs@gmplib.org https://gmplib.org/mailman/listinfo/gmp-bugs