From patchwork Mon Aug 21 01:04:53 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: 136303 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp2722485vqi; Sun, 20 Aug 2023 18:05:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFhOcPEG1fozFcFgNUl9y9/PGCNbTxMRQ2BI5mPY7SVo3ol5u/6hRjqrL25JETquZ/JmKxU X-Received: by 2002:a5d:494c:0:b0:319:68ba:7c8e with SMTP id r12-20020a5d494c000000b0031968ba7c8emr3556460wrs.38.1692579934465; Sun, 20 Aug 2023 18:05:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692579934; cv=none; d=google.com; s=arc-20160816; b=pxJgqXA3z67QQXwb4EgL8YX8FHVvQ9GZMLYn2YF98mRzib4bFk5DndhB04fFu/Xp8P vvpMOpbF1SehPOYX3fEB/IycHRQMTn2i6UjtIoxcsz6/BND31Vkb2GqfWyX9b+Zong8I MtQgU0OezbTj/YAXkhg9CMszI0dOvK5HokxgabB8O8Ia3AOpmx6wJcXiDzE7W8DcjhxC RaYPGyPA3brGuQ0WCkV7Fulz26NglaJN0hb9G9BiWCTR05omxNHGezUhVNqeyS1y6xgs wVhiltyaoQBL+D3XOFX/5pCNwnX7BUsuzMX59n+hnTNerRfVm/1KYx9kWjAPcGymsoCw GdcA== 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=huBYy++tRtpUJdthfarADjSQ5QyETm1saWO7C9xD90M=; fh=nNuj2Uqt9W0wtRbSLOHkQbsi22Jg4LUedYv5iAAeV3A=; b=PSqmIy62tIVaohscU77YK+WtqRUhjpxacVV/w8RkKOC9YB0ZZYQxsaBFMj+5O6W1BD OryBHzbYUcV+bh2qqUNPR+4g+helnFD2pZpp48JyaYkq05zF5ZvKO7TQU95wrLMKkfUE 4zmzJ/Ukhj0ZInA6XK171J3jhBiaQxfFZfrgrVoCw9VabU32q2paJNrRqVFQoDwCQEoO EdaQgyeQkcWi4ZnZXsDl7gay4scvlhvwUawgCzePBRNBNvUcMgIHWMxbXMeb1Byjmz0F p/33HBOHm0oIwl7270kmNkWxbOyfD3vST5xKXsmGog9ORFqz20lrhxZgdyyyQNOZ9/A3 uZLQ== 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 server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id s13-20020aa7c54d000000b005233ded4188si5057851edr.432.2023.08.20.18.05.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Aug 2023 18:05:34 -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 E75BF385B528 for ; Mon, 21 Aug 2023 01:05:30 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbgbr2.qq.com (smtpbgbr2.qq.com [54.207.22.56]) by sourceware.org (Postfix) with ESMTPS id 7C2943858C78 for ; Mon, 21 Aug 2023 01:05:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7C2943858C78 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: bizesmtp67t1692579896tnq5kevo Received: from rios-cad122.hadoop.rioslab.org ( [58.60.1.8]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 21 Aug 2023 09:04:55 +0800 (CST) X-QQ-SSF: 01400000000000G0V000000A0000000 X-QQ-FEAT: QityeSR92A0FLOAyflJ7kV9RmVfsjlfWQwKMMVeZxuAXfhQTymtTsKaMT+rgY aQR30FSCg8llCmjplV+dATCVwzlYV7dXgxTUhAp34KYrdothreNJKMBf35d5Am4wijQsUXS X5c7cOBhoHjlRCA7sVU2ackQwqP/DQZbrZ2RWIagSD3auafhwaUtPV4QH0GAqt3vhEonmEG 4QteEOsnGHhzqynz4z5htPxEP769iOE8t/60RDhJXJgNyr2Uo01+VL8zz3z6VcrUe+qi0Rc OkpF31vxMyjklsoc64vno08V9FmQq4AAkjjZhg6GkzTSKnTZ8FZpSjHSFJ+C6ACddMqWRMk gHB7BigATw9sT/wiKtw9bc8NGwNgKOCrZg5aS0Ux8P4LzrtS/8aAs5L9mKLzA== X-QQ-GoodBg: 2 X-BIZMAIL-ID: 10779854847428936559 From: Juzhe-Zhong To: gcc-patches@gcc.gnu.org Cc: rguenther@suse.de, jeffreyalaw@gmail.com, Juzhe-Zhong Subject: [PATCH] LCM: Export 2 helpful functions as global for VSETVL PASS use in RISC-V backend Date: Mon, 21 Aug 2023 09:04:53 +0800 Message-Id: <20230821010453.3916192-1-juzhe.zhong@rivai.ai> X-Mailer: git-send-email 2.36.3 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:rivai.ai:qybglogicsvrgz:qybglogicsvrgz7a-one-0 X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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: INBOX X-GMAIL-THRID: 1774798697401453505 X-GMAIL-MSGID: 1774798697401453505 This patch exports 'compute_antinout_edge' and 'compute_earliest' as global scope which is going to be used in VSETVL PASS of RISC-V backend. The demand fusion is the fusion of VSETVL information to emit VSETVL which dominate and pre-config for most of the RVV instructions in order to elide redundant VSETVLs. For exmaple: for for for if (cond} VSETVL demand 1: SEW/LMUL = 16 and TU policy else VSETVL demand 2: SEW = 32 VSETVL pass should be able to fuse demand 1 and demand 2 into new demand: SEW = 32, LMUL = M2, TU policy. Then emit such VSETVL at the outmost of the for loop to get the most optimal codegen and run-time execution. Currenty the VSETVL PASS Phase 3 (demand fusion) is really messy and un-reliable as well as un-maintainable. And, I recently read dragon book and morgan's book again, I found there "earliest" can allow us to do the demand fusion in a very reliable and optimal way. So, this patch exports these 2 functions which are very helpful for VSETVL pass. gcc/ChangeLog: * lcm.cc (compute_antinout_edge): Export as global use. (compute_earliest): Ditto. (compute_rev_insert_delete): Ditto. * lcm.h (compute_antinout_edge): Ditto. (compute_earliest): Ditto. --- gcc/lcm.cc | 7 ++----- gcc/lcm.h | 3 +++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gcc/lcm.cc b/gcc/lcm.cc index 94a3ed43aea..03421e490e4 100644 --- a/gcc/lcm.cc +++ b/gcc/lcm.cc @@ -56,9 +56,6 @@ along with GCC; see the file COPYING3. If not see #include "lcm.h" /* Edge based LCM routines. */ -static void compute_antinout_edge (sbitmap *, sbitmap *, sbitmap *, sbitmap *); -static void compute_earliest (struct edge_list *, int, sbitmap *, sbitmap *, - sbitmap *, sbitmap *, sbitmap *); static void compute_laterin (struct edge_list *, sbitmap *, sbitmap *, sbitmap *, sbitmap *); static void compute_insert_delete (struct edge_list *edge_list, sbitmap *, @@ -79,7 +76,7 @@ static void compute_rev_insert_delete (struct edge_list *edge_list, sbitmap *, This is done based on the flow graph, and not on the pred-succ lists. Other than that, its pretty much identical to compute_antinout. */ -static void +void compute_antinout_edge (sbitmap *antloc, sbitmap *transp, sbitmap *antin, sbitmap *antout) { @@ -170,7 +167,7 @@ compute_antinout_edge (sbitmap *antloc, sbitmap *transp, sbitmap *antin, /* Compute the earliest vector for edge based lcm. */ -static void +void compute_earliest (struct edge_list *edge_list, int n_exprs, sbitmap *antin, sbitmap *antout, sbitmap *avout, sbitmap *kill, sbitmap *earliest) diff --git a/gcc/lcm.h b/gcc/lcm.h index e08339352e0..7145d6fc46d 100644 --- a/gcc/lcm.h +++ b/gcc/lcm.h @@ -31,4 +31,7 @@ extern struct edge_list *pre_edge_rev_lcm (int, sbitmap *, sbitmap *, sbitmap *, sbitmap *, sbitmap **, sbitmap **); +extern void compute_antinout_edge (sbitmap *, sbitmap *, sbitmap *, sbitmap *); +extern void compute_earliest (struct edge_list *, int, sbitmap *, sbitmap *, + sbitmap *, sbitmap *, sbitmap *); #endif /* GCC_LCM_H */