diff options
author | Abseil Team <absl-team@google.com> | 2024-02-15 23:54:17 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-02-15 23:55:05 -0800 |
commit | 8a3caf7dea955b513a6c1b572a2423c6b4213402 (patch) | |
tree | de68093898cdea318859c9e37dcb7eaf20c700b2 /absl/container/internal/raw_hash_set.h | |
parent | 4580d86d07dbd7614aaedce0b519752334245db6 (diff) | |
download | abseil-8a3caf7dea955b513a6c1b572a2423c6b4213402.tar.gz abseil-8a3caf7dea955b513a6c1b572a2423c6b4213402.tar.bz2 abseil-8a3caf7dea955b513a6c1b572a2423c6b4213402.zip |
Introduce `Group::MaskNonFull` without usage.
It can be used instead of `MaskEmptyOrDeleted` in case of inserting to empty table.
`MaskNonFull` requires less operations, in particular it eliminates `_mm_set1_epi8` and `_mm_cmpgt_epi8` operations.
PiperOrigin-RevId: 607587394
Change-Id: Ia48f922d1ca6de38cc91e7ab0d608c45f8f2c446
Diffstat (limited to 'absl/container/internal/raw_hash_set.h')
-rw-r--r-- | absl/container/internal/raw_hash_set.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h index d6950e61..cef042e7 100644 --- a/absl/container/internal/raw_hash_set.h +++ b/absl/container/internal/raw_hash_set.h @@ -657,6 +657,14 @@ struct GroupSse2Impl { static_cast<uint16_t>(_mm_movemask_epi8(ctrl) ^ 0xffff)); } + // Returns a bitmask representing the positions of non full slots. + // Note: this includes: kEmpty, kDeleted, kSentinel. + // It is useful in contexts when kSentinel is not present. + auto MaskNonFull() const { + return BitMask<uint16_t, kWidth>( + static_cast<uint16_t>(_mm_movemask_epi8(ctrl))); + } + // Returns a bitmask representing the positions of empty or deleted slots. NonIterableBitMask<uint16_t, kWidth> MaskEmptyOrDeleted() const { auto special = _mm_set1_epi8(static_cast<char>(ctrl_t::kSentinel)); @@ -725,6 +733,18 @@ struct GroupAArch64Impl { /*NullifyBitsOnIteration=*/true>(mask); } + // Returns a bitmask representing the positions of non full slots. + // Note: this includes: kEmpty, kDeleted, kSentinel. + // It is useful in contexts when kSentinel is not present. + auto MaskNonFull() const { + uint64_t mask = vget_lane_u64( + vreinterpret_u64_u8(vclt_s8(vreinterpret_s8_u8(ctrl), + vdup_n_s8(static_cast<int8_t>(0)))), + 0); + return BitMask<uint64_t, kWidth, /*Shift=*/3, + /*NullifyBitsOnIteration=*/true>(mask); + } + NonIterableBitMask<uint64_t, kWidth, 3> MaskEmptyOrDeleted() const { uint64_t mask = vget_lane_u64(vreinterpret_u64_u8(vcgt_s8( @@ -797,6 +817,13 @@ struct GroupPortableImpl { return BitMask<uint64_t, kWidth, 3>((ctrl ^ kMsbs8Bytes) & kMsbs8Bytes); } + // Returns a bitmask representing the positions of non full slots. + // Note: this includes: kEmpty, kDeleted, kSentinel. + // It is useful in contexts when kSentinel is not present. + auto MaskNonFull() const { + return BitMask<uint64_t, kWidth, 3>(ctrl & kMsbs8Bytes); + } + NonIterableBitMask<uint64_t, kWidth, 3> MaskEmptyOrDeleted() const { return NonIterableBitMask<uint64_t, kWidth, 3>((ctrl & ~(ctrl << 7)) & kMsbs8Bytes); |