From patchwork Wed Aug 16 07:32:27 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: 135732 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:3f2:4152:657d with SMTP id x8csp935384vqo; Wed, 16 Aug 2023 00:33:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEDYX4A0FJFYdq3Iunhuk2NUonCK/amqvaqXsO24hggWyQCAxspuZWExFTHcx0HFBn+AZSy X-Received: by 2002:a17:906:5307:b0:99c:281:9987 with SMTP id h7-20020a170906530700b0099c02819987mr690162ejo.36.1692171207859; Wed, 16 Aug 2023 00:33:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692171207; cv=none; d=google.com; s=arc-20160816; b=r1fgW9N3tm7QTthr8fyixc/zsufFCPAcl3PDRBgH9VrE/v2CkxiDJfNcFuI1UxETRx I4JZBVT8y+sV809GUKap23w3FhCyoWs1mJ4eFGHUVXW3MQDk1wdRi8rftTd95psfScn4 i/Yv9HZ2Nd82WRCvaJyWFmWG46lCHnkGFpc5Nl76/6vQMBmx3LcmB/LYE2Cxu3r6utHP ev+Pq8qoFqpFjxfkogyGTXV4R9e+ymiHvKgLYhhzPGHK4+oatrYUQvYrxFxLbbD76yVm +kNYD9RyoUG0LZMTJKttznUkvx+w/x8yDstbrMhdPbYu6/gLYPGhFHxV+PuUN4YQgdo6 NZMA== 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=OXvpigR9I4wMLxNfjl3BL6/EGrYlJNowQL3NxOcAa94=; fh=/JJEj+I5j40/Spkll6HT+Gte92Mjc5mpTnWowlKfaJ8=; b=pNFrgMemldxHOYbFeUmKQvnhDhpyayct0F+zETGyD1wlOiP5DmnQ6QkB01LQe9D0Iy GGcgvsPrZ0S8B8jXre17n9eD0Qm4rMy5gSaH3Et7f2buJuSjFYzwLR9hGqoJb5UkwSeD FQRKdFt/4ka9rGVDgQHczYmQs/8LCSg3s0JgJX1PgBGuBqIxK7pKh0ksx+ovgGWaNH8U SDQln1XgiK7oU4ZvAAOzJQnznn5ERBi4Fxc1qkTt3t01bS8XVQoX0qVqU0JrV0iRVQFP dhnKNEjXEG/+iilznqwEmG199LDE0Vcp5YK2xwWTyYhoygtbLm8kRd66RL8n5dSW7wKo PBSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=fX92rLj4; 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 qw24-20020a170906fcb800b00993a37b5e5csi10091890ejb.394.2023.08.16.00.33.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Aug 2023 00:33:27 -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=fX92rLj4; 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 A5C633858C52 for ; Wed, 16 Aug 2023 07:33:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A5C633858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692171206; bh=OXvpigR9I4wMLxNfjl3BL6/EGrYlJNowQL3NxOcAa94=; 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=fX92rLj4opsSxNNOSm+lDNZeUsxFHib0A/GJUwhVvM8PsKPulKRtd8D7JLVAGvM+j 4M/Omh0dwg9cdaeAYn1G57eV/IHlUiiSThiXJCFKCLcPbZ66RYqAAddhqLPPdBlkYy a/6eQvvyLBHCxCg6CmCGxvxe5ilxgg/AGOvtmNes= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by sourceware.org (Postfix) with ESMTPS id CF8B33858002 for ; Wed, 16 Aug 2023 07:32:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CF8B33858002 X-IronPort-AV: E=McAfee;i="6600,9927,10803"; a="369938794" X-IronPort-AV: E=Sophos;i="6.01,176,1684825200"; d="scan'208";a="369938794" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2023 00:32:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10803"; a="1064736084" X-IronPort-AV: E=Sophos;i="6.01,176,1684825200"; d="scan'208";a="1064736084" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by fmsmga005.fm.intel.com with ESMTP; 16 Aug 2023 00:32:29 -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 981BE100569E; Wed, 16 Aug 2023 15:32:28 +0800 (CST) To: gcc-patches@gcc.gnu.org Cc: juzhe.zhong@rivai.ai, kito.cheng@sifive.com, pan2.li@intel.com, yanzhang.wang@intel.com Subject: [PATCH v2] RISC-V: Support RVV VFWCVT.X.F.V rounding mode intrinsic API Date: Wed, 16 Aug 2023 15:32:27 +0800 Message-Id: <20230816073227.934463-1-pan2.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230815080147.1986255-1-pan2.li@intel.com> References: <20230815080147.1986255-1-pan2.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 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 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: INBOX X-GMAIL-THRID: 1774281388190876218 X-GMAIL-MSGID: 1774370116462666174 From: Pan Li This patch would like to support the rounding mode API for the VFWCVT.X.F.V as the below samples. * __riscv_vfwcvt_x_f_v_i64m2_rm * __riscv_vfwcvt_x_f_v_i64m2_rm_m Signed-off-by: Pan Li gcc/ChangeLog: * config/riscv/riscv-vector-builtins-bases.cc (BASE): New declaration. * config/riscv/riscv-vector-builtins-bases.h: Ditto. * config/riscv/riscv-vector-builtins-functions.def (vfwcvt_x_frm): New intrinsic function def. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/float-point-wcvt-x.c: New test. Signed-off-by: Pan Li > --- .../riscv/riscv-vector-builtins-bases.cc | 9 +++++- .../riscv/riscv-vector-builtins-bases.h | 1 + .../riscv/riscv-vector-builtins-functions.def | 2 ++ .../riscv/rvv/base/float-point-wcvt-x.c | 29 +++++++++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/float-point-wcvt-x.c diff --git a/gcc/config/riscv/riscv-vector-builtins-bases.cc b/gcc/config/riscv/riscv-vector-builtins-bases.cc index c78fa8e5b62..22640745398 100644 --- a/gcc/config/riscv/riscv-vector-builtins-bases.cc +++ b/gcc/config/riscv/riscv-vector-builtins-bases.cc @@ -1715,10 +1715,15 @@ public: }; /* Implements vfwcvt.x. */ -template +template class vfwcvt_x : public function_base { public: + bool has_rounding_mode_operand_p () const override + { + return FRM_OP == HAS_FRM; + } + rtx expand (function_expander &e) const override { return e.use_exact_insn ( @@ -2490,6 +2495,7 @@ static CONSTEXPR const vfcvt_rtz_x vfcvt_rtz_xu_obj; static CONSTEXPR const vfcvt_f vfcvt_f_obj; static CONSTEXPR const vfcvt_f vfcvt_f_frm_obj; static CONSTEXPR const vfwcvt_x vfwcvt_x_obj; +static CONSTEXPR const vfwcvt_x vfwcvt_x_frm_obj; static CONSTEXPR const vfwcvt_x vfwcvt_xu_obj; static CONSTEXPR const vfwcvt_rtz_x vfwcvt_rtz_x_obj; static CONSTEXPR const vfwcvt_rtz_x vfwcvt_rtz_xu_obj; @@ -2742,6 +2748,7 @@ BASE (vfcvt_rtz_xu) BASE (vfcvt_f) BASE (vfcvt_f_frm) BASE (vfwcvt_x) +BASE (vfwcvt_x_frm) BASE (vfwcvt_xu) BASE (vfwcvt_rtz_x) BASE (vfwcvt_rtz_xu) diff --git a/gcc/config/riscv/riscv-vector-builtins-bases.h b/gcc/config/riscv/riscv-vector-builtins-bases.h index 08452587180..dd711846cbe 100644 --- a/gcc/config/riscv/riscv-vector-builtins-bases.h +++ b/gcc/config/riscv/riscv-vector-builtins-bases.h @@ -213,6 +213,7 @@ extern const function_base *const vfcvt_rtz_xu; extern const function_base *const vfcvt_f; extern const function_base *const vfcvt_f_frm; extern const function_base *const vfwcvt_x; +extern const function_base *const vfwcvt_x_frm; extern const function_base *const vfwcvt_xu; extern const function_base *const vfwcvt_rtz_x; extern const function_base *const vfwcvt_rtz_xu; diff --git a/gcc/config/riscv/riscv-vector-builtins-functions.def b/gcc/config/riscv/riscv-vector-builtins-functions.def index 8dbcd946d11..4e6cc793447 100644 --- a/gcc/config/riscv/riscv-vector-builtins-functions.def +++ b/gcc/config/riscv/riscv-vector-builtins-functions.def @@ -459,6 +459,8 @@ DEF_RVV_FUNCTION (vfwcvt_f, alu, full_preds, i_to_wf_x_v_ops) DEF_RVV_FUNCTION (vfwcvt_f, alu, full_preds, u_to_wf_xu_v_ops) DEF_RVV_FUNCTION (vfwcvt_f, alu, full_preds, f_to_wf_f_v_ops) +DEF_RVV_FUNCTION (vfwcvt_x_frm, alu_frm, full_preds, f_to_wi_f_v_ops) + // 13.19. Narrowing Floating-Point/Integer Type-Convert Instructions DEF_RVV_FUNCTION (vfncvt_x, narrow_alu, full_preds, f_to_ni_f_w_ops) DEF_RVV_FUNCTION (vfncvt_xu, narrow_alu, full_preds, f_to_nu_f_w_ops) diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/float-point-wcvt-x.c b/gcc/testsuite/gcc.target/riscv/rvv/base/float-point-wcvt-x.c new file mode 100644 index 00000000000..8f67ec00966 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/float-point-wcvt-x.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64 -O3 -Wno-psabi" } */ + +#include "riscv_vector.h" + +vint64m2_t +test_riscv_vfwcvt_x_f_v_i64m2_rm (vfloat32m1_t op1, size_t vl) { + return __riscv_vfwcvt_x_f_v_i64m2_rm (op1, 0, vl); +} + +vint64m2_t +test_vfwcvt_x_f_v_i64m2_rm_m (vbool32_t mask, vfloat32m1_t op1, size_t vl) { + return __riscv_vfwcvt_x_f_v_i64m2_rm_m (mask, op1, 1, vl); +} + +vint64m2_t +test_riscv_vfwcvt_x_f_v_i64m2 (vfloat32m1_t op1, size_t vl) { + return __riscv_vfwcvt_x_f_v_i64m2 (op1, vl); +} + +vint64m2_t +test_vfwcvt_x_f_v_i64m2_m (vbool32_t mask, vfloat32m1_t op1, size_t vl) { + return __riscv_vfwcvt_x_f_v_i64m2_m (mask, op1, vl); +} + +/* { dg-final { scan-assembler-times {vfwcvt\.x\.f\.v\s+v[0-9]+,\s*v[0-9]+} 4 } } */ +/* { dg-final { scan-assembler-times {frrm\s+[axs][0-9]+} 2 } } */ +/* { dg-final { scan-assembler-times {fsrm\s+[axs][0-9]+} 2 } } */ +/* { dg-final { scan-assembler-times {fsrmi\s+[01234]} 2 } } */