Received: from eggs.gnu.org ([2001:4830:134:3::10]:46157) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zjl6H-0000xp-W8 for qemu-devel@nongnu.org; Wed, 07 Oct 2015 05:33:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zjl6G-0004rh-9n for qemu-devel@nongnu.org; Wed, 07 Oct 2015 05:33:29 -0400 Received: from mail-pa0-x22b.google.com ([2607:f8b0:400e:c03::22b]:35852) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zjl6G-0004rX-4W for qemu-devel@nongnu.org; Wed, 07 Oct 2015 05:33:28 -0400 Received: by pablk4 with SMTP id lk4so16440022pab.3 for ; Wed, 07 Oct 2015 02:33:27 -0700 (PDT) Sender: Richard Henderson From: Richard Henderson Date: Wed, 7 Oct 2015 20:32:59 +1100 Message-Id: <1444210397-20679-2-git-send-email-rth@twiddle.net> In-Reply-To: <1444210397-20679-1-git-send-email-rth@twiddle.net> References: <1444210397-20679-1-git-send-email-rth@twiddle.net> Subject: [Qemu-devel] [PULL 01/19] target-tilegx: Tidy simd_helper.c List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Using the V1 macro when we want to replicate a byte across the 8 elements of the word. Using deposit and extract for manipulating specific elements. Signed-off-by: Richard Henderson --- target-tilegx/simd_helper.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/target-tilegx/simd_helper.c b/target-tilegx/simd_helper.c index b931929..f573f9b 100644 --- a/target-tilegx/simd_helper.c +++ b/target-tilegx/simd_helper.c @@ -23,12 +23,16 @@ #include "exec/helper-proto.h" +/* Broadcast a value to all elements of a vector. */ +#define V1(X) (((X) & 0xff) * 0x0101010101010101ull) + + uint64_t helper_v1shl(uint64_t a, uint64_t b) { uint64_t m; b &= 7; - m = 0x0101010101010101ULL * (0xff >> b); + m = V1(0xff >> b); return (a & m) << b; } @@ -37,7 +41,7 @@ uint64_t helper_v1shru(uint64_t a, uint64_t b) uint64_t m; b &= 7; - m = 0x0101010101010101ULL * ((0xff << b) & 0xff); + m = V1(0xff << b); return (a & m) >> b; } @@ -48,8 +52,7 @@ uint64_t helper_v1shrs(uint64_t a, uint64_t b) b &= 7; for (i = 0; i < 64; i += 8) { - int64_t ae = (int8_t)(a >> i); - r |= ((ae >> b) & 0xff) << i; + r = deposit64(r, i, 8, sextract64(a, i + b, 8 - b)); } return r; } -- 2.4.3