diff --git a/string/test-strncat.c b/string/test-strncat.c index f7cf7df..2ffa550 100644 --- a/string/test-strncat.c +++ b/string/test-strncat.c @@ -94,16 +94,12 @@ do_test (size_t align1, size_t align2, size_t len1, size_t len2, size_t i; char *s1, *s2; - align1 &= 7; - if (align1 + len1 >= page_size) + if (align1 + (len1 > n ? n : len1) >= page_size) return; - if (align1 + n > page_size) - return; - align2 &= 7; - if (align2 + len1 + len2 >= page_size) - return; - if (align2 + len1 + n > page_size) + + if (align2 + (len1 > n ? n : len1) + len2 >= page_size) return; + s1 = (char *) (buf1 + align1); s2 = (char *) (buf2 + align2); @@ -269,6 +265,10 @@ main (void) printf ("\t%s", impl->name); putchar ('\n'); + do_test (50, 2, 20, 20, -1, 127); + do_test (50, 59, 40, 40, -1, 255); + do_test (53, 53, 80, 80, -1, 127); + for (n = 2; n <= 2048; n*=4) { do_test (0, 2, 2, 2, n, 127); diff --git a/sysdeps/i386/i686/multiarch/strcat-sse2.S b/sysdeps/i386/i686/multiarch/strcat-sse2.S index 43a6945..b692036 100644 --- a/sysdeps/i386/i686/multiarch/strcat-sse2.S +++ b/sysdeps/i386/i686/multiarch/strcat-sse2.S @@ -307,6 +307,10 @@ L(StartStrcpyPart_1): pxor %xmm0, %xmm0 pxor %xmm1, %xmm1 +# ifdef USE_AS_STRNCAT + cmp $48, %ebx + ja L(BigN) +# endif pcmpeqb (%esi), %xmm1 # ifdef USE_AS_STRNCAT add %ecx, %ebx @@ -348,7 +352,7 @@ L(Unalign16Both): # endif test %edx, %edx jnz L(CopyFrom1To16Bytes) - +L(Unalign16BothBigN): movaps 16(%esi, %ecx), %xmm3 movdqu %xmm2, (%eax, %ecx) pcmpeqb %xmm3, %xmm0 @@ -418,7 +422,6 @@ L(Unalign16Both): # ifdef USE_AS_STRNCAT lea 128(%ebx, %edx), %ebx # endif -L(Unaligned64Loop): movaps (%esi), %xmm2 movaps %xmm2, %xmm4 movaps 16(%esi), %xmm5 @@ -437,6 +440,7 @@ L(Unaligned64Loop): test %edx, %edx jnz L(Unaligned64Leave) + .p2align 4 L(Unaligned64Loop_start): add $64, %eax add $64, %esi @@ -489,6 +493,38 @@ L(Unaligned64Leave): add $48, %eax BRANCH_TO_JMPTBL_ENTRY (L(ExitTable), %edx, 4) +# ifdef USE_AS_STRNCAT + .p2align 4 +L(BigN): + pcmpeqb (%esi), %xmm1 + pmovmskb %xmm1, %edx + shr %cl, %edx + test %edx, %edx + jnz L(CopyFrom1To16BytesTail) + + pcmpeqb 16(%esi), %xmm0 + pmovmskb %xmm0, %edx + test %edx, %edx + jnz L(CopyFrom1To32Bytes) + + movdqu (%esi, %ecx), %xmm1 /* copy 16 bytes */ + movdqu %xmm1, (%eax) + sub %ecx, %eax + sub $48, %ebx + add %ecx, %ebx + + mov $16, %ecx + movdqa (%esi, %ecx), %xmm1 + movaps 16(%esi, %ecx), %xmm2 + movdqu %xmm1, (%eax, %ecx) + pcmpeqb %xmm2, %xmm0 + pmovmskb %xmm0, %edx + add $16, %ecx + test %edx, %edx + jnz L(CopyFrom1To16Bytes) + jmp L(Unalign16BothBigN) +# endif + /*------------end of main part-------------------------------*/ /* Case1 */ diff --git a/sysdeps/i386/i686/multiarch/strcpy-ssse3.S b/sysdeps/i386/i686/multiarch/strcpy-ssse3.S index 813dcc1..073856f 100644 --- a/sysdeps/i386/i686/multiarch/strcpy-ssse3.S +++ b/sysdeps/i386/i686/multiarch/strcpy-ssse3.S @@ -124,6 +124,7 @@ ENTRY (STRCPY) PUSH (%esi) # ifdef USE_AS_STRNCPY mov %ecx, %esi + sub $16, %ebx and $0xf, %esi /* add 16 bytes ecx_shift to ebx */ @@ -160,7 +161,7 @@ ENTRY (STRCPY) /* eax = 0: there isn't end of string from position esi to esi+15 */ # ifdef USE_AS_STRNCPY - sub $32, %ebx + sub $16, %ebx jbe L(CopyFrom1To16BytesCase2OrCase3) # endif test %eax, %eax