From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 53B1B38582BF; Fri, 2 Sep 2022 12:56:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 53B1B38582BF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662123365; bh=94bNhDGk70yEhqM0KpTrPUsd2fSTs6XYzDduQCgpcyU=; h=From:To:Subject:Date:From; b=ysgQcAtfwFpQSn50TNQIg5UXB1nUWX6DEfq03H6174J8iITfax53xhXXZG7arCF4O otL6sFwmRPPeub+v481r+uHBmSMBv7IRONLciLBBTNJpvOw3u5nbNLuTiahzb3twhz 3O+NaPUvLw5CG0gRd1f+HB5NJrGvN7xRvjmT1M9g= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-2376] Refactor RPO VN API to allow timevar tracking X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: be1b42de9c151d46c89f9a8f82d4c5839a19ea94 X-Git-Newrev: 805c91843f2f8fc73d17a07d1545cc6ddcbd8935 Message-Id: <20220902125605.53B1B38582BF@sourceware.org> Date: Fri, 2 Sep 2022 12:56:05 +0000 (GMT) List-Id: https://gcc.gnu.org/g:805c91843f2f8fc73d17a07d1545cc6ddcbd8935 commit r13-2376-g805c91843f2f8fc73d17a07d1545cc6ddcbd8935 Author: Richard Biener Date: Fri Sep 2 14:10:40 2022 +0200 Refactor RPO VN API to allow timevar tracking The following refactors things sligtly so "utility" use of the RPO VN machinery gets its own timevar when invoked from other passes. * timevar.def (TV_TREE_RPO_VN): New. * tree-ssa-sccvn.h (do_rpo_vn): Remove one overload. * tree-ssa-sccvn.cc (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. Diff: --- 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);