From nobody Sun May 5 20:04:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1554207296331461.2949785484992; Tue, 2 Apr 2019 05:14:56 -0700 (PDT) Received: from localhost ([127.0.0.1]:38751 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hBIJZ-0003CX-6n for importer@patchew.org; Tue, 02 Apr 2019 08:14:53 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50318) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hBIGm-0001qn-10 for qemu-devel@nongnu.org; Tue, 02 Apr 2019 08:12:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hBIGk-0007JB-NP for qemu-devel@nongnu.org; Tue, 02 Apr 2019 08:12:00 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:59639 helo=mail.rt-rk.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hBIGk-0007HD-Da for qemu-devel@nongnu.org; Tue, 02 Apr 2019 08:11:58 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 7B6591A2255; Tue, 2 Apr 2019 14:11:55 +0200 (CEST) Received: from rtrkw310-lin.domain.local (rtrkw310-lin.domain.local [10.10.13.97]) by mail.rt-rk.com (Postfix) with ESMTPSA id 605A51A21ED; Tue, 2 Apr 2019 14:11:55 +0200 (CEST) X-Virus-Scanned: amavisd-new at rt-rk.com From: Mateja Marjanovic To: qemu-devel@nongnu.org Date: Tue, 2 Apr 2019 14:11:49 +0200 Message-Id: <1554207110-9113-2-git-send-email-mateja.marjanovic@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554207110-9113-1-git-send-email-mateja.marjanovic@rt-rk.com> References: <1554207110-9113-1-git-send-email-mateja.marjanovic@rt-rk.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 89.216.37.149 Subject: [Qemu-devel] [PATCH v2 1/2] target/mips: Make the results of DIV_. the same as on hardware X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: arikalo@wavecomp.com, amarkovic@wavecomp.com, aurelien@aurel32.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Mateja Marjanovic MSA instructions DIV_. when dividing by zero, didn't return the same value when executed on a referent hardware (FPGA MIPS 64 r6, little endian) and when executed on QEMU, which is not a real bug, because the result when dividing by zero is UNPREDICTABLE [1] (page 141, 142). [1] MIPS Architecture for Programmers Volume IV-j: The MIPS64 SIMD Architecture Module, Revision 1.12 Signed-off-by: Mateja Marjanovic Reviewed-by: Aleksandar Markovic --- target/mips/msa_helper.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/target/mips/msa_helper.c b/target/mips/msa_helper.c index 655148d..8c77f12 100644 --- a/target/mips/msa_helper.c +++ b/target/mips/msa_helper.c @@ -641,14 +641,15 @@ static inline int64_t msa_div_s_df(uint32_t df, int64= _t arg1, int64_t arg2) if (arg1 =3D=3D DF_MIN_INT(df) && arg2 =3D=3D -1) { return DF_MIN_INT(df); } - return arg2 ? arg1 / arg2 : 0; + return arg2 ? arg1 / arg2 + : arg1 >=3D 0 ? -1 : 1; } =20 static inline int64_t msa_div_u_df(uint32_t df, int64_t arg1, int64_t arg2) { uint64_t u_arg1 =3D UNSIGNED(arg1, df); uint64_t u_arg2 =3D UNSIGNED(arg2, df); - return u_arg2 ? u_arg1 / u_arg2 : 0; + return arg2 ? u_arg1 / u_arg2 : -1; } =20 static inline int64_t msa_mod_s_df(uint32_t df, int64_t arg1, int64_t arg2) --=20 2.7.4 From nobody Sun May 5 20:04:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1554207474051697.5567865155914; Tue, 2 Apr 2019 05:17:54 -0700 (PDT) Received: from localhost ([127.0.0.1]:39372 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hBIMS-0005u6-Ob for importer@patchew.org; Tue, 02 Apr 2019 08:17:52 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50310) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hBIGl-0001ql-Km for qemu-devel@nongnu.org; Tue, 02 Apr 2019 08:12:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hBIGk-0007J6-N3 for qemu-devel@nongnu.org; Tue, 02 Apr 2019 08:11:59 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:59662 helo=mail.rt-rk.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hBIGk-0007HF-DI for qemu-devel@nongnu.org; Tue, 02 Apr 2019 08:11:58 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 86A7B1A21E9; Tue, 2 Apr 2019 14:11:55 +0200 (CEST) Received: from rtrkw310-lin.domain.local (rtrkw310-lin.domain.local [10.10.13.97]) by mail.rt-rk.com (Postfix) with ESMTPSA id 6887F1A21FF; Tue, 2 Apr 2019 14:11:55 +0200 (CEST) X-Virus-Scanned: amavisd-new at rt-rk.com From: Mateja Marjanovic To: qemu-devel@nongnu.org Date: Tue, 2 Apr 2019 14:11:50 +0200 Message-Id: <1554207110-9113-3-git-send-email-mateja.marjanovic@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554207110-9113-1-git-send-email-mateja.marjanovic@rt-rk.com> References: <1554207110-9113-1-git-send-email-mateja.marjanovic@rt-rk.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 89.216.37.149 Subject: [Qemu-devel] [PATCH v2 2/2] target/mips: Make the results of MOD_. the same as on hardware X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: arikalo@wavecomp.com, amarkovic@wavecomp.com, aurelien@aurel32.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Mateja Marjanovic MSA instructions MOD_. when dividing by zero, didn't return the same value when executed on a referent hardware (FPGA MIPS 64 r6, little endian) and when executed on QEMU, which is not a real bug, because the result when dividing by zero is UNPREDICTABLE [1] (page 255, 256). [1] MIPS Architecture for Programmers Volume IV-j: The MIPS64 SIMD Architecture Module, Revision 1.12 Signed-off-by: Mateja Marjanovic Reviewed-by: Aleksandar Markovic --- target/mips/msa_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/mips/msa_helper.c b/target/mips/msa_helper.c index 8c77f12..6693ba6 100644 --- a/target/mips/msa_helper.c +++ b/target/mips/msa_helper.c @@ -657,14 +657,14 @@ static inline int64_t msa_mod_s_df(uint32_t df, int64= _t arg1, int64_t arg2) if (arg1 =3D=3D DF_MIN_INT(df) && arg2 =3D=3D -1) { return 0; } - return arg2 ? arg1 % arg2 : 0; + return arg2 ? arg1 % arg2 : arg1; } =20 static inline int64_t msa_mod_u_df(uint32_t df, int64_t arg1, int64_t arg2) { uint64_t u_arg1 =3D UNSIGNED(arg1, df); uint64_t u_arg2 =3D UNSIGNED(arg2, df); - return u_arg2 ? u_arg1 % u_arg2 : 0; + return u_arg2 ? u_arg1 % u_arg2 : u_arg1; } =20 #define SIGNED_EVEN(a, df) \ --=20 2.7.4