[cfe-commits] r39060 - /cfe/cfe/trunk/Lex/Lexer.cpp

sabre at cs.uiuc.edu sabre at cs.uiuc.edu
Wed Jul 11 09:27:13 PDT 2007


Author: sabre
Date: Wed Jul 11 11:27:12 2007
New Revision: 39060

URL: http://llvm.org/viewvc/llvm-project?rev=39060&view=rev
Log:
Implement an sse2 version of the block comment scanner.

Modified:
    cfe/cfe/trunk/Lex/Lexer.cpp

Modified: cfe/cfe/trunk/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/Lexer.cpp?rev=39060&r1=39059&r2=39060&view=diff

==============================================================================
--- cfe/cfe/trunk/Lex/Lexer.cpp (original)
+++ cfe/cfe/trunk/Lex/Lexer.cpp Wed Jul 11 11:27:12 2007
@@ -770,6 +770,10 @@
   return true;
 }
 
+#ifdef __SSE2__
+#include <emmintrin.h>
+#endif
+
 /// SkipBlockComment - We have just read the /* characters from input.  Read
 /// until we find the */ characters that terminate the comment.  Note that we
 /// don't bother decoding trigraphs or escaped newlines in block comments,
@@ -799,7 +803,15 @@
         C = *CurPtr++;
       
       if (C == '/') goto FoundSlash;
-      
+
+#ifdef __SSE2__
+      __m128i Slashes = _mm_set_epi8('/', '/', '/', '/', '/', '/', '/', '/',
+                                     '/', '/', '/', '/', '/', '/', '/', '/');
+      while (CurPtr+16 <= BufferEnd &&
+             _mm_movemask_epi8(_mm_cmpeq_epi8(*(__m128i*)CurPtr, Slashes)) == 0)
+        CurPtr += 16;
+#else             
+      // Scan for '/' quickly.  Many block comments are very large.
       while (CurPtr[0] != '/' &&
              CurPtr[1] != '/' &&
              CurPtr[2] != '/' &&
@@ -807,9 +819,13 @@
              CurPtr+4 < BufferEnd) {
         CurPtr += 4;
       }
+#endif
+      
+      // It has to be one of the bytes scanned, increment to it and read one.
       C = *CurPtr++;
     }
     
+    // Loop to scan the remainder.
     while (C != '/' && C != '\0')
       C = *CurPtr++;
     





More information about the cfe-commits mailing list