PowerPC LE memset

http://sourceware.org/ml/libc-alpha/2013-08/msg00104.html

One of the things I noticed when looking at power7 timing is that rlwimi
is cracked and the two resulting insns have a register dependency.
That makes it a little slower than the equivalent rldimi.

	* sysdeps/powerpc/powerpc64/memset.S: Replace rlwimi with
        insrdi.  Formatting.
	* sysdeps/powerpc/powerpc64/power4/memset.S: Likewise.
	* sysdeps/powerpc/powerpc64/power6/memset.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/memset.S: Likewise.
	* sysdeps/powerpc/powerpc32/power4/memset.S: Likewise.
	* sysdeps/powerpc/powerpc32/power6/memset.S: Likewise.
	* sysdeps/powerpc/powerpc32/power7/memset.S: Likewise.
This commit is contained in:
Alan Modra 2013-08-17 18:47:59 +09:30
parent 759cfef3ac
commit 3be87c77d2
8 changed files with 45 additions and 34 deletions

View File

@ -1,3 +1,14 @@
2013-10-04 Alan Modra <amodra@gmail.com>
* sysdeps/powerpc/powerpc64/memset.S: Replace rlwimi with
insrdi. Formatting.
* sysdeps/powerpc/powerpc64/power4/memset.S: Likewise.
* sysdeps/powerpc/powerpc64/power6/memset.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/memset.S: Likewise.
* sysdeps/powerpc/powerpc32/power4/memset.S: Likewise.
* sysdeps/powerpc/powerpc32/power6/memset.S: Likewise.
* sysdeps/powerpc/powerpc32/power7/memset.S: Likewise.
2013-10-04 Alan Modra <amodra@gmail.com> 2013-10-04 Alan Modra <amodra@gmail.com>
* sysdeps/powerpc/powerpc32/power4/memcpy.S: Add little endian support. * sysdeps/powerpc/powerpc32/power4/memcpy.S: Add little endian support.

View File

@ -50,7 +50,7 @@ L(_memset):
/* Align to word boundary. */ /* Align to word boundary. */
cmplwi cr5, rLEN, 31 cmplwi cr5, rLEN, 31
rlwimi rCHR, rCHR, 8, 16, 23 /* Replicate byte to halfword. */ insrdi rCHR, rCHR, 8, 48 /* Replicate byte to halfword. */
beq+ L(aligned) beq+ L(aligned)
mtcrf 0x01, rMEMP0 mtcrf 0x01, rMEMP0
subfic rALIGN, rALIGN, 4 subfic rALIGN, rALIGN, 4
@ -65,7 +65,7 @@ L(g0):
/* Handle the case of size < 31. */ /* Handle the case of size < 31. */
L(aligned): L(aligned):
mtcrf 0x01, rLEN mtcrf 0x01, rLEN
rlwimi rCHR, rCHR, 16, 0, 15 /* Replicate halfword to word. */ insrdi rCHR, rCHR, 16, 32 /* Replicate halfword to word. */
ble cr5, L(medium) ble cr5, L(medium)
/* Align to 32-byte boundary. */ /* Align to 32-byte boundary. */
andi. rALIGN, rMEMP, 0x1C andi. rALIGN, rMEMP, 0x1C

View File

@ -48,7 +48,7 @@ L(_memset):
ble- cr1, L(small) ble- cr1, L(small)
/* Align to word boundary. */ /* Align to word boundary. */
cmplwi cr5, rLEN, 31 cmplwi cr5, rLEN, 31
rlwimi rCHR, rCHR, 8, 16, 23 /* Replicate byte to halfword. */ insrdi rCHR, rCHR, 8, 48 /* Replicate byte to halfword. */
beq+ L(aligned) beq+ L(aligned)
mtcrf 0x01, rMEMP0 mtcrf 0x01, rMEMP0
subfic rALIGN, rALIGN, 4 subfic rALIGN, rALIGN, 4
@ -64,7 +64,7 @@ L(g0):
/* Handle the case of size < 31. */ /* Handle the case of size < 31. */
L(aligned): L(aligned):
mtcrf 0x01, rLEN mtcrf 0x01, rLEN
rlwimi rCHR, rCHR, 16, 0, 15 /* Replicate halfword to word. */ insrdi rCHR, rCHR, 16, 32 /* Replicate halfword to word. */
ble cr5, L(medium) ble cr5, L(medium)
/* Align to 32-byte boundary. */ /* Align to 32-byte boundary. */
andi. rALIGN, rMEMP, 0x1C andi. rALIGN, rMEMP, 0x1C

View File

@ -35,8 +35,8 @@ L(_memset):
cfi_offset(31,-8) cfi_offset(31,-8)
/* Replicate byte to word. */ /* Replicate byte to word. */
rlwimi 4,4,8,16,23 insrdi 4,4,8,48
rlwimi 4,4,16,0,15 insrdi 4,4,16,32
ble cr6,L(small) /* If length <= 8, use short copy code. */ ble cr6,L(small) /* If length <= 8, use short copy code. */

View File

