From patchwork Tue Aug 15 08:01:47 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: 135629 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:3f2:4152:657d with SMTP id x8csp276338vqo; Tue, 15 Aug 2023 01:03:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGr2kd/CQAAPgqWRTFa5Qny9gKw2O/l6kvsItRWXfcUFY9qjrFeHDEVAPX1MdHsogVZZRXz X-Received: by 2002:a17:907:270e:b0:99b:dd1d:64ba with SMTP id w14-20020a170907270e00b0099bdd1d64bamr10075533ejk.50.1692086590402; Tue, 15 Aug 2023 01:03:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692086590; cv=none; d=google.com; s=arc-20160816; b=J2gOUaXkViUkShnCUTOOfGtOnLnFOEFtRXqb50u6aw8fj/eqrSHG4t2/siALSH76vM 2pOUF3pNv0JmmxkTq0g/7UvEzABdhcdkL4gX16299E036wXbBWbqrsbV9Z8eX6KSdtsq G5rsOOm1nQzhuduPdNVxJThpqkVylZvBEL3mGHQGS749Tu9wsqAQmZDqX0u79AZjYvbS SbxWRz7zADKmPFKFSxy95ZilTMfCBQ5THuY2pd60X0xXT4ctz5edFDXlsBi40mJtPyLj 2arb//kdnwLUOrG+PxXJvk9XSE6NLH3W6egq3vxSAhQ2c+WPWIovDKWan2ks+ldtGZqm mn1g== 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:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=V2CCEmHfXXs7upYTaGPjc4+ifqKt+LURMOY6IK12t7A=; fh=9EZcvfVI324lLsRm78AR5trG4A9hqVpSpoTtyXFX1N4=; b=UTX7RU/J4xAu7luCV18Znp+oDwNyO8uL18qYKEpcwKovlUpmg8RD8NpAgX6tPvTCnV kYzAHv6VwgXeZfFV8ZRP83GygqjzGOlOCDsD7jBtRUtVBTvPyCgbKJQ/6PJv9ZgJeuMS Wptn+58Q2/98B6RWEjZcRULi4/zeZkDrGXICgeoWYrKcyQ+pJ5bvmQnq9FnbgrF330eb FuwTqyJ9AtSEeGFmduxgMfVlMyAI0m5h2ETZvXXhp7l6MCPdBxHahAeSnPpSVFoEkyGN MVzZyLGuajLS3QOuX6rtCS7QhOAjxMum56VhMKyR6atMFQ1LQhxv6dCKbmqvy4Xrxsgp Dudw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xpJsAg22; 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 oz18-20020a170906cd1200b00993321873fesi8397425ejb.665.2023.08.15.01.03.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Aug 2023 01:03:10 -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=xpJsAg22; 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 25D7B3858028 for ; Tue, 15 Aug 2023 08:03:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 25D7B3858028 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692086589; bh=V2CCEmHfXXs7upYTaGPjc4+ifqKt+LURMOY6IK12t7A=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=xpJsAg22MH8rsYtY5d39Ds0gDJQkQn7VgZs6YWOOEKqwP2CXQ7BnHDipM83JBCOv1 9/QbEkincNMjXpk1rk5Ygu9PjSWtFJTrw322jAr9nJPYw5RfL6vnT50bdXF13bpBk5 HRR8+r/Yj91A6PziaR/TKRhyBMm5ccgfUrS9jMlE= 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.151]) by sourceware.org (Postfix) with ESMTPS id 8070E3858C5F for ; Tue, 15 Aug 2023 08:01:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8070E3858C5F X-IronPort-AV: E=McAfee;i="6600,9927,10802"; a="352551748" X-IronPort-AV: E=Sophos;i="6.01,174,1684825200"; d="scan'208";a="352551748" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Aug 2023 01:01:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10802"; a="847979863" X-IronPort-AV: E=Sophos;i="6.01,174,1684825200"; d="scan'208";a="847979863" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by fmsmga002.fm.intel.com with ESMTP; 15 Aug 2023 01:01:49 -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 DBFDC100516D; Tue, 15 Aug 2023 16:01:48 +0800 (CST) To: gcc-patches@gcc.gnu.org Cc: juzhe.zhong@rivai.ai, pan2.li@intel.com, yanzhang.wang@intel.com, kito.cheng@gmail.com Subject: [PATCH v1] RISC-V: Support RVV VFWCVT.X.F.V rounding mode intrinsic API Date: Tue, 15 Aug 2023 16:01:47 +0800 Message-Id: <20230815080147.1986255-1-pan2.li@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 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: 1774281388190876218 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 (class vfwcvt_x_frm): New class for frm. (vfwcvt_x_frm_obj): New declaration. (BASE): Ditto. * config/riscv/riscv-vector-builtins-bases.h: Ditto. * config/riscv/riscv-vector-builtins-functions.def (vfwcvt_x_frm): New intrinsic function definition. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/float-point-wcvt-x.c: New test. --- .../riscv/riscv-vector-builtins-bases.cc | 18 ++++++++++++ .../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, 50 insertions(+) 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 3c2bc13b586..7bd72653b9c 100644 --- a/gcc/config/riscv/riscv-vector-builtins-bases.cc +++ b/gcc/config/riscv/riscv-vector-builtins-bases.cc @@ -695,6 +695,22 @@ public: } }; +/* Implements below instructions for frm + - vfwcvt_x +*/ +template +class vfwcvt_x_frm : public function_base +{ +public: + bool has_rounding_mode_operand_p () const override { return true; } + + rtx expand (function_expander &e) const override + { + return e.use_exact_insn ( + code_for_pred_widen_fcvt_x_f (UNSPEC, e.vector_mode ())); + } +}; + /* Implements vrsub. */ class vrsub : public function_base { @@ -2508,6 +2524,7 @@ static CONSTEXPR const vfcvt_rtz_x vfcvt_rtz_xu_obj; static CONSTEXPR const vfcvt_f vfcvt_f_obj; static CONSTEXPR const vfcvt_f_frm vfcvt_f_frm_obj; static CONSTEXPR const vfwcvt_x vfwcvt_x_obj; +static CONSTEXPR const vfwcvt_x_frm 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; @@ -2760,6 +2777,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 } } */