From df7ede08f08348a791ebaadafaa963ed804a725d Mon Sep 17 00:00:00 2001 From: =?utf8?q?P=C3=A1draig=20Brady?= Date: Tue, 6 Jan 2015 02:27:16 +0000 Subject: [PATCH] count-leading-zeros: avoid 64-bit intrinsics on 32-bit Windows * lib/count-leading-zeros.h (count_leading_zeros_ll): Use 32 bit intrinsics in this case. * lib/count-trailing-zeros.h: Likewise. * lib/count-one-bits.h: Likewise. --- ChangeLog | 8 ++++++++ lib/count-leading-zeros.h | 5 +++++ lib/count-one-bits.h | 4 ++++ lib/count-trailing-zeros.h | 5 +++++ 4 files changed, 22 insertions(+) diff --git a/ChangeLog b/ChangeLog index 10fd5e848f..f1fe8e2263 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2015-01-06 Pádraig Brady + + count-leading-zeros: avoid 64-bit intrinsics on 32-bit Windows + * lib/count-leading-zeros.h (count_leading_zeros_ll): Use 32 bit + intrinsics in this case. + * lib/count-trailing-zeros.h: Likewise. + * lib/count-one-bits.h: Likewise. + 2015-01-06 Daiki Ueno uniname/uniname: update to Unicode 7.0.0 To accommodate new diff --git a/lib/count-leading-zeros.h b/lib/count-leading-zeros.h index 722615f9b5..9e72fffe1f 100644 --- a/lib/count-leading-zeros.h +++ b/lib/count-leading-zeros.h @@ -104,8 +104,13 @@ count_leading_zeros_l (unsigned long int x) COUNT_LEADING_ZEROS_INLINE int count_leading_zeros_ll (unsigned long long int x) { +# if _MSC_VER && ! defined _M_X64 + int count = count_leading_zeros (x >> 31 >> 1); + return count < 32 ? count : 32 + count_leading_zeros (x); +# else COUNT_LEADING_ZEROS (__builtin_clzll, _BitScanReverse64, unsigned long long int); +# endif } #endif diff --git a/lib/count-one-bits.h b/lib/count-one-bits.h index d54397f5fa..bd79fc5609 100644 --- a/lib/count-one-bits.h +++ b/lib/count-one-bits.h @@ -127,7 +127,11 @@ count_one_bits_l (unsigned long int x) COUNT_ONE_BITS_INLINE int count_one_bits_ll (unsigned long long int x) { +# if _MSC_VER && ! defined _M_X64 + return count_one_bits (x >> 31 >> 1) + count_one_bits (x); +# else COUNT_ONE_BITS (__builtin_popcountll, __popcnt64, unsigned long long int); +# endif } #endif diff --git a/lib/count-trailing-zeros.h b/lib/count-trailing-zeros.h index 83ce2fbe26..1e71977fab 100644 --- a/lib/count-trailing-zeros.h +++ b/lib/count-trailing-zeros.h @@ -96,8 +96,13 @@ count_trailing_zeros_l (unsigned long int x) COUNT_TRAILING_ZEROS_INLINE int count_trailing_zeros_ll (unsigned long long int x) { +# if _MSC_VER && ! defined _M_X64 + int count = count_trailing_zeros (x); + return count < 32 ? count : 32 + count_trailing_zeros (x >> 31 >> 1); +# else COUNT_TRAILING_ZEROS (__builtin_ctzll, _BitScanForward64, unsigned long long int); +# endif } #endif -- 2.39.5