[llvm-commits] [llvm] r56227 - in /llvm/branches/ggreif/use-diet: include/llvm/Use.h lib/VMCore/getValue.cpp

Gabor Greif ggreif at gmail.com
Mon Sep 15 13:01:55 PDT 2008


Author: ggreif
Date: Mon Sep 15 15:01:53 2008
New Revision: 56227

URL: http://llvm.org/viewvc/llvm-project?rev=56227&view=rev
Log:
more cleanups, enable other efficiency hack

Modified:
    llvm/branches/ggreif/use-diet/include/llvm/Use.h
    llvm/branches/ggreif/use-diet/lib/VMCore/getValue.cpp

Modified: llvm/branches/ggreif/use-diet/include/llvm/Use.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Use.h?rev=56227&r1=56226&r2=56227&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/Use.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/Use.h Mon Sep 15 15:01:53 2008
@@ -161,7 +161,6 @@
     if (isStop(Next))
       assert((isStop(*StrippedPrev) || (StrippedNext ? isStop(StrippedNext->Next) : true)) && "joining digits?");
     *StrippedPrev = Next;
-  //    Use *StrippedNext(getNext());
     if (StrippedNext) StrippedNext->setPrev(StrippedPrev);
   }
 

Modified: llvm/branches/ggreif/use-diet/lib/VMCore/getValue.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/getValue.cpp?rev=56227&r1=56226&r2=56227&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/VMCore/getValue.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/VMCore/getValue.cpp Mon Sep 15 15:01:53 2008
@@ -12,8 +12,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/User.h"
-#include <new>
-//#include <cassert>
 // this can later be removed:
 #include <iostream>
 
@@ -23,7 +21,7 @@
 
   friend class Use;
 
-enum { requiredSteps = sizeof(Value*) * 8 - 2 };
+enum { spareBits = 2, requiredSteps = sizeof(Value*) * 8 - spareBits };
 
 /// repaintByCopying -- given a pattern and a
 /// junk tagspace, copy the former's tags into
