From patchwork Mon Jan 9 23:10:59 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: 41211 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2431215wrt; Mon, 9 Jan 2023 15:11:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXujbejRm5S70i1YawPn+ieVayhAJ/34pynpb4CUir5PygUa8AC7C4lPu8VM9mYQqAKStMQO X-Received: by 2002:a05:6402:35b:b0:488:e7ae:5cc4 with SMTP id r27-20020a056402035b00b00488e7ae5cc4mr34687274edw.41.1673305896452; Mon, 09 Jan 2023 15:11:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673305896; cv=none; d=google.com; s=arc-20160816; b=ToSseIUnue41xo7ErBfl9laHW1/J9bj6oURstUt1SKApFMb27lag9Mv/wzoY5/UfTG hKJII1epZoqjO1XmiX1L98HgLwCPg+2wHNyJGMi8kbvSz3D4iULOIgz0+4cq1t7Q41la 7pQx6RmkQkDeK4/7o3J9B8KJHWU/CcYd0GEtd1QMERtld2hDETFX7TUji9565TBlT8py pBgXEDQibmJElGpo485YrGEJzaULnNKgRWikGh2E4UKpEWWV4+adk0jEVh3eUNbL/f8S aRwTzPwKhf6qSZhaAyqmPZ28BX9qY8MM/8RPHI4JwL4LAadRlhVjo0tq3sBq3wxhqP4s jvoA== 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:message-id:date:subject:cc :to:from:dmarc-filter:delivered-to; bh=iNdLeNoEJ2ItkY5fT0ALvxOxBZs63vcAtGRDPraV8R8=; b=C6cFIjEFYfPOGOQHbqWPE84ADFoErGNN08/9e10IPPIbVqrIeC6sXN4TWblwE5vHMv S/G5f+DFADNd7PApghwKYiF0W6PCsjIIb7Ubf9HdjDjJJfIA+G40D3+QAvNbahsWfP99 WFEeawTfk20H8yctpP1rreZ/mLoHPscRyprZsmhkI95KKBsKbvP41e6AHSZnUJ99CwZT 424iRch0Fs1bkCQ69csmp3A8dnYL8zKsSYd/8Z+xeAfSBqyz/+6Zo6TLoxMEe3kk7+Bu n/qzJ6w/7dk4tiN86WzTVqnMZ1RkKsHRYWOQbx+OsBxHWX0pYrVElBW1oxj8g2AU5IHq YpQA== ARC-Authentication-Results: i=1; mx.google.com; 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" Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id eh9-20020a0564020f8900b00469322471e2si9427045edb.534.2023.01.09.15.11.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 15:11:36 -0800 (PST) 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; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 995713858404 for ; Mon, 9 Jan 2023 23:11:34 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbg150.qq.com (smtpbg150.qq.com [18.132.163.193]) by sourceware.org (Postfix) with ESMTPS id F14793858CDB for ; Mon, 9 Jan 2023 23:11:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F14793858CDB 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: bizesmtp77t1673305861tlpg6378 Received: from server1.localdomain ( [58.60.1.22]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 10 Jan 2023 07:11:00 +0800 (CST) X-QQ-SSF: 01400000002000E0L000B00A0000000 X-QQ-FEAT: /k/C/wqbhzgkxHQOp9QJrizH8pnXWlM15l/tT74vjjdjfbfWbPdlwn+CeFTWQ CIaULpMNGNWuuUX56caEPF44wuee1isihTz+ueGyTP/qegnpgxF5KFYvLxFF/d25VRWj/mr czaaTNWl0eapHyXn3GUlTIIO+LO8wp9xCkL6BeXsvzU34sTrfiUxbFLbyLETRfiUPjrhCY2 hDgpm0QIcj7klQ1W5475paIviBNwBa0awhw5aL2ceM+4EipCeGQZne1pbWQFqvz+x2B39nh o7PFEtOZ+8vR63x+TaJnKXW/iRtBXudNbJAWxw4pmE0hjJHfSTQh4/nyprFZZN+1YfxNu24 JZMLCR95NQeZyqkmLNh9G3JnoKAnbPtm7KZQxlZp/Cu2vxplcip1w/rbeKX6Rt25YCRlW0Y X-QQ-GoodBg: 2 From: juzhe.zhong@rivai.ai To: gcc-patches@gcc.gnu.org Cc: kito.cheng@gmail.com, palmer@dabbelt.com, Ju-Zhe Zhong Subject: [PATCH] RISC-V: Remove dirty_pat since it is redundant Date: Tue, 10 Jan 2023 07:10:59 +0800 Message-Id: <20230109231059.154229-1-juzhe.zhong@rivai.ai> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:rivai.ai:qybglogicsvr:qybglogicsvr7 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 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?1754588403266197618?= X-GMAIL-MSGID: =?utf-8?q?1754588403266197618?= From: Ju-Zhe Zhong gcc/ChangeLog: * config/riscv/riscv-vsetvl.cc (vector_insn_info::operator==): Remove dirty_pat. (vector_insn_info::merge): Ditto. (vector_insn_info::dump): Ditto. (pass_vsetvl::merge_successors): Ditto. (pass_vsetvl::backward_demand_fusion): Ditto. (pass_vsetvl::forward_demand_fusion): Ditto. (pass_vsetvl::commit_vsetvls): Ditto. * config/riscv/riscv-vsetvl.h: Ditto. --- gcc/config/riscv/riscv-vsetvl.cc | 28 ++++++++++++---------------- gcc/config/riscv/riscv-vsetvl.h | 11 +---------- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc index 3c920779992..0f12d4ddb23 100644 --- a/gcc/config/riscv/riscv-vsetvl.cc +++ b/gcc/config/riscv/riscv-vsetvl.cc @@ -1083,10 +1083,10 @@ vector_insn_info::operator== (const vector_insn_info &other) const if (m_demands[i] != other.demand_p ((enum demand_type) i)) return false; - if (m_insn != other.get_insn ()) - return false; - if (m_dirty_pat != other.get_dirty_pat ()) - return false; + if (vector_config_insn_p (m_insn->rtl ()) + || vector_config_insn_p (other.get_insn ()->rtl ())) + if (m_insn != other.get_insn ()) + return false; if (!same_avl_p (other)) return false; @@ -1317,8 +1317,6 @@ vector_insn_info::merge (const vector_insn_info &merge_info, new_info.set_insn (merge_info.get_insn ()); } - new_info.set_dirty_pat (merge_info.get_dirty_pat ()); - if (!demand_p (DEMAND_AVL) && !merge_info.demand_p (DEMAND_AVL)) new_info.undemand (DEMAND_AVL); if (!demand_p (DEMAND_SEW) && !merge_info.demand_p (DEMAND_SEW)) @@ -1431,11 +1429,6 @@ vector_insn_info::dump (FILE *file) const fprintf (file, "The real INSN="); print_rtl_single (file, get_insn ()->rtl ()); } - if (get_dirty_pat ()) - { - fprintf (file, "Dirty RTL Pattern="); - print_rtl_single (file, get_dirty_pat ()); - } } } @@ -1967,7 +1960,6 @@ pass_vsetvl::merge_successors (const basic_block father, new_info.set_dirty (); rtx new_pat = gen_vsetvl_pat (new_info.get_insn ()->rtl (), new_info); - new_info.set_dirty_pat (new_pat); father_info.local_dem = new_info; father_info.reaching_out = new_info; @@ -2051,7 +2043,6 @@ pass_vsetvl::backward_demand_fusion (void) block_info.reaching_out = prop; block_info.reaching_out.set_dirty (); - block_info.reaching_out.set_dirty_pat (new_pat); block_info.local_dem = block_info.reaching_out; changed_p = true; } @@ -2080,7 +2071,6 @@ pass_vsetvl::backward_demand_fusion (void) rtx new_pat = gen_vsetvl_pat (new_info.get_insn ()->rtl (), new_info); new_info.set_dirty (); - new_info.set_dirty_pat (new_pat); block_info.local_dem = new_info; block_info.reaching_out = new_info; changed_p = true; @@ -2178,7 +2168,6 @@ pass_vsetvl::forward_demand_fusion (void) = gen_vsetvl_pat (prop.get_insn ()->rtl (), prop); local_dem = prop; local_dem.set_dirty (); - local_dem.set_dirty_pat (dirty_pat); reaching_out = local_dem; } else @@ -2507,10 +2496,17 @@ pass_vsetvl::commit_vsetvls (void) if (!reaching_out.dirty_p ()) continue; - rtx new_pat = reaching_out.get_dirty_pat (); + + rtx new_pat; if (can_refine_vsetvl_p (cfg_bb, reaching_out.get_ratio ())) new_pat = gen_vsetvl_pat (VSETVL_VTYPE_CHANGE_ONLY, reaching_out, NULL_RTX); + else if (vlmax_avl_p (reaching_out.get_avl ())) + new_pat = gen_vsetvl_pat (VSETVL_NORMAL, reaching_out, + get_vl (reaching_out.get_insn ()->rtl ())); + else + new_pat + = gen_vsetvl_pat (VSETVL_DISCARD_RESULT, reaching_out, NULL_RTX); start_sequence (); emit_insn (new_pat); diff --git a/gcc/config/riscv/riscv-vsetvl.h b/gcc/config/riscv/riscv-vsetvl.h index dc16c55b918..563ad3084ed 100644 --- a/gcc/config/riscv/riscv-vsetvl.h +++ b/gcc/config/riscv/riscv-vsetvl.h @@ -220,13 +220,6 @@ private: (with AVL included) before vmv.x.s, but vmv.x.s is not the INSN holding the definition of AVL. */ rtl_ssa::insn_info *m_insn; - /* Save instruction pattern for Dirty block. - Since empty block may be polluted as a dirty block during dem backward - propagation (phase 3) which is intending to cheat LCM there is a VSETVL - instruction here to gain better LCM optimization. Such instruction is not - emit yet, we save this here and then emit it in the 4th phase if it is - necessary. */ - rtx m_dirty_pat; /* Parse the instruction to get VL/VTYPE information and demanding * information. */ @@ -243,7 +236,7 @@ private: public: vector_insn_info () : vl_vtype_info (), m_state (UNINITIALIZED), m_demands{false}, - m_insn (nullptr), m_dirty_pat (NULL_RTX) + m_insn (nullptr) {} bool operator> (const vector_insn_info &) const; @@ -271,7 +264,6 @@ public: void set_unknown () { m_state = UNKNOWN; } void set_empty () { m_state = EMPTY; } void set_dirty () { m_state = DIRTY; } - void set_dirty_pat (rtx pat) { m_dirty_pat = pat; } void set_insn (rtl_ssa::insn_info *insn) { m_insn = insn; } void set_demand_info (const vector_insn_info &); @@ -287,7 +279,6 @@ public: vector_insn_info merge (const vector_insn_info &, bool) const; rtl_ssa::insn_info *get_insn () const { return m_insn; } - rtx get_dirty_pat () const { return m_dirty_pat; } void dump (FILE *) const; };