diff mbox

[tree-inline,obvious] Delete redundant count_insns_seq

Message ID 5602CDBA.8080001@arm.com
State New
Headers show

Commit Message

Kyrylo Tkachov Sept. 23, 2015, 4:05 p.m. UTC
Hi all,

I notice that the functions count_insns_seq and estimate_num_insns_seq perform the exact same function for exactly the same arguments.
It's redundant to keep both around. I've decided to delete count_insns_seq and replace its one use by estimate_num_insns_seq.

Bootstrapped and tested on aarch64, x86_64.
I think this change is obvious, so I'll commit it in 24 hours unless someone objects.

Thanks,
Kyrill

2015-09-23  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

     * tree-inline.h (count_insns_seq): Delete prototype.
     (estimate_num_insns_seq): Define prototype.
     * tree-inline.c (count_insns_seq): Delete.
     (estimate_num_insns_seq): Remove static qualifier.
     * tree-eh.c (decide_copy_try_finally): Replace use of count_insns_seq
     with estimate_num_insns_seq.

Comments

Jeff Law Sept. 23, 2015, 6:23 p.m. UTC | #1
On 09/23/2015 10:05 AM, Kyrill Tkachov wrote:
> Hi all,
>
> I notice that the functions count_insns_seq and estimate_num_insns_seq
> perform the exact same function for exactly the same arguments.
> It's redundant to keep both around. I've decided to delete
> count_insns_seq and replace its one use by estimate_num_insns_seq.
>
> Bootstrapped and tested on aarch64, x86_64.
> I think this change is obvious, so I'll commit it in 24 hours unless
> someone objects.
>
> Thanks,
> Kyrill
>
> 2015-09-23  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
>
>      * tree-inline.h (count_insns_seq): Delete prototype.
>      (estimate_num_insns_seq): Define prototype.
>      * tree-inline.c (count_insns_seq): Delete.
>      (estimate_num_insns_seq): Remove static qualifier.
>      * tree-eh.c (decide_copy_try_finally): Replace use of count_insns_seq
>      with estimate_num_insns_seq.
This is fine and I think would fall under the "obvious" rule.

Note that we don't have a "no objections" rule.

Jeff
diff mbox

Patch

commit b4266c4bd350628fe5d333998b7a76a7d4ab2ad5
Author: Kyrylo Tkachov <kyrylo.tkachov@arm.com>
Date:   Wed Sep 23 12:14:46 2015 +0100

    [tree-inline] Delete redundant count_insns_seq

diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index c19d2be..cb1f08a 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -1621,7 +1621,7 @@  decide_copy_try_finally (int ndests, bool may_throw, gimple_seq finally)
     }
 
   /* Finally estimate N times, plus N gotos.  */
-  f_estimate = count_insns_seq (finally, &eni_size_weights);
+  f_estimate = estimate_num_insns_seq (finally, &eni_size_weights);
   f_estimate = (f_estimate + 1) * ndests;
 
   /* Switch statement (cost 10), N variable assignments, N gotos.  */
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index abaea3f..36075b2 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -3972,8 +3972,8 @@  estimate_operator_cost (enum tree_code code, eni_weights *weights,
    the statements in the statement sequence STMTS.
    WEIGHTS contains weights attributed to various constructs.  */
 
-static
-int estimate_num_insns_seq (gimple_seq stmts, eni_weights *weights)
+int
+estimate_num_insns_seq (gimple_seq stmts, eni_weights *weights)
 {
   int cost;
   gimple_stmt_iterator gsi;
@@ -4262,19 +4262,6 @@  init_inline_once (void)
   eni_time_weights.return_cost = 2;
 }
 
-/* Estimate the number of instructions in a gimple_seq. */
-
-int
-count_insns_seq (gimple_seq seq, eni_weights *weights)
-{
-  gimple_stmt_iterator gsi;
-  int n = 0;
-  for (gsi = gsi_start (seq); !gsi_end_p (gsi); gsi_next (&gsi))
-    n += estimate_num_insns (gsi_stmt (gsi), weights);
-
-  return n;
-}
-
 
 /* Install new lexical TREE_BLOCK underneath 'current_block'.  */
 
diff --git a/gcc/tree-inline.h b/gcc/tree-inline.h
index f0e5436..b8fb2a2 100644
--- a/gcc/tree-inline.h
+++ b/gcc/tree-inline.h
@@ -207,7 +207,7 @@  tree copy_decl_no_change (tree decl, copy_body_data *id);
 int estimate_move_cost (tree type, bool);
 int estimate_num_insns (gimple *, eni_weights *);
 int estimate_num_insns_fn (tree, eni_weights *);
-int count_insns_seq (gimple_seq, eni_weights *);
+int estimate_num_insns_seq (gimple_seq, eni_weights *);
 bool tree_versionable_function_p (tree);
 extern tree remap_decl (tree decl, copy_body_data *id);
 extern tree remap_type (tree type, copy_body_data *id);