aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorPeter Lieven <pl@kamp.de>2013-03-26 10:58:33 +0100
committerJuan Quintela <quintela@redhat.com>2013-03-26 13:32:32 +0100
commit56ded708ec38e4cb75a7c7357480ca34c0dc6875 (patch)
tree5819b3f8f66612df3b1ad07ef74e5286c89fb780 /util
parent41a259bd2b1796ddabdae600ee539269a7ddb6a5 (diff)
downloadqemu-56ded708ec38e4cb75a7c7357480ca34c0dc6875.zip
qemu-56ded708ec38e4cb75a7c7357480ca34c0dc6875.tar.gz
qemu-56ded708ec38e4cb75a7c7357480ca34c0dc6875.tar.bz2
buffer_is_zero: use vector optimizations if possible
performance gain on SSE2 is approx. 20-25%. altivec is not tested. performance for unsigned long arithmetic is unchanged. Signed-off-by: Peter Lieven <pl@kamp.de> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Orit Wasserman <owasserm@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
Diffstat (limited to 'util')
-rw-r--r--util/cutils.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/util/cutils.c b/util/cutils.c
index 0696a3b..5024253 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -215,6 +215,11 @@ bool buffer_is_zero(const void *buf, size_t len)
long d0, d1, d2, d3;
const long * const data = buf;
+ /* use vector optimized zero check if possible */
+ if (can_use_buffer_find_nonzero_offset(buf, len)) {
+ return buffer_find_nonzero_offset(buf, len) == len;
+ }
+
assert(len % (4 * sizeof(long)) == 0);
len /= sizeof(long);