[Bug](compile) fix clang build for be (#12183)

This commit is contained in:
xy720
2022-08-30 17:58:54 +08:00
committed by GitHub
parent 9a74ad1702
commit 370b92a2ea

View File

@ -35,6 +35,13 @@ inline int64_t BitPacking::NumValuesToUnpack(int bit_width, int64_t in_bytes, in
}
}
constexpr uint64_t GetMask(int num_bits) {
if (num_bits >= 64) {
return ~0L;
}
return (1ULL << num_bits) - 1;
}
template <typename T>
constexpr bool IsSupportedUnpackingType() {
return std::is_same<T, uint8_t>::value || std::is_same<T, uint16_t>::value ||
@ -176,7 +183,7 @@ inline uint64_t ALWAYS_INLINE UnpackValue(const uint8_t* __restrict__ in_buf) {
static_assert(WORDS_TO_READ <= 3, "At most three 32-bit words need to be loaded.");
constexpr int FIRST_BIT_OFFSET = FIRST_BIT_IDX - FIRST_WORD_IDX * 32;
constexpr uint64_t mask = BIT_WIDTH == 64 ? ~0L : (1UL << BIT_WIDTH) - 1;
constexpr uint64_t mask = GetMask(BIT_WIDTH);
const uint32_t* const in = reinterpret_cast<const uint32_t*>(in_buf);
// Avoid reading past the end of the buffer. We can safely read 64 bits if we know that