From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Cc: vijay.kilari@gmail.com, qemu-arm@nongnu.org, pbonzini@redhat.com,
peter.maydell@linaro.org, qemu-ppc@nongnu.org,
David Gibson <david@gibson.dropbear.id.au>
Subject: [Qemu-devel] [PATCH 7/7] cutils: Rewrite ppc buffer zero checking
Date: Tue, 23 Aug 2016 21:17:59 -0700 [thread overview]
Message-ID: <1472012279-20581-8-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1472012279-20581-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/cutils.c | 41 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 39 insertions(+), 2 deletions(-)
diff --git a/util/cutils.c b/util/cutils.c
index fe860e8..30fac02 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -254,8 +254,45 @@ static bool select_accel_int(const void *buf, size_t len)
#undef pixel
#undef bool
#define bool _Bool
-#define DO_ZERO(X) vec_all_eq(X, (__vector unsigned char){ 0 })
-ACCEL_BUFFER_ZERO(buffer_zero_ppc, 128, __vector unsigned char, DO_ZERO)
+
+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);
+ /* ??? GCC6 does poorly with power64le; extra xxswap. */
+ __asm volatile("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
next prev parent reply other threads:[~2016-08-24 4:19 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-24 4:17 [Qemu-devel] [PATCH 0/7] Improve buffer_is_zero Richard Henderson
2016-08-24 4:17 ` [Qemu-devel] [PATCH 1/7] cutils: Remove SPLAT macro Richard Henderson
2016-08-24 4:17 ` [Qemu-devel] [PATCH 2/7] cutils: Export only buffer_is_zero Richard Henderson
2016-08-24 8:37 ` Dr. David Alan Gilbert
2016-08-24 4:17 ` [Qemu-devel] [PATCH 3/7] cutils: Rearrange buffer_is_zero acceleration Richard Henderson
2016-08-24 4:17 ` [Qemu-devel] [PATCH 4/7] cutils: Add generic prefetch Richard Henderson
2016-08-24 4:17 ` [Qemu-devel] [PATCH 5/7] cutils: Rewrite x86 buffer zero checking Richard Henderson
2016-08-24 4:17 ` [Qemu-devel] [PATCH 6/7] cutils: Rewrite aarch64 " Richard Henderson
2016-08-24 4:17 ` Richard Henderson [this message]
2016-08-24 4:30 ` [Qemu-devel] [PATCH 0/7] Improve buffer_is_zero no-reply
2016-08-24 4:38 ` Paolo Bonzini
2016-08-24 14:53 ` Richard Henderson
2016-08-24 14:59 ` Paolo Bonzini
2016-08-24 8:34 ` Dr. David Alan Gilbert
2016-08-24 10:26 ` Adam Richter
2016-08-24 10:52 ` Peter Maydell
2016-08-24 11:45 ` Paolo Bonzini
2016-08-24 12:22 ` Peter Maydell
2016-08-25 6:37 ` Vijay Kilari
2016-08-25 8:04 ` Vijay Kilari
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=1472012279-20581-8-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-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=vijay.kilari@gmail.com \
/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).