From patchwork Fri Sep 2 12:55:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 929 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp716900wro; Fri, 2 Sep 2022 05:56:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR4TLPKjFeoeWQesMQl6+oZyqoXvmnbMegPGEAAgWU2d89xbRESO1lf6s1XbCKzoJXH4SZis X-Received: by 2002:aa7:d913:0:b0:447:bac0:4ea9 with SMTP id a19-20020aa7d913000000b00447bac04ea9mr32413231edr.426.1662123362080; Fri, 02 Sep 2022 05:56:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662123362; cv=none; d=google.com; s=arc-20160816; b=n4o7I9ueyalXceqE4TVRCB3X0WH3DDvVcUBXL6gH331MWzXxM3uPDq1exLMtCmbG+O kK5eCJfOgb+CaErSNicM8xZxMVXSgGeHvUrIgpSmp0W0X2uMuqepk2PZCv5aTnS3+3v9 ivWKvkv1sOjpYq9ujJwak0mzCaSCe+9oVghQfTBTFziz2qKV8QpFP6mtahEm+X7L0dvZ auj72hLibudZbFcWvOnvUxhXfYdYK/y6Z1Y3d+gzycdxcvBYZh8MQrQCk0cYJV2ObZLQ VgmdROZbuFP9+8YDOZCZhlQCdxuZFBExmL9S+9nbNhfltmJsUw8SSZA/pg6DrN5XIS1x iV5A== 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:message-id :mime-version:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=7bJd9gCU3irRSXtKvb3LNzylJLb8hXexAJPfhJSr8O4=; b=sjlRxeMjcNvLlol9QAfDE9AI3NLwP1uCAiprZiJi7MRlT5+csYKt/pMvZlZnwA1alB iASA5KD0F7dInuYRCJehfCrVvw5tmed/fzLLTZoAyfpBlntCgA060EZ79037fvn49G79 qr2H9oPXVbykwxypQXFGpAU103Qrv/JyJgDsiDIxopu0rzGp2bd2KX1aaU/TKFRCXPR4 iyEW+JIdXRem9Ue0TuAbd6eqiwonehaoJZt7slVP9pmFGEJJIkZ2Ey0AYDkA9utcNkoo lTKeYJbKDNQx8RviZQxnFClaiNOiC1mS7IvCiSCtgH3h6wxvf5U7J7MXtLBJ/b7STTmB 9STA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=am+LVcTR; 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 sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id oz10-20020a1709077d8a00b0073d70b7bfb6si2280441ejc.277.2022.09.02.05.56.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 05:56:02 -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=am+LVcTR; 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 0D28638582B5 for ; Fri, 2 Sep 2022 12:56:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0D28638582B5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662123361; bh=7bJd9gCU3irRSXtKvb3LNzylJLb8hXexAJPfhJSr8O4=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=am+LVcTRPvYT6j06ImXmGD7GCcUY8W+B73yG3D/Db6ZOhU6KuxzHxRjtge/1ugAYI 2g+2ZhnuTyZ8yDAwRWUSwuJ4Qso8Yrog7EQFKUVYDpKcSDHNQimP+6mJROEa772NuJ g6D4MpxMbHbVOkGjCMRKn8omUPuRyDRdv5lcmN6g= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 762A83858C54 for ; Fri, 2 Sep 2022 12:55:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 762A83858C54 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 2B7FE5BE5A for ; Fri, 2 Sep 2022 12:55:15 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 195C91330E for ; Fri, 2 Sep 2022 12:55:15 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id rH8qBTP9EWOlcgAAMHmgww (envelope-from ) for ; Fri, 02 Sep 2022 12:55:15 +0000 Date: Fri, 2 Sep 2022 14:55:14 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Refactor RPO VN API to allow timevar tracking MIME-Version: 1.0 Message-Id: <20220902125515.195C91330E@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, 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: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener 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?1742862666481850720?= X-GMAIL-MSGID: =?utf-8?q?1742862666481850720?= The following refactors things sligtly so "utility" use of the RPO VN machinery gets its own timevar when invoked from other passes. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. * timevar.def (TV_TREE_RPO_VN): New. * tree-ssa-sccvn.c (do_rpo_vn): Remove one overload. * tree-ssa-sccvn.c (do_rpo_vn_1): Rename the worker. (do_rpo_vn): Unify the public API, track with TV_TREE_RPO_VN. (pass_fre::execute): Adjust. * tree-ssa-uninit.cc (execute_early_warn_uninitialized): Adjust. --- gcc/timevar.def | 1 + gcc/tree-ssa-sccvn.cc | 28 +++++++++++++++++----------- gcc/tree-ssa-sccvn.h | 8 ++++++-- gcc/tree-ssa-uninit.cc | 5 +---- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/gcc/timevar.def b/gcc/timevar.def index 651af19876f..eac4370431f 100644 --- a/gcc/timevar.def +++ b/gcc/timevar.def @@ -176,6 +176,7 @@ DEFTIMEVAR (TV_TREE_SPLIT_EDGES , "tree split crit edges") DEFTIMEVAR (TV_TREE_REASSOC , "tree reassociation") DEFTIMEVAR (TV_TREE_PRE , "tree PRE") DEFTIMEVAR (TV_TREE_FRE , "tree FRE") +DEFTIMEVAR (TV_TREE_RPO_VN , "tree RPO VN") DEFTIMEVAR (TV_TREE_SINK , "tree code sinking") DEFTIMEVAR (TV_TREE_PHIOPT , "tree linearize phis") DEFTIMEVAR (TV_TREE_BACKPROP , "tree backward propagate") diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc index 5abc8667ce6..74b8d8d18ef 100644 --- a/gcc/tree-ssa-sccvn.cc +++ b/gcc/tree-ssa-sccvn.cc @@ -7290,14 +7290,14 @@ eliminate_with_rpo_vn (bitmap inserted_exprs) return walker.eliminate_cleanup (); } -unsigned -do_rpo_vn (function *fn, edge entry, bitmap exit_bbs, - bool iterate, bool eliminate, vn_lookup_kind kind); +static unsigned +do_rpo_vn_1 (function *fn, edge entry, bitmap exit_bbs, + bool iterate, bool eliminate, vn_lookup_kind kind); void run_rpo_vn (vn_lookup_kind kind) { - do_rpo_vn (cfun, NULL, NULL, true, false, kind); + do_rpo_vn_1 (cfun, NULL, NULL, true, false, kind); /* ??? Prune requirement of these. */ constant_to_value_id = new hash_table (23); @@ -7995,9 +7995,9 @@ do_unwind (unwind_state *to, rpo_elim &avail) executed and iterate. If ELIMINATE is true then perform elimination, otherwise leave that to the caller. */ -unsigned -do_rpo_vn (function *fn, edge entry, bitmap exit_bbs, - bool iterate, bool eliminate, vn_lookup_kind kind) +static unsigned +do_rpo_vn_1 (function *fn, edge entry, bitmap exit_bbs, + bool iterate, bool eliminate, vn_lookup_kind kind) { unsigned todo = 0; default_vn_walk_kind = kind; @@ -8415,12 +8415,18 @@ do_rpo_vn (function *fn, edge entry, bitmap exit_bbs, /* Region-based entry for RPO VN. Performs value-numbering and elimination on the SEME region specified by ENTRY and EXIT_BBS. If ENTRY is not the only edge into the region at ENTRY->dest PHI nodes in ENTRY->dest - are not considered. */ + are not considered. + If ITERATE is true then treat backedges optimistically as not + executed and iterate. If ELIMINATE is true then perform + elimination, otherwise leave that to the caller. + KIND specifies the amount of work done for handling memory operations. */ unsigned -do_rpo_vn (function *fn, edge entry, bitmap exit_bbs) +do_rpo_vn (function *fn, edge entry, bitmap exit_bbs, + bool iterate, bool eliminate, vn_lookup_kind kind) { - unsigned todo = do_rpo_vn (fn, entry, exit_bbs, false, true, VN_WALKREWRITE); + auto_timevar tv (TV_TREE_RPO_VN); + unsigned todo = do_rpo_vn_1 (fn, entry, exit_bbs, iterate, eliminate, kind); free_rpo_vn (); return todo; } @@ -8476,7 +8482,7 @@ pass_fre::execute (function *fun) if (iterate_p) loop_optimizer_init (AVOID_CFG_MODIFICATIONS); - todo = do_rpo_vn (fun, NULL, NULL, iterate_p, true, VN_WALKREWRITE); + todo = do_rpo_vn_1 (fun, NULL, NULL, iterate_p, true, VN_WALKREWRITE); free_rpo_vn (); if (iterate_p) diff --git a/gcc/tree-ssa-sccvn.h b/gcc/tree-ssa-sccvn.h index a1b1e6bdd1e..abcf7e666c2 100644 --- a/gcc/tree-ssa-sccvn.h +++ b/gcc/tree-ssa-sccvn.h @@ -295,8 +295,12 @@ value_id_constant_p (unsigned int v) tree fully_constant_vn_reference_p (vn_reference_t); tree vn_nary_simplify (vn_nary_op_t); -unsigned do_rpo_vn (function *, edge, bitmap, bool, bool, vn_lookup_kind); -unsigned do_rpo_vn (function *, edge, bitmap); +unsigned do_rpo_vn (function *, edge, bitmap, + /* iterate */ bool = false, + /* eliminate */ bool = true, + vn_lookup_kind = VN_WALKREWRITE); + +/* Private interface for PRE. */ void run_rpo_vn (vn_lookup_kind); unsigned eliminate_with_rpo_vn (bitmap); void free_rpo_vn (void); diff --git a/gcc/tree-ssa-uninit.cc b/gcc/tree-ssa-uninit.cc index c25fbe6381e..29dc48c4a29 100644 --- a/gcc/tree-ssa-uninit.cc +++ b/gcc/tree-ssa-uninit.cc @@ -1466,10 +1466,7 @@ execute_early_warn_uninitialized (struct function *fun) elimination to compute edge reachability. Don't bother when we only warn for unconditionally executed code though. */ if (!optimize) - { - do_rpo_vn (fun, NULL, NULL, false, false, VN_NOWALK); - free_rpo_vn (); - } + do_rpo_vn (fun, NULL, NULL, false, false, VN_NOWALK); else set_all_edges_as_executable (fun);