Skip to content

Commit

Permalink
Relax the criteria for using intrinsics
Browse files Browse the repository at this point in the history
  • Loading branch information
jk-jeon committed Apr 26, 2021
1 parent e65f6b0 commit 4032d67
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions include/dragonbox/dragonbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ namespace jkj::dragonbox {
template <class UInt>
inline int countr_zero(UInt n) noexcept {
static_assert(std::is_unsigned_v<UInt> && value_bits<UInt> <= 64);
#if (defined(__GNUC__) || defined(__clang__)) && defined(__x86_64__)
#if defined(__GNUC__) || defined(__clang__)
#define JKJ_HAS_COUNTR_ZERO_INTRINSIC 1
if constexpr (std::is_same_v<UInt, unsigned long>) {
return __builtin_ctzl(n);
Expand Down Expand Up @@ -370,7 +370,7 @@ namespace jkj::dragonbox {
struct uint128 {
uint128() = default;

#if (defined(__GNUC__) || defined(__clang__)) && defined(__SIZEOF_INT128__) && defined(__x86_64__)
#if defined(__SIZEOF_INT128__)
unsigned __int128 internal_;

constexpr uint128(std::uint64_t high, std::uint64_t low) noexcept :
Expand Down Expand Up @@ -428,7 +428,7 @@ namespace jkj::dragonbox {

// Get 128-bit result of multiplication of two 64-bit unsigned integers
JKJ_SAFEBUFFERS inline uint128 umul128(std::uint64_t x, std::uint64_t y) noexcept {
#if (defined(__GNUC__) || defined(__clang__)) && defined(__SIZEOF_INT128__) && defined(__x86_64__)
#if defined(__SIZEOF_INT128__)
return (unsigned __int128)(x) * (unsigned __int128)(y);
#elif defined(_MSC_VER) && defined(_M_X64)
uint128 result;
Expand All @@ -453,7 +453,7 @@ namespace jkj::dragonbox {
}

JKJ_SAFEBUFFERS inline std::uint64_t umul128_upper64(std::uint64_t x, std::uint64_t y) noexcept {
#if (defined(__GNUC__) || defined(__clang__)) && defined(__SIZEOF_INT128__) && defined(__x86_64__)
#if defined(__SIZEOF_INT128__)
auto p = (unsigned __int128)(x) * (unsigned __int128)(y);
return std::uint64_t(p >> 64);
#elif defined(_MSC_VER) && defined(_M_X64)
Expand Down Expand Up @@ -484,7 +484,7 @@ namespace jkj::dragonbox {

// Get upper 32-bits of multiplication of a 32-bit unsigned integer and a 64-bit unsigned integer
inline std::uint32_t umul96_upper32(std::uint32_t x, std::uint64_t y) noexcept {
#if defined(__x86_64__) || defined(_M_X64)
#if defined(__SIZEOF_INT128__) || (defined(_MSC_VER) && defined(_M_X64))
return std::uint32_t(umul128_upper64(x, y));
#else
//std::uint32_t a = 0;
Expand Down

0 comments on commit 4032d67

Please sign in to comment.