Remove unused MaskFullOrSentinel and duplicate static_assert in hashtable_control_bytes Delete MaskFullOrSentinel from GroupSse2Impl, GroupAArch64Impl, and GroupPortableImpl (along with its unit test), drop the duplicate kEmpty == -128 static_assert, and delegate NonIterableBitMask::LowestBitSet to TrailingZeros. PiperOrigin-RevId: 1025723511
diff --git a/absl/container/internal/hashtable_control_bytes.h b/absl/container/internal/hashtable_control_bytes.h index 9a83c3b..8dd58f4 100644 --- a/absl/container/internal/hashtable_control_bytes.h +++ b/absl/container/internal/hashtable_control_bytes.h
@@ -86,9 +86,7 @@ explicit operator bool() const { return mask_ != 0; } // Returns the index of the lowest *abstract* bit set in `self`. - uint32_t LowestBitSet() const { - return container_internal::TrailingZeros(mask_) >> Shift; - } + uint32_t LowestBitSet() const { return TrailingZeros(); } // Returns the number of trailing zero *abstract* bits. uint32_t TrailingZeros() const { @@ -213,9 +211,6 @@ static_assert(ctrl_t::kDeleted == static_cast<ctrl_t>(-2), "ctrl_t::kDeleted must be -2 to make the implementation of " "ConvertSpecialToEmptyAndFullToDeleted efficient"); -static_assert(ctrl_t::kEmpty == static_cast<ctrl_t>(-128), - "ctrl_t::kEmpty must be -128 to use saturated subtraction in" - " ConvertSpecialToEmptyAndFullToDeleted"); // Helpers for checking the state of a control byte. inline bool IsEmpty(ctrl_t c) { return c == ctrl_t::kEmpty; } @@ -328,15 +323,6 @@ MoveMask(_mm_cmpgt_epi8_fixed(special, ctrl))); } - // Returns a bitmask representing the positions of full or sentinel slots. - // Note: for `is_small()` tables group may contain the "same" slot twice: - // original and mirrored. - NonIterableBitMaskType MaskFullOrSentinel() const { - auto special = _mm_set1_epi8(static_cast<char>(ctrl_t::kSentinel) - 1); - return NonIterableBitMaskType( - MoveMask(_mm_cmpgt_epi8_fixed(ctrl, special))); - } - void ConvertSpecialToEmptyAndFullToDeleted(ctrl_t* dst) const { // Take advantage of the fact that kEmpty is already the smallest signed // char value, and using a saturated subtraction will not affect it. @@ -416,15 +402,6 @@ return NonIterableBitMaskType(mask); } - NonIterableBitMaskType MaskFullOrSentinel() const { - uint64_t mask = vget_lane_u64( - vreinterpret_u64_u8( - vcgt_s8(vreinterpret_s8_u8(ctrl), - vdup_n_s8(static_cast<int8_t>(ctrl_t::kSentinel) - 1))), - 0); - return NonIterableBitMaskType(mask); - } - void ConvertSpecialToEmptyAndFullToDeleted(ctrl_t* dst) const { uint64_t mask = vget_lane_u64(vreinterpret_u64_u8(ctrl), 0); constexpr uint64_t slsbs = 0x0202020202020202ULL; @@ -487,10 +464,6 @@ return NonIterableBitMaskType((ctrl & ~(ctrl << 7)) & kMsbs8Bytes); } - auto MaskFullOrSentinel() const { - return NonIterableBitMaskType((~ctrl | (ctrl << 7)) & kMsbs8Bytes); - } - void ConvertSpecialToEmptyAndFullToDeleted(ctrl_t* dst) const { constexpr uint64_t lsbs = 0x0101010101010101ULL; auto x = ctrl & kMsbs8Bytes;
diff --git a/absl/container/internal/hashtable_control_bytes_test.cc b/absl/container/internal/hashtable_control_bytes_test.cc index a4aa3a9..007bf0f 100644 --- a/absl/container/internal/hashtable_control_bytes_test.cc +++ b/absl/container/internal/hashtable_control_bytes_test.cc
@@ -233,26 +233,6 @@ } } -TYPED_TEST(GroupTest, MaskFullOrSentinel) { - using GroupType = TypeParam; - if (GroupType::kWidth == 16) { - ctrl_t group[] = { - ctrl_t::kEmpty, ctrl_t::kDeleted, ctrl_t::kEmpty, CtrlT(3), - ctrl_t::kDeleted, CtrlT(5), ctrl_t::kSentinel, ctrl_t::kEmpty, - ctrl_t::kEmpty, ctrl_t::kDeleted, ctrl_t::kDeleted, ctrl_t::kDeleted, - ctrl_t::kEmpty, ctrl_t::kDeleted, ctrl_t::kDeleted, ctrl_t::kDeleted, - }; - EXPECT_THAT(GroupType{group}.MaskFullOrSentinel().LowestBitSet(), 3); - } else if (GroupType::kWidth == 8) { - ctrl_t group[] = {ctrl_t::kEmpty, ctrl_t::kDeleted, CtrlT(2), - ctrl_t::kDeleted, CtrlT(2), ctrl_t::kSentinel, - ctrl_t::kDeleted, ctrl_t::kEmpty}; - EXPECT_THAT(GroupType{group}.MaskFullOrSentinel().LowestBitSet(), 2); - } else { - FAIL() << "No test coverage for Group::kWidth==" << GroupType::kWidth; - } -} - } // namespace } // namespace container_internal ABSL_NAMESPACE_END