This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/21182] __memchr_sse2: regression in glibc-2.25 on i686


https://sourceware.org/bugzilla/show_bug.cgi?id=21182

Adhemerval Zanella <adhemerval.zanella at linaro dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |adhemerval.zanella at linaro dot o
                   |                            |rg

--- Comment #9 from Adhemerval Zanella <adhemerval.zanella at linaro dot org> ---
Indeed the subtraction is at wrong place and for this specific case we case use
LEA (since it won't set CF flag use in following jbe).  I think following the
logic already in place for x86_64 version is the correct approach:

diff --git a/sysdeps/i386/i686/multiarch/memchr-sse2.S
b/sysdeps/i386/i686/multiarch/memchr-sse2.S
index 910679c..e41f324 100644
--- a/sysdeps/i386/i686/multiarch/memchr-sse2.S
+++ b/sysdeps/i386/i686/multiarch/memchr-sse2.S
@@ -117,7 +117,6 @@ L(crosscache):

 # ifndef USE_AS_RAWMEMCHR
        jnz     L(match_case2_prolog1)
-       lea     -16(%edx), %edx
         /* Calculate the last acceptable address and check for possible
            addition overflow by using satured math:
            edx = ecx + edx
@@ -125,6 +124,7 @@ L(crosscache):
        add     %ecx, %edx
        sbb     %eax, %eax
        or      %eax, %edx
+       sub     $16, %edx
        jbe     L(return_null)
        lea     16(%edi), %edi
 # else

If the sub is negative (as for the testcase since size is 1), sub will set CF
flag after the saturated addition and then return NULL as expected.  I will
prepare the patch with the testcase as well.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]