mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-02 04:13:39 +00:00
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.
This commit is contained in:
parent
dfe11c5d9d
commit
aacd7f348e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=13064
@ -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 */
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user