Skip to content

Commit

Permalink
Fix x86-64 memchr for large lengths.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Jelinek authored and Ulrich Drepper committed Jun 16, 2009
1 parent 435aa54 commit fab8238
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2009-06-16 Jakub Jelinek <jakub@redhat.com>

* sysdeps/x86_64/memchr.S (memchr): Use unsigned instead of signed
comparisons.
* string/test-memchr.c (do_random_tests): Test very large lengths
as well.

2009-06-02 H.J. Lu <hongjiu.lu@intel.com>

* Makeconfig (+link-pie): Define.
Expand Down
9 changes: 7 additions & 2 deletions string/test-memchr.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Test and measure memchr functions.
Copyright (C) 1999, 2002, 2003, 2005 Free Software Foundation, Inc.
Copyright (C) 1999, 2002, 2003, 2005, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Jakub Jelinek <jakub@redhat.com>, 1999.
Expand Down Expand Up @@ -144,7 +144,12 @@ do_random_tests (void)
}

if (pos < len)
result = (char *) (p + pos + align);
{
size_t r = random ();
if ((r & 31) == 0)
len = ~(uintptr_t) (p + align) - ((r >> 5) & 31);
result = (char *) (p + pos + align);
}
else
result = NULL;

Expand Down
6 changes: 3 additions & 3 deletions sysdeps/x86_64/memchr.S
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ENTRY (memchr)
movl $16, %esi
jnz 1f
cmpq %rsi, %rdx
jle 3f
jbe 3f

2: movdqa (%rdi,%rsi), %xmm0
leaq 16(%rsi), %rsi
Expand All @@ -50,7 +50,7 @@ ENTRY (memchr)
testl %ecx, %ecx
jnz 1f
cmpq %rsi, %rdx
jg 2b
ja 2b

3: xorl %eax, %eax
ret
Expand All @@ -60,7 +60,7 @@ ENTRY (memchr)
addq %rcx, %rax
leaq -16(%rsi,%rcx), %rsi
cmpq %rsi, %rdx
jle 3b
jbe 3b
ret
END (memchr)

Expand Down

0 comments on commit fab8238

Please sign in to comment.