aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-06-07 14:15:48 -0700
committerChris Robinson <[email protected]>2020-06-07 14:15:48 -0700
commit9322c86e2f464da6889385c389dee7374f1bc30e (patch)
treea6c9b0adfa5515b96fed933e886a8f1d282ab03c
parentab3ccb513a0c18a380411069e0cfb9c856b02b05 (diff)
Avoid explicit checks for _BitScanForward[64]
-rw-r--r--CMakeLists.txt14
-rw-r--r--common/alnumeric.h19
-rw-r--r--config.h.in6
3 files changed, 10 insertions, 29 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4793afe5..4d0bb217 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -433,20 +433,6 @@ IF(HAVE_INTRIN_H)
__cpuid(regs, 0);
return regs[0];
}" HAVE_CPUID_INTRINSIC)
- CHECK_C_SOURCE_COMPILES("#include <intrin.h>
- int main()
- {
- unsigned long idx = 0;
- _BitScanForward64(&idx, 1);
- return idx;
- }" HAVE_BITSCANFORWARD64_INTRINSIC)
- CHECK_C_SOURCE_COMPILES("#include <intrin.h>
- int main()
- {
- unsigned long idx = 0;
- _BitScanForward(&idx, 1);
- return idx;
- }" HAVE_BITSCANFORWARD_INTRINSIC)
ENDIF()
check_cxx_source_compiles("#include <cstdlib>
diff --git a/common/alnumeric.h b/common/alnumeric.h
index 9158b764..df05b966 100644
--- a/common/alnumeric.h
+++ b/common/alnumeric.h
@@ -132,7 +132,7 @@ inline int fallback_popcnt64(uint64_t v)
}
#define POPCNT64 fallback_popcnt64
-#if defined(HAVE_BITSCANFORWARD64_INTRINSIC)
+#if defined(_WIN64)
inline int msvc64_ctz32(uint32_t v)
{
@@ -149,7 +149,7 @@ inline int msvc64_ctz64(uint64_t v)
}
#define CTZ64 msvc64_ctz64
-#elif defined(HAVE_BITSCANFORWARD_INTRINSIC)
+#elif defined(_WIN32)
inline int msvc_ctz32(uint32_t v)
{
@@ -225,8 +225,9 @@ inline int float2int(float f) noexcept
#if defined(HAVE_SSE_INTRINSICS)
return _mm_cvtt_ss2si(_mm_set_ss(f));
-#elif ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__)) && \
- !defined(__SSE_MATH__)) || (defined(_MSC_VER) && defined(_M_IX86_FP) && _M_IX86_FP == 0)
+#elif (defined(_MSC_VER) && defined(_M_IX86_FP) && _M_IX86_FP == 0) \
+ || ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__)) \
+ && !defined(__SSE_MATH__))
int sign, shift, mant;
union {
float f;
@@ -260,9 +261,9 @@ inline int double2int(double d) noexcept
#if defined(HAVE_SSE_INTRINSICS)
return _mm_cvttsd_si32(_mm_set_sd(d));
-#elif ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__)) && \
- !defined(__SSE2_MATH__)) || (defined(_MSC_VER) && defined(_M_IX86_FP) && _M_IX86_FP < 2)
-
+#elif (defined(_MSC_VER) && defined(_M_IX86_FP) && _M_IX86_FP < 2) \
+ || ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__)) \
+ && !defined(__SSE2_MATH__))
int sign, shift;
int64_t mant;
union {
@@ -296,8 +297,8 @@ inline int double2int(double d) noexcept
*/
inline float fast_roundf(float f) noexcept
{
-#if (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__)) && \
- !defined(__SSE_MATH__)
+#if (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__)) \
+ && !defined(__SSE_MATH__)
float out;
__asm__ __volatile__("frndint" : "=t"(out) : "0"(f));
diff --git a/config.h.in b/config.h.in
index 75aacc0d..2de3640e 100644
--- a/config.h.in
+++ b/config.h.in
@@ -107,12 +107,6 @@
/* Define if we have the __cpuid() intrinsic */
#cmakedefine HAVE_CPUID_INTRINSIC
-/* Define if we have the _BitScanForward64() intrinsic */
-#cmakedefine HAVE_BITSCANFORWARD64_INTRINSIC
-
-/* Define if we have the _BitScanForward() intrinsic */
-#cmakedefine HAVE_BITSCANFORWARD_INTRINSIC
-
/* Define if we have SSE intrinsics */
#cmakedefine HAVE_SSE_INTRINSICS