llvm-project/llvm/benchmarks/GetIntrinsicInfoTableEntriesBM.cpp
Rahul Joshi dcf0160bd6
[TableGen] Optimize intrinsic info type signature encoding (#106809)
Change the "fixed encoding" table used for encoding intrinsic
type signature to use 16-bit encoding as opposed to 32-bit.

This results in both space and time improvements. For space,
the total static storage size (in bytes) of this info reduces by 50%:
- Current = 14193*4 (Fixed table) + 16058 + 3 (Long Table) = 72833
- New size = 14193*2 (Fixed table) + 19879 + 3 (Long Table) = 48268.
- Reduction = 50.9%

For time, with the added benchmark, we see a 7.3% speedup in 
`GetIntrinsicInfoTableEntries` benchmark. Actual output of the 
benchmark in included in the GitHub MR.
2024-09-04 14:46:48 -07:00

31 lines
1023 B
C++

//===- GetIntrinsicInfoTableEntries.cpp - IIT signature benchmark ---------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "benchmark/benchmark.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/IR/Intrinsics.h"
using namespace llvm;
using namespace Intrinsic;
static void BM_GetIntrinsicInfoTableEntries(benchmark::State &state) {
SmallVector<IITDescriptor> Table;
for (auto _ : state) {
for (ID ID = 1; ID < num_intrinsics; ++ID) {
// This makes sure the vector does not keep growing, as well as after the
// first iteration does not result in additional allocations.
Table.clear();
getIntrinsicInfoTableEntries(ID, Table);
}
}
}
BENCHMARK(BM_GetIntrinsicInfoTableEntries);
BENCHMARK_MAIN();