]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - sysdeps/i386/i686/multiarch/memchr-sse2.S
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / sysdeps / i386 / i686 / multiarch / memchr-sse2.S
index 17f9ed04101f176676649f244752ab083de194e7..fbd8411fdff42b9405d3fb33e8e3f3c3a2c6f474 100644 (file)
@@ -1,5 +1,5 @@
 /* Optimized memchr with sse2 without bsf
-   Copyright (C) 2011 Free Software Foundation, Inc.
+   Copyright (C) 2011-2019 Free Software Foundation, Inc.
    Contributed by Intel Corporation.
    This file is part of the GNU C Library.
 
@@ -15,9 +15,9 @@
 
    You should have received a copy of the GNU Lesser General Public
    License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
+   <https://www.gnu.org/licenses/>.  */
 
-#ifndef  NOT_IN_libc
+#if IS_IN (libc)
 
 # include <sysdep.h>
 
@@ -117,9 +117,13 @@ L(crosscache):
 
 # ifndef USE_AS_RAWMEMCHR
        jnz     L(match_case2_prolog1)
-       lea     -16(%edx), %edx
-       add     %ecx, %edx
-       jle     L(return_null)
+        /* "ecx" is less than 16.  Calculate "edx + ecx - 16" by using
+          "edx - (16 - ecx)" instead of "(edx + ecx) - 16" to void
+          possible addition overflow.  */
+       neg     %ecx
+       add     $16, %ecx
+       sub     %ecx, %edx
+       jbe     L(return_null)
        lea     16(%edi), %edi
 # else
        jnz     L(match_case1_prolog1)