]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
lex.c (search_line_sse42): New main loop using asm flag outputs.
authorUros Bizjak <ubizjak@gmail.com>
Tue, 30 Jun 2015 08:26:57 +0000 (10:26 +0200)
committerUros Bizjak <uros@gcc.gnu.org>
Tue, 30 Jun 2015 08:26:57 +0000 (10:26 +0200)
* lex.c (search_line_sse42) [__GCC_ASM_FLAG_OUTPUTS__]: New main
loop using asm flag outputs.

From-SVN: r225160

libcpp/ChangeLog
libcpp/lex.c

index f373dad5130d0514d32d57bb13ff3973e77fc0e3..c7ac1e3aec021da7bbc247baa44c67fbd5f92815 100644 (file)
@@ -1,3 +1,8 @@
+2015-06-30  Uros Bizjak  <ubizjak@gmail.com>
+
+       * lex.c (search_line_sse42) [__GCC_ASM_FLAG_OUTPUTS__]: New main
+       loop using asm flag outputs.
+
 2015-06-08  Marek Polacek  <polacek@redhat.com>
 
        PR c/66415
index c7296a110b6b0944232c78506e8ba64f1644f79a..5758e580c2ba09729a0e5874c838691c44ee6102 100644 (file)
@@ -450,15 +450,33 @@ search_line_sse42 (const uchar *s, const uchar *end)
       s = (const uchar *)((si + 16) & -16);
     }
 
-  /* Main loop, processing 16 bytes at a time.  By doing the whole loop
-     in inline assembly, we can make proper use of the flags set.  */
-  __asm (      "sub $16, %1\n"
-       "       .balign 16\n"
+  /* Main loop, processing 16 bytes at a time.  */
+#ifdef __GCC_ASM_FLAG_OUTPUTS__
+  while (1)
+    {
+      char f;
+
+      /* By using inline assembly instead of the builtin,
+        we can use the result, as well as the flags set.  */
+      __asm ("%vpcmpestri\t$0, %2, %3"
+            : "=c"(index), "=@ccc"(f)
+            : "m"(*s), "x"(search), "a"(4), "d"(16));
+      if (f)
+       break;
+      
+      s += 16;
+    }
+#else
+  s -= 16;
+  /* By doing the whole loop in inline assembly,
+     we can make proper use of the flags set.  */
+  __asm (      ".balign 16\n"
        "0:     add $16, %1\n"
-       "       %vpcmpestri $0, (%1), %2\n"
+       "       %vpcmpestri\t$0, (%1), %2\n"
        "       jnc 0b"
        : "=&c"(index), "+r"(s)
        : "x"(search), "a"(4), "d"(16));
+#endif
 
  found:
   return s + index;