diff options
author | Abseil Team <absl-team@google.com> | 2022-06-09 03:12:43 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-06-09 03:13:29 -0700 |
commit | 7383f346c9e33a08ed2132f117b3de6b13eac173 (patch) | |
tree | 2f7c916152eb449e7eb672832824334802db78d3 /absl/container/internal/raw_hash_set_test.cc | |
parent | e0a32c2aee27aadce321471be734d7643d7d9439 (diff) |
Optimize SwissMap iteration by another 5-10% for ARM
https://pastebin.com/fDvgWgHe
After having a chat with Dougall Johnson (https://twitter.com/dougallj/status/1534213050944802816), we realized that __clzll works with zero arguments per documentation:
https://developer.arm.com/documentation/101028/0009/Data-processing-intrinsics
```
Returns the number of leading zero bits in x. When x is zero it returns the argument width, i.e. 32 or 64.
```
Codegen improves https://godbolt.org/z/ebadf717Y
Thus we can use a little bit different construction not involving CLS but using more understandable CLZ and removing some operations.
PiperOrigin-RevId: 453879080
Change-Id: Ie2d7f834f63364d7bd50dd6a682c107985f21942
Diffstat (limited to 'absl/container/internal/raw_hash_set_test.cc')
-rw-r--r-- | absl/container/internal/raw_hash_set_test.cc | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/absl/container/internal/raw_hash_set_test.cc b/absl/container/internal/raw_hash_set_test.cc index dc6bc3d2..f77ffbc1 100644 --- a/absl/container/internal/raw_hash_set_test.cc +++ b/absl/container/internal/raw_hash_set_test.cc @@ -266,20 +266,16 @@ TEST(Group, CountLeadingEmptyOrDeleted) { for (ctrl_t empty : empty_examples) { std::vector<ctrl_t> e(Group::kWidth, empty); - EXPECT_TRUE(IsEmptyOrDeleted(e[0])); EXPECT_EQ(Group::kWidth, Group{e.data()}.CountLeadingEmptyOrDeleted()); for (ctrl_t full : full_examples) { - // First is always kEmpty or kDeleted. - for (size_t i = 1; i != Group::kWidth; ++i) { + for (size_t i = 0; i != Group::kWidth; ++i) { std::vector<ctrl_t> f(Group::kWidth, empty); f[i] = full; - EXPECT_TRUE(IsEmptyOrDeleted(f[0])); EXPECT_EQ(i, Group{f.data()}.CountLeadingEmptyOrDeleted()); } std::vector<ctrl_t> f(Group::kWidth, empty); f[Group::kWidth * 2 / 3] = full; f[Group::kWidth / 2] = full; - EXPECT_TRUE(IsEmptyOrDeleted(f[0])); EXPECT_EQ( Group::kWidth / 2, Group{f.data()}.CountLeadingEmptyOrDeleted()); } |