From nobody Wed Nov 19 00:14:00 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1613142727; cv=none; d=zohomail.com; s=zohoarc; b=SLx9xFYp3pWD4614bR6G2VNAdpUsogbk3gMSOb5RsofVIy1If1SNrmESQg/TXch0IXejO2uPYubkp2iEwh6tNoEwhILJ6jmfv8jP/IKr0UWMJxhJDKsUe7fC7ehad7QK0Y+eg8yrzXdxleGEtCwuYSC41JURXbClhQJh/o1pV+E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613142727; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=YaKfLRDAWHHwsThJulX4LZwLYJHt+odsUZNiJh7zyzo=; b=jdRtdQSnwr68Jq3q517uyzHIZjgotg/sW06p4Wc4u2qlh5Reefoex96NV2Tgd+X9j5RMu/ubUdqWdtG9wVnupOvF1jZZO2GjHdLK65qldTGjoDFlanJdDyCijk61gwHFQYXeYv0/r39dtr88ayXQyiO+Cb3xF6fC1CzXzd3buzU= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.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 1613142726824287.6739379882132; Fri, 12 Feb 2021 07:12:06 -0800 (PST) Received: from localhost ([::1]:41672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lAa73-0003jg-LN for importer@patchew.org; Fri, 12 Feb 2021 10:12:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42990) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lAa5x-0002gz-3q; Fri, 12 Feb 2021 10:10:57 -0500 Received: from smtp2200-217.mail.aliyun.com ([121.197.200.217]:50699) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lAa5t-00078D-S9; Fri, 12 Feb 2021 10:10:56 -0500 Received: from localhost.localdomain(mailfrom:zhiwei_liu@c-sky.com fp:SMTPD_---.JYH-.kU_1613142640) by smtp.aliyun-inc.com(10.147.40.2); Fri, 12 Feb 2021 23:10:41 +0800 X-Alimail-AntiSpam: AC=CONTINUE; BC=0.1636807|-1; CH=green; DM=|CONTINUE|false|; DS=CONTINUE|ham_system_inform|0.0202074-0.000563671-0.979229; FP=0|0|0|0|0|-1|-1|-1; HT=ay29a033018047207; MF=zhiwei_liu@c-sky.com; NM=1; PH=DS; RN=6; RT=6; SR=0; TI=SMTPD_---.JYH-.kU_1613142640; From: LIU Zhiwei To: qemu-devel@nongnu.org Subject: [PATCH 03/38] target/riscv: Fixup saturate subtract function Date: Fri, 12 Feb 2021 23:02:21 +0800 Message-Id: <20210212150256.885-4-zhiwei_liu@c-sky.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210212150256.885-1-zhiwei_liu@c-sky.com> References: <20210212150256.885-1-zhiwei_liu@c-sky.com> Received-SPF: pass (zohomail.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; Received-SPF: none client-ip=121.197.200.217; envelope-from=zhiwei_liu@c-sky.com; helo=smtp2200-217.mail.aliyun.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_NONE=0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: richard.henderson@linaro.org, LIU Zhiwei , qemu-riscv@nongnu.org, palmer@dabbelt.com, alistair23@gmail.com 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" The overflow predication ((a - b) ^ a) & (a ^ b) & INT64_MIN is right. However, when the predication is ture and a is 0, it should return maximum. Signed-off-by: LIU Zhiwei Reviewed-by: Alistair Francis Reviewed-by: Richard Henderson --- target/riscv/vector_helper.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c index 9371d70f6b..9786f630b4 100644 --- a/target/riscv/vector_helper.c +++ b/target/riscv/vector_helper.c @@ -2425,7 +2425,7 @@ int8_t ssub8(CPURISCVState *env, int vxrm, int8_t a, = int8_t b) { int8_t res =3D a - b; if ((res ^ a) & (a ^ b) & INT8_MIN) { - res =3D a > 0 ? INT8_MAX : INT8_MIN; + res =3D a >=3D 0 ? INT8_MAX : INT8_MIN; env->vxsat =3D 0x1; } return res; @@ -2435,7 +2435,7 @@ int16_t ssub16(CPURISCVState *env, int vxrm, int16_t = a, int16_t b) { int16_t res =3D a - b; if ((res ^ a) & (a ^ b) & INT16_MIN) { - res =3D a > 0 ? INT16_MAX : INT16_MIN; + res =3D a >=3D 0 ? INT16_MAX : INT16_MIN; env->vxsat =3D 0x1; } return res; @@ -2445,7 +2445,7 @@ int32_t ssub32(CPURISCVState *env, int vxrm, int32_t = a, int32_t b) { int32_t res =3D a - b; if ((res ^ a) & (a ^ b) & INT32_MIN) { - res =3D a > 0 ? INT32_MAX : INT32_MIN; + res =3D a >=3D 0 ? INT32_MAX : INT32_MIN; env->vxsat =3D 0x1; } return res; @@ -2455,7 +2455,7 @@ int64_t ssub64(CPURISCVState *env, int vxrm, int64_t = a, int64_t b) { int64_t res =3D a - b; if ((res ^ a) & (a ^ b) & INT64_MIN) { - res =3D a > 0 ? INT64_MAX : INT64_MIN; + res =3D a >=3D 0 ? INT64_MAX : INT64_MIN; env->vxsat =3D 0x1; } return res; --=20 2.17.1