From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:58195) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGXDr-0001W6-0q for qemu-devel@nongnu.org; Fri, 15 Mar 2013 12:11:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UGXDm-0006Iy-Tc for qemu-devel@nongnu.org; Fri, 15 Mar 2013 12:11:10 -0400 Received: from [2a02:248:0:30:223:aeff:fefe:7f1c] (port=48342 helo=dns.kamp-intra.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGXDm-0006Hp-NR for qemu-devel@nongnu.org; Fri, 15 Mar 2013 12:11:06 -0400 From: Peter Lieven Date: Fri, 15 Mar 2013 16:50:12 +0100 Message-Id: <1363362619-3190-4-git-send-email-pl@kamp.de> In-Reply-To: <1363362619-3190-1-git-send-email-pl@kamp.de> References: <1363362619-3190-1-git-send-email-pl@kamp.de> Subject: [Qemu-devel] [PATCHv2 3/9] buffer_is_zero: use vector optimizations if possible List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Lieven performance gain on SSE2 is approx. 20-25%. altivec is not tested. performance for unsigned long arithmetic is unchanged. Signed-off-by: Peter Lieven --- util/cutils.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/util/cutils.c b/util/cutils.c index 857dd7d..00d98fb 100644 --- a/util/cutils.c +++ b/util/cutils.c @@ -190,6 +190,13 @@ size_t buffer_find_nonzero_offset(const void *buf, size_t len) */ bool buffer_is_zero(const void *buf, size_t len) { + /* use vector optimized zero check if possible */ + if (((uintptr_t) buf) % sizeof(VECTYPE) == 0 + && len % (BUFFER_FIND_NONZERO_OFFSET_UNROLL_FACTOR + * sizeof(VECTYPE)) == 0) { + return buffer_find_nonzero_offset(buf, len)==len; + } + /* * Use long as the biggest available internal data type that fits into the * CPU register and unroll the loop to smooth out the effect of memory -- 1.7.9.5