diff options
author | Chris Lattner <sabre@nondot.org> | 2004-01-18 22:35:34 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-01-18 22:35:34 +0000 |
commit | 241024381f245bd02ba0e3bda80f3690f84c11de (patch) | |
tree | 8b5e70e12f00c5ba1d6709da9496e46558d632af /lib/Bytecode/Writer/Writer.cpp | |
parent | 33522d4f2553afbcba69aab39da438782fb0505c (diff) |
Save another 30K from 176.gcc by encoding the compaction table a bit more
intelligently.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10918 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode/Writer/Writer.cpp')
-rw-r--r-- | lib/Bytecode/Writer/Writer.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp index d0b04d2dab..a55508e6e0 100644 --- a/lib/Bytecode/Writer/Writer.cpp +++ b/lib/Bytecode/Writer/Writer.cpp @@ -293,12 +293,24 @@ void BytecodeWriter::outputCompactionTablePlane(unsigned PlaneNo, assert(StartNo < End && "Cannot emit negative range!"); assert(StartNo < Plane.size() && End <= Plane.size()); - output_vbr(unsigned(End-StartNo), Out); // Output the number of things. - output_vbr(PlaneNo, Out); // Emit the type plane this is - // Do not emit the null initializer! if (PlaneNo != Type::TypeTyID) ++StartNo; + // Figure out which encoding to use. By far the most common case we have is + // to emit 0-2 entries in a compaction table plane. + switch (End-StartNo) { + case 0: // Avoid emitting two vbr's if possible. + case 1: + case 2: + output_vbr((PlaneNo << 2) | End-StartNo, Out); + break; + default: + // Output the number of things. + output_vbr((unsigned(End-StartNo) << 2) | 3, Out); + output_vbr(PlaneNo, Out); // Emit the type plane this is + break; + } + for (unsigned i = StartNo; i != End; ++i) output_vbr(Table.getGlobalSlot(Plane[i]), Out); } |