[clang] [clang] Provide an SSE4.2 implementation of identifier token lexer (PR #68962)

via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 13 02:03:10 PDT 2023


github-actions[bot] wrote:


<!--LLVM CODE FORMAT COMMENT: {clang-format}-->

:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 9a8ff346bb20a684e8edd62035077aba06bea084 ccf33cafada526241a3fb1aca9c2d280444b589b -- clang/lib/Lex/Lexer.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index f2d9eb3a8af4..ff8584a9614f 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -1851,7 +1851,8 @@ bool Lexer::LexUnicodeIdentifierStart(Token &Result, uint32_t C,
   return true;
 }
 
-static const char *fastParseASCIIIdentifier(const char *CurPtr, const char* BufferEnd) {
+static const char *fastParseASCIIIdentifier(const char *CurPtr,
+                                            const char *BufferEnd) {
 #ifdef __SSE4_2__
   static constexpr char AsciiIdentifierRange[16] = {
       '_', '_', 'A', 'Z', 'a', 'z', '0', '9',
@@ -1859,17 +1860,17 @@ static const char *fastParseASCIIIdentifier(const char *CurPtr, const char* Buff
   constexpr ssize_t BytesPerRegister = 16;
 
   while (LLVM_LIKELY(BufferEnd - CurPtr >= BytesPerRegister)) {
-    __m128i AsciiIdentifierRangeV = _mm_loadu_si128((const __m128i *)AsciiIdentifierRange);
-
-      __m128i Cv = _mm_loadu_si128((const __m128i *)(CurPtr));
-      int Consumed =
-          _mm_cmpistri(AsciiIdentifierRangeV, Cv,
-                       _SIDD_LEAST_SIGNIFICANT | _SIDD_CMP_RANGES |
-                           _SIDD_UBYTE_OPS | _SIDD_NEGATIVE_POLARITY);
-      CurPtr += Consumed;
-      if (Consumed == BytesPerRegister)
-        continue;
-      return CurPtr;
+    __m128i AsciiIdentifierRangeV =
+        _mm_loadu_si128((const __m128i *)AsciiIdentifierRange);
+
+    __m128i Cv = _mm_loadu_si128((const __m128i *)(CurPtr));
+    int Consumed = _mm_cmpistri(AsciiIdentifierRangeV, Cv,
+                                _SIDD_LEAST_SIGNIFICANT | _SIDD_CMP_RANGES |
+                                    _SIDD_UBYTE_OPS | _SIDD_NEGATIVE_POLARITY);
+    CurPtr += Consumed;
+    if (Consumed == BytesPerRegister)
+      continue;
+    return CurPtr;
   }
 #else
   (void)BufferEnd;

``````````

</details>


https://github.com/llvm/llvm-project/pull/68962


More information about the cfe-commits mailing list