diff options
author | sobomax <sobomax@FreeBSD.org> | 2002-10-15 09:50:07 +0000 |
---|---|---|
committer | sobomax <sobomax@FreeBSD.org> | 2002-10-15 09:50:07 +0000 |
commit | 30e3020a42e25ac9152207a9199af209e89edbcb (patch) | |
tree | 8be11b12f2e43fdf75e9b5aa9200c6477abfdbde /lib/libc | |
parent | fbb20002c72e71194f283493113b188f4a9982f3 (diff) | |
download | FreeBSD-src-30e3020a42e25ac9152207a9199af209e89edbcb.zip FreeBSD-src-30e3020a42e25ac9152207a9199af209e89edbcb.tar.gz |
Eliminate superfluous memory access in memcpy(3)/memmove(3).
Obtained from: NetBSD
MFC after: 1 week
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/i386/string/bcopy.S | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/lib/libc/i386/string/bcopy.S b/lib/libc/i386/string/bcopy.S index 0c57134..1050ed2 100644 --- a/lib/libc/i386/string/bcopy.S +++ b/lib/libc/i386/string/bcopy.S @@ -59,27 +59,25 @@ ENTRY(bcopy) #if defined(MEMCOPY) || defined(MEMMOVE) movl 12(%esp),%edi movl 16(%esp),%esi + movl %edi,%eax #else movl 12(%esp),%esi movl 16(%esp),%edi #endif movl 20(%esp),%ecx - movl %edi,%eax - subl %esi,%eax - cmpl %ecx,%eax /* overlapping? */ + movl %edi,%edx + subl %esi,%edx + cmpl %ecx,%edx /* overlapping? */ jb 1f cld /* nope, copy forwards. */ - movl %ecx,%eax + movl %ecx,%edx shrl $2,%ecx /* copy by words */ rep movsl - movl %eax,%ecx + movl %edx,%ecx andl $3,%ecx /* any bytes left? */ rep movsb -#if defined(MEMCOPY) || defined(MEMMOVE) - movl 12(%esp),%eax -#endif popl %edi popl %esi ret @@ -87,21 +85,18 @@ ENTRY(bcopy) addl %ecx,%edi /* copy backwards. */ addl %ecx,%esi std - movl %ecx,%eax + movl %ecx,%edx andl $3,%ecx /* any fractional bytes? */ decl %edi decl %esi rep movsb - movl %eax,%ecx /* copy remainder by words */ + movl %edx,%ecx /* copy remainder by words */ shrl $2,%ecx subl $3,%esi subl $3,%edi rep movsl -#if defined(MEMCOPY) || defined(MEMMOVE) - movl 12(%esp),%eax -#endif popl %edi popl %esi cld |