<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Apr 3, 2014 at 11:04 AM, Roman Divacky <span dir="ltr"><<a href="mailto:rdivacky@freebsd.org" target="_blank">rdivacky@freebsd.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rdivacky<br>
Date: Thu Apr  3 13:04:52 2014<br>
New Revision: 205548<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=205548&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=205548&view=rev</a><br>
Log:<br>
Revert r205436:<br>
<br>
        Extend the SSE2 comment lexing to AVX2. Only 16byte align when not on AVX2.<br>
<br>
        This provides some 3% speedup when preprocessing gcc.c as a single file.<br>
<br>
<br>
The patch is wrong, it always uses SSE2, and when I fix that there's no speedup<br>
at all. I am not sure where the 3% came from previously.<br>
<br>
--Thi lie, and those below, will be ignored--<br>
<br>
M    Lex/Lexer.cpp<br>
<br>
Modified:<br>
    cfe/trunk/lib/Lex/Lexer.cpp<br>
<br>
Modified: cfe/trunk/lib/Lex/Lexer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=205548&r1=205547&r2=205548&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=205548&r1=205547&r2=205548&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Lex/Lexer.cpp (original)<br>
+++ cfe/trunk/lib/Lex/Lexer.cpp Thu Apr  3 13:04:52 2014<br>
@@ -2251,8 +2251,6 @@ static bool isEndOfBlockCommentWithEscap<br>
<br>
 #ifdef __SSE2__<br>
 #include <emmintrin.h><br>
-#elif __AVX2__<br>
-#include <avx2intrin.h><br>
 #elif __ALTIVEC__<br>
 #include <altivec.h><br>
 #undef bool<br>
@@ -2308,33 +2306,17 @@ bool Lexer::SkipBlockComment(Token &Resu<br>
         // If there is a code-completion point avoid the fast scan because it<br>
         // doesn't check for '\0'.<br>
         !(PP && PP->getCodeCompletionFileLoc() == FileLoc)) {<br>
-#ifndef __AVX2__<br>
       // While not aligned to a 16-byte boundary.<br>
       while (C != '/' && ((intptr_t)CurPtr & 0x0F) != 0)<br>
         C = *CurPtr++;<br>
-#endif<br></blockquote><div><br></div><div>Many comments are short; perhaps the speedup came from using vector ops for short misaligned comments?</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

       if (C == '/') goto FoundSlash;<br>
<br>
 #ifdef __SSE2__<br>
-#define VECTOR_TYPE             __m128i<br>
-#define SET1_EPI8(v)            _mm_set1_epi8(v)<br>
-#define CMPEQ_EPI8(v1,v2)       _mm_cmpeq_epi8(v1,v2)<br>
-#define MOVEMASK_EPI8(v)        _mm_movemask_epi8(v)<br>
-#define STEP                    16<br>
-#elif __AVX2__<br>
-#define VECTOR_TYPE             __m256i<br>
-#define SET1_EPI8(v)            _mm256_set1_epi8(v)<br>
-#define CMPEQ_EPI8(v1,v2)       _mm256_cmpeq_epi8(v1,v2)<br>
-#define MOVEMASK_EPI8(v)        _mm256_movemask_epi8(v)<br>
-#define STEP                    32<br>
-#endif<br>
-<br>
-#if defined(__SSE2__) || defined(__AVX2__)<br>
-      VECTOR_TYPE Slashes = SET1_EPI8('/');<br>
-      while (CurPtr+STEP <= BufferEnd) {<br>
-        int cmp = MOVEMASK_EPI8(CMPEQ_EPI8(*(const VECTOR_TYPE*)CurPtr,<br>
-                                Slashes));<br>
+      __m128i Slashes = _mm_set1_epi8('/');<br>
+      while (CurPtr+16 <= BufferEnd) {<br>
+        int cmp = _mm_movemask_epi8(_mm_cmpeq_epi8(*(const __m128i*)CurPtr,<br>
+                                    Slashes));<br>
         if (cmp != 0) {<br>
           // Adjust the pointer to point directly after the first slash. It's<br>
           // not necessary to set C here, it will be overwritten at the end of<br>
@@ -2342,13 +2324,8 @@ bool Lexer::SkipBlockComment(Token &Resu<br>
           CurPtr += llvm::countTrailingZeros<unsigned>(cmp) + 1;<br>
           goto FoundSlash;<br>
         }<br>
-        CurPtr += STEP;<br>
+        CurPtr += 16;<br>
       }<br>
-#undef VECTOR_TYPE<br>
-#undef SET1_EPI8<br>
-#undef CMPEQ_EPI8<br>
-#undef MOVEMASK_EPI8<br>
-#undef STEP<br>
 #elif __ALTIVEC__<br>
       __vector unsigned char Slashes = {<br>
         '/', '/', '/', '/',  '/', '/', '/', '/',<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>