[llvm-commits] [llvm] r50120 - /llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp

Gabor Greif ggreif at gmail.com
Tue Apr 22 17:52:30 PDT 2008


Author: ggreif
Date: Tue Apr 22 19:52:30 2008
New Revision: 50120

URL: http://llvm.org/viewvc/llvm-project?rev=50120&view=rev
Log:
less naive implementation: duplicate loop

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

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

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp Tue Apr 22 19:52:30 2008
@@ -20,29 +20,36 @@
 //===----------------------------------------------------------------------===//
 
 const Use *Use::getImpliedUser() const {
-  bool StopEncountered = false;
-  ptrdiff_t Offset = 1;
   const Use *Current = this;
 
   while (true) {
-    unsigned Tag = extractTag<PrevPtrTag, fullStopTag>(Current->Prev);
+    unsigned Tag = extractTag<PrevPtrTag, fullStopTag>((Current++)->Prev);
     switch (Tag) {
       case zeroDigitTag:
       case oneDigitTag:
-        if (StopEncountered)
-          Offset = (Offset << 1) + Tag;
-        break;
-      case stopTag:
-        if (StopEncountered)
-          return Current + Offset;
-        StopEncountered = true;
-        Current += 2;
         continue;
-      case fullStopTag:
-        return Current + 1;
+
+      case stopTag: {
+        ++Current;
+        ptrdiff_t Offset = 1;
+        while (true) {
+          unsigned Tag = extractTag<PrevPtrTag, fullStopTag>((Current++)->Prev);
+          switch (Tag) {
+            case zeroDigitTag:
+            case oneDigitTag:
+              Offset = (Offset << 1) + Tag;
+              continue;
+            case stopTag:
+              return Current + Offset - 1;
+            case fullStopTag:
+              return Current;
+          }
+        }
       }
 
-    ++Current;
+      case fullStopTag:
+        return Current;
+    }
   }
 }
 





More information about the llvm-commits mailing list