From patchwork Mon Aug 14 03:29:09 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: 135113 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp2494770vqi; Sun, 13 Aug 2023 20:30:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFJ175MziMgp4SxGgsRs3+vV5x/mUGk7kCDTjAeuSgHHupn+jO3e0FytvQNnsmipMzWAY/y X-Received: by 2002:aa7:d584:0:b0:522:1e24:afb6 with SMTP id r4-20020aa7d584000000b005221e24afb6mr6408302edq.0.1691983802478; Sun, 13 Aug 2023 20:30:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691983802; cv=none; d=google.com; s=arc-20160816; b=TISu5OCs+a6KdssjyVoxkxRelTs9/9P/97W72gH+tym6mL4H5xoq9gkaNmEfcoCHG0 ZzklQcz6AIq7TxPfLBQj9WamKQ3siwiZHKimkW11ZRn2JT1+2+8pKw36R3VtLBmfoS/X 144RZSvILf61Rj8V+2mjW0IHsN++3GC5edVNA3/P8GhgjsBEwieYLnZP1lEfd6Mgau24 EVVWnHFvwIijXWDAhlLlW5ZDbdxN2t+ijANQpDtAADVsdNNCGyqZl/Hl/0aBTuLT/fZ6 kwZDlUiYt8ohriZpUXrNd7FiVVRTCEbbq4tBB4vCCfYM1mDr6ase9oWaygcjdbwlUX88 iaTg== 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=7TBOEMX/7Ah06uYt43NCgxRvjf1psE/6GWxkbIeW4mw=; fh=9EZcvfVI324lLsRm78AR5trG4A9hqVpSpoTtyXFX1N4=; b=fGXIZUCJgF+Nqb0qG0I62K6lVQgkPRX+2peg2QCjyCrXA0AM20Y7fS2YFURz7YTo/P Tya4D3YgAq1LCmXFdxS4sQS2Z9+movN23hl5mgE2YF4EgrQpYWngrTvCo+mVfbZLKo9Q 9szz0SliN3fGUmTw8PBFjwTAA9kKodS1BrImT/uuGZu+DRqeVfcMilywDcAPU+ade275 biZ242J3PnJWhElNDpn7OILFZ7fkVF2jKj6+VGUat98VE7Pf2c/TZifGyO3juoywBi76 51Xmy2wmYe1c7N0lY+6kAaUXD/lq/n02evhZBZPOnkzsrv56pc8xvhfQ5BjHk2Q6CMVh dYew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=UaJwComi; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id a16-20020aa7cf10000000b00523d1ab159csi4669262edy.674.2023.08.13.20.30.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Aug 2023 20:30:02 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=UaJwComi; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 2BC3E3858C20 for ; Mon, 14 Aug 2023 03:30:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2BC3E3858C20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691983801; bh=7TBOEMX/7Ah06uYt43NCgxRvjf1psE/6GWxkbIeW4mw=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=UaJwComi7R7xtMv/qZWBLEGiUVMkL4lPtiKBM9nbNGi1ARJoVAhRw92YfBHZrvdpx awLu1Fa8+dKq8HRSyU7NfDgzRfvD7QYhdbxnAHzSyXyZTBPnh1jzU2nz6l3+rw+rj4 MaJ5VM0y1ck+F7qmQKFSqeTT4HQRcG0VpidZX1ms= 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.136]) by sourceware.org (Postfix) with ESMTPS id 99CF93858D39 for ; Mon, 14 Aug 2023 03:29:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 99CF93858D39 X-IronPort-AV: E=McAfee;i="6600,9927,10801"; a="351554107" X-IronPort-AV: E=Sophos;i="6.01,171,1684825200"; d="scan'208";a="351554107" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Aug 2023 20:29:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.01,202,1684825200"; d="scan'208";a="876799483" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by fmsmga001.fm.intel.com with ESMTP; 13 Aug 2023 20:29:15 -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 C75C61005171; Mon, 14 Aug 2023 11:29:10 +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 VFWMSAC rounding mode intrinsic API Date: Mon, 14 Aug 2023 11:29:09 +0800 Message-Id: <20230814032909.1898090-1-pan2.li@intel.com> X-Mailer: git-send-email 2.34.1 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: 1774173608076102909 X-GMAIL-MSGID: 1774173608076102909 From: Pan Li This patch would like to support the rounding mode API for the VFWMSAC as the below samples. * __riscv_vfwmsac_vv_f64m2_rm * __riscv_vfwmsac_vv_f64m2_rm_m * __riscv_vfwmsac_vf_f64m2_rm * __riscv_vfwmsac_vf_f64m2_rm_m Signed-off-by: Pan Li gcc/ChangeLog: * config/riscv/riscv-vector-builtins-bases.cc (class vfwmsac_frm): New class for frm. (vfwmsac_frm_obj): New declaration. (BASE): Ditto. * config/riscv/riscv-vector-builtins-bases.h: Ditto. * config/riscv/riscv-vector-builtins-functions.def (vfwmsac_frm): New intrinsic function definition. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/float-point-wmsac.c: New test. Signed-off-by: Pan Li --- .../riscv/riscv-vector-builtins-bases.cc | 25 ++++++++++ .../riscv/riscv-vector-builtins-bases.h | 1 + .../riscv/riscv-vector-builtins-functions.def | 2 + .../riscv/rvv/base/float-point-wmsac.c | 47 +++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/float-point-wmsac.c diff --git a/gcc/config/riscv/riscv-vector-builtins-bases.cc b/gcc/config/riscv/riscv-vector-builtins-bases.cc index 4a7f2b8e3e9..5a5da903cb2 100644 --- a/gcc/config/riscv/riscv-vector-builtins-bases.cc +++ b/gcc/config/riscv/riscv-vector-builtins-bases.cc @@ -585,6 +585,29 @@ public: } }; +/* Implements below instructions for frm + - vfwmsac +*/ +class vfwmsac_frm : public function_base +{ +public: + bool has_rounding_mode_operand_p () const override { return true; } + + bool has_merge_operand_p () const override { return false; } + + rtx expand (function_expander &e) const override + { + if (e.op_info->op == OP_TYPE_vf) + return e.use_widen_ternop_insn ( + code_for_pred_widen_mul_scalar (MINUS, e.vector_mode ())); + if (e.op_info->op == OP_TYPE_vv) + return e.use_widen_ternop_insn ( + code_for_pred_widen_mul (MINUS, e.vector_mode ())); + + gcc_unreachable (); + } +}; + /* Implements vrsub. */ class vrsub : public function_base { @@ -2365,6 +2388,7 @@ static CONSTEXPR const vfwmacc_frm vfwmacc_frm_obj; static CONSTEXPR const vfwnmacc vfwnmacc_obj; static CONSTEXPR const vfwnmacc_frm vfwnmacc_frm_obj; static CONSTEXPR const vfwmsac vfwmsac_obj; +static CONSTEXPR const vfwmsac_frm vfwmsac_frm_obj; static CONSTEXPR const vfwnmsac vfwnmsac_obj; static CONSTEXPR const unop vfsqrt_obj; static CONSTEXPR const float_misc vfrsqrt7_obj; @@ -2610,6 +2634,7 @@ BASE (vfwmacc_frm) BASE (vfwnmacc) BASE (vfwnmacc_frm) BASE (vfwmsac) +BASE (vfwmsac_frm) BASE (vfwnmsac) BASE (vfsqrt) BASE (vfrsqrt7) diff --git a/gcc/config/riscv/riscv-vector-builtins-bases.h b/gcc/config/riscv/riscv-vector-builtins-bases.h index 27c7deb4ec2..09356dd7ac8 100644 --- a/gcc/config/riscv/riscv-vector-builtins-bases.h +++ b/gcc/config/riscv/riscv-vector-builtins-bases.h @@ -180,6 +180,7 @@ extern const function_base *const vfwmacc_frm; extern const function_base *const vfwnmacc; extern const function_base *const vfwnmacc_frm; extern const function_base *const vfwmsac; +extern const function_base *const vfwmsac_frm; extern const function_base *const vfwnmsac; extern const function_base *const vfsqrt; extern const function_base *const vfrsqrt7; diff --git a/gcc/config/riscv/riscv-vector-builtins-functions.def b/gcc/config/riscv/riscv-vector-builtins-functions.def index 481c3b899f2..e2a79607d04 100644 --- a/gcc/config/riscv/riscv-vector-builtins-functions.def +++ b/gcc/config/riscv/riscv-vector-builtins-functions.def @@ -380,6 +380,8 @@ DEF_RVV_FUNCTION (vfwmacc_frm, alu_frm, full_preds, f_wwvv_ops) DEF_RVV_FUNCTION (vfwmacc_frm, alu_frm, full_preds, f_wwfv_ops) DEF_RVV_FUNCTION (vfwnmacc_frm, alu_frm, full_preds, f_wwvv_ops) DEF_RVV_FUNCTION (vfwnmacc_frm, alu_frm, full_preds, f_wwfv_ops) +DEF_RVV_FUNCTION (vfwmsac_frm, alu_frm, full_preds, f_wwvv_ops) +DEF_RVV_FUNCTION (vfwmsac_frm, alu_frm, full_preds, f_wwfv_ops) // 13.8. Vector Floating-Point Square-Root Instruction DEF_RVV_FUNCTION (vfsqrt, alu, full_preds, f_v_ops) diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/float-point-wmsac.c b/gcc/testsuite/gcc.target/riscv/rvv/base/float-point-wmsac.c new file mode 100644 index 00000000000..886a0b13695 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/float-point-wmsac.c @@ -0,0 +1,47 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64 -O3 -Wno-psabi" } */ + +#include "riscv_vector.h" + +typedef float float32_t; + +vfloat64m2_t +test_vfwmsac_vv_f32m1_rm (vfloat64m2_t vd, vfloat32m1_t op1, vfloat32m1_t op2, + size_t vl) { + return __riscv_vfwmsac_vv_f64m2_rm (vd, op1, op2, 0, vl); +} + +vfloat64m2_t +test_vfwmsac_vv_f32m1_rm_m (vbool32_t mask, vfloat64m2_t vd, vfloat32m1_t op1, + vfloat32m1_t op2, size_t vl) { + return __riscv_vfwmsac_vv_f64m2_rm_m (mask, vd, op1, op2, 1, vl); +} + +vfloat64m2_t +test_vfwmsac_vf_f32m1_rm (vfloat64m2_t vd, float32_t op1, vfloat32m1_t op2, + size_t vl) { + return __riscv_vfwmsac_vf_f64m2_rm (vd, op1, op2, 2, vl); +} + +vfloat64m2_t +test_vfwmsac_vf_f32m1_rm_m (vbool32_t mask, vfloat64m2_t vd, float32_t op1, + vfloat32m1_t op2, size_t vl) { + return __riscv_vfwmsac_vf_f64m2_rm_m (mask, vd, op1, op2, 3, vl); +} + +vfloat64m2_t +test_vfwmsac_vv_f32m1 (vfloat64m2_t vd, vfloat32m1_t op1, vfloat32m1_t op2, + size_t vl) { + return __riscv_vfwmsac_vv_f64m2 (vd, op1, op2, vl); +} + +vfloat64m2_t +test_vfwmsac_vv_f32m1_m (vbool32_t mask, vfloat64m2_t vd, vfloat32m1_t op1, + vfloat32m1_t op2, size_t vl) { + return __riscv_vfwmsac_vv_f64m2_m (mask, vd, op1, op2, vl); +} + +/* { dg-final { scan-assembler-times {vfwmsac\.[vw][vf]\s+v[0-9]+,\s*[fav]+[0-9]+,\s*[fav]+[0-9]+} 6 } } */ +/* { dg-final { scan-assembler-times {frrm\s+[axs][0-9]+} 4 } } */ +/* { dg-final { scan-assembler-times {fsrm\s+[axs][0-9]+} 4 } } */ +/* { dg-final { scan-assembler-times {fsrmi\s+[01234]} 4 } } */