Skip to content

Commit

Permalink
Remove FMT_BUILTIN_CTZ
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Oct 27, 2024
1 parent 27110bc commit be1ad64
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,26 +185,16 @@ FMT_END_NAMESPACE
# endif
#endif

// __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 || \
defined(__NVCOMPILER)
# define FMT_BUILTIN_CTZ(n) __builtin_ctz(n)
# endif
#endif

// Some compilers masquerade as both MSVC and GCC-likes but otherwise support
// __builtin_clz and __builtin_clzll, so only define FMT_BUILTIN_CLZ using the
// MSVC intrinsics if the clz and clzll builtins are not available.
#if FMT_MSC_VERSION && !defined(FMT_BUILTIN_CLZLL)
FMT_BEGIN_NAMESPACE
namespace detail {
// Avoid Clang with Microsoft CodeGen's -Wunknown-pragmas warning.
# if !defined(__clang__)
# pragma intrinsic(_BitScanForward)
# ifndef __clang__
# pragma intrinsic(_BitScanReverse)
# if defined(_WIN64)
# ifdef _WIN64
# pragma intrinsic(_BitScanReverse64)
# endif
# endif
Expand Down Expand Up @@ -236,15 +226,6 @@ inline auto clzll(uint64_t x) -> int {
return 63 ^ static_cast<int>(r);
}
# define FMT_BUILTIN_CLZLL(n) detail::clzll(n)

inline auto ctz(uint32_t x) -> int {
unsigned long r = 0;
_BitScanForward(&r, x);
FMT_ASSERT(x != 0, "");
FMT_MSC_WARNING(suppress : 6102) // Suppress a bogus static analysis warning.
return static_cast<int>(r);
}
# define FMT_BUILTIN_CTZ(n) detail::ctz(n)
} // namespace detail
FMT_END_NAMESPACE
#endif
Expand Down

0 comments on commit be1ad64

Please sign in to comment.