14template<
typename ByteToBit>
17 const int64_t allowed_overshoot,
18 const ByteToBit &byte_to_bit)
26 const char *bytes_ = bytes.
data();
28 bool any_true =
false;
34 if (iteration_end % 16 > 0) {
35 if (allowed_overshoot >= 16) {
36 iteration_end = (iteration_end + 16) & ~15;
40 for (; byte_i + 16 <= iteration_end; byte_i += 16) {
42 const __m128i group = _mm_loadu_si128(
reinterpret_cast<const __m128i *
>(bytes_ + byte_i));
43 const uint16_t is_true_mask = byte_to_bit.see2_chunk(group);
44 any_true |= is_true_mask != 0;
48 *start_bit_int |=
BitInt(is_true_mask) << start_bit_in_int;
52 start_bit_int[1] |=
BitInt(is_true_mask) >> (64 - start_bit_in_int);
58 for (; byte_i < bytes.
size(); byte_i++) {
59 if (byte_to_bit.single(bytes_[byte_i])) {
74 static uint16_t see2_chunk(
const __m128i chunk)
76 const __m128i zero_bytes = _mm_set1_epi8(0);
78 const __m128i is_false_byte_mask = _mm_cmpeq_epi8(chunk, zero_bytes);
80 const uint16_t is_false_mask = _mm_movemask_epi8(is_false_byte_mask);
82 const uint16_t is_true_mask = ~is_false_mask;
90 const int64_t allowed_overshoot)
constexpr int64_t start() const
Span< NewT > constexpr cast() const
constexpr const T * data() const
constexpr int64_t size() const
constexpr bool is_empty() const
const IndexRange & bit_range() const
bool or_bools_into_bits(Span< bool > bools, MutableBitSpan r_bits, int64_t allowed_overshoot=0)
bool or_bytes_into_bits(const Span< char > bytes, MutableBitSpan r_bits, const int64_t allowed_overshoot, const ByteToBit &byte_to_bit)
static constexpr BitInt BitIndexMask
static constexpr int64_t BitsPerInt
BitInt * int_containing_bit(BitInt *data, const int64_t bit_index)
static bool single(const char c)