From b1ba3e6d5c608b16f05adc6d331ec22a6ed443ae Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sat, 2 Oct 2021 06:06:08 -0700 Subject: [PATCH] Refactor Windows workarounds --- include/fmt/core.h | 3 --- include/fmt/format.h | 35 ++++++++++++++++++----------------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 7a66433e9fd42..18cdf2237d042 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -34,13 +34,10 @@ #ifdef __ICL # define FMT_ICC_VERSION __ICL -# define FMT_ICC_INTRINSIC_BUG 1 #elif defined(__INTEL_COMPILER) # define FMT_ICC_VERSION __INTEL_COMPILER -# define FMT_ICC_INTRINSIC_BUG 0 #else # define FMT_ICC_VERSION 0 -# define FMT_ICC_INTRINSIC_BUG 0 #endif #ifdef __NVCC__ diff --git a/include/fmt/format.h b/include/fmt/format.h index 9e132fa1f346b..23dbe1d9fbe69 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -162,24 +162,25 @@ FMT_END_NAMESPACE #endif // __builtin_clz is broken in clang with Microsoft CodeGen: -// https://github.com/fmtlib/fmt/issues/519 -#if (FMT_GCC_VERSION || FMT_HAS_BUILTIN(__builtin_clz) || FMT_ICC_VERSION) && \ - !FMT_MSC_VER -# define FMT_BUILTIN_CLZ(n) __builtin_clz(n) -#endif -#if (FMT_GCC_VERSION || FMT_HAS_BUILTIN(__builtin_clzll) || \ - FMT_ICC_VERSION) && \ - !FMT_MSC_VER -# define FMT_BUILTIN_CLZLL(n) __builtin_clzll(n) -#endif -#if (FMT_GCC_VERSION || FMT_HAS_BUILTIN(__builtin_ctz) || FMT_ICC_VERSION) && \ - !FMT_ICC_INTRINSIC_BUG -# define FMT_BUILTIN_CTZ(n) __builtin_ctz(n) +// https://github.com/fmtlib/fmt/issues/519. +#ifndef FMT_MSC_VER +# if FMT_HAS_BUILTIN(__builtin_clz) || FMT_GCC_VERSION || FMT_ICC_VERSION +# define FMT_BUILTIN_CLZ(n) __builtin_clz(n) +# endif +# if FMT_HAS_BUILTIN(__builtin_clzll) || FMT_GCC_VERSION || FMT_ICC_VERSION +# define FMT_BUILTIN_CLZLL(n) __builtin_clzll(n) +# endif #endif -#if (FMT_GCC_VERSION || FMT_HAS_BUILTIN(__builtin_ctzll) || \ - FMT_ICC_VERSION) && \ - !FMT_ICC_INTRINSIC_BUG -# define FMT_BUILTIN_CTZLL(n) __builtin_ctzll(n) + +// __builtin_ctz is broken in Intel Compiler Classic on Windows: +// https://github.com/fmtlib/fmt/issues/2510. +#ifndef __ICL +# if FMT_HAS_BUILTIN(__builtin_ctz) || FMT_GCC_VERSION || FMT_ICC_VERSION +# define FMT_BUILTIN_CTZ(n) __builtin_ctz(n) +# endif +# if FMT_HAS_BUILTIN(__builtin_ctzll) || FMT_GCC_VERSION || FMT_ICC_VERSION +# define FMT_BUILTIN_CTZLL(n) __builtin_ctzll(n) +# endif #endif #if FMT_MSC_VER