From patchwork Wed Jul 5 07:02:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 115966 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp1679972vqx; Wed, 5 Jul 2023 00:03:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlFSPttuUT72iEQR3wgRFjV0XOUNgWZdYGAE/6rSeGEX+RawhqKUy2ROtLXmwMkM/jttfiao X-Received: by 2002:a2e:9947:0:b0:2b6:effd:9a3b with SMTP id r7-20020a2e9947000000b002b6effd9a3bmr4376549ljj.24.1688540600234; Wed, 05 Jul 2023 00:03:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688540600; cv=none; d=google.com; s=arc-20160816; b=AdqQGtzr3Mti95Iy8h33ImPYndjIhGgXrbD9C1TPPE4NnyI2n32Zwaaz4qZS2UB2Yr BDzdGF8WKUN/VwgqSQkup7TlGsCMtuzwjHmnwO9ZNclTqcaV/DU3mQjiD2Q85PO0Uped 8m+z4hl5D3MmHU08Ug7luALJu8Z/lwOni6BQbDROwUiWHv/y2uwwPnzKDj3aJI04Z9JP rDACCGvei9Dtl+LaswNDRaI84qrNpRTXEaybSEq8GllkFnoNXlPB8eZp4EE7D9acvInx AaLIqyJyeYNByuEbQVIS2l/3xaxZ4sn3veEAycdXy57/n+WNAPD9txL5YEgHTMzyj3aW g26A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from: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:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=ILVpSA0pgaPvcHnmZ8I4laigu0fEw3LbVItG90OLuic=; fh=pkXPG0zZoOjKbXQnATK84Jhfe9+m7e3mrEEB76hUHx4=; b=eGE/NocXf6i5xiwswlaaZgOyOH/JcPSYDx5PFRHmsIC/VXWyu8P6K5CXAuRSW6W1WZ 0CCO3ZKGxahk9CJkAePQ+SCGGSv58kDElxEPfYoTuZXQPdnp4d2NeZXNmGn5njnJo0N6 w1jE5xsz1/1j3qpoMgWYOiuyRDH1z8BENFQdDSDCnP2dAvM/ByzwKIQSQUiJni6sy/2H hufzeTl3N5FuYzRkTVcH9WJ6oDF/t2c50g1Fn+qVAGlpzIm3sBTwWxzhNxoA51Nwr7Hj TOkmpioX6Rs7keQOz1IZMnF13UX+iZXPA0a61PAQnT/z3AZ1ghyCIhWscDJbzkcz3klt A4zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Z2VYKvVH; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id gg18-20020a170906e29200b00988e963c3adsi15885895ejb.755.2023.07.05.00.03.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 00:03:20 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Z2VYKvVH; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 265E7385771F for ; Wed, 5 Jul 2023 07:03:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 265E7385771F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688540599; bh=ILVpSA0pgaPvcHnmZ8I4laigu0fEw3LbVItG90OLuic=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Z2VYKvVHQPrXVtWYqWAWsONiOveVBPrEx3Vu72rLTBzDSBzw3FpXwUzoV44r+Ms/m qoWTgBg+lYKs2MaOD1QxzNccsWfJPp+IfxjWkKEfYmMXBxICduU4kfyQETMO69EDr4 vD42MhBEAneq1pxaAH8bv6dYCeqzeN9ngRHgmIQU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by sourceware.org (Postfix) with ESMTPS id B428F3858CD1 for ; Wed, 5 Jul 2023 07:02:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B428F3858CD1 X-IronPort-AV: E=McAfee;i="6600,9927,10761"; a="342858092" X-IronPort-AV: E=Sophos;i="6.01,182,1684825200"; d="scan'208";a="342858092" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jul 2023 00:02:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10761"; a="669298155" X-IronPort-AV: E=Sophos;i="6.01,182,1684825200"; d="scan'208";a="669298155" Received: from shvmail02.sh.intel.com ([10.239.244.9]) by orsmga003.jf.intel.com with ESMTP; 05 Jul 2023 00:02:31 -0700 Received: from pli-ubuntu.sh.intel.com (pli-ubuntu.sh.intel.com [10.239.159.47]) by shvmail02.sh.intel.com (Postfix) with ESMTP id 47D5D10119E6; Wed, 5 Jul 2023 15:02:30 +0800 (CST) To: gcc-patches@gcc.gnu.org Cc: juzhe.zhong@rivai.ai, rdapp.gcc@gmail.com, jeffreyalaw@gmail.com, pan2.li@intel.com, yanzhang.wang@intel.com, kito.cheng@gmail.com Subject: [PATCH v4] RISC-V: Fix one bug for floating-point static frm Date: Wed, 5 Jul 2023 15:02:23 +0800 Message-Id: <20230705070223.806580-1-pan2.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Pan Li via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: pan2.li@intel.com Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770468048104487685?= X-GMAIL-MSGID: =?utf-8?q?1770563148072804263?= From: Pan Li This patch would like to fix one bug to align below items of spec. 1. By default, the RVV floating-point will take dyn mode. 2. DYN is invalid in FRM register for RVV floating-point. When mode switching the function entry and exit, it will take DYN as the frm mode. Signed-off-by: Pan Li gcc/ChangeLog: * config/riscv/riscv.cc (riscv_emit_mode_set): Avoid emit insn when FRM_MODE_DYN. (riscv_mode_entry): Take FRM_MODE_DYN as entry mode. (riscv_mode_exit): Likewise for exit mode. (riscv_mode_needed): Likewise for needed mode. (riscv_mode_after): Likewise for after mode. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/float-point-frm-insert-6.c: New test. --- gcc/config/riscv/riscv.cc | 16 +++++++--- .../riscv/rvv/base/float-point-frm-insert-6.c | 31 +++++++++++++++++++ 2 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/float-point-frm-insert-6.c diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index e4dc8115e69..4db32de5696 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -7670,7 +7670,7 @@ riscv_emit_mode_set (int entity, int mode, int prev_mode, emit_insn (gen_vxrmsi (gen_int_mode (mode, SImode))); break; case RISCV_FRM: - if (mode != FRM_MODE_NONE && mode != prev_mode) + if (mode != FRM_MODE_DYN && mode != prev_mode) { rtx scaler = gen_reg_rtx (SImode); rtx imm = gen_int_mode (mode, SImode); @@ -7697,7 +7697,9 @@ riscv_mode_needed (int entity, rtx_insn *insn) case RISCV_VXRM: return code >= 0 ? get_attr_vxrm_mode (insn) : VXRM_MODE_NONE; case RISCV_FRM: - return code >= 0 ? get_attr_frm_mode (insn) : FRM_MODE_NONE; + /* According to RVV 1.0 spec, all vector floating-point operations use + the dynamic rounding mode in the frm register. */ + return code >= 0 ? get_attr_frm_mode (insn) : FRM_MODE_DYN; default: gcc_unreachable (); } @@ -7757,7 +7759,7 @@ riscv_mode_after (int entity, int mode, rtx_insn *insn) case RISCV_FRM: return riscv_entity_mode_after (FRM_REGNUM, insn, mode, (int (*)(rtx_insn *)) get_attr_frm_mode, - FRM_MODE_NONE); + FRM_MODE_DYN); default: gcc_unreachable (); } @@ -7774,7 +7776,9 @@ riscv_mode_entry (int entity) case RISCV_VXRM: return VXRM_MODE_NONE; case RISCV_FRM: - return FRM_MODE_NONE; + /* According to RVV 1.0 spec, all vector floating-point operations use + the dynamic rounding mode in the frm register. */ + return FRM_MODE_DYN; default: gcc_unreachable (); } @@ -7791,7 +7795,9 @@ riscv_mode_exit (int entity) case RISCV_VXRM: return VXRM_MODE_NONE; case RISCV_FRM: - return FRM_MODE_NONE; + /* According to RVV 1.0 spec, all vector floating-point operations use + the dynamic rounding mode in the frm register. */ + return FRM_MODE_DYN; default: gcc_unreachable (); } diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/float-point-frm-insert-6.c b/gcc/testsuite/gcc.target/riscv/rvv/base/float-point-frm-insert-6.c new file mode 100644 index 00000000000..6d896e0953e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/float-point-frm-insert-6.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64 -O3 -Wno-psabi" } */ + +#include "riscv_vector.h" + +typedef float float32_t; + +vfloat32m1_t +test_riscv_vfadd_vv_f32m1_rm (vfloat32m1_t op1, vfloat32m1_t op2, size_t vl) { + return __riscv_vfadd_vv_f32m1_rm (op1, op2, 7, vl); +} + +vfloat32m1_t +test_vfadd_vv_f32m1_m_rm(vbool32_t mask, vfloat32m1_t op1, vfloat32m1_t op2, + size_t vl) { + return __riscv_vfadd_vv_f32m1_m_rm(mask, op1, op2, 7, vl); +} + +vfloat32m1_t +test_vfadd_vf_f32m1_rm(vfloat32m1_t op1, float32_t op2, size_t vl) { + return __riscv_vfadd_vf_f32m1_rm(op1, op2, 7, vl); +} + +vfloat32m1_t +test_vfadd_vf_f32m1_m_rm(vbool32_t mask, vfloat32m1_t op1, float32_t op2, + size_t vl) { + return __riscv_vfadd_vf_f32m1_m_rm(mask, op1, op2, 7, vl); +} + +/* { dg-final { scan-assembler-times {vfadd\.v[vf]\s+v[0-9]+,\s*v[0-9]+,\s*[fav]+[0-9]+} 4 } } */ +/* { dg-final { scan-assembler-not {fsrm\s+[ax][0-9]+,\s*[ax][0-9]+} } } */