Avoid out-of-bounds software prefetching in Abseil large-input hash.

Skip software prefetching for inputs up to kPrefetchBytes (5 cache lines,
320 bytes) and stop prefetching in the loop tail once the remaining bytes fit
within kPrefetchBytes. Handle 33..64-byte inputs directly in
CombineLargeContiguousImplOn64BitLengthGt32 and call LowLevelHashWithPrefetch
directly for full PiecewiseChunkSize chunks in SplitAndCombine<8>.

PiperOrigin-RevId: 1026839446
diff --git a/absl/hash/internal/hash.cc b/absl/hash/internal/hash.cc
index 67971a6..e61b21b 100644
--- a/absl/hash/internal/hash.cc
+++ b/absl/hash/internal/hash.cc
@@ -17,7 +17,9 @@
 #include <cassert>
 #include <cstddef>
 #include <cstdint>
+#include <tuple>
 #include <type_traits>
+#include <utility>
 
 #include "absl/base/attributes.h"
 #include "absl/base/config.h"
@@ -46,16 +48,59 @@
 #define ABSL_AES_INTERNAL_HAVE_ARM_SIMD
 #endif  // ABSL_INTERNAL_HAVE_ARM_NEON
 
+#ifdef ABSL_HASH_INTERNAL_DISABLE_LOOP_UNROLL
+#error ABSL_HASH_INTERNAL_DISABLE_LOOP_UNROLL cannot be directly set
+#elif defined(__clang__)
+#define ABSL_HASH_INTERNAL_DISABLE_LOOP_UNROLL \
+  _Pragma("clang loop unroll(disable)")
+#else
+#define ABSL_HASH_INTERNAL_DISABLE_LOOP_UNROLL
+#endif
+
 namespace absl {
 ABSL_NAMESPACE_BEGIN
 namespace hash_internal {
 
 namespace {
 
+// Software prefetch lookahead distance (320 bytes on 64-byte cache-line CPUs).
+constexpr size_t kPrefetchBytes = 5 * ABSL_CACHELINE_SIZE;
+static_assert(kPrefetchBytes >= 128 && kPrefetchBytes < PiecewiseChunkSize(),
+              "kPrefetchBytes must lie in [128, PiecewiseChunkSize())");
+
 void PrefetchFutureDataToLocalCache(const uint8_t* ptr) {
-  PrefetchToLocalCache(ptr + 5 * ABSL_CACHELINE_SIZE);
+  PrefetchToLocalCache(ptr + kPrefetchBytes);
 }
 
+template <bool kPrefetch, typename Mix64Fn>
+ABSL_ATTRIBUTE_ALWAYS_INLINE inline std::pair<const uint8_t*, size_t>
+Hash64ByteBlocks(const uint8_t* ptr, size_t len, Mix64Fn mix_64_bytes) {
+  assert(len > 64);
+  if constexpr (kPrefetch) {
+    assert(len > kPrefetchBytes);
+    // Stop prefetching once remaining bytes fit within the prefetch distance
+    // so we never read past the end of the buffer.
+    ABSL_HASH_INTERNAL_DISABLE_LOOP_UNROLL
+    do {
+      PrefetchFutureDataToLocalCache(ptr);
+      mix_64_bytes(ptr);
+      ptr += 64;
+      len -= 64;
+    } while (len > kPrefetchBytes);
+  }
+  // Already 64B/iter and >1 iteration (>128B, ~2.2% in fleetbench) is rare,
+  // so avoid extra unroll bloat (and GPR spills under preserve_most).
+  ABSL_HASH_INTERNAL_DISABLE_LOOP_UNROLL
+  do {
+    mix_64_bytes(ptr);
+    ptr += 64;
+    len -= 64;
+  } while (len > 64);
+  return {ptr, len};
+}
+
+#undef ABSL_HASH_INTERNAL_DISABLE_LOOP_UNROLL
+
 #if defined(ABSL_AES_INTERNAL_HAVE_X86_SIMD) || \
     defined(ABSL_AES_INTERNAL_HAVE_ARM_SIMD)
 
@@ -232,8 +277,9 @@
   return Mix4x16Vectors(state0, state1, state2, state3);
 }
 
-[[maybe_unused]] ABSL_INTERNAL_PRESERVE_MOST ABSL_ATTRIBUTE_NOINLINE uint64_t
-LowLevelHashLenGt64(uint64_t seed, const unsigned char* ptr, size_t len) {
+template <bool kPrefetch>
+ABSL_ATTRIBUTE_ALWAYS_INLINE inline uint64_t LowLevelHashLenGt64Impl(
+    uint64_t seed, const unsigned char* ptr, size_t len) {
   assert(len > 64);
   const uint8_t* last_32_ptr = ptr + len - 32;
 
@@ -245,22 +291,18 @@
   Vector128 state2 = state1;
   Vector128 state3 = state2;
 
-  // Already 64B/iter and >1 iteration (>128B, ~2.2% in fleetbench) is rare,
-  // so avoid extra unroll bloat (and GPR spills under preserve_most).
-#if defined(__clang__)
-#pragma clang loop unroll(disable)
-#endif
-  do {
-    PrefetchFutureDataToLocalCache(ptr);
-    MixAB(ptr, state0, state1);
-    MixCD(ptr + 32, state2, state3);
-
-    ptr += 64;
-    len -= 64;
-  } while (len > 64);
+  std::tie(ptr, len) = Hash64ByteBlocks<kPrefetch>(
+      ptr, len, [&](const uint8_t* p) ABSL_ATTRIBUTE_ALWAYS_INLINE {
+        MixAB(p, state0, state1);
+        MixCD(p + 32, state2, state3);
+      });
 
   // We now have a data `ptr` with at most 64 bytes.
   if (len > 32) {
+    // Note: forcing the loop pointer to stay in its register across this check
+    // avoids recomputing the exit offset from the initial arguments, saving a
+    // few instructions. One way to force this on GCC/Clang is:
+    //   asm("" : "+r"(ptr));
     MixAB(ptr, state0, state1);
   }
   MixCD(last_32_ptr, state2, state3);
@@ -288,8 +330,9 @@
   return Mix32Bytes(last_32_ptr, Mix32Bytes(ptr, current_state));
 }
 
-[[maybe_unused]] ABSL_INTERNAL_PRESERVE_MOST ABSL_ATTRIBUTE_NOINLINE uint64_t
-LowLevelHashLenGt64(uint64_t seed, const unsigned char* ptr, size_t len) {
+template <bool kPrefetch>
+ABSL_ATTRIBUTE_ALWAYS_INLINE inline uint64_t LowLevelHashLenGt64Impl(
+    uint64_t seed, const unsigned char* ptr, size_t len) {
   assert(len > 64);
   uint64_t current_state = seed ^ kStaticRandomData[0] ^ len;
   const uint8_t* last_32_ptr = ptr + len - 32;
@@ -300,32 +343,26 @@
   uint64_t duplicated_state1 = current_state;
   uint64_t duplicated_state2 = current_state;
 
-  // Already 64B/iter and >1 iteration (>128B, ~2.2% in fleetbench) is rare,
-  // so avoid extra unroll bloat (and GPR spills under preserve_most).
-#if defined(__clang__)
-#pragma clang loop unroll(disable)
-#endif
-  do {
-    PrefetchFutureDataToLocalCache(ptr);
+  std::tie(ptr, len) = Hash64ByteBlocks<kPrefetch>(
+      ptr, len, [&](const uint8_t* p) ABSL_ATTRIBUTE_ALWAYS_INLINE {
+        uint64_t a = absl::base_internal::UnalignedLoad64(p);
+        uint64_t b = absl::base_internal::UnalignedLoad64(p + 8);
+        uint64_t c = absl::base_internal::UnalignedLoad64(p + 16);
+        uint64_t d = absl::base_internal::UnalignedLoad64(p + 24);
+        uint64_t e = absl::base_internal::UnalignedLoad64(p + 32);
+        uint64_t f = absl::base_internal::UnalignedLoad64(p + 40);
+        uint64_t g = absl::base_internal::UnalignedLoad64(p + 48);
+        uint64_t h = absl::base_internal::UnalignedLoad64(p + 56);
 
-    uint64_t a = absl::base_internal::UnalignedLoad64(ptr);
-    uint64_t b = absl::base_internal::UnalignedLoad64(ptr + 8);
-    uint64_t c = absl::base_internal::UnalignedLoad64(ptr + 16);
-    uint64_t d = absl::base_internal::UnalignedLoad64(ptr + 24);
-    uint64_t e = absl::base_internal::UnalignedLoad64(ptr + 32);
-    uint64_t f = absl::base_internal::UnalignedLoad64(ptr + 40);
-    uint64_t g = absl::base_internal::UnalignedLoad64(ptr + 48);
-    uint64_t h = absl::base_internal::UnalignedLoad64(ptr + 56);
+        current_state = Mix(a ^ kStaticRandomData[1], b ^ current_state);
+        duplicated_state0 =
+            Mix(c ^ kStaticRandomData[2], d ^ duplicated_state0);
 
-    current_state = Mix(a ^ kStaticRandomData[1], b ^ current_state);
-    duplicated_state0 = Mix(c ^ kStaticRandomData[2], d ^ duplicated_state0);
-
-    duplicated_state1 = Mix(e ^ kStaticRandomData[3], f ^ duplicated_state1);
-    duplicated_state2 = Mix(g ^ kStaticRandomData[4], h ^ duplicated_state2);
-
-    ptr += 64;
-    len -= 64;
-  } while (len > 64);
+        duplicated_state1 =
+            Mix(e ^ kStaticRandomData[3], f ^ duplicated_state1);
+        duplicated_state2 =
+            Mix(g ^ kStaticRandomData[4], h ^ duplicated_state2);
+      });
 
   current_state = (current_state ^ duplicated_state0) ^
                   (duplicated_state1 + duplicated_state2);
@@ -342,41 +379,56 @@
 }
 #endif  // ABSL_AES_INTERNAL_HAVE_X86_SIMD
 
-[[maybe_unused]] ABSL_INTERNAL_PRESERVE_MOST uint64_t
-LowLevelHashLenGt32(uint64_t seed, const unsigned char* data, size_t len) {
-  assert(len > 32);
-  if (ABSL_PREDICT_FALSE(len > 64)) {
-    ABSL_INTERNAL_MUSTTAIL return LowLevelHashLenGt64(seed, data, len);
+template <int kSizeofSizeT>
+ABSL_INTERNAL_PRESERVE_MOST ABSL_ATTRIBUTE_NOINLINE uint64_t
+SplitAndCombine(uint64_t state, const unsigned char* first, size_t len);
+
+// Hashes inputs larger than the prefetch lookahead distance with bounded
+// software prefetching, delegating multi-chunk inputs to chunked hashing.
+[[maybe_unused]] ABSL_INTERNAL_PRESERVE_MOST ABSL_ATTRIBUTE_NOINLINE uint64_t
+LowLevelHashWithPrefetch(uint64_t seed, const unsigned char* data, size_t len) {
+  assert(len > kPrefetchBytes);
+  if (ABSL_PREDICT_FALSE(len > PiecewiseChunkSize())) {
+    ABSL_INTERNAL_MUSTTAIL return SplitAndCombine<8>(seed, data, len);
   }
-  return LowLevelHash33To64(seed, data, len);
+  return LowLevelHashLenGt64Impl</*kPrefetch=*/true>(seed, data, len);
 }
 
-template <int kSizeofSizeT>
-ABSL_INTERNAL_PRESERVE_MOST ABSL_ATTRIBUTE_ALWAYS_INLINE inline uint64_t
-HashBlock(uint64_t state, const unsigned char* data, size_t len) {
-  if constexpr (kSizeofSizeT == 4) {
-    // TODO(b/417141985): expose and use CityHash32WithSeed.
-    // Note: we can't use PrecombineLengthMix here because len can be up to
-    // 1024.
-    return CombineRawImpl(
-        state + len,
-        hash_internal::CityHash32(reinterpret_cast<const char*>(data), len));
-  } else {
-    static_assert(kSizeofSizeT == 8);
-#ifdef ABSL_HAVE_INTRINSIC_INT128
-    ABSL_INTERNAL_MUSTTAIL return LowLevelHashLenGt32(state, data, len);
-#else
-    return hash_internal::CityHash64WithSeed(
-        reinterpret_cast<const char*>(data), len, state);
-#endif
+// Skips software prefetching until inputs exceed the prefetch lookahead
+// distance, avoiding out-of-bounds prefetches on medium inputs.
+[[maybe_unused]] ABSL_INTERNAL_PRESERVE_MOST ABSL_ATTRIBUTE_NOINLINE uint64_t
+LowLevelHashLenGt64(uint64_t seed, const unsigned char* data, size_t len) {
+  assert(len > 64);
+  if (ABSL_PREDICT_FALSE(len > kPrefetchBytes)) {
+    ABSL_INTERNAL_MUSTTAIL return LowLevelHashWithPrefetch(seed, data, len);
   }
+  return LowLevelHashLenGt64Impl</*kPrefetch=*/false>(seed, data, len);
+}
+
+ABSL_ATTRIBUTE_ALWAYS_INLINE inline uint64_t HashBlockOn32Bit(
+    uint64_t state, const unsigned char* data, size_t len) {
+  // TODO(b/417141985): expose and use CityHash32WithSeed.
+  // Note: we can't use PrecombineLengthMix here because len can be up to 1024.
+  return CombineRawImpl(
+      state + len,
+      hash_internal::CityHash32(reinterpret_cast<const char*>(data), len));
 }
 
 template <int kSizeofSizeT>
 ABSL_INTERNAL_PRESERVE_MOST ABSL_ATTRIBUTE_NOINLINE uint64_t
 SplitAndCombine(uint64_t state, const unsigned char* first, size_t len) {
   while (len >= PiecewiseChunkSize()) {
-    state = HashBlock<kSizeofSizeT>(state, first, PiecewiseChunkSize());
+    if constexpr (kSizeofSizeT == 4) {
+      state = HashBlockOn32Bit(state, first, PiecewiseChunkSize());
+    } else {
+      static_assert(kSizeofSizeT == 8);
+#ifdef ABSL_HAVE_INTRINSIC_INT128
+      state = LowLevelHashWithPrefetch(state, first, PiecewiseChunkSize());
+#else
+      state = hash_internal::CityHash64WithSeed(
+          reinterpret_cast<const char*>(first), PiecewiseChunkSize(), state);
+#endif
+    }
     len -= PiecewiseChunkSize();
     first += PiecewiseChunkSize();
   }
@@ -395,7 +447,7 @@
   assert(len > 8);
   assert(sizeof(size_t) == 4);  // NOLINT(misc-static-assert)
   if (ABSL_PREDICT_TRUE(len <= PiecewiseChunkSize())) {
-    return HashBlock<4>(state, first, len);
+    return HashBlockOn32Bit(state, first, len);
   }
   return SplitAndCombine<4>(state, first, len);
 }
@@ -406,10 +458,18 @@
                                             size_t len) {
   assert(len > 32);
   assert(sizeof(size_t) == 8);  // NOLINT(misc-static-assert)
+#ifdef ABSL_HAVE_INTRINSIC_INT128
+  if (ABSL_PREDICT_FALSE(len > 64)) {
+    ABSL_INTERNAL_MUSTTAIL return LowLevelHashLenGt64(state, first, len);
+  }
+  return LowLevelHash33To64(state, first, len);
+#else
   if (ABSL_PREDICT_TRUE(len <= PiecewiseChunkSize())) {
-    ABSL_INTERNAL_MUSTTAIL return HashBlock<8>(state, first, len);
+    return hash_internal::CityHash64WithSeed(
+        reinterpret_cast<const char*>(first), len, state);
   }
   ABSL_INTERNAL_MUSTTAIL return SplitAndCombine<8>(state, first, len);
+#endif
 }
 
 ABSL_CONST_INIT const void* const MixingHashState::kSeed = &kSeed;
diff --git a/absl/hash/internal/low_level_hash_test.cc b/absl/hash/internal/low_level_hash_test.cc
index f1e2d15..3a2a2a1 100644
--- a/absl/hash/internal/low_level_hash_test.cc
+++ b/absl/hash/internal/low_level_hash_test.cc
@@ -15,6 +15,8 @@
 #include <cstddef>
 #include <cstdint>
 #include <string>
+#include <utility>
+#include <vector>
 
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
@@ -22,16 +24,37 @@
 #include "absl/strings/escaping.h"
 #include "absl/strings/string_view.h"
 
+#ifndef UPDATE_GOLDEN
 #define UPDATE_GOLDEN 0
+#endif
+
+#if defined(ABSL_IS_BIG_ENDIAN) || !defined(ABSL_HAVE_INTRINSIC_INT128) || \
+    UINTPTR_MAX != UINT64_MAX
+#define ABSL_HASH_INTERNAL_SKIP_GOLDEN 1
+#else
+#define ABSL_HASH_INTERNAL_SKIP_GOLDEN 0
+#endif
 
 namespace {
 
+// Returns a non-empty skip reason when golden data is not maintained for the
+// current platform. Returning the reason from a helper avoids unreachable-code
+// warnings after GTEST_SKIP().
+absl::string_view GoldenSkipReason() {
+#if ABSL_HASH_INTERNAL_SKIP_GOLDEN
+  return "We only maintain golden data for little endian 64 bit systems with "
+         "128 bit intrinsics.";
+#else
+  return {};
+#endif
+}
+
 TEST(LowLevelHashTest, VerifyGolden) {
-  constexpr size_t kNumGoldenOutputs = 95;
+  constexpr size_t kNumShortCases = 95;
   static struct {
     absl::string_view base64_data;
     uint64_t seed;
-  } cases[kNumGoldenOutputs] = {
+  } cases[kNumShortCases] = {
       {"VprUGNH+5NnNRaORxgH/ySrZFQFDL+4VAodhfBNinmn8cg==",
        uint64_t{0x531858a40bfa7ea1}},
       {"gc1xZaY+q0nPcUvOOnWnT3bqfmT/geth/f7Dm2e/DemMfk4=",
@@ -358,16 +381,26 @@
        uint64_t{0xc9ae5c8759b4877a}},
   };
 
-#if defined(ABSL_IS_BIG_ENDIAN) || !defined(ABSL_HAVE_INTRINSIC_INT128) || \
-    UINTPTR_MAX != UINT64_MAX
-  constexpr uint64_t kGolden[kNumGoldenOutputs] = {};
-  // This conditional is to avoid an unreachable code warning.
-  bool skip = true;
-  if (skip) {
-    GTEST_SKIP()
-        << "We only maintain golden data for little endian 64 bit systems with "
-           "128 bit intristics.";
+  // Additional lengths longer than the cases above: around the 5-cache-line
+  // prefetch lookahead distance (320 bytes), the 1024-byte piecewise chunk
+  // boundary, and multi-chunk inputs with remainders across each length class.
+  constexpr size_t kLongInputLengths[] = {
+      129,        320,       321,       385,
+      1023,       1024,      1025,      1024 + 32,
+      1024 + 33,  1024 + 64, 1024 + 65, 1024 + 320,
+      1024 + 321, 2048,      2048 + 48, 3 * 1024 + 1000,
+  };
+  constexpr size_t kNumLongCases =
+      sizeof(kLongInputLengths) / sizeof(kLongInputLengths[0]);
+  constexpr size_t kNumGoldenOutputs = kNumShortCases + kNumLongCases;
+
+  if (const absl::string_view skip_reason = GoldenSkipReason();
+      !skip_reason.empty()) {
+    GTEST_SKIP() << skip_reason;
   }
+
+#if ABSL_HASH_INTERNAL_SKIP_GOLDEN
+  constexpr uint64_t kGolden[kNumGoldenOutputs] = {};
 #elif (defined(__SSE4_2__) && defined(__AES__))
   constexpr uint64_t kGolden[kNumGoldenOutputs] = {
       0xd6bdb2c9ba5e55f2, 0xffd3e23d4115a8ae, 0x2c3218ef486127de,
@@ -401,7 +434,12 @@
       0x4f9457fb4aa12865, 0x30a49d9563643b32, 0x0302e2c5b46d5a3a,
       0x77553f42fb0bfbf7, 0x26b95e89f0077110, 0x76ce68ebe01191ba,
       0x724110fb509e4376, 0xebe74b016b5cfb88, 0x3b0fe11dcf175fc9,
-      0x20b737b9c0490538, 0x0db21c429b45fd17,
+      0x20b737b9c0490538, 0x0db21c429b45fd17, 0x1eda7e7ad5243cc7,
+      0x5b994a0ad6efb144, 0x71322097e51082cb, 0x5db5be33f91e0132,
+      0x5a9a66174f9d3958, 0x7c36745f70e2820d, 0xdca994179f5a8256,
+      0x1d5f43689148715e, 0x7488d5477d606216, 0x6903eed56891bef3,
+      0x5580876be492ba8f, 0xaa6d0be8d8b1d38f, 0xd69b6019a6619d4f,
+      0x4fc7de37699fca57, 0x63c1b3eaeb3b41b0, 0xa0461a76580405fe,
   };
 #elif (defined(ABSL_INTERNAL_HAVE_ARM_NEON) && defined(__ARM_FEATURE_CRYPTO))
   constexpr uint64_t kGolden[kNumGoldenOutputs] = {
@@ -436,7 +474,12 @@
       0x050f54d0478ffd52, 0xc5c1bff1bc3c008c, 0x48fd0f2729c9402d,
       0x7685b990e3e264af, 0x940dccac3264ed16, 0x688f94ee88c9ba90,
       0xca112c7825f3944b, 0x584cb5ddba130be2, 0xb7ced01f7140dff6,
-      0xc10dcbb4e77168e6, 0xb5ea4360351ebaef,
+      0xc10dcbb4e77168e6, 0xb5ea4360351ebaef, 0x7aecdc439abc1674,
+      0x01a854952dc7f1e6, 0x9ed69609d2fa4d0e, 0xec35767879254472,
+      0xd1773d876a705742, 0x047ea4d7f293e9ef, 0x30c4cdc7a4e24bc4,
+      0x0949cb26e6d75cd0, 0xab7b8d7304c7a429, 0x65288951d7f0261f,
+      0xa5efc10bf4516551, 0x6a0cc1536268870f, 0xe76bc77a31b30008,
+      0x25620f0d8cb45743, 0x61d529f2ee744026, 0x47b2da673d7dab4c,
   };
 #else
   constexpr uint64_t kGolden[kNumGoldenOutputs] = {
@@ -471,10 +514,39 @@
       0xb8116dd26cf6feec, 0x7a77a6e4ed0cf081, 0xb71eec2d5a184316,
       0x6fa932f77b4da817, 0x795f79b33909b2c4, 0x1b8755ef6b5eb34e,
       0x2255b72d7d6b2d79, 0xf2bdafafa90bd50a, 0x442a578f02cb1fc8,
-      0xc25aefe55ecf83db, 0x3114c056f9c5a676,
+      0xc25aefe55ecf83db, 0x3114c056f9c5a676, 0xe1881e3f8db57fc0,
+      0x1e0ab3f84fd9a6e3, 0x18d016fb9198d1c2, 0x93080774750fc68b,
+      0x741f07304a7de0da, 0xc16d061f4418af5d, 0xd9798b22d4d4299a,
+      0xd078016020f7ef68, 0xae4b228fc00cf2ac, 0xc2161b5b4469831c,
+      0x192aeda565563537, 0x84b926991dbf5860, 0x93e1dcc7a547129c,
+      0x7979f2a1ded1af87, 0xb8c7b1d0fafb10cd, 0x2d87f42c68592301,
   };
 #endif
 
+  struct GoldenInput {
+    std::string data;
+    uint64_t seed;
+  };
+  std::vector<GoldenInput> inputs;
+  inputs.reserve(kNumGoldenOutputs);
+  for (const auto& c : cases) {
+    std::string str;
+    ASSERT_TRUE(absl::Base64Unescape(c.base64_data, &str));
+    ASSERT_GT(str.size(), 32);
+    inputs.push_back({std::move(str), c.seed});
+  }
+  std::string long_data(4096, '\0');
+  for (size_t i = 0; i < long_data.size(); ++i) {
+    long_data[i] = static_cast<char>(i * 0x9d + (i >> 7));
+  }
+  for (size_t i = 0; i < kNumLongCases; ++i) {
+    const size_t len = kLongInputLengths[i];
+    ASSERT_GT(len, 32);
+    inputs.push_back(
+        {long_data.substr(0, len), uint64_t{0x9e3779b97f4a7c15} * (i + 1)});
+  }
+  ASSERT_EQ(inputs.size(), kNumGoldenOutputs);
+
   auto hash_fn = [](absl::string_view s, uint64_t state) {
     return absl::hash_internal::CombineLargeContiguousImplOn64BitLengthGt32(
         state, reinterpret_cast<const unsigned char*>(s.data()), s.size());
@@ -483,10 +555,7 @@
 #if UPDATE_GOLDEN
   (void)kGolden;  // Silence warning.
   for (size_t i = 0; i < kNumGoldenOutputs; ++i) {
-    std::string str;
-    ASSERT_TRUE(absl::Base64Unescape(cases[i].base64_data, &str));
-    ASSERT_GT(str.size(), 32);
-    uint64_t h = hash_fn(str, cases[i].seed);
+    uint64_t h = hash_fn(inputs[i].data, inputs[i].seed);
     printf("0x%016" PRIx64 ", ", h);
     if (i % 3 == 2) {
       printf("\n");
@@ -497,11 +566,8 @@
 #else
   for (size_t i = 0; i < kNumGoldenOutputs; ++i) {
     SCOPED_TRACE(::testing::Message()
-                 << "i = " << i << "; input = " << cases[i].base64_data);
-    std::string str;
-    ASSERT_TRUE(absl::Base64Unescape(cases[i].base64_data, &str));
-    ASSERT_GT(str.size(), 32);
-    EXPECT_EQ(hash_fn(str, cases[i].seed), kGolden[i]);
+                 << "i = " << i << "; len = " << inputs[i].data.size());
+    EXPECT_EQ(hash_fn(inputs[i].data, inputs[i].seed), kGolden[i]);
   }
 #endif
 }