mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-16 01:51:51 +08:00
fix msvc clz
(cherry picked from commit 2c4541f735d3dad2ce312bf785c366668d646f3b)
This commit is contained in:
parent
b8f894947a
commit
bd57b99f44
@ -982,10 +982,9 @@ struct count_bits_impl<BitsType, std::enable_if_t<sizeof(BitsType) <= sizeof(uns
|
||||
static const int kNumBits = static_cast<int>(sizeof(BitsType) * CHAR_BIT);
|
||||
static_assert(std::is_integral<BitsType>::value, "BitsType must be a built-in integer");
|
||||
static EIGEN_DEVICE_FUNC inline int clz(BitsType bits) {
|
||||
static const int kLeadingBitsOffset = static_cast<int>((sizeof(unsigned long) - sizeof(BitsType)) * CHAR_BIT);
|
||||
unsigned long out;
|
||||
_BitScanReverse(&out, static_cast<unsigned long>(bits));
|
||||
return bits == 0 ? kNumBits : static_cast<int>(out - kLeadingBitsOffset);
|
||||
return bits == 0 ? kNumBits : (kNumBits - 1) - static_cast<int>(out);
|
||||
}
|
||||
|
||||
static EIGEN_DEVICE_FUNC inline int ctz(BitsType bits) {
|
||||
@ -1003,10 +1002,9 @@ struct count_bits_impl<
|
||||
static const int kNumBits = static_cast<int>(sizeof(BitsType) * CHAR_BIT);
|
||||
static_assert(std::is_integral<BitsType>::value, "BitsType must be a built-in integer");
|
||||
static EIGEN_DEVICE_FUNC inline int clz(BitsType bits) {
|
||||
static const int kLeadingBitsOffset = static_cast<int>((sizeof(__int64) - sizeof(BitsType)) * CHAR_BIT);
|
||||
unsigned long out;
|
||||
_BitScanReverse64(&out, static_cast<unsigned __int64>(bits));
|
||||
return bits == 0 ? kNumBits : static_cast<int>(out - kLeadingBitsOffset);
|
||||
return bits == 0 ? kNumBits : (kNumBits - 1) - static_cast<int>(out);
|
||||
}
|
||||
|
||||
static EIGEN_DEVICE_FUNC inline int ctz(BitsType bits) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user