Fixes IBM XLC behavior with uint128 fallback

This commit is contained in:
Federico Busato 2022-07-14 12:04:32 -07:00
parent d82e1a108d
commit 987e16820c
2 changed files with 17 additions and 2 deletions

View File

@ -49,6 +49,18 @@
# define FMT_ICC_VERSION 0
#endif
#ifdef __xlC_ver__
# define FMT_XLC_VERSION __xlC_ver__
#elif defined(__xlC__)
# define FMT_XLC_VERSION __xlC__
#elif defined(__IBMC__)
# define FMT_XLC_VERSION __IBMC__
#elif defined(__IBMCPP__)
# define FMT_XLC_VERSION __IBMCPP__
#else
# define FMT_XLC_VERSION 0
#endif
#ifdef _MSC_VER
# define FMT_MSC_VERSION _MSC_VER
# define FMT_MSC_WARNING(...) __pragma(warning(__VA_ARGS__))

View File

@ -391,11 +391,14 @@ class uint128_fallback {
hi_ += (lo_ < n ? 1 : 0);
return *this;
}
#if FMT_HAS_BUILTIN(__builtin_addcll)
#if FMT_XLC_VERSION && defined(_ARCH_PWR9) && defined(_ARCH_PPC64)
lo_ = __addex(lo_, n, 0, &carry);
hi_ += carry;
#elif FMT_HAS_BUILTIN(__builtin_addcll) && !FMT_XLC_VERSION
unsigned long long carry;
lo_ = __builtin_addcll(lo_, n, 0, &carry);
hi_ += carry;
#elif FMT_HAS_BUILTIN(__builtin_ia32_addcarryx_u64)
#elif FMT_HAS_BUILTIN(__builtin_ia32_addcarryx_u64) && !FMT_XLC_VERSION
unsigned long long result;
auto carry = __builtin_ia32_addcarryx_u64(0, lo_, n, &result);
lo_ = result;