IR: de-duplicate two CmpInst routines (NFC) (#116866)
[llvm-project.git] / llvm / benchmarks / xxhash.cpp
blob429cbc0fa87d4b2e267bf029a028f93cf12fab08
1 #include "llvm/Support/xxhash.h"
2 #include "benchmark/benchmark.h"
4 #include <memory>
6 static uint32_t xorshift(uint32_t State) {
7 State ^= State << 13;
8 State ^= State >> 17;
9 State ^= State << 5;
10 return State;
13 static void BM_xxh3_64bits(benchmark::State &State) {
14 std::unique_ptr<uint32_t[]> Data(new uint32_t[State.range(0) / 4]);
16 uint32_t Prev = 0xcafebabe;
17 for (int64_t I = 0; I < State.range(0) / 4; I++)
18 Data[I] = Prev = xorshift(Prev);
20 llvm::ArrayRef DataRef =
21 llvm::ArrayRef(reinterpret_cast<uint8_t *>(Data.get()), State.range(0));
23 for (auto _ : State)
24 llvm::xxh3_64bits(DataRef);
27 BENCHMARK(BM_xxh3_64bits)->Arg(32)->Arg(512)->Arg(64 * 1024)->Arg(1024 * 1024);
29 BENCHMARK_MAIN();