From 45da8fb996aa0b6c51efb7cc572f7252d83ec1a4 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Fri, 28 Jun 2024 22:52:39 -0700 Subject: [PATCH] Use the faster unvectorized implementation for Node3 --- ConflictSet.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/ConflictSet.cpp b/ConflictSet.cpp index b7a6fc6..f0aa31f 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -1923,29 +1923,34 @@ bool checkMaxBetweenExclusive(Node *n, int begin, int end, // [begin, end) is now the half-open interval of children we're interested in. assert(begin < end); - const unsigned shiftUpperBound = end - begin; - const unsigned shiftAmount = begin; - auto inBounds = [&](unsigned c) { return c - shiftAmount < shiftUpperBound; }; - switch (n->getType()) { case Type_Node0: // GCOVR_EXCL_LINE // We would have returned above, after not finding a child __builtin_unreachable(); // GCOVR_EXCL_LINE case Type_Node3: { auto *self = static_cast(n); - bool result = true; - for (int i = 0; i < 3; ++i) { - result &= !((self->childMaxVersion[i] > readVersion) && - inBounds(self->index[i])); + + const unsigned shiftUpperBound = end - begin; + const unsigned shiftAmount = begin; + auto inBounds = [&](unsigned c) { + return c - shiftAmount < shiftUpperBound; + }; + + uint32_t compared = 0; + for (int i = 0; i < Node3::kMaxNodes; ++i) { + compared |= (self->childMaxVersion[i] > readVersion) << i; } - return result; - } break; + uint32_t mask = 0; + for (int i = 0; i < Node3::kMaxNodes; ++i) { + mask |= inBounds(self->index[i]) << i; + } + return !(compared & mask); + } case Type_Node16: { auto *self = static_cast(n); return scan16(self->childMaxVersion, self->index, begin, end, readVersion); - - } break; + } case Type_Node48: { auto *self = static_cast(n); // Check all pages