@@ -46,7 +44,7 @@
 /// junk tagspace, compute tags into the latter
 ///
 static inline void repaintByCalculating(unsigned long Tags, Use *Junk) {
-    Tags >>= 2;
+    Tags >>= spareBits;
 
     for (int I = requiredSteps - 1; I >= 0; --I) {
         Use::NextPtrTag Tag(Tags & (1 << I) ? Use::oneDigitTagN : Use::zeroDigitTagN);
@@ -62,12 +60,11 @@
 /// punchAwayDigits -- ensure that repainted area
 /// begins with a stop
 ///
-static inline void punchAwayDigits(Use *PrevU, Use **Uprev) {
+static inline void punchAwayDigits(Use **Uprev) {
   Uprev = stripTag<Use::tagMask>(Uprev);
-  if (PrevU)
-    assert(&PrevU->Next == Uprev && "U->Prev differs from PrevU?");
-
-    *Uprev = stripTag<Use::tagMaskN>(*Uprev);
+  // if (PrevU)
+  //   assert(&PrevU->Next == Uprev && "U->Prev differs from PrevU?");
+  *Uprev = stripTag<Use::tagMaskN>(*Uprev);
 }
 
 
@@ -79,6 +76,7 @@
 ///    overpainted.
 ///  In any case this routine is invoked with U being
 ///  pointed at from a Use with a stop tag.
+///
 static inline Value *gatherAndPotentiallyRepaint(Use *U) {
   int Cushion = requiredSteps;
 
@@ -94,23 +92,14 @@
       if (Cushion <= 0) {
           assert((Tag == Use::fullStopTagN || Tag == Use::stopTagN)
                  && "More digits?");
-          return reinterpret_cast<Value*>(Acc << 2);
+          return reinterpret_cast<Value*>(Acc << spareBits);
       }
 
       switch (Tag) {
           case Use::fullStopTagN:
               return reinterpret_cast<Value*>(Next);
           case Use::stopTagN: {
-              // for efficieny:
-              // goto efficiency
-              /* THIS PESSIMIZES THE ddsd30S case !!!
-              Next = Next->Next;
-              // __builtin_prefetch(Next);
-              --Cushion;
-              Tag = extractTag<Use::NextPtrTag, Use::tagMaskN>(Next);
-              Next = stripTag<Use::tagMaskN>(Next);
-              */
-              break;
+	      goto efficiency;
           }
           default:
               Acc = (Acc << 1) | (Tag & 1);
@@ -124,12 +113,6 @@
       break;
   }
 
-  // FIXME: We track prev this way, in the real
-  // Use struct there is a (tagged) Prev.
-  // It is needed to punch over junk
-  // digit sequence just before repaint.
-  Use *PrevU = NULL;
-
   while (Cushion > 0) {
     switch (Tag) {
     case Use::fullStopTagN:
@@ -142,7 +125,7 @@
 
         while (1) {
             if (!digits)
-                return reinterpret_cast<Value*>(Acc << 2);
+                return reinterpret_cast<Value*>(Acc << spareBits);
 
             Next = Next->Next;
             // __builtin_prefetch(Next);
@@ -152,13 +135,12 @@
             switch (Tag) {
                 case Use::fullStopTagN:
                     if (Cushion <= 0) {
-                        punchAwayDigits(PrevU, U->Prev);
+                        punchAwayDigits(U->Prev);
                         repaintByCalculating(reinterpret_cast<unsigned long>(Next), U);
                     }
                     return reinterpret_cast<Value*>(Next);
                 case Use::stopTagN: {
                     if (Cushion <= 0) {
-                        PrevU = U;
                         U = stripTag<Use::tagMaskN>(U->Next);
                     }
                     goto efficiency;
@@ -167,7 +149,6 @@
                     --digits;
                     Acc = (Acc << 1) | (Tag & 1);
                     if (Cushion <= 0) {
-                        PrevU = U;
                         U = stripTag<Use::tagMaskN>(U->Next);
                     }
                     continue;
@@ -185,16 +166,14 @@
     } // switch
   } // while
 
-  // Now we know that we have a nice cushion between
-  // U and Next. Do the same thing as above, but
-  // don't decrement Cushion any more, instead
-  // push U forward. After the value is found,
-  // repaint beginning at U.
+  // Now we know that we have a nice cushion between U and Next. Do the same
+  // thing as above, but don't decrement Cushion any more, instead push U
+  // forward. After the value is found, repaint beginning at U.
 
   while (1) {
     switch (Tag) {
     case Use::fullStopTagN: {
-        punchAwayDigits(PrevU, U->Prev);
+        punchAwayDigits(U->Prev);
         repaintByCalculating(reinterpret_cast<unsigned long>(Next), U);
         return reinterpret_cast<Value*>(Next);
     }
@@ -206,20 +185,19 @@
 
         while (1) {
             if (!digits) {
-                punchAwayDigits(PrevU, U->Prev);
+                punchAwayDigits(U->Prev);
                 repaintByCopying(Tagspace, U);
-                return reinterpret_cast<Value*>(Acc << 2);
+                return reinterpret_cast<Value*>(Acc << spareBits);
             }
 
             Next = Next->Next;
             // __builtin_prefetch(Next);
-            PrevU = U;
             U = stripTag<Use::tagMaskN>(U->Next);
             Tag = extractTag<Use::NextPtrTag, Use::tagMaskN>(Next);
             Next = stripTag<Use::tagMaskN>(Next);
             switch (Tag) {
                 case Use::fullStopTagN: {
-                    punchAwayDigits(PrevU, U->Prev);
+                    punchAwayDigits(U->Prev);
                     repaintByCalculating(reinterpret_cast<unsigned long>(Next), U);
                     return reinterpret_cast<Value*>(Next);
                 }
@@ -238,7 +216,6 @@
     default:
         Next = Next->Next;
         // __builtin_prefetch(Next);
-        PrevU = U;
         U = stripTag<Use::tagMaskN>(U->Next);
         Tag = extractTag<Use::NextPtrTag, Use::tagMaskN>(Next);
         Next = stripTag<Use::tagMaskN>(Next);
@@ -251,12 +228,13 @@
 ///  - picking up exactly ToGo digits
 ///  - or finding a stop which marks the beginning
 ///    of a repaintable area
+///
 static inline Value *skipPotentiallyGathering(Use *U,
                                               unsigned long Acc,
                                               int ToGo) {
   while (1) {
     if (!ToGo)
-      return reinterpret_cast<Value*>(Acc << 2);
+      return reinterpret_cast<Value*>(Acc << spareBits);
 
     Use *Next(U->Next);
     // __builtin_prefetch(Next);





More information about the llvm-commits mailing list