GNU C Library master sources branch master updated. glibc-2.22-314-gb0f8163

tuliom@sourceware.org tuliom@sourceware.org
Thu Oct 1 20:38:00 GMT 2015


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  b0f81637d5bda47be93bac34b68f429a12979321 (commit)
       via  850713336effc17b6dcd9902f51eb7700e07bba7 (commit)
      from  4b84e2471b5f0c9197073395eb77843c6f23e790 (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=b0f81637d5bda47be93bac34b68f429a12979321

commit b0f81637d5bda47be93bac34b68f429a12979321
Author: Gabriel F. T. Gomes <gftg@linux.vnet.ibm.com>
Date:   Tue Sep 15 10:51:08 2015 -0300

    PowerPC: Add comments to optimized strncpy
    
    	* sysdeps/powerpc/powerpc64/power8/strncpy.S: Added comments to some
    	assembly instructions.

diff --git a/ChangeLog b/ChangeLog
index 9039de1..d410e0f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2015-10-01  Gabriel F. T. Gomes  <gftg@linux.vnet.ibm.com>
 
+	* sysdeps/powerpc/powerpc64/power8/strncpy.S: Added comments to some
+	assembly instructions.
+
+2015-10-01  Gabriel F. T. Gomes  <gftg@linux.vnet.ibm.com>
+
 	* sysdeps/powerpc/powerpc64/power8/strncpy.S: Remove or add register
 	prefix from operands.
 
diff --git a/sysdeps/powerpc/powerpc64/power8/strncpy.S b/sysdeps/powerpc/powerpc64/power8/strncpy.S
index 380d7e1..663829f 100644
--- a/sysdeps/powerpc/powerpc64/power8/strncpy.S
+++ b/sysdeps/powerpc/powerpc64/power8/strncpy.S
@@ -82,44 +82,80 @@ EALIGN (FUNC_NAME, 4, 0)
 L(short_path):
 	mr	r9,r3
 L(short_path_1):
+	/* Return if there are no more bytes to be written.  */
 	cmpdi	cr7,r5,0
 	beq	cr7,L(short_path_loop_end_1)
 L(short_path_2):
+	/* Copy one char from src (r4) and write it to dest (r9).  If it is the
+	   end-of-string, start the null padding.  Continue, otherwise.  */
 	lbz	r10,0(r4)
 	cmpdi	cr7,r10,0
 	stb	r10,0(r9)
 	beq	cr7,L(zero_pad_start_1)
+	/* If there are no more bytes to be written, return.  */
 	cmpdi	cr0,r5,1
 	addi	r8,r9,1
 	addi	r6,r5,-1
 	beq	cr0,L(short_path_loop_end_0)
+	/* Copy another char from src (r4) to dest (r9).  Check again if it is
+	   the end-of-string.  If so, start the null padding.  */
 	lbz	r10,1(r4)
 	cmpdi	cr7,r10,0
 	stb	r10,1(r9)
 	beq	cr7,L(zero_pad_start_prepare_1)
+	/* Eagerly decrement r5 by 3, which is the number of bytes already
+	   written, plus one write that will be performed later on.  */
 	addi	r10,r5,-3
 	b	L(short_path_loop_1)
 
 	.align	4
 L(short_path_loop):
+	/* At this point, the induction variable, r5, as well as the pointers
+	   to dest and src (r9 and r4, respectivelly) have been updated.
+
+	   Note: The registers r7 and r10 are induction variables derived from
+	   r5.  They are used to determine if the total number of writes has
+	   been reached at every other write.
+
+	   Copy one char from src (r4) and write it to dest (r9).  If it is the
+	   end-of-string, start the null padding.  Continue, otherwise.  */
 	lbz	r8,0(r4)
 	addi	r7,r10,-2
 	cmpdi	cr5,r8,0
 	stb	r8,0(r9)
 	beq	cr5,L(zero_pad_start_1)
 	beq	cr7,L(short_path_loop_end_0)
+	/* Copy another char from src (r4) to dest (r9).  Check again if it is
+	   the end-of-string.  If so, start the null padding.  */
 	lbz	r8,1(r4)
 	cmpdi	cr7,r8,0
 	stb	r8,1(r9)
 	beq	cr7,L(zero_pad_start)
 	mr	r10,r7
 L(short_path_loop_1):
+	/* This block is reached after two chars have been already written to
+	   dest.  Nevertheless, r5 (the induction variable), r9 (the pointer to
+	   dest), and r4 (the pointer to src) have not yet been updated.
+
+	   At this point:
+	     r5 holds the count of bytes yet to be written plus 2.
+	     r9 points to the last two chars that were already written to dest.
+	     r4 points to the last two chars that were already copied from src.
+
+	   The algorithm continues by decrementing r5, the induction variable,
+	   so that it reflects the last two writes.  The pointers to dest (r9)
+	   and to src (r4) are increment by two, for the same reason.
+
+	   Note: Register r10 is another induction variable, derived from r5,
+	   which determines if the total number of writes has been reached.  */
 	addic.	r5,r5,-2
 	addi	r9,r9,2
-	cmpdi	cr7,r10,0
+	cmpdi	cr7,r10,0 /* Eagerly check if the next write is the last.  */
 	addi	r4,r4,2
 	addi	r6,r9,1
-	bne	cr0,L(short_path_loop)
+	bne	cr0,L(short_path_loop) /* Check if the total number of writes
+					  has been reached at every other
+					  write.  */
 #ifdef USE_AS_STPNCPY
 	mr	r3,r9
 	b	L(short_path_loop_end)

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=850713336effc17b6dcd9902f51eb7700e07bba7

commit 850713336effc17b6dcd9902f51eb7700e07bba7
Author: Gabriel F. T. Gomes <gftg@linux.vnet.ibm.com>
Date:   Tue Sep 15 10:51:07 2015 -0300

    PowerPC: Fix operand prefixes
    
    The file sysdeps/powerpc/sysdeps.h defines aliases for register operands,
    which add the letter 'r' as a prefix to a register name.  E.g.: register 20
    can be written as 'r20', instead of '20'.  On the one hand, this increases
    readability, as it makes it easier for readers to know whether the operand is a
    register or an immediate.  On the other hand, this permits that immediate
    operands be written as if they were registers, and vice-versa, thus reducing
    the readability of the code.
    
    This commit removes some of these unintentional misuses.
    
    This commit also increases readability of the code by adding the prefix 'cr' to
    some uses of the control register.
    
    Both changes have no effect on the final code.  Checked with objdump.
    
    	* sysdeps/powerpc/powerpc64/power8/strncpy.S: Remove or add register
    	prefix from operands.

diff --git a/ChangeLog b/ChangeLog
index 6e05949..9039de1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-10-01  Gabriel F. T. Gomes  <gftg@linux.vnet.ibm.com>
+
+	* sysdeps/powerpc/powerpc64/power8/strncpy.S: Remove or add register
+	prefix from operands.
+
 2015-10-01  Joseph Myers  <joseph@codesourcery.com>
 
 	[BZ #16347]
diff --git a/sysdeps/powerpc/powerpc64/power8/strncpy.S b/sysdeps/powerpc/powerpc64/power8/strncpy.S
index 5fda953..380d7e1 100644
--- a/sysdeps/powerpc/powerpc64/power8/strncpy.S
+++ b/sysdeps/powerpc/powerpc64/power8/strncpy.S
@@ -64,7 +64,7 @@ EALIGN (FUNC_NAME, 4, 0)
 	std	r28,-32(r1)
 	std	r29,-24(r1)
 
-	cmpld	r7,r9,r8
+	cmpld	cr7,r9,r8
 
 	std	r30,-16(r1)
 	std	r31,-8(r1)
@@ -107,7 +107,7 @@ L(short_path_loop):
 	cmpdi	cr5,r8,0
 	stb	r8,0(r9)
 	beq	cr5,L(zero_pad_start_1)
-	beq	r7,L(short_path_loop_end_0)
+	beq	cr7,L(short_path_loop_end_0)
 	lbz	r8,1(r4)
 	cmpdi	cr7,r8,0
 	stb	r8,1(r9)
@@ -234,7 +234,7 @@ L(unaligned_lt_16):
 	bne	cr7,L(short_path_prepare_2)
 	addi	r6,r5,-8
 	std	r7,0(r3)
-	addi	r9,r3,r8
+	addi	r9,r3,8
 	cmpldi	cr7,r6,7
 	addi	r7,r4,8
 	ble	cr7,L(short_path_prepare_1_1)
@@ -288,11 +288,11 @@ L(pagecross):
 	cmpdi	cr7,r9,0
 	bne	cr7,L(short_path_prepare_2)
 	addi	r8,r8,-16
-	cmpldi	r7,r8,8
+	cmpldi	cr7,r8,8
 	ble	cr7,L(short_path_prepare_2)
 	ld	r8,24(r11)
 	cmpb	r9,r8,r9
-	cmpdi	r7,r9,0
+	cmpdi	cr7,r9,0
 	bne	cr7,L(short_path_prepare_2)
 
 	/* No null byte found in the 32 bytes readed and length not reached,
@@ -367,7 +367,7 @@ L(loop_16b):
 	cmpb	r7,r0,r30
 	or.	r7,r8,r7
 	addi	r12,r12,-32
-	cmpldi	r7,r12,15
+	cmpldi	cr7,r12,15
 	addi	r11,r11,32
 	bne	cr0,L(short_path_2)
 	std	r10,16(r6)

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

Summary of changes:
 ChangeLog                                  |   10 +++++
 sysdeps/powerpc/powerpc64/power8/strncpy.S |   52 +++++++++++++++++++++++----
 2 files changed, 54 insertions(+), 8 deletions(-)


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



More information about the Glibc-cvs mailing list