This is the mail archive of the glibc-cvs@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]

GNU C Library master sources branch master updated. glibc-2.25-351-g402bf06


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  402bf0695218bbe290418b9486b1dd5fe284d903 (commit)
      from  1d71a6315396f6e1cc79a1d7ecca0a559929230a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=402bf0695218bbe290418b9486b1dd5fe284d903

commit 402bf0695218bbe290418b9486b1dd5fe284d903
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri May 19 10:46:29 2017 -0700

    x86: Optimize SSE2 memchr overflow calculation
    
    SSE2 memchr computes "edx + ecx - 16" where ecx is less than 16.  Use
    "edx - (16 - ecx)", instead of satured math, to avoid possible addition
    overflow.  This replaces
    
    	add	%ecx, %edx
    	sbb	%eax, %eax
    	or	%eax, %edx
    	sub	$16, %edx
    
    with
    
    	neg	%ecx
    	add	$16, %ecx
    	sub	%ecx, %edx
    
    It is the same for x86_64, except for rcx/rdx, instead of ecx/edx.
    
    	* sysdeps/i386/i686/multiarch/memchr-sse2.S (MEMCHR): Use
    	"edx + ecx - 16" to avoid possible addition overflow.
    	* sysdeps/x86_64/memchr.S (memchr): Likewise.

diff --git a/ChangeLog b/ChangeLog
index 3c8d9f1..b9fbdb8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-05-19  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* sysdeps/i386/i686/multiarch/memchr-sse2.S (MEMCHR): Use
+	"edx + ecx - 16" to avoid possible addition overflow.
+	* sysdeps/x86_64/memchr.S (memchr): Likewise.
+
 2017-05-19  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 
 	* misc/Makefile (CFLAGS-vmsplice.c): Remove rule.
diff --git a/sysdeps/i386/i686/multiarch/memchr-sse2.S b/sysdeps/i386/i686/multiarch/memchr-sse2.S
index e41f324..172d70d 100644
--- a/sysdeps/i386/i686/multiarch/memchr-sse2.S
+++ b/sysdeps/i386/i686/multiarch/memchr-sse2.S
@@ -117,14 +117,12 @@ L(crosscache):
 
 # ifndef USE_AS_RAWMEMCHR
 	jnz	L(match_case2_prolog1)
-        /* Calculate the last acceptable address and check for possible
-           addition overflow by using satured math:
-           edx = ecx + edx
-           edx |= -(edx < ecx)  */
-	add	%ecx, %edx
-	sbb	%eax, %eax
-	or	%eax, %edx
-	sub	$16, %edx
+        /* "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
diff --git a/sysdeps/x86_64/memchr.S b/sysdeps/x86_64/memchr.S
index a205a25..f82e1c5 100644
--- a/sysdeps/x86_64/memchr.S
+++ b/sysdeps/x86_64/memchr.S
@@ -76,14 +76,12 @@ L(crosscache):
 
 	.p2align 4
 L(unaligned_no_match):
-        /* Calculate the last acceptable address and check for possible
-           addition overflow by using satured math:
-           rdx = rcx + rdx
-           rdx |= -(rdx < rcx)  */
-	add	%rcx, %rdx
-	sbb	%rax, %rax
-	or	%rax, %rdx
-	sub	$16, %rdx
+        /* "rcx" is less than 16.  Calculate "rdx + rcx - 16" by using
+	   "rdx - (16 - rcx)" instead of "(rdx + rcx) - 16" to void
+	   possible addition overflow.  */
+	neg	%rcx
+	add	$16, %rcx
+	sub	%rcx, %rdx
 	jbe	L(return_null)
 	add	$16, %rdi
 	sub	$64, %rdx

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                                 |    6 ++++++
 sysdeps/i386/i686/multiarch/memchr-sse2.S |   14 ++++++--------
 sysdeps/x86_64/memchr.S                   |   14 ++++++--------
 3 files changed, 18 insertions(+), 16 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


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