diff options
author | Rahul Joshi <rjoshi@nvidia.com> | 2024-09-04 14:46:48 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-04 14:46:48 -0700 |
commit | dcf0160bd61d150e7b94067fcd991b466a361b08 (patch) | |
tree | c4f1706420e268d68157e75f6a362a34928f97f3 /llvm/lib/IR/Function.cpp | |
parent | dd754cd262222bcb489038ac791e4278d90697f0 (diff) | |
download | llvm-dcf0160bd61d150e7b94067fcd991b466a361b08.zip llvm-dcf0160bd61d150e7b94067fcd991b466a361b08.tar.gz llvm-dcf0160bd61d150e7b94067fcd991b466a361b08.tar.bz2 |
[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.
Diffstat (limited to 'llvm/lib/IR/Function.cpp')
-rw-r--r-- | llvm/lib/IR/Function.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp index 69520fd..afef893 100644 --- a/llvm/lib/IR/Function.cpp +++ b/llvm/lib/IR/Function.cpp @@ -1381,22 +1381,24 @@ static void DecodeIITType(unsigned &NextElt, ArrayRef<unsigned char> Infos, void Intrinsic::getIntrinsicInfoTableEntries(ID id, SmallVectorImpl<IITDescriptor> &T){ + static_assert(sizeof(IIT_Table[0]) == 2, + "Expect 16-bit entries in IIT_Table"); // Check to see if the intrinsic's type was expressible by the table. - unsigned TableVal = IIT_Table[id-1]; + uint16_t TableVal = IIT_Table[id - 1]; // Decode the TableVal into an array of IITValues. - SmallVector<unsigned char, 8> IITValues; + SmallVector<unsigned char> IITValues; ArrayRef<unsigned char> IITEntries; unsigned NextElt = 0; - if ((TableVal >> 31) != 0) { + if (TableVal >> 15) { // This is an offset into the IIT_LongEncodingTable. IITEntries = IIT_LongEncodingTable; // Strip sentinel bit. - NextElt = (TableVal << 1) >> 1; + NextElt = TableVal & 0x7fff; } else { - // Decode the TableVal into an array of IITValues. If the entry was encoded - // into a single word in the table itself, decode it now. + // If the entry was encoded into a single word in the table itself, decode + // it from an array of nibbles to an array of bytes. do { IITValues.push_back(TableVal & 0xF); TableVal >>= 4; |