public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] x86-64: Skip zero length in __mem[pcpy|move|set]_erms
@ 2018-05-23 17:28 H.J. Lu
  0 siblings, 0 replies; only message in thread
From: H.J. Lu @ 2018-05-23 17:28 UTC (permalink / raw)
  To: GNU C Library

This patch skips zero length in __mempcpy_erms, __memmove_erms and
__memset_erms.

Tested on x86-64.  I will check it in shortly.


H.J.
---
	* sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
	(__mempcpy_erms): Skip zero length.
	(__memmove_erms): Likewise.
	* sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
	(__memset_erms): Likewise.
---
 sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S | 6 ++++++
 sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S  | 5 +++++
 2 files changed, 11 insertions(+)

diff --git a/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S b/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
index 1404131bb7..e2ede45e9f 100644
--- a/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
+++ b/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
@@ -156,6 +156,9 @@ END (__mempcpy_chk_erms)
 /* Only used to measure performance of REP MOVSB.  */
 ENTRY (__mempcpy_erms)
 	movq	%rdi, %rax
+	/* Skip zero length.  */
+	testq	%rdx, %rdx
+	jz	2f
 	addq	%rdx, %rax
 	jmp	L(start_movsb)
 END (__mempcpy_erms)
@@ -167,6 +170,9 @@ END (__memmove_chk_erms)
 
 ENTRY (__memmove_erms)
 	movq	%rdi, %rax
+	/* Skip zero length.  */
+	testq	%rdx, %rdx
+	jz	2f
 L(start_movsb):
 	movq	%rdx, %rcx
 	cmpq	%rsi, %rdi
diff --git a/sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S b/sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
index 0a827f3e47..dc9cb88b37 100644
--- a/sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
+++ b/sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
@@ -128,6 +128,11 @@ END (__memset_chk_erms)
 
 /* Only used to measure performance of REP STOSB.  */
 ENTRY (__memset_erms)
+	/* Skip zero length.  */
+	testq	%rdx, %rdx
+	jnz	 L(stosb)
+	movq	%rdi, %rax
+	ret
 # else
 /* Provide a hidden symbol to debugger.  */
 	.hidden	MEMSET_SYMBOL (__memset, erms)
-- 
2.17.0

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-05-23 17:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-23 17:28 [PATCH] x86-64: Skip zero length in __mem[pcpy|move|set]_erms H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).