summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/Lexer.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2011-11-22 18:56:46 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2011-11-22 18:56:46 +0000
commit3885737a1b824e55902e384956fd0bdf80376a7a (patch)
treef323d8931f77e8f0c818a4900673049a37a9b677 /clang/lib/Lex/Lexer.cpp
parentddfda81ab887cc424873766dc6fda35f477469da (diff)
downloadbcm5719-llvm-3885737a1b824e55902e384956fd0bdf80376a7a.tar.gz
bcm5719-llvm-3885737a1b824e55902e384956fd0bdf80376a7a.zip
Lexer: Don't throw away the hard work SSE did to find a slash.
We can reuse the information and avoid looping over all the bytes again. llvm-svn: 145070
Diffstat (limited to 'clang/lib/Lex/Lexer.cpp')
-rw-r--r--clang/lib/Lex/Lexer.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index 796110a34fd..a1155798433 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -1916,11 +1916,18 @@ bool Lexer::SkipBlockComment(Token &Result, const char *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)
+ __m128i Slashes = _mm_set1_epi8('/');
+ while (CurPtr+16 <= BufferEnd) {
+ int cmp = _mm_movemask_epi8(_mm_cmpeq_epi8(*(__m128i*)CurPtr, Slashes));
+ if (cmp != 0) {
+ // Adjust the pointer to the first '/' that was found.
+ CurPtr += llvm::CountTrailingZeros_32(cmp);
+ C = *CurPtr++;
+ assert(C == '/');
+ goto FoundSlash;
+ }
CurPtr += 16;
+ }
#elif __ALTIVEC__
__vector unsigned char Slashes = {
'/', '/', '/', '/', '/', '/', '/', '/',
@@ -1948,8 +1955,8 @@ bool Lexer::SkipBlockComment(Token &Result, const char *CurPtr) {
while (C != '/' && C != '\0')
C = *CurPtr++;
- FoundSlash:
if (C == '/') {
+ FoundSlash:
if (CurPtr[-2] == '*') // We found the final */. We're done!
break;
OpenPOWER on IntegriCloud