@ -55,14 +55,14 @@ L(_memset):
/* Align to doubleword boundary. */ /* Align to doubleword boundary. */
cmpldi cr5, rLEN, 31 cmpldi cr5, rLEN, 31
rlwimi rCHR, rCHR, 8, 16, 23 /* Replicate byte to halfword. */ insrdi rCHR, rCHR, 8, 48 /* Replicate byte to halfword. */
beq+ L(aligned2) beq+ L(aligned2)
mtcrf 0x01, rMEMP0 mtcrf 0x01, rMEMP0
subfic rALIGN, rALIGN, 8 subfic rALIGN, rALIGN, 8
cror 28,30,31 /* Detect odd word aligned. */ cror 28,30,31 /* Detect odd word aligned. */
add rMEMP, rMEMP, rALIGN add rMEMP, rMEMP, rALIGN
sub rLEN, rLEN, rALIGN sub rLEN, rLEN, rALIGN
rlwimi rCHR, rCHR, 16, 0, 15 /* Replicate halfword to word. */ insrdi rCHR, rCHR, 16, 32 /* Replicate halfword to word. */
bt 29, L(g4) bt 29, L(g4)
/* Process the even word of doubleword. */ /* Process the even word of doubleword. */
bf+ 31, L(g2) bf+ 31, L(g2)
@ -84,7 +84,7 @@ L(g0):
/* Handle the case of size < 31. */ /* Handle the case of size < 31. */
L(aligned2): L(aligned2):
rlwimi rCHR, rCHR, 16, 0, 15 /* Replicate halfword to word. */ insrdi rCHR, rCHR, 16, 32 /* Replicate halfword to word. */
L(aligned): L(aligned):
mtcrf 0x01, rLEN mtcrf 0x01, rLEN
ble cr5, L(medium) ble cr5, L(medium)

View File

@ -50,14 +50,14 @@ L(_memset):
/* Align to doubleword boundary. */ /* Align to doubleword boundary. */
cmpldi cr5, rLEN, 31 cmpldi cr5, rLEN, 31
rlwimi rCHR, rCHR, 8, 16, 23 /* Replicate byte to halfword. */ insrdi rCHR, rCHR, 8, 48 /* Replicate byte to halfword. */
beq+ L(aligned2) beq+ L(aligned2)
mtcrf 0x01, rMEMP0 mtcrf 0x01, rMEMP0
subfic rALIGN, rALIGN, 8 subfic rALIGN, rALIGN, 8
cror 28,30,31 /* Detect odd word aligned. */ cror 28,30,31 /* Detect odd word aligned. */
add rMEMP, rMEMP, rALIGN add rMEMP, rMEMP, rALIGN
sub rLEN, rLEN, rALIGN sub rLEN, rLEN, rALIGN
rlwimi rCHR, rCHR, 16, 0, 15 /* Replicate halfword to word. */ insrdi rCHR, rCHR, 16, 32 /* Replicate halfword to word. */
bt 29, L(g4) bt 29, L(g4)
/* Process the even word of doubleword. */ /* Process the even word of doubleword. */
bf+ 31, L(g2) bf+ 31, L(g2)
@ -79,7 +79,7 @@ L(g0):
/* Handle the case of size < 31. */ /* Handle the case of size < 31. */
L(aligned2): L(aligned2):
rlwimi rCHR, rCHR, 16, 0, 15 /* Replicate halfword to word. */ insrdi rCHR, rCHR, 16, 32 /* Replicate halfword to word. */
L(aligned): L(aligned):
mtcrf 0x01, rLEN mtcrf 0x01, rLEN
ble cr5, L(medium) ble cr5, L(medium)

View File

@ -47,14 +47,14 @@ L(_memset):
/* Align to doubleword boundary. */ /* Align to doubleword boundary. */
cmpldi cr5, rLEN, 31 cmpldi cr5, rLEN, 31
rlwimi rCHR, rCHR, 8, 16, 23 /* Replicate byte to halfword. */ insrdi rCHR, rCHR, 8, 48 /* Replicate byte to halfword. */
beq+ L(aligned2) beq+ L(aligned2)
mtcrf 0x01, rMEMP0 mtcrf 0x01, rMEMP0
subfic rALIGN, rALIGN, 8 subfic rALIGN, rALIGN, 8
cror 28,30,31 /* Detect odd word aligned. */ cror 28,30,31 /* Detect odd word aligned. */
add rMEMP, rMEMP, rALIGN add rMEMP, rMEMP, rALIGN
sub rLEN, rLEN, rALIGN sub rLEN, rLEN, rALIGN
rlwimi rCHR, rCHR, 16, 0, 15 /* Replicate halfword to word. */ insrdi rCHR, rCHR, 16, 32 /* Replicate halfword to word. */
bt 29, L(g4) bt 29, L(g4)
/* Process the even word of doubleword. */ /* Process the even word of doubleword. */
bf+ 31, L(g2) bf+ 31, L(g2)
@ -76,7 +76,7 @@ L(g0):
/* Handle the case of size < 31. */ /* Handle the case of size < 31. */
L(aligned2): L(aligned2):
rlwimi rCHR, rCHR, 16, 0, 15 /* Replicate halfword to word. */ insrdi rCHR, rCHR, 16, 32 /* Replicate halfword to word. */
L(aligned): L(aligned):
mtcrf 0x01, rLEN mtcrf 0x01, rLEN
ble cr5, L(medium) ble cr5, L(medium)

View File

@ -32,8 +32,8 @@ L(_memset):
mr 10,3 mr 10,3
/* Replicate byte to word. */ /* Replicate byte to word. */
rlwimi 4,4,8,16,23 insrdi 4,4,8,48
rlwimi 4,4,16,0,15 insrdi 4,4,16,32
ble cr6,L(small) /* If length <= 8, use short copy code. */ ble cr6,L(small) /* If length <= 8, use short copy code. */
neg 0,3 neg 0,3
@ -321,7 +321,7 @@ L(medium):
clrldi 0,0,62 clrldi 0,0,62
beq L(medium_aligned) beq L(medium_aligned)
/* Force 4-bytes alignment for SRC. */ /* Force 4-bytes alignment for DST. */
mtocrf 0x01,0 mtocrf 0x01,0
subf 5,0,5 subf 5,0,5
1: /* Copy 1 byte. */ 1: /* Copy 1 byte. */