From patchwork Tue Sep 27 06:48:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gaosong X-Patchwork-Id: 12989959 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 07CFCC54EE9 for ; Tue, 27 Sep 2022 07:19:59 +0000 (UTC) Received: from localhost ([::1]:58614 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od4sn-00010T-Ke for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 03:19:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od4Oh-0002za-7R for qemu-devel@nongnu.org; Tue, 27 Sep 2022 02:48:54 -0400 Received: from mail.loongson.cn ([114.242.206.163]:47476 helo=loongson.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od4OY-0003pq-HU for qemu-devel@nongnu.org; Tue, 27 Sep 2022 02:48:45 -0400 Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxPGvGnDJj8aEiAA--.2457S3; Tue, 27 Sep 2022 14:48:38 +0800 (CST) From: Song Gao To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, yangxiaojuan@loongson.cn, huqi@loongson.cn, peter.maydell@linaro.org, alex.bennee@linaro.org, maobibo@loongson.cn Subject: [PATCH v2 1/4] target/loongarch: ftint_xxx insns set the result high 32bit 0xffffffff Date: Tue, 27 Sep 2022 14:48:35 +0800 Message-Id: <20220927064838.3570928-2-gaosong@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220927064838.3570928-1-gaosong@loongson.cn> References: <20220927064838.3570928-1-gaosong@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8DxPGvGnDJj8aEiAA--.2457S3 X-Coremail-Antispam: 1UD129KBjvJXoWxAF4xCFy8uFWfZw15Wr4kWFg_yoWruFy3p3 4rGrW3KrWvqFZ5Za4xJ398GF15Xw4UGa4xtr4DWa4SvFsFyws8urW7t3y7ZrWDWFWrZr45 Ja4jyFy3G3Z0qFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnUUvcSsGvfC2KfnxnUUI43ZEXa7xR_UUUUUUUUU== X-CM-SenderInfo: 5jdr20tqj6z05rqj20fqof0/ Received-SPF: pass client-ip=114.242.206.163; envelope-from=gaosong@loongson.cn; helo=loongson.cn 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_PASS=-0.001, SPF_PASS=-0.001 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" we just set high 32bit 0xffffffff as the other float instructions do. Signed-off-by: Song Gao --- target/loongarch/fpu_helper.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/target/loongarch/fpu_helper.c b/target/loongarch/fpu_helper.c index 4b9637210a..1a24667eaf 100644 --- a/target/loongarch/fpu_helper.c +++ b/target/loongarch/fpu_helper.c @@ -518,7 +518,7 @@ uint64_t helper_frint_s(CPULoongArchState *env, uint64_t fj) { uint64_t fd; - fd = (uint64_t)(float32_round_to_int((uint32_t)fj, &env->fp_status)); + fd = nanbox_s(float32_round_to_int((uint32_t)fj, &env->fp_status)); update_fcsr0(env, GETPC()); return fd; } @@ -574,7 +574,7 @@ uint64_t helper_ftintrm_w_d(CPULoongArchState *env, uint64_t fj) FloatRoundMode old_mode = get_float_rounding_mode(&env->fp_status); set_float_rounding_mode(float_round_down, &env->fp_status); - fd = (uint64_t)float64_to_int32(fj, &env->fp_status); + fd = nanbox_s(float64_to_int32(fj, &env->fp_status)); set_float_rounding_mode(old_mode, &env->fp_status); if (get_float_exception_flags(&env->fp_status) & (float_flag_invalid)) { @@ -592,7 +592,7 @@ uint64_t helper_ftintrm_w_s(CPULoongArchState *env, uint64_t fj) FloatRoundMode old_mode = get_float_rounding_mode(&env->fp_status); set_float_rounding_mode(float_round_down, &env->fp_status); - fd = (uint64_t)float32_to_int32((uint32_t)fj, &env->fp_status); + fd = nanbox_s(float32_to_int32((uint32_t)fj, &env->fp_status)); set_float_rounding_mode(old_mode, &env->fp_status); if (get_float_exception_flags(&env->fp_status) & (float_flag_invalid)) { @@ -646,7 +646,7 @@ uint64_t helper_ftintrp_w_d(CPULoongArchState *env, uint64_t fj) FloatRoundMode old_mode = get_float_rounding_mode(&env->fp_status); set_float_rounding_mode(float_round_up, &env->fp_status); - fd = (uint64_t)float64_to_int32(fj, &env->fp_status); + fd = nanbox_s(float64_to_int32(fj, &env->fp_status)); set_float_rounding_mode(old_mode, &env->fp_status); if (get_float_exception_flags(&env->fp_status) & (float_flag_invalid)) { @@ -664,7 +664,7 @@ uint64_t helper_ftintrp_w_s(CPULoongArchState *env, uint64_t fj) FloatRoundMode old_mode = get_float_rounding_mode(&env->fp_status); set_float_rounding_mode(float_round_up, &env->fp_status); - fd = (uint64_t)float32_to_int32((uint32_t)fj, &env->fp_status); + fd = nanbox_s(float32_to_int32((uint32_t)fj, &env->fp_status)); set_float_rounding_mode(old_mode, &env->fp_status); if (get_float_exception_flags(&env->fp_status) & (float_flag_invalid)) { @@ -715,7 +715,7 @@ uint64_t helper_ftintrz_w_d(CPULoongArchState *env, uint64_t fj) uint64_t fd; FloatRoundMode old_mode = get_float_rounding_mode(&env->fp_status); - fd = (uint64_t)float64_to_int32_round_to_zero(fj, &env->fp_status); + fd = nanbox_s(float64_to_int32_round_to_zero(fj, &env->fp_status)); set_float_rounding_mode(old_mode, &env->fp_status); if (get_float_exception_flags(&env->fp_status) & (float_flag_invalid)) { @@ -786,7 +786,7 @@ uint64_t helper_ftintrne_w_d(CPULoongArchState *env, uint64_t fj) FloatRoundMode old_mode = get_float_rounding_mode(&env->fp_status); set_float_rounding_mode(float_round_nearest_even, &env->fp_status); - fd = (uint64_t)float64_to_int32(fj, &env->fp_status); + fd = nanbox_s(float64_to_int32(fj, &env->fp_status)); set_float_rounding_mode(old_mode, &env->fp_status); if (get_float_exception_flags(&env->fp_status) & (float_flag_invalid)) { @@ -848,7 +848,7 @@ uint64_t helper_ftint_w_s(CPULoongArchState *env, uint64_t fj) { uint64_t fd; - fd = (uint64_t)float32_to_int32((uint32_t)fj, &env->fp_status); + fd = nanbox_s(float32_to_int32((uint32_t)fj, &env->fp_status)); if (get_float_exception_flags(&env->fp_status) & (float_flag_invalid)) { if (float32_is_any_nan((uint32_t)fj)) { fd = 0; @@ -862,7 +862,7 @@ uint64_t helper_ftint_w_d(CPULoongArchState *env, uint64_t fj) { uint64_t fd; - fd = (uint64_t)float64_to_int32(fj, &env->fp_status); + fd = nanbox_s(float64_to_int32(fj, &env->fp_status)); if (get_float_exception_flags(&env->fp_status) & (float_flag_invalid)) { if (float64_is_any_nan(fj)) { fd = 0; From patchwork Tue Sep 27 06:48:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gaosong X-Patchwork-Id: 12990020 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 665D3C07E9D for ; Tue, 27 Sep 2022 07:57:52 +0000 (UTC) Received: from localhost ([::1]:54826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od5TT-00067a-Ia for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 03:57:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49306) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od4Oh-0002zb-7o for qemu-devel@nongnu.org; Tue, 27 Sep 2022 02:48:54 -0400 Received: from mail.loongson.cn ([114.242.206.163]:47472 helo=loongson.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od4OY-0003pr-HW for qemu-devel@nongnu.org; Tue, 27 Sep 2022 02:48:46 -0400 Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxPGvGnDJj8aEiAA--.2457S4; Tue, 27 Sep 2022 14:48:38 +0800 (CST) From: Song Gao To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, yangxiaojuan@loongson.cn, huqi@loongson.cn, peter.maydell@linaro.org, alex.bennee@linaro.org, maobibo@loongson.cn Subject: [PATCH v2 2/4] target/loongarch: bstrins.w need set dest register EXT_SIGN Date: Tue, 27 Sep 2022 14:48:36 +0800 Message-Id: <20220927064838.3570928-3-gaosong@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220927064838.3570928-1-gaosong@loongson.cn> References: <20220927064838.3570928-1-gaosong@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8DxPGvGnDJj8aEiAA--.2457S4 X-Coremail-Antispam: 1UD129KBjvJXoW7CrW8AF1Utr48XrWrtr45Awb_yoW8Xry3pF yUCr1UKr4UXr93Zr97Za1DXFnrJFs5Kw47WF4I9345Ca90qry0gr4Ig39Igryrtwn7XrWv yan5u3yjgw4UJ37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnUUvcSsGvfC2KfnxnUUI43ZEXa7xR_UUUUUUUUU== X-CM-SenderInfo: 5jdr20tqj6z05rqj20fqof0/ Received-SPF: pass client-ip=114.242.206.163; envelope-from=gaosong@loongson.cn; helo=loongson.cn 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_PASS=-0.001, SPF_PASS=-0.001 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Song Gao --- target/loongarch/insn_trans/trans_bit.c.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/loongarch/insn_trans/trans_bit.c.inc b/target/loongarch/insn_trans/trans_bit.c.inc index 9337714ec4..33e94878fd 100644 --- a/target/loongarch/insn_trans/trans_bit.c.inc +++ b/target/loongarch/insn_trans/trans_bit.c.inc @@ -37,7 +37,7 @@ static bool gen_rr_ms_ls(DisasContext *ctx, arg_rr_ms_ls *a, DisasExtend src_ext, DisasExtend dst_ext, void (*func)(TCGv, TCGv, unsigned int, unsigned int)) { - TCGv dest = gpr_dst(ctx, a->rd, dst_ext); + TCGv dest = gpr_dst(ctx, a->rd, EXT_NONE); TCGv src1 = gpr_src(ctx, a->rj, src_ext); if (a->ls > a->ms) { @@ -206,7 +206,7 @@ TRANS(maskeqz, gen_rrr, EXT_NONE, EXT_NONE, EXT_NONE, gen_maskeqz) TRANS(masknez, gen_rrr, EXT_NONE, EXT_NONE, EXT_NONE, gen_masknez) TRANS(bytepick_w, gen_rrr_sa, EXT_NONE, EXT_NONE, gen_bytepick_w) TRANS(bytepick_d, gen_rrr_sa, EXT_NONE, EXT_NONE, gen_bytepick_d) -TRANS(bstrins_w, gen_rr_ms_ls, EXT_NONE, EXT_NONE, gen_bstrins) +TRANS(bstrins_w, gen_rr_ms_ls, EXT_NONE, EXT_SIGN, gen_bstrins) TRANS(bstrins_d, gen_rr_ms_ls, EXT_NONE, EXT_NONE, gen_bstrins) TRANS(bstrpick_w, gen_rr_ms_ls, EXT_NONE, EXT_SIGN, tcg_gen_extract_tl) TRANS(bstrpick_d, gen_rr_ms_ls, EXT_NONE, EXT_NONE, tcg_gen_extract_tl) From patchwork Tue Sep 27 06:48:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gaosong X-Patchwork-Id: 12989978 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CB21CC6FA86 for ; Tue, 27 Sep 2022 07:44:15 +0000 (UTC) Received: from localhost ([::1]:58940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od5GI-0007DP-TP for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 03:44:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49302) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od4Oh-0002zZ-6U for qemu-devel@nongnu.org; Tue, 27 Sep 2022 02:48:54 -0400 Received: from mail.loongson.cn ([114.242.206.163]:47478 helo=loongson.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od4OY-0003pt-Gz for qemu-devel@nongnu.org; Tue, 27 Sep 2022 02:48:46 -0400 Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxPGvGnDJj8aEiAA--.2457S5; Tue, 27 Sep 2022 14:48:39 +0800 (CST) From: Song Gao To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, yangxiaojuan@loongson.cn, huqi@loongson.cn, peter.maydell@linaro.org, alex.bennee@linaro.org, maobibo@loongson.cn Subject: [PATCH v2 3/4] target/loongarch: Fix fnm{sub/add}_{s/d} set wrong flags Date: Tue, 27 Sep 2022 14:48:37 +0800 Message-Id: <20220927064838.3570928-4-gaosong@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220927064838.3570928-1-gaosong@loongson.cn> References: <20220927064838.3570928-1-gaosong@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8DxPGvGnDJj8aEiAA--.2457S5 X-Coremail-Antispam: 1UD129KBjvJXoW7uryrKrykCFyrAFyxCFy8Zrb_yoW8WrWfpr 17urnrKr4UJay8ZwnFqasFy3s7Xr4qvw10q3Z7tFyYyr4Yqa9F9ayrKayq9FWrZw10grW8 Aa1qk342kws8WFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnUUvcSsGvfC2KfnxnUUI43ZEXa7xR_UUUUUUUUU== X-CM-SenderInfo: 5jdr20tqj6z05rqj20fqof0/ Received-SPF: pass client-ip=114.242.206.163; envelope-from=gaosong@loongson.cn; helo=loongson.cn 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_PASS=-0.001, SPF_PASS=-0.001 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Song Gao Reviewed-by: Richard Henderson --- target/loongarch/insn_trans/trans_farith.c.inc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/target/loongarch/insn_trans/trans_farith.c.inc b/target/loongarch/insn_trans/trans_farith.c.inc index 65ad2ffab8..7bb3f41aee 100644 --- a/target/loongarch/insn_trans/trans_farith.c.inc +++ b/target/loongarch/insn_trans/trans_farith.c.inc @@ -97,9 +97,9 @@ TRANS(fmadd_s, gen_muladd, gen_helper_fmuladd_s, 0) TRANS(fmadd_d, gen_muladd, gen_helper_fmuladd_d, 0) TRANS(fmsub_s, gen_muladd, gen_helper_fmuladd_s, float_muladd_negate_c) TRANS(fmsub_d, gen_muladd, gen_helper_fmuladd_d, float_muladd_negate_c) -TRANS(fnmadd_s, gen_muladd, gen_helper_fmuladd_s, - float_muladd_negate_product | float_muladd_negate_c) -TRANS(fnmadd_d, gen_muladd, gen_helper_fmuladd_d, - float_muladd_negate_product | float_muladd_negate_c) -TRANS(fnmsub_s, gen_muladd, gen_helper_fmuladd_s, float_muladd_negate_product) -TRANS(fnmsub_d, gen_muladd, gen_helper_fmuladd_d, float_muladd_negate_product) +TRANS(fnmadd_s, gen_muladd, gen_helper_fmuladd_s, float_muladd_negate_result) +TRANS(fnmadd_d, gen_muladd, gen_helper_fmuladd_d, float_muladd_negate_result) +TRANS(fnmsub_s, gen_muladd, gen_helper_fmuladd_s, + float_muladd_negate_c | float_muladd_negate_result) +TRANS(fnmsub_d, gen_muladd, gen_helper_fmuladd_d, + float_muladd_negate_c | float_muladd_negate_result) From patchwork Tue Sep 27 06:48:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gaosong X-Patchwork-Id: 12989985 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 02807C07E9D for ; Tue, 27 Sep 2022 07:54:54 +0000 (UTC) Received: from localhost ([::1]:59112 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od5Qb-0001qI-V2 for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 03:54:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49308) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od4Oh-0002zc-7u for qemu-devel@nongnu.org; Tue, 27 Sep 2022 02:48:54 -0400 Received: from mail.loongson.cn ([114.242.206.163]:47482 helo=loongson.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od4Oa-0003q6-By for qemu-devel@nongnu.org; Tue, 27 Sep 2022 02:48:48 -0400 Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxPGvGnDJj8aEiAA--.2457S6; Tue, 27 Sep 2022 14:48:39 +0800 (CST) From: Song Gao To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, yangxiaojuan@loongson.cn, huqi@loongson.cn, peter.maydell@linaro.org, alex.bennee@linaro.org, maobibo@loongson.cn Subject: [PATCH v2 4/4] target/loongarch: flogb_{s/d} add set float_flag_divbyzero Date: Tue, 27 Sep 2022 14:48:38 +0800 Message-Id: <20220927064838.3570928-5-gaosong@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220927064838.3570928-1-gaosong@loongson.cn> References: <20220927064838.3570928-1-gaosong@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8DxPGvGnDJj8aEiAA--.2457S6 X-Coremail-Antispam: 1UD129KBjvJXoW7Cw4fuFykCr1kKrWxAF45GFg_yoW8WrW5pr WfuFW3trW8XFZ7Za93A39Yqr45X3y8GrWIvrnav3y5tr4UXr4DCr4fKasFgFy5XryUGr1Y qFsYyrW7GF45X37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnUUvcSsGvfC2KfnxnUUI43ZEXa7xR_UUUUUUUUU== X-CM-SenderInfo: 5jdr20tqj6z05rqj20fqof0/ Received-SPF: pass client-ip=114.242.206.163; envelope-from=gaosong@loongson.cn; helo=loongson.cn 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_PASS=-0.001, SPF_PASS=-0.001 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" if fj ==0 or fj == INT32_MIN/INT64_MIN, LoongArch host set fcsr cause exception FP_DIV0, So we need set exception flags float_flagdivbyzero if fj ==0. Signed-off-by: Song Gao --- target/loongarch/fpu_helper.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/target/loongarch/fpu_helper.c b/target/loongarch/fpu_helper.c index 1a24667eaf..d40e608bb4 100644 --- a/target/loongarch/fpu_helper.c +++ b/target/loongarch/fpu_helper.c @@ -322,6 +322,13 @@ uint64_t helper_flogb_s(CPULoongArchState *env, uint64_t fj) fp = float32_log2((uint32_t)fj, status); fd = nanbox_s(float32_round_to_int(fp, status)); set_float_rounding_mode(old_mode, status); + /* + * LoongArch host if fj == 0 or INT32_MIN , set the fcsr cause FP_DIV0 + * so we need set exception flags float_flag_divbyzero. + */ + if (((uint32_t)fj == 0) | ((uint32_t)fj == INT32_MIN)) { + set_float_exception_flags(float_flag_divbyzero, status); + } update_fcsr0_mask(env, GETPC(), float_flag_inexact); return fd; } @@ -336,6 +343,13 @@ uint64_t helper_flogb_d(CPULoongArchState *env, uint64_t fj) fd = float64_log2(fj, status); fd = float64_round_to_int(fd, status); set_float_rounding_mode(old_mode, status); + /* + * LoongArch host if fj == 0 or INT64_MIN , set the fcsr cause FP_DIV0 + * so we need set exception flags float_flag_divbyzero. + */ + if ((fj == 0) | (fj == INT64_MIN)) { + set_float_exception_flags(float_flag_divbyzero, status); + } update_fcsr0_mask(env, GETPC(), float_flag_inexact); return fd; }