[llvm-commits] CVS: llvm/lib/Bytecode/Writer/Writer.cpp

Chris Lattner lattner at cs.uiuc.edu
Sun Jan 18 16:36:01 PST 2004


Changes in directory llvm/lib/Bytecode/Writer:

Writer.cpp updated: 1.58 -> 1.59

---
Log message:

Save another 30K from 176.gcc by encoding the compaction table a bit more
intelligently.



---
Diffs of the changes:  (+15 -3)

Index: llvm/lib/Bytecode/Writer/Writer.cpp
diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.58 llvm/lib/Bytecode/Writer/Writer.cpp:1.59
--- llvm/lib/Bytecode/Writer/Writer.cpp:1.58	Sun Jan 18 16:26:53 2004
+++ llvm/lib/Bytecode/Writer/Writer.cpp	Sun Jan 18 16:35:34 2004
@@ -293,11 +293,23 @@
   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);





More information about the llvm-commits mailing list