qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, peter.maydell@linaro.org,
	qemu-ppc@nongnu.org, David Gibson <david@gibson.dropbear.id.au>
Subject: [Qemu-devel] [PATCH v2 8/8] cutils: Rewrite ppc buffer zero checking
Date: Wed, 24 Aug 2016 10:48:35 -0700	[thread overview]
Message-ID: <1472060915-6011-9-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1472060915-6011-1-git-send-email-rth@twiddle.net>

GCC versions through 6 do a poor job with the indexed addressing,
and (for ppc64le) issues unnecessary xxswapd insns.

Cc: qemu-ppc@nongnu.org
Cc: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 util/bufferiszero.c | 40 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/util/bufferiszero.c b/util/bufferiszero.c
index 28a1419..d580b57 100644
--- a/util/bufferiszero.c
+++ b/util/bufferiszero.c
@@ -119,8 +119,44 @@ static bool select_accel_int(const void *buf, size_t len)
 #undef pixel
 #undef bool
 #define bool _Bool
-#define DO_NONZERO(X)  vec_any_ne(X, (__vector unsigned char){ 0 })
-ACCEL_BUFFER_ZERO(buffer_zero_ppc, 128, __vector unsigned char, DO_NONZERO)
+
+static bool __attribute__((noinline))
+buffer_zero_ppc(const void *buf, size_t len)
+{
+    typedef unsigned char vec __attribute__((vector_size(16)));
+    const vec *p = buf;
+    const vec *end = buf + len;
+    vec t0, t1, t2, t3, zero = (vec){ 0 };
+
+    do {
+        p += 8;
+        __builtin_prefetch(p);
+        barrier();
+        /* ??? GCC6 does poorly with power64le; extra xxswap.  */
+        __asm("lvebx %0,%4,%5\n\t"
+              "lvebx %1,%4,%6\n\t"
+              "lvebx %2,%4,%7\n\t"
+              "lvebx %3,%4,%8\n\t"
+              "vor %0,%0,%1\n\t"
+              "vor %1,%2,%3\n\t"
+              "lvebx %2,%4,%9\n\t"
+              "lvebx %3,%4,%10\n\t"
+              "vor %0,%0,%1\n\t"
+              "vor %1,%2,%3\n\t"
+              "lvebx %2,%4,%11\n\t"
+              "lvebx %3,%4,%12\n\t"
+              "vor %0,%0,%1\n\t"
+              "vor %1,%2,%3\n\t"
+              "vor %0,%0,%1"
+              : "=v"(t0), "=v"(t1), "=v"(t2), "=v"(t3)
+              : "b"(p), "b"(-8 * 16), "b"(-7 * 16), "b"(-6 * 16), "b"(-5 * 16),
+                "b"(-4 * 16), "b"(-3 * 16), "b"(-2 * 16), "b"(-1 * 16));
+        if (unlikely(vec_any_ne(t0, zero))) {
+            return false;
+        }
+    } while (p < end);
+    return true;
+}
 
 static bool select_accel_fn(const void *buf, size_t len)
 {
-- 
2.7.4

  parent reply	other threads:[~2016-08-24 17:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-24 17:48 [Qemu-devel] [PATCH v2 0/8] Improve buffer_is_zero Richard Henderson
2016-08-24 17:48 ` [Qemu-devel] [PATCH v2 1/8] cutils: Move buffer_is_zero and subroutines to a new file Richard Henderson
2016-08-24 17:48 ` [Qemu-devel] [PATCH v2 3/8] cutils: Export only buffer_is_zero Richard Henderson
2016-08-24 17:48 ` [Qemu-devel] [PATCH v2 4/8] cutils: Rearrange buffer_is_zero acceleration Richard Henderson
2016-08-24 17:48 ` [Qemu-devel] [PATCH v2 5/8] cutils: Add generic prefetch Richard Henderson
2016-08-24 17:48 ` [Qemu-devel] [PATCH v2 6/8] cutils: Rewrite x86 buffer zero checking Richard Henderson
2016-08-24 17:48 ` [Qemu-devel] [PATCH v2 7/8] cutils: Rewrite aarch64 " Richard Henderson
2016-08-24 17:48 ` Richard Henderson [this message]
2016-08-24 19:18 ` [Qemu-devel] [PATCH v2 0/8] Improve buffer_is_zero Eric Blake
2016-08-24 20:31   ` Richard Henderson
2016-08-25 12:49 ` Daniel P. Berrange

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1472060915-6011-9-git-send-email-rth@twiddle.net \
    --to=rth@twiddle.net \
    --cc=david@gibson.dropbear.id.au \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).