From patchwork Thu Aug 17 08:05:58 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: 135861 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp536077vqi; Thu, 17 Aug 2023 01:07:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGXFjcbbOslpGwBD92vW8VIwpbPclu0tvcYX5vZRrcd3yIA8lbXmORd0+aEwhjwWVDMEbA4 X-Received: by 2002:a17:906:2099:b0:99c:440b:a46a with SMTP id 25-20020a170906209900b0099c440ba46amr3859392ejq.1.1692259636086; Thu, 17 Aug 2023 01:07:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692259636; cv=none; d=google.com; s=arc-20160816; b=0n126jpWVdgRM3VX/6NUEDavW79ryBiT4PGgGY0BGiRvjIxF8AvpuEtatcx0bf3pqt XCqrRfYQ8bz72Oy0uqvErgsUjnpd+fNa0EVEUNKcjxJLTKuUA2sW8/gRTPsmML8yFMVb +WU2OfuqMkGCaN7hOvHZ5DMsmTbaOw6LB+jSzZ9lqRd6pt7BJFWZJIUluLiMJcm1ovd9 jh1AmFVcPcxjgZ912CyCQ283XgFcHwDkCzRN32RzrCAWRsowyZa74E1g+JhyQ+g6vAVP rG4JYiSwfzEQHMntfX0tG5uQYrN0Dspdtcds3KDaNsqf+aKsoU1VUBMI3OppXB3Q+JQi dgLg== 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=0gZz2hR2jy7qki2XTdbDiYs7rG1CFB307kID5l+Hyf8=; fh=9EZcvfVI324lLsRm78AR5trG4A9hqVpSpoTtyXFX1N4=; b=cYCLJPbgOc0n7KZQP0QkNQsxNLYeya9Tb11dK63U27PbYYT7A/QlZIeuk/0Z6DE5LN kj13Y4ZOHRSFsiytXMEoRdqoFOoOs9jUhnMbBpK3XaQQ3owCWc2Eyflf67FanAZfcBz8 IjkjblSg5X8pSNAZ/SDWOMPT8GYhqsrlEYYHNfVMO/y3qy01tEKb5c3ZOM9smfhYQoy/ u8ZTg5lZ499ZE6OEWyrqZPVafGyBolN3cII0vyF5g57hYk1lhiI2JRuuMkdNud18OqxE gMFmKMvQ6O+9B4gLPiSITYVY5p+LgWGKLIzeHhYjgrSsZV9wL9yzP9j7kVQVaGc+5H5r GmKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=OP7SXasg; 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 z25-20020a1709064e1900b00991bd84725asi11550876eju.227.2023.08.17.01.07.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Aug 2023 01:07:16 -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=OP7SXasg; 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 0D8C93854179 for ; Thu, 17 Aug 2023 08:06:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0D8C93854179 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692259612; bh=0gZz2hR2jy7qki2XTdbDiYs7rG1CFB307kID5l+Hyf8=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=OP7SXasgq8M/5iBnkISgI6Opn6J7NmZG2fUKEL/rSea6Y93fKYMgSX6yV0Ne7hKw8 n9Ujdq5FE0GuIvQJDJ3vvlKxc4sQ30HRMz2VMnYWUYxk4chreHCD1wHBmUB4tXU2YF Cd0Py4MTSjyyu1fwKN6+NqbWC0uYavFGe696M5pQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by sourceware.org (Postfix) with ESMTPS id 8DA963858D38 for ; Thu, 17 Aug 2023 08:06:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8DA963858D38 X-IronPort-AV: E=McAfee;i="6600,9927,10803"; a="357710076" X-IronPort-AV: E=Sophos;i="6.01,179,1684825200"; d="scan'208";a="357710076" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2023 01:06:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10803"; a="804543653" X-IronPort-AV: E=Sophos;i="6.01,179,1684825200"; d="scan'208";a="804543653" Received: from shvmail02.sh.intel.com ([10.239.244.9]) by fmsmga004.fm.intel.com with ESMTP; 17 Aug 2023 01:05:59 -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 E27121006F2C; Thu, 17 Aug 2023 16:05:58 +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 VFWREDUSUM.VS rounding mode intrinsic API Date: Thu, 17 Aug 2023 16:05:58 +0800 Message-Id: <20230817080558.117051-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: 1774462839811597577 X-GMAIL-MSGID: 1774462839811597577 From: Pan Li This patch would like to support the rounding mode API for the VFWREDUSUM.VS as the below samples * __riscv_vfwredusum_vs_f32m1_f64m1_rm * __riscv_vfwredusum_vs_f32m1_f64m1_rm_m Signed-off-by: Pan Li gcc/ChangeLog: * config/riscv/riscv-vector-builtins-bases.cc (vfwredusum_frm_obj): New declaration. (BASE): Ditto. * config/riscv/riscv-vector-builtins-bases.h: Ditto. * config/riscv/riscv-vector-builtins-functions.def (vfwredusum_frm): New intrinsic function def. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/float-point-wredusum.c: New test. Signed-off-by: Pan Li Signed-off-by: Pan Li --- .../riscv/riscv-vector-builtins-bases.cc | 2 ++ .../riscv/riscv-vector-builtins-bases.h | 1 + .../riscv/riscv-vector-builtins-functions.def | 1 + .../riscv/rvv/base/float-point-wredusum.c | 33 +++++++++++++++++++ 4 files changed, 37 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/float-point-wredusum.c diff --git a/gcc/config/riscv/riscv-vector-builtins-bases.cc b/gcc/config/riscv/riscv-vector-builtins-bases.cc index abf03bab0da..5ee7d3119db 100644 --- a/gcc/config/riscv/riscv-vector-builtins-bases.cc +++ b/gcc/config/riscv/riscv-vector-builtins-bases.cc @@ -2548,6 +2548,7 @@ static CONSTEXPR const freducop vfredosum_frm_obj; static CONSTEXPR const reducop vfredmax_obj; static CONSTEXPR const reducop vfredmin_obj; static CONSTEXPR const widen_freducop vfwredusum_obj; +static CONSTEXPR const widen_freducop vfwredusum_frm_obj; static CONSTEXPR const widen_freducop vfwredosum_obj; static CONSTEXPR const widen_freducop vfwredosum_frm_obj; static CONSTEXPR const vmv vmv_x_obj; @@ -2810,6 +2811,7 @@ BASE (vfredmin) BASE (vfwredosum) BASE (vfwredosum_frm) BASE (vfwredusum) +BASE (vfwredusum_frm) BASE (vmv_x) BASE (vmv_s) BASE (vfmv_f) diff --git a/gcc/config/riscv/riscv-vector-builtins-bases.h b/gcc/config/riscv/riscv-vector-builtins-bases.h index c1bb164a712..69d4562091f 100644 --- a/gcc/config/riscv/riscv-vector-builtins-bases.h +++ b/gcc/config/riscv/riscv-vector-builtins-bases.h @@ -247,6 +247,7 @@ extern const function_base *const vfredmin; extern const function_base *const vfwredosum; extern const function_base *const vfwredosum_frm; extern const function_base *const vfwredusum; +extern const function_base *const vfwredusum_frm; extern const function_base *const vmv_x; extern const function_base *const vmv_s; extern const function_base *const vfmv_f; diff --git a/gcc/config/riscv/riscv-vector-builtins-functions.def b/gcc/config/riscv/riscv-vector-builtins-functions.def index da1157f5a56..3ce06dc60b7 100644 --- a/gcc/config/riscv/riscv-vector-builtins-functions.def +++ b/gcc/config/riscv/riscv-vector-builtins-functions.def @@ -508,6 +508,7 @@ DEF_RVV_FUNCTION (vfwredosum, reduc_alu, no_mu_preds, wf_vs_ops) DEF_RVV_FUNCTION (vfwredusum, reduc_alu, no_mu_preds, wf_vs_ops) DEF_RVV_FUNCTION (vfwredosum_frm, reduc_alu_frm, no_mu_preds, wf_vs_ops) +DEF_RVV_FUNCTION (vfwredusum_frm, reduc_alu_frm, no_mu_preds, wf_vs_ops) /* 15. Vector Mask Instructions. */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/float-point-wredusum.c b/gcc/testsuite/gcc.target/riscv/rvv/base/float-point-wredusum.c new file mode 100644 index 00000000000..6c888c10c0d --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/float-point-wredusum.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64 -O3 -Wno-psabi" } */ + +#include "riscv_vector.h" + +vfloat64m1_t +test_riscv_vfwredusum_vs_f32m1_f64m1_rm (vfloat32m1_t op1, vfloat64m1_t op2, + size_t vl) { + return __riscv_vfwredusum_vs_f32m1_f64m1_rm (op1, op2, 0, vl); +} + +vfloat64m1_t +test_vfwredusum_vs_f32m1_f64m1_rm_m (vbool32_t mask, vfloat32m1_t op1, + vfloat64m1_t op2, size_t vl) { + return __riscv_vfwredusum_vs_f32m1_f64m1_rm_m (mask, op1, op2, 1, vl); +} + +vfloat64m1_t +test_riscv_vfwredusum_vs_f32m1_f64m1 (vfloat32m1_t op1, vfloat64m1_t op2, + size_t vl) { + return __riscv_vfwredusum_vs_f32m1_f64m1 (op1, op2, vl); +} + +vfloat64m1_t +test_vfwredusum_vs_f32m1_f64m1_m (vbool32_t mask, vfloat32m1_t op1, + vfloat64m1_t op2, size_t vl) { + return __riscv_vfwredusum_vs_f32m1_f64m1_m (mask, op1, op2, vl); +} + +/* { dg-final { scan-assembler-times {vfwredusum\.vs\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 } } */