From patchwork Sat Mar 2 05:15:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 777483 Delivered-To: patch@linaro.org Received: by 2002:adf:e94d:0:b0:33d:f458:43ce with SMTP id m13csp1694582wrn; Fri, 1 Mar 2024 21:18:40 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUbED8vSu5OK4USgqpPZ6x+ZbXzcAUqsAjsSiMdNY+BBlGDpqpKoHHiVSpIpgiVDpLWNNsvquKTdXghJT5wKE0D X-Google-Smtp-Source: AGHT+IEYQmnvlh+jNKEJwL5uPDMPeuXHnK9R/5Wrn6XH+cdHO3nI49r2qchc9ifrnBu9ET32N+yb X-Received: by 2002:a0d:cb4a:0:b0:609:338b:5cd0 with SMTP id n71-20020a0dcb4a000000b00609338b5cd0mr3558724ywd.5.1709356720125; Fri, 01 Mar 2024 21:18:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709356720; cv=none; d=google.com; s=arc-20160816; b=WdRLm+CRlFIgMhW1nMNhztZuMq5RQ9ozey4nDQoKhfJP0O4gfBmypwob1PsHfupd2v M8GOSbIZw6GBBOjfyc7xVYWXPMH9lhdyg/dq4PFI1OOAsZGHcEubcb5J7SQWE3gzsGUa 2jjL3jM0d6F27EJuLc+EvCu3bE+OY3Ux7AMYWrWA/GOOFVC2VGuXiVxiNo7AZNYmW1Pq gzHUoPsdo6jifOPqWgQwIS8NQXt18mrfllGHsfSVHJ00YMpxy3xN/CiKLJDvdiv0AdFd UaiwXJtG6b6KS0EwvL9kB71wWR2SydstR8bCHNlFBIkUg5B5vUfC8WQa905CDajhrlpD rKrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vjGfHOCM0m98uQm7bh3lP0qVKdngpnelcO2QCf7+7gs=; fh=OY/jf0qYEhT53LcIJp8d/e39mN3vEzshkseI36O8N8s=; b=OKpYFF7BxT9HmBJHORwSn7mf2cpyVlTdR3VGVheRlWkUL+l9nFui734BLY85C9d5Mr WV/qsdfWnEWyKqS0kBLCqe4goLTBOzHSgpKchyVREosqd6XJqR1lE1GBBGRiYrpYRLwg dICPCChQ7P3EIAxyU0YU6u5G8Pzdog7cIYthJFMRAR1tFUH1YBepR5JG7dsIXIPyrvVY oApT6QxYKdCvlIsIjbarvQWmF8Ws5wUlKxQ0K2ZsYvzIGtaaIIMx2qVuZDoGU6goxMv7 X6yImtUdL6PllDIVUPemlaVUm5M7UevbNH3+EuqYz3nP3+3GdHbRNl14GV32aHDosWS0 hh2A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SFf7Ax3B; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h10-20020ac846ca000000b0042dedf3dc9fsi4802942qto.434.2024.03.01.21.18.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Mar 2024 21:18:40 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SFf7Ax3B; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rgHjT-0002PK-OU; Sat, 02 Mar 2024 00:16:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rgHjQ-0002Og-5e for qemu-devel@nongnu.org; Sat, 02 Mar 2024 00:16:20 -0500 Received: from mail-oo1-xc35.google.com ([2607:f8b0:4864:20::c35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rgHjO-0007Ur-Cw for qemu-devel@nongnu.org; Sat, 02 Mar 2024 00:16:19 -0500 Received: by mail-oo1-xc35.google.com with SMTP id 006d021491bc7-5a11b231ec5so88110eaf.3 for ; Fri, 01 Mar 2024 21:16:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709356577; x=1709961377; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vjGfHOCM0m98uQm7bh3lP0qVKdngpnelcO2QCf7+7gs=; b=SFf7Ax3B32T/vYHXXk/SSkgpkl7W5+6V0L6XHlw0csaB5P32Xk5JSonglmkfcW7JaL q3RWB9sY18hehFe2qW7yxY5Af92DFko0f4DYbqccz8PCxdmpPnzriY5r8t+560vtkPNv x3Ks0eMtljeadOyL1EJMseKEo8jwYrqmkJhhHIv0yvoG1GSC6JGbctrdXjl0nCCPKPdN Moi5PVW9LvRlslVKxiKlYdVgYF89llKBIEiI7+GYpLe4ROls4WpKc43y9PDgl6CZbA01 NFhOSbk1CVIYED3Z3MT5gLwiESfylwlUQOotjpx/NqVuPpA4VIfi9ffsujkvnKvAuLDa kEmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709356577; x=1709961377; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vjGfHOCM0m98uQm7bh3lP0qVKdngpnelcO2QCf7+7gs=; b=TriE+3n8VgNColcXcJZOPnR1JEplpsKmdzn0E/d+ini0xMwsghA4J6hmTUQFH9R8HT gbaHU1D0E0IR6DpcJqDZl1JEBJNqIWECt5GkIWc6DPOSbG4nljYiP7oKv7vUI0p5x4fX uINRtLEOH2yVMkX2SZoCrwr7J/RFHe8B8QDDT+PkLqzAjYXeUSA5PJAcQi2Pch9GFkcF Pu/VBI77zV8Y76ZUhLvgiDMt9qrvnJ65aA3XlDf3iMp5rMawMS2w8Rzwf1fFBu7fde7b +Xp1F0iJ8y2e9IqGqv2gEEB6gVx1judqp15J9WpgoT1w2YoBMrgaN4znIUwWI8CtTpOf SWCA== X-Gm-Message-State: AOJu0YwuedgEsSEHObOySQakMT5B/6DLgB+27bxkHSHSxU5PJUkoNFcC GTJXq54UJJBtMPIb46RQE0eJt9OYn0aTIE0u2OVfZlIznCbkyxNpxbIEl0aUDGfRODjBQDabt81 u X-Received: by 2002:a05:6808:1481:b0:3c1:5f09:b16f with SMTP id e1-20020a056808148100b003c15f09b16fmr4558767oiw.26.1709356577259; Fri, 01 Mar 2024 21:16:17 -0800 (PST) Received: from stoup.. (098-147-055-211.res.spectrum.com. [98.147.55.211]) by smtp.gmail.com with ESMTPSA id v8-20020a17090a458800b0029af67d4fd0sm4034901pjg.44.2024.03.01.21.16.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 21:16:16 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk, atar4qemu@gmail.com Subject: [PATCH 07/41] target/sparc: Split out do_ms16b Date: Fri, 1 Mar 2024 19:15:27 -1000 Message-Id: <20240302051601.53649-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240302051601.53649-1-richard.henderson@linaro.org> References: <20240302051601.53649-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::c35; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc35.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The unit operation for fmul8x16 and friends is described in the manual as "MS16b". Split that out for clarity. Improve rounding with an unconditional addition of 0.5 as a fixed-point integer. Signed-off-by: Richard Henderson --- target/sparc/vis_helper.c | 76 +++++++++++++-------------------------- 1 file changed, 24 insertions(+), 52 deletions(-) diff --git a/target/sparc/vis_helper.c b/target/sparc/vis_helper.c index 89eea05ddb..e15c6bb34e 100644 --- a/target/sparc/vis_helper.c +++ b/target/sparc/vis_helper.c @@ -44,6 +44,7 @@ target_ulong helper_array8(target_ulong pixel_addr, target_ulong cubesize) #if HOST_BIG_ENDIAN #define VIS_B64(n) b[7 - (n)] +#define VIS_SB64(n) sb[7 - (n)] #define VIS_W64(n) w[3 - (n)] #define VIS_SW64(n) sw[3 - (n)] #define VIS_L64(n) l[1 - (n)] @@ -51,6 +52,7 @@ target_ulong helper_array8(target_ulong pixel_addr, target_ulong cubesize) #define VIS_W32(n) w[1 - (n)] #else #define VIS_B64(n) b[n] +#define VIS_SB64(n) sb[n] #define VIS_W64(n) w[n] #define VIS_SW64(n) sw[n] #define VIS_L64(n) l[n] @@ -60,6 +62,7 @@ target_ulong helper_array8(target_ulong pixel_addr, target_ulong cubesize) typedef union { uint8_t b[8]; + int8_t sb[8]; uint16_t w[4]; int16_t sw[4]; uint32_t l[2]; @@ -95,27 +98,23 @@ uint64_t helper_fpmerge(uint32_t src1, uint32_t src2) return d.ll; } +static inline int do_ms16b(int x, int y) +{ + return ((x * y) + 0x80) >> 8; +} + uint64_t helper_fmul8x16(uint32_t src1, uint64_t src2) { VIS64 d; VIS32 s; - uint32_t tmp; s.l = src1; d.ll = src2; -#define PMUL(r) \ - tmp = (int32_t)d.VIS_SW64(r) * (int32_t)s.VIS_B32(r); \ - if ((tmp & 0xff) > 0x7f) { \ - tmp += 0x100; \ - } \ - d.VIS_W64(r) = tmp >> 8; - - PMUL(0); - PMUL(1); - PMUL(2); - PMUL(3); -#undef PMUL + d.VIS_W64(0) = do_ms16b(s.VIS_B32(0), d.VIS_SW64(0)); + d.VIS_W64(1) = do_ms16b(s.VIS_B32(1), d.VIS_SW64(1)); + d.VIS_W64(2) = do_ms16b(s.VIS_B32(2), d.VIS_SW64(2)); + d.VIS_W64(3) = do_ms16b(s.VIS_B32(3), d.VIS_SW64(3)); return d.ll; } @@ -124,23 +123,14 @@ uint64_t helper_fmul8x16a(uint32_t src1, int32_t src2) { VIS32 s; VIS64 d; - uint32_t tmp; s.l = src1; d.ll = 0; -#define PMUL(r) \ - tmp = src2 * (int32_t)s.VIS_B64(r); \ - if ((tmp & 0xff) > 0x7f) { \ - tmp += 0x100; \ - } \ - d.VIS_W64(r) = tmp >> 8; - - PMUL(0); - PMUL(1); - PMUL(2); - PMUL(3); -#undef PMUL + d.VIS_W64(0) = do_ms16b(s.VIS_B32(0), src2); + d.VIS_W64(1) = do_ms16b(s.VIS_B32(1), src2); + d.VIS_W64(2) = do_ms16b(s.VIS_B32(2), src2); + d.VIS_W64(3) = do_ms16b(s.VIS_B32(3), src2); return d.ll; } @@ -148,23 +138,14 @@ uint64_t helper_fmul8x16a(uint32_t src1, int32_t src2) uint64_t helper_fmul8sux16(uint64_t src1, uint64_t src2) { VIS64 s, d; - uint32_t tmp; s.ll = src1; d.ll = src2; -#define PMUL(r) \ - tmp = (int32_t)d.VIS_SW64(r) * ((int32_t)s.VIS_SW64(r) >> 8); \ - if ((tmp & 0xff) > 0x7f) { \ - tmp += 0x100; \ - } \ - d.VIS_W64(r) = tmp >> 8; - - PMUL(0); - PMUL(1); - PMUL(2); - PMUL(3); -#undef PMUL + d.VIS_W64(0) = do_ms16b(s.VIS_SB64(1), d.VIS_SW64(0)); + d.VIS_W64(1) = do_ms16b(s.VIS_SB64(3), d.VIS_SW64(1)); + d.VIS_W64(2) = do_ms16b(s.VIS_SB64(5), d.VIS_SW64(2)); + d.VIS_W64(3) = do_ms16b(s.VIS_SB64(7), d.VIS_SW64(3)); return d.ll; } @@ -172,23 +153,14 @@ uint64_t helper_fmul8sux16(uint64_t src1, uint64_t src2) uint64_t helper_fmul8ulx16(uint64_t src1, uint64_t src2) { VIS64 s, d; - uint32_t tmp; s.ll = src1; d.ll = src2; -#define PMUL(r) \ - tmp = (int32_t)d.VIS_SW64(r) * ((uint32_t)s.VIS_B64(r * 2)); \ - if ((tmp & 0xff) > 0x7f) { \ - tmp += 0x100; \ - } \ - d.VIS_W64(r) = tmp >> 8; - - PMUL(0); - PMUL(1); - PMUL(2); - PMUL(3); -#undef PMUL + d.VIS_W64(0) = do_ms16b(s.VIS_B64(0), d.VIS_SW64(0)); + d.VIS_W64(1) = do_ms16b(s.VIS_B64(2), d.VIS_SW64(1)); + d.VIS_W64(2) = do_ms16b(s.VIS_B64(4), d.VIS_SW64(2)); + d.VIS_W64(3) = do_ms16b(s.VIS_B64(6), d.VIS_SW64(3)); return d.ll; }