From: Andrew Pinski Date: Fri, 31 Mar 2023 00:00:20 +0000 (+0000) Subject: PHIOPT: Move tree_ssa_cs_elim into pass_cselim::execute. X-Git-Tag: basepoints/gcc-15~10088 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6c11d30799ff3160729315d07c3df641c3ca9870;p=thirdparty%2Fgcc.git PHIOPT: Move tree_ssa_cs_elim into pass_cselim::execute. This moves around the code for tree_ssa_cs_elim slightly improving code readability and removing declarations that are no longer needed. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * tree-ssa-phiopt.cc (tree_ssa_phiopt_worker): Remove declaration. (make_pass_phiopt): Make execute out of line. (tree_ssa_cs_elim): Move code into ... (pass_cselim::execute): here. --- diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 616b5778602a..945507be11e0 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -55,7 +55,6 @@ along with GCC; see the file COPYING3. If not see #include "tree-ssa-propagate.h" #include "tree-ssa-dce.h" -static unsigned int tree_ssa_phiopt_worker (bool, bool, bool); static bool two_value_replacement (basic_block, basic_block, edge, gphi *, tree, tree); static bool match_simplify_replacement (basic_block, basic_block, @@ -78,62 +77,6 @@ static hash_set * get_non_trapping (); static void hoist_adjacent_loads (basic_block, basic_block, basic_block, basic_block); -/* This pass tries to transform conditional stores into unconditional - ones, enabling further simplifications with the simpler then and else - blocks. In particular it replaces this: - - bb0: - if (cond) goto bb2; else goto bb1; - bb1: - *p = RHS; - bb2: - - with - - bb0: - if (cond) goto bb1; else goto bb2; - bb1: - condtmp' = *p; - bb2: - condtmp = PHI - *p = condtmp; - - This transformation can only be done under several constraints, - documented below. It also replaces: - - bb0: - if (cond) goto bb2; else goto bb1; - bb1: - *p = RHS1; - goto bb3; - bb2: - *p = RHS2; - bb3: - - with - - bb0: - if (cond) goto bb3; else goto bb1; - bb1: - bb3: - condtmp = PHI - *p = condtmp; */ - -static unsigned int -tree_ssa_cs_elim (void) -{ - unsigned todo; - /* ??? We are not interested in loop related info, but the following - will create it, ICEing as we didn't init loops with pre-headers. - An interfacing issue of find_data_references_in_bb. */ - loop_optimizer_init (LOOPS_NORMAL); - scev_initialize (); - todo = tree_ssa_phiopt_worker (true, false, false); - scev_finalize (); - loop_optimizer_finalize (); - return todo; -} - /* Return the singleton PHI in the SEQ of PHIs for edges E0 and E1. */ static gphi * @@ -4278,6 +4221,47 @@ make_pass_phiopt (gcc::context *ctxt) return new pass_phiopt (ctxt); } +/* This pass tries to transform conditional stores into unconditional + ones, enabling further simplifications with the simpler then and else + blocks. In particular it replaces this: + + bb0: + if (cond) goto bb2; else goto bb1; + bb1: + *p = RHS; + bb2: + + with + + bb0: + if (cond) goto bb1; else goto bb2; + bb1: + condtmp' = *p; + bb2: + condtmp = PHI + *p = condtmp; + + This transformation can only be done under several constraints, + documented below. It also replaces: + + bb0: + if (cond) goto bb2; else goto bb1; + bb1: + *p = RHS1; + goto bb3; + bb2: + *p = RHS2; + bb3: + + with + + bb0: + if (cond) goto bb3; else goto bb1; + bb1: + bb3: + condtmp = PHI + *p = condtmp; */ + namespace { const pass_data pass_data_cselim = @@ -4302,10 +4286,7 @@ public: /* opt_pass methods: */ bool gate (function *) final override { return flag_tree_cselim; } - unsigned int execute (function *) final override - { - return tree_ssa_cs_elim (); - } + unsigned int execute (function *) final override; }; // class pass_cselim @@ -4316,3 +4297,18 @@ make_pass_cselim (gcc::context *ctxt) { return new pass_cselim (ctxt); } + +unsigned int +pass_cselim::execute (function *) +{ + unsigned todo; + /* ??? We are not interested in loop related info, but the following + will create it, ICEing as we didn't init loops with pre-headers. + An interfacing issue of find_data_references_in_bb. */ + loop_optimizer_init (LOOPS_NORMAL); + scev_initialize (); + todo = tree_ssa_phiopt_worker (true, false, false); + scev_finalize (); + loop_optimizer_finalize (); + return todo; +}