Merge pull request #9433 from shuffle2/constexpr-error
BitUtils: loosen clz to inline on msvc/arm64
This commit is contained in:
commit
87debc6641
|
@ -362,7 +362,16 @@ T ExpandValue(T value, size_t left_shift_amount)
|
||||||
(T(-ExtractBit<0>(value)) >> (BitSize<T>() - left_shift_amount));
|
(T(-ExtractBit<0>(value)) >> (BitSize<T>() - left_shift_amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr int CountLeadingZeros(uint64_t value)
|
// On some compiler / arch combinations, the compiler does not see instrinsics as constexpr, so mark
|
||||||
|
// the function as inline instead.
|
||||||
|
#if defined(_MSC_VER) && defined(_M_ARM_64)
|
||||||
|
#define CONSTEXPR_FROM_INTRINSIC inline
|
||||||
|
#else
|
||||||
|
#define CONSTEXPR_FROM_INTRINSIC constexpr
|
||||||
|
#endif
|
||||||
|
|
||||||
|
CONSTEXPR_FROM_INTRINSIC
|
||||||
|
int CountLeadingZeros(uint64_t value)
|
||||||
{
|
{
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
return value ? __builtin_clzll(value) : 64;
|
return value ? __builtin_clzll(value) : 64;
|
||||||
|
@ -382,7 +391,8 @@ constexpr int CountLeadingZeros(uint64_t value)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr int CountLeadingZeros(uint32_t value)
|
CONSTEXPR_FROM_INTRINSIC
|
||||||
|
int CountLeadingZeros(uint32_t value)
|
||||||
{
|
{
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
return value ? __builtin_clz(value) : 32;
|
return value ? __builtin_clz(value) : 32;
|
||||||
|
@ -402,4 +412,6 @@ constexpr int CountLeadingZeros(uint32_t value)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef CONSTEXPR_FROM_INTRINSIC
|
||||||
|
|
||||||
} // namespace Common
|
} // namespace Common
|
||||||
|
|
Loading…
Reference in New Issue