From patchwork Tue Jul 4 08:08:06 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: 115605 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp1053077vqx; Tue, 4 Jul 2023 01:09:13 -0700 (PDT) X-Google-Smtp-Source: APBJJlGZcmfBlrS1X2VM3gweuQGap1CNIP5XnDIvAk69NWhJa2jJlZbkdzlFJr9+Z1EF9HRAVJIG X-Received: by 2002:aa7:d98f:0:b0:51d:e59c:6190 with SMTP id u15-20020aa7d98f000000b0051de59c6190mr9679315eds.2.1688458153236; Tue, 04 Jul 2023 01:09:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688458153; cv=none; d=google.com; s=arc-20160816; b=noDOcg6QmESAXGGrOEpJHR4uWVoKgZqIkUAb0V5yolh0obugveK9LGQsomaL3YJpye 62AF1G75LNwjhtSRZwWpWxnqBKLNLfo96lhHnnaEulN7tUowpKOhX0FrfR1hkX1s3mxJ geZQjEiIXE10VMSMF9sdI+GX0cn8WQgqtEm/pliLTv+0i48ZejwQm7NmpR2oip5QmVg7 DudC8aTh5bzpEy9xm7dUBFRV+GBr/WX6AVM6sDlKr+rMSDcFiPd+H6s3+dlw2u3zMfhC x8MCsci4NmN/Sg1k1Gd98gOPVRJoythVrpisTqvMiSYV8QEI/EJ2KTYK/ZlcQj4GGx2m mhwA== 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=i0jWEYSrOBWxJsmid+0CTo7ZR9PjSL44leIghmk9q1o=; fh=pkXPG0zZoOjKbXQnATK84Jhfe9+m7e3mrEEB76hUHx4=; b=fd804sm7ywpQPIqqbfFE6GnjwHdPIUqBb6E9Kry9GP16fSQHhm61klkzGPOoYlk+en L48JicqEOdn3eg/QltgoLSsXFXGOjYVts2zkkujjklGfwwGEpqPJhVXwM4mR5eGAEqBU Rj/GY0rV6ZIFbKSP5sdGB2X5MqbLKcgPQy0Kr46AnROo52CjCaoQVPDgz61jiRUq30AE qbOw0ExTebOAYJDAPuP5iHnvMq5eUGrP7oTqwz9RbQMTCyk3FtIGT3JArScCH8tPqVSJ VsbjgNxbgLYj4T6ox+iwASW/cY7SdOJ69+yQFoAaK2ZqVppZDfrnbUgns+Kq0UR4x8zY GJeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=KwNE5hSf; 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 b10-20020a056402138a00b00518c6e070f8si11847896edv.663.2023.07.04.01.09.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jul 2023 01:09:13 -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=KwNE5hSf; 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 E5D003857733 for ; Tue, 4 Jul 2023 08:08:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E5D003857733 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688458136; bh=i0jWEYSrOBWxJsmid+0CTo7ZR9PjSL44leIghmk9q1o=; 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=KwNE5hSfgF3HmGBQlOTQ/4RYhohnxO9mWjoX9fAnX92JtD/aN2AWrAD4jIMXPVJGu gaHQsmgInkuLjtPmowlUg+OgoyhSl34CZ15eusU9GbO737C1kUdG7PQXI3g+7YhKI2 ktFc5IzF9XL2EQoY6irxQ0BYgoX36jOFzs2JA8W4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by sourceware.org (Postfix) with ESMTPS id 274F0385841D for ; Tue, 4 Jul 2023 08:08:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 274F0385841D X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="366546982" X-IronPort-AV: E=Sophos;i="6.01,180,1684825200"; d="scan'208";a="366546982" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jul 2023 01:08:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="965433030" X-IronPort-AV: E=Sophos;i="6.01,180,1684825200"; d="scan'208";a="965433030" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by fmsmga006.fm.intel.com with ESMTP; 04 Jul 2023 01:08:08 -0700 Received: from pli-ubuntu.sh.intel.com (pli-ubuntu.sh.intel.com [10.239.159.47]) by shvmail03.sh.intel.com (Postfix) with ESMTP id 64FF91005129; Tue, 4 Jul 2023 16:08:07 +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 v2] RISC-V: Fix one bug for floating-point static frm Date: Tue, 4 Jul 2023 16:08:06 +0800 Message-Id: <20230704080806.2677374-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_NONE, 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?1770476696563610027?= 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. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/float-point-frm-insert-6.c: New test. Signed-off-by: Pan Li --- gcc/config/riscv/riscv.cc | 8 ++--- .../riscv/rvv/base/float-point-frm-insert-6.c | 31 +++++++++++++++++++ 2 files changed, 35 insertions(+), 4 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..37f96f8a238 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,7 @@ 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; + return code >= 0 ? get_attr_frm_mode (insn) : FRM_MODE_DYN; default: gcc_unreachable (); } @@ -7774,7 +7774,7 @@ riscv_mode_entry (int entity) case RISCV_VXRM: return VXRM_MODE_NONE; case RISCV_FRM: - return FRM_MODE_NONE; + return FRM_MODE_DYN; default: gcc_unreachable (); } @@ -7791,7 +7791,7 @@ riscv_mode_exit (int entity) case RISCV_VXRM: return VXRM_MODE_NONE; case RISCV_FRM: - return FRM_MODE_NONE; + 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]+} } } */