diff mbox

[2/6] Remove first_pass_instance from pass_reassoc

Message ID 56486598.6030905@mentor.com
State New
Headers show

Commit Message

Tom de Vries Nov. 15, 2015, 10:59 a.m. UTC
On 15/11/15 11:55, Tom de Vries wrote:
> [ was: Re: [PATCH] Remove first_pass_instance from pass_vrp ]
>
> This patch series removes first_pass_instance.
>
>       1    Remove first_pass_instance from pass_vrp
>       2    Remove first_pass_instance from pass_reassoc
>       3    Remove first_pass_instance from pass_dominator
>       4    Remove first_pass_instance from pass_object_sizes
>       5    Remove first_pass_instance from pass_ccp
>       6    Remove first_pass_instance
>
> Bootstrapped and reg-tested on x86_64.
>
> I will post the individual patches in reply to this email.
>
> [ I won't post the first patch though. It was already posted here:
> https://gcc.gnu.org/ml/gcc-patches/2015-11/msg01701.html . ]

this patch removes first_pass_instance from pass_reassoc.

Thanks,
- Tom
diff mbox

Patch

Remove first_pass_instance from pass_reassoc

2015-11-15  Tom de Vries  <tom@codesourcery.com>

	* passes.def: Add arg to pass_reassoc pass instantiation.
	* tree-ssa-reassoc.c (reassoc_insert_powi_p): New static variable.
	(acceptable_pow_call, reassociate_bb): Use reassoc_insert_powi_p instead
	of first_pass_instance.
	(execute_reassoc): Add and handle insert_powi_p parameter.
	(pass_reassoc::insert_powi_p): New private member.
	(pass_reassoc::pass_reassoc): Initialize insert_powi_p.
	(pass_reassoc::set_pass_param): New member function.  Set insert_powi_p.
	(pass_reassoc::execute): Call execute_reassoc with extra arg.

---
 gcc/passes.def         |  4 ++--
 gcc/tree-ssa-reassoc.c | 28 ++++++++++++++++++++++------
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/gcc/passes.def b/gcc/passes.def
index 64c1fa1..78fdf0f 100644
--- a/gcc/passes.def
+++ b/gcc/passes.def
@@ -205,7 +205,7 @@  along with GCC; see the file COPYING3.  If not see
 	 opportunities.  */
       NEXT_PASS (pass_phi_only_cprop);
       NEXT_PASS (pass_dse);
-      NEXT_PASS (pass_reassoc);
+      NEXT_PASS (pass_reassoc, true /* insert_powi_p */);
       NEXT_PASS (pass_dce);
       NEXT_PASS (pass_forwprop);
       NEXT_PASS (pass_phiopt);
@@ -276,7 +276,7 @@  along with GCC; see the file COPYING3.  If not see
       NEXT_PASS (pass_lower_vector_ssa);
       NEXT_PASS (pass_split_paths);
       NEXT_PASS (pass_cse_reciprocals);
-      NEXT_PASS (pass_reassoc);
+      NEXT_PASS (pass_reassoc, false /* insert_powi_p */);
       NEXT_PASS (pass_strength_reduction);
       NEXT_PASS (pass_tracer);
       NEXT_PASS (pass_dominator);
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index a75290c..6b08a59 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -172,6 +172,9 @@  along with GCC; see the file COPYING3.  If not see
     destructive update for the associating op, and keep the destructive
     update together for vector sum reduction recognition.  */
 
+/* Enable insertion of __builtin_powi calls during execute_reassoc.  See
+   point 3a in the pass header comment.  */
+static bool reassoc_insert_powi_p;
 
 /* Statistics */
 static struct
@@ -3940,7 +3943,7 @@  acceptable_pow_call (gimple *stmt, tree *base, HOST_WIDE_INT *exponent)
   tree fndecl, arg1;
   REAL_VALUE_TYPE c, cint;
 
-  if (!first_pass_instance
+  if (!reassoc_insert_powi_p
       || !flag_unsafe_math_optimizations
       || !is_gimple_call (stmt)
       || !has_single_use (gimple_call_lhs (stmt)))
@@ -4856,7 +4859,7 @@  reassociate_bb (basic_block bb)
 	      if (rhs_code == MULT_EXPR)
 		attempt_builtin_copysign (&ops);
 
-	      if (first_pass_instance
+	      if (reassoc_insert_powi_p
 		  && rhs_code == MULT_EXPR
 		  && flag_unsafe_math_optimizations)
 		powi_result = attempt_builtin_powi (stmt, &ops);
@@ -5111,11 +5114,14 @@  fini_reassoc (void)
   loop_optimizer_finalize ();
 }
 
-/* Gate and execute functions for Reassociation.  */
+/* Gate and execute functions for Reassociation.  If INSERT_POWI_P, enable
+   insertion of __builtin_powi calls.  */
 
 static unsigned int
-execute_reassoc (void)
+execute_reassoc (bool insert_powi_p)
 {
+  reassoc_insert_powi_p = insert_powi_p;
+
   init_reassoc ();
 
   do_reassoc ();
@@ -5145,14 +5151,24 @@  class pass_reassoc : public gimple_opt_pass
 {
 public:
   pass_reassoc (gcc::context *ctxt)
-    : gimple_opt_pass (pass_data_reassoc, ctxt)
+    : gimple_opt_pass (pass_data_reassoc, ctxt), insert_powi_p (false)
   {}
 
   /* opt_pass methods: */
   opt_pass * clone () { return new pass_reassoc (m_ctxt); }
+  void set_pass_param (unsigned int n, bool param)
+    {
+      gcc_assert (n == 0);
+      insert_powi_p = param;
+    }
   virtual bool gate (function *) { return flag_tree_reassoc != 0; }
-  virtual unsigned int execute (function *) { return execute_reassoc (); }
+  virtual unsigned int execute (function *)
+    { return execute_reassoc (insert_powi_p); }
 
+ private:
+  /* Enable insertion of __builtin_powi calls during execute_reassoc.  See
+     point 3a in the pass header comment.  */
+  bool insert_powi_p;
 }; // class pass_reassoc
 
 } // anon namespace