PHIOPT: Move tree_ssa_cs_elim into pass_cselim::execute.

Message ID 20230418192136.286589-1-apinski@marvell.com
State Repeat Merge
Headers
Series PHIOPT: Move tree_ssa_cs_elim into pass_cselim::execute. |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Andrew Pinski April 18, 2023, 7:21 p.m. UTC
  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.
---
 gcc/tree-ssa-phiopt.cc | 118 ++++++++++++++++++++---------------------
 1 file changed, 57 insertions(+), 61 deletions(-)
  

Comments

Jeff Law April 18, 2023, 7:25 p.m. UTC | #1
On 4/18/23 13:21, Andrew Pinski via Gcc-patches wrote:
> 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.
OK
jeff
  

Patch

diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
index 616b5778602..945507be11e 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<tree> * 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 <RHS, condtmp'>
-       *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 <RHS1, RHS2>
-       *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 <RHS, condtmp'>
+       *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 <RHS1, RHS2>
+       *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;
+}