Reorganize to prepare for better vectorized first/last page

This commit is contained in:
2024-06-27 17:21:41 -07:00
parent a2bf839b19
commit 12c6ed2568

View File

@@ -1820,8 +1820,13 @@ bool checkMaxBetweenExclusive(Node *n, int begin, int end,
}
case Type_Node256: {
auto *self = static_cast<Node256 *>(n);
if (end <= 0) {
return true;
}
const int firstPage = begin >> Node256::kMaxOfMaxShift;
const int lastPage = (end - 1) >> Node256::kMaxOfMaxShift;
// Check the first page
if (self->maxOfMax[begin >> Node256::kMaxOfMaxShift] > readVersion) {
if (self->maxOfMax[firstPage] > readVersion) {
bool result = true;
for (int i = 0; i < Node256::kMaxOfMaxPageSize; ++i) {
int j = (begin & ~(Node256::kMaxOfMaxPageSize - 1)) + i;
@@ -1832,8 +1837,7 @@ bool checkMaxBetweenExclusive(Node *n, int begin, int end,
}
}
// Check the last page
if (end >= 1 &&
self->maxOfMax[(end - 1) >> Node256::kMaxOfMaxShift] > readVersion) {
if (self->maxOfMax[lastPage] > readVersion) {
bool result = true;
for (int i = 0; i < Node256::kMaxOfMaxPageSize; ++i) {
int j = ((end - 1) & ~(Node256::kMaxOfMaxPageSize - 1)) + i;
@@ -1849,10 +1853,10 @@ bool checkMaxBetweenExclusive(Node *n, int begin, int end,
conflict |= (self->maxOfMax[i] > readVersion) << i;
}
// Only keep inner pages
const int pageBegin = (begin >> Node256::kMaxOfMaxShift) + 1;
const int pageEnd = (end - 1) >> Node256::kMaxOfMaxShift;
conflict &= (1 << pageEnd) - 1;
conflict >>= pageBegin;
const int innerPageBegin = (begin >> Node256::kMaxOfMaxShift) + 1;
const int innerPageEnd = (end - 1) >> Node256::kMaxOfMaxShift;
conflict &= (1 << innerPageEnd) - 1;
conflict >>= innerPageBegin;
return !conflict;
}
default: // GCOVR_EXCL_LINE