Subject: Re: Performance of various memcpy()'s
To: Bang Jun-Young <junyoung@mogua.com>
From: David Laight <david@l8s.co.uk>
List: tech-userlevel
Date: 10/28/2002 09:01:11
Given the significant performance improvent, I'd go for:

> +ENTRY(memcpy)
> +	pushl	%esi
> +	pushl	%edi
> +
> +	movl	12(%esp),%edi
> +	movl	16(%esp),%esi
> +	movl	20(%esp),%ecx
> +	movl	%edi,%eax	/* return value */
> +
> +	movl	%ecx,%edx
> +	cld			/* nope, copy forwards. */
> +	shrl	$2,%ecx		/* copy by words */
> +	rep
> +	movsl

	andl	$3,%edx
	jne	1f
	popl	%edi
	popl	%esi
	ret
   1:
> +	movl	%edx,%ecx
> +	rep
> +	movsb
> +	popl	%edi
> +	popl	%esi
> +	ret

Or even finish off with:
	movb	(%esi),%cl
	decl	%edx
	movb	%cl,(%di)
	jne	1b
	popl	%edi
	popl	%esi
	ret

	David

-- 
David Laight: david@l8s.co.uk