summaryrefslogtreecommitdiffstats
path: root/lib/libc/i386
diff options
context:
space:
mode:
authordg <dg@FreeBSD.org>1995-12-27 18:47:45 +0000
committerdg <dg@FreeBSD.org>1995-12-27 18:47:45 +0000
commit092f38aea585d6cdfb5955a340362bb4a51fd2ff (patch)
tree6c2961ce400b6ccc62cd0e124f7a530d8372d5bb /lib/libc/i386
parente9380ac25166321871462c50797fb4ca791b8105 (diff)
downloadFreeBSD-src-092f38aea585d6cdfb5955a340362bb4a51fd2ff.zip
FreeBSD-src-092f38aea585d6cdfb5955a340362bb4a51fd2ff.tar.gz
Be smarter about handling overlapped copies and only go backwards if it
is really necessary. Going backwards on a P6 is much slower than forwards and it's a little slower on a P5. Also moved the count mask and 'std' down a few lines - it's a couple percent faster this way on a P5.
Diffstat (limited to 'lib/libc/i386')
-rw-r--r--lib/libc/i386/string/bcopy.S14
-rw-r--r--lib/libc/i386/string/memmove.S14
2 files changed, 16 insertions, 12 deletions
diff --git a/lib/libc/i386/string/bcopy.S b/lib/libc/i386/string/bcopy.S
index 1a6762c..6d99938 100644
--- a/lib/libc/i386/string/bcopy.S
+++ b/lib/libc/i386/string/bcopy.S
@@ -32,12 +32,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: bcopy.S,v 1.1 1994/08/05 01:18:24 wollman Exp $
+ * $Id: bcopy.S,v 1.2 1995/01/23 01:28:49 davidg Exp $
*/
#if defined(LIBC_RCS) && !defined(lint)
.text
- .asciz "$Id: bcopy.S,v 1.1 1994/08/05 01:18:24 wollman Exp $"
+ .asciz "$Id: bcopy.S,v 1.2 1995/01/23 01:28:49 davidg Exp $"
#endif /* LIBC_RCS and not lint */
#include "DEFS.h"
@@ -53,8 +53,10 @@ ENTRY(bcopy)
movl 12(%esp),%esi
movl 16(%esp),%edi
movl 20(%esp),%ecx
- cmpl %esi,%edi /* potentially overlapping? */
- jnb 1f
+ movl %edi,%eax
+ subl %esi,%eax
+ cmpl %ecx,%eax /* overlapping? */
+ jb 1f
cld /* nope, copy forwards. */
shrl $2,%ecx /* copy by words */
rep
@@ -69,10 +71,10 @@ ENTRY(bcopy)
1:
addl %ecx,%edi /* copy backwards. */
addl %ecx,%esi
- std
- andl $3,%ecx /* any fractional bytes? */
decl %edi
decl %esi
+ andl $3,%ecx /* any fractional bytes? */
+ std
rep
movsb
movl 20(%esp),%ecx /* copy remainder by words */
diff --git a/lib/libc/i386/string/memmove.S b/lib/libc/i386/string/memmove.S
index 1c74561..497af4f 100644
--- a/lib/libc/i386/string/memmove.S
+++ b/lib/libc/i386/string/memmove.S
@@ -32,12 +32,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: memmove.S,v 1.1 1994/08/05 01:18:29 wollman Exp $
+ * $Id: memmove.S,v 1.2 1995/01/23 01:29:02 davidg Exp $
*/
#if defined(LIBC_RCS) && !defined(lint)
.text
- .asciz "$Id: memmove.S,v 1.1 1994/08/05 01:18:29 wollman Exp $"
+ .asciz "$Id: memmove.S,v 1.2 1995/01/23 01:29:02 davidg Exp $"
#endif /* LIBC_RCS and not lint */
#include "DEFS.h"
@@ -54,8 +54,10 @@ ENTRY(memmove)
movl 12(%esp),%edi
movl 16(%esp),%esi
movl 20(%esp),%ecx
- cmpl %esi,%edi /* potentially overlapping? */
- jnb 1f
+ movl %edi,%eax
+ subl %esi,%eax
+ cmpl %ecx,%eax
+ jb 1f
cld /* nope, copy forwards. */
shrl $2,%ecx /* copy by words */
rep
@@ -71,10 +73,10 @@ ENTRY(memmove)
1:
addl %ecx,%edi /* copy backwards. */
addl %ecx,%esi
- std
- andl $3,%ecx /* any fractional bytes? */
decl %edi
decl %esi
+ andl $3,%ecx /* any fractional bytes? */
+ std
rep
movsb
movl 20(%esp),%ecx /* copy remainder by words */
OpenPOWER on IntegriCloud