From 5ac530c601220928fbb470c5dc54ba61c9394d4b Mon Sep 17 00:00:00 2001 From: David Sherwood Date: Mon, 23 Feb 2026 19:27:20 +0000 Subject: [PATCH] memoCacheGet using pnext --- .../src/folly/container/detail/F14Table.h | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/third-party/folly/src/folly/container/detail/F14Table.h b/third-party/folly/src/folly/container/detail/F14Table.h index b79757319922da..ac38f78739e5fa 100644 --- a/third-party/folly/src/folly/container/detail/F14Table.h +++ b/third-party/folly/src/folly/container/detail/F14Table.h @@ -16,6 +16,8 @@ #pragma once +#define FOLLY_PURE_SVE 1 + #include #include #include @@ -1701,6 +1703,24 @@ class F14Table : public Policy { if (prefetch == Prefetch::ENABLED && sizeof(Chunk) > 64) { prefetchAddr(chunk->itemAddr(8)); } +#if FOLLY_PURE_SVE + svuint8_t tagV = svld1_u8(pred, &chunk->tags_[0]); + svbool_t eqV = svcmpeq_n_u8(pred, tagV, static_cast(hp.second)); + if (svptest_any(eqV, eqV)) { + svbool_t nextBit = svpnext_b8(eqV, svpfalse()); + do { + svbool_t maskUpToBit = svbrkb_b_z(svptrue_b8(), nextBit); + uint64_t i = svcntp_b8(maskUpToBit, maskUpToBit); + if (FOLLY_LIKELY(this->keyMatchesItem(key, chunk->item(i)))) { + // Tag match and key match were both successful. The chance + // of a false tag match is 1/128 for each key in the chunk + // (with a proper hash function). + return ItemIter{chunk, i}; + } + nextBit = svpnext_b8(eqV, nextBit); + } while (svptest_any(eqV, nextBit)); + } +#else #if FOLLY_ARM_FEATURE_NEON_SVE_BRIDGE auto hits = chunk->tagMatchIter(needleV, pred); #else @@ -1715,6 +1735,7 @@ class F14Table : public Policy { return ItemIter{chunk, i}; } } +#endif if (FOLLY_LIKELY(chunk->outboundOverflowCount() == 0)) { // No keys that wanted to be placed in this chunk were denied // entry, so our search is over. This is the common case.