From patchwork Mon May 15 12:22:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "juzhe.zhong@rivai.ai" X-Patchwork-Id: 94108 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp6878328vqo; Mon, 15 May 2023 05:23:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ78itCDeHeL/zbEC4YEwQilURD2MaqDd6U54X9Rx8w6pSeKdsvZw9s2RW4lVz0jEgbu7j2F X-Received: by 2002:a17:907:982:b0:965:7fba:6bcf with SMTP id bf2-20020a170907098200b009657fba6bcfmr29585590ejc.67.1684153429860; Mon, 15 May 2023 05:23:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684153429; cv=none; d=google.com; s=arc-20160816; b=q5OsxMYaFqGwMrgGBuPF15LHAwPBZsJG0fDwzEh5L8QZiqBRo9O0YuRxbUNobK9JXf qtUVwSnPownwN/j8oReIPU3l3Qp43K1yhlW3yHvgkb8s4CyOhpE8C8xcUxrs5f074e9M XC4aIwaWrtS7g7yYLzxQrSdtbYYGfKlJFg+hXd4/n/zYTMkPw9NYjOlhoTaYnXXfYDBG uOW9t8rWNa1nql07FJ6c7mFGrdD+YQEgO8eB95S3A6y5Yb2Pd1AD+d3zE6micziL6Axe zhOYL6rBtoVyQLgFhMwvyh3xDFFdFs/ErltoPaEUvhSQFk+5NXcd/EjPuEsmqXh8VEeO Po/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:feedback-id :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dmarc-filter:delivered-to; bh=vwGa060Ggfn5P/9VxkC770ao6ctjCfSPsd1HbG4OT7c=; b=eV+BU2L3/Gw0LVgIV7MLpkMHVRosK7VA9x6p4M6Iu9383stYbURMCe/k+4GbE8li2z 7922UOM6a/wLwvqF7DUribEkyDhoLTFwOxIDP2pfSGFbZfGI8S3AEL2Bwv3lqeGGls1/ Wykeuc5YVqqrai63fkANFMkI6bubN6BiIQtsotZewz+8FN1D2uE1m1Lk1YsTZ098jL9U 0ZPgBIg1TG5XJj2jjAlE/XhWiQBwT9TfdJ+av2/MY0iMGQv2Er1RpJoKb0LvvOj+k1w8 SG3+/wNF2T7wa94AOzUeSvzAgYtZUtOJ9o2rju9Jy3oqClsw7fPyi632gY9Fj1lwjbLe zfJQ== ARC-Authentication-Results: i=1; mx.google.com; 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" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id sa6-20020a1709076d0600b0096a3c9a8ff1si11932384ejc.391.2023.05.15.05.23.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 05:23:49 -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; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2D5E93853817 for ; Mon, 15 May 2023 12:23:11 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbgjp3.qq.com (smtpbgjp3.qq.com [54.92.39.34]) by sourceware.org (Postfix) with ESMTPS id AA528385772D for ; Mon, 15 May 2023 12:22:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AA528385772D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivai.ai Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivai.ai X-QQ-mid: bizesmtp75t1684153361tdpcqma4 Received: from server1.localdomain ( [58.60.1.22]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 15 May 2023 20:22:40 +0800 (CST) X-QQ-SSF: 01400000000000F0R000000A0000000 X-QQ-FEAT: 5rzXCDem++VSCLlJBK97XwTV3E4v16jw1WT8Vu4Oh1j8/YFpPWXXUNxS0zX8V EJ6pAp3iA1uTo6+l+r+sHhH2mncTwB0rCLF5NTZV6/oVTlSPzwhIin4ctL0aY4oyUe6BWVk APJajsxg49MLJzvTqXBMvPNCtlWYyJG+6iFFqGZa0gfjJ7QKLK467Ff61OesB4OaRDigm4y pBLYJ+zJ4Q/CZ68xXrNEzpIJjOz4qbd2uJpTI1nIMxEBz8Dto1/FsmIBQxw6SJ4cRuwNXi0 u+HXoAGy0oG8NHh3oJbuDa9AsISm62QzADvivHsvos/ZW1flfaRabq/XiK3+BOVaSQxbAIt 0DQOQuE0/AxFtNLP1YlKoMk/pWBROhYdeQxK+TVxVk2Mckjy6a5his1rUKP9J/is/8Ykxw/ 0+aThio1Pow= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 14563433769259793016 From: juzhe.zhong@rivai.ai To: gcc-patches@gcc.gnu.org Cc: richard.guenther@gmail.com, rguenther@suse.de, Juzhe-Zhong Subject: [PATCH] RISC-V: Add FRM and rounding mode operand into floating-point ternary instructions Date: Mon, 15 May 2023 20:22:35 +0800 Message-Id: <20230515122235.293830-2-juzhe.zhong@rivai.ai> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20230515122235.293830-1-juzhe.zhong@rivai.ai> References: <20230515122235.293830-1-juzhe.zhong@rivai.ai> MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:rivai.ai:qybglogicsvrgz:qybglogicsvrgz7a-one-0 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, 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: , 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?1765962866505411313?= X-GMAIL-MSGID: =?utf-8?q?1765962866505411313?= From: Juzhe-Zhong This patch is adding FRM and rounding mode into floating-point ternary instructions. This patch should be merged after optabs.cc patch. gcc/ChangeLog: * config/riscv/riscv-vector-builtins.cc (function_expander::use_ternop_insn): Add default rounding mode. * config/riscv/vector.md: Add rounding mode operand and FRM_REGNUM. --- gcc/config/riscv/riscv-vector-builtins.cc | 7 +++ gcc/config/riscv/vector.md | 64 +++++++++++++++++------ 2 files changed, 55 insertions(+), 16 deletions(-) diff --git a/gcc/config/riscv/riscv-vector-builtins.cc b/gcc/config/riscv/riscv-vector-builtins.cc index f10f38f6425..b7458aaace6 100644 --- a/gcc/config/riscv/riscv-vector-builtins.cc +++ b/gcc/config/riscv/riscv-vector-builtins.cc @@ -3460,6 +3460,13 @@ function_expander::use_ternop_insn (bool vd_accum_p, insn_code icode) add_input_operand (Pmode, get_tail_policy_for_pred (pred)); add_input_operand (Pmode, get_mask_policy_for_pred (pred)); add_input_operand (Pmode, get_avl_type_rtx (avl_type::NONVLMAX)); + + /* TODO: Currently, we don't support intrinsic that is modeling rounding mode. + We add default rounding mode for the intrinsics that didn't model rounding + mode yet. */ + if (opno != insn_data[icode].n_generator_args) + add_input_operand (Pmode, const0_rtx); + return generate_insn (icode); } diff --git a/gcc/config/riscv/vector.md b/gcc/config/riscv/vector.md index 0929d19d5ec..80f9ba9bd28 100644 --- a/gcc/config/riscv/vector.md +++ b/gcc/config/riscv/vector.md @@ -5902,8 +5902,10 @@ (match_operand 7 "const_int_operand") (match_operand 8 "const_int_operand") (match_operand 9 "const_int_operand") + (match_operand 10 "const_int_operand") (reg:SI VL_REGNUM) - (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) + (reg:SI VTYPE_REGNUM) + (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE) (plus_minus:VF (mult:VF (match_operand:VF 2 "register_operand") @@ -5927,8 +5929,10 @@ (match_operand 6 "const_int_operand" " i, i, i, i") (match_operand 7 "const_int_operand" " i, i, i, i") (match_operand 8 "const_int_operand" " i, i, i, i") + (match_operand 9 "const_int_operand" " i, i, i, i") (reg:SI VL_REGNUM) - (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) + (reg:SI VTYPE_REGNUM) + (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE) (plus_minus:VF (mult:VF (match_operand:VF 2 "register_operand" " 0, vr, 0, vr") @@ -5958,8 +5962,10 @@ (match_operand 6 "const_int_operand" " i, i, i, i") (match_operand 7 "const_int_operand" " i, i, i, i") (match_operand 8 "const_int_operand" " i, i, i, i") + (match_operand 9 "const_int_operand" " i, i, i, i") (reg:SI VL_REGNUM) - (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) + (reg:SI VTYPE_REGNUM) + (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE) (plus_minus:VF (mult:VF (match_operand:VF 2 "register_operand" " vr, vr, vr, vr") @@ -5989,8 +5995,10 @@ (match_operand 7 "const_int_operand" " i, i") (match_operand 8 "const_int_operand" " i, i") (match_operand 9 "const_int_operand" " i, i") + (match_operand 10 "const_int_operand" " i, i") (reg:SI VL_REGNUM) - (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) + (reg:SI VTYPE_REGNUM) + (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE) (plus_minus:VF (mult:VF (match_operand:VF 2 "register_operand" " vr, vr") @@ -6024,8 +6032,10 @@ (match_operand 7 "const_int_operand") (match_operand 8 "const_int_operand") (match_operand 9 "const_int_operand") + (match_operand 10 "const_int_operand") (reg:SI VL_REGNUM) - (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) + (reg:SI VTYPE_REGNUM) + (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE) (plus_minus:VF (mult:VF (vec_duplicate:VF @@ -6045,8 +6055,10 @@ (match_operand 6 "const_int_operand" " i, i, i, i") (match_operand 7 "const_int_operand" " i, i, i, i") (match_operand 8 "const_int_operand" " i, i, i, i") + (match_operand 9 "const_int_operand" " i, i, i, i") (reg:SI VL_REGNUM) - (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) + (reg:SI VTYPE_REGNUM) + (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE) (plus_minus:VF (mult:VF (vec_duplicate:VF @@ -6077,8 +6089,10 @@ (match_operand 6 "const_int_operand" " i, i, i, i") (match_operand 7 "const_int_operand" " i, i, i, i") (match_operand 8 "const_int_operand" " i, i, i, i") + (match_operand 9 "const_int_operand" " i, i, i, i") (reg:SI VL_REGNUM) - (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) + (reg:SI VTYPE_REGNUM) + (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE) (plus_minus:VF (mult:VF (vec_duplicate:VF @@ -6109,8 +6123,10 @@ (match_operand 7 "const_int_operand" " i, i") (match_operand 8 "const_int_operand" " i, i") (match_operand 9 "const_int_operand" " i, i") + (match_operand 10 "const_int_operand" " i, i") (reg:SI VL_REGNUM) - (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) + (reg:SI VTYPE_REGNUM) + (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE) (plus_minus:VF (mult:VF (vec_duplicate:VF @@ -6144,8 +6160,10 @@ (match_operand 7 "const_int_operand") (match_operand 8 "const_int_operand") (match_operand 9 "const_int_operand") + (match_operand 10 "const_int_operand") (reg:SI VL_REGNUM) - (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) + (reg:SI VTYPE_REGNUM) + (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE) (plus_minus:VF (neg:VF (mult:VF @@ -6170,8 +6188,10 @@ (match_operand 6 "const_int_operand" " i, i, i, i") (match_operand 7 "const_int_operand" " i, i, i, i") (match_operand 8 "const_int_operand" " i, i, i, i") + (match_operand 9 "const_int_operand" " i, i, i, i") (reg:SI VL_REGNUM) - (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) + (reg:SI VTYPE_REGNUM) + (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE) (plus_minus:VF (neg:VF (mult:VF @@ -6202,8 +6222,10 @@ (match_operand 6 "const_int_operand" " i, i, i, i") (match_operand 7 "const_int_operand" " i, i, i, i") (match_operand 8 "const_int_operand" " i, i, i, i") + (match_operand 9 "const_int_operand" " i, i, i, i") (reg:SI VL_REGNUM) - (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) + (reg:SI VTYPE_REGNUM) + (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE) (plus_minus:VF (neg:VF (mult:VF @@ -6234,8 +6256,10 @@ (match_operand 7 "const_int_operand" " i, i") (match_operand 8 "const_int_operand" " i, i") (match_operand 9 "const_int_operand" " i, i") + (match_operand 10 "const_int_operand" " i, i") (reg:SI VL_REGNUM) - (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) + (reg:SI VTYPE_REGNUM) + (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE) (plus_minus:VF (neg:VF (mult:VF @@ -6270,8 +6294,10 @@ (match_operand 7 "const_int_operand") (match_operand 8 "const_int_operand") (match_operand 9 "const_int_operand") + (match_operand 10 "const_int_operand") (reg:SI VL_REGNUM) - (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) + (reg:SI VTYPE_REGNUM) + (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE) (plus_minus:VF (neg:VF (mult:VF @@ -6292,8 +6318,10 @@ (match_operand 6 "const_int_operand" " i, i, i, i") (match_operand 7 "const_int_operand" " i, i, i, i") (match_operand 8 "const_int_operand" " i, i, i, i") + (match_operand 9 "const_int_operand" " i, i, i, i") (reg:SI VL_REGNUM) - (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) + (reg:SI VTYPE_REGNUM) + (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE) (plus_minus:VF (neg:VF (mult:VF @@ -6325,8 +6353,10 @@ (match_operand 6 "const_int_operand" " i, i, i, i") (match_operand 7 "const_int_operand" " i, i, i, i") (match_operand 8 "const_int_operand" " i, i, i, i") + (match_operand 9 "const_int_operand" " i, i, i, i") (reg:SI VL_REGNUM) - (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) + (reg:SI VTYPE_REGNUM) + (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE) (plus_minus:VF (neg:VF (mult:VF @@ -6358,8 +6388,10 @@ (match_operand 7 "const_int_operand" " i, i") (match_operand 8 "const_int_operand" " i, i") (match_operand 9 "const_int_operand" " i, i") + (match_operand 10 "const_int_operand" " i, i") (reg:SI VL_REGNUM) - (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) + (reg:SI VTYPE_REGNUM) + (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE) (plus_minus:VF (neg:VF (mult:VF