Discussion:
[PATCH] Clean up duplicated function seq_cost
Zhenqiang Chen
2014-10-09 09:14:01 UTC
Permalink
Hi,

The are two implementations of seq_cost. The function bodies are exactly the
same. The patch removes one of them and make the other global.

Bootstrap and no make check regression on X86-64.

OK for trunk?

Thanks!
-Zhenqiang

ChangeLog:
2014-10-09 Zhenqiang Chen <***@arm.com>

* cfgloopanal.c (seq_cost): Make it global.
* rtl.h (seq_cost): New prototype.
* tree-ssa-loop-ivopts.c (seq_cost): Delete.

diff --git a/gcc/cfgloopanal.c b/gcc/cfgloopanal.c
index 7ea1a5f..dd37aa0 100644
--- a/gcc/cfgloopanal.c
+++ b/gcc/cfgloopanal.c
@@ -304,7 +304,7 @@ get_loop_level (const struct loop *loop)

/* Returns estimate on cost of computing SEQ. */

-static unsigned
+unsigned
seq_cost (const rtx_insn *seq, bool speed)
{
unsigned cost = 0;
diff --git a/gcc/rtl.h b/gcc/rtl.h
index e73f731..b697417 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2921,6 +2921,7 @@ extern rtx_insn *find_first_parameter_load (rtx_insn
*, rtx_insn *);
extern bool keep_with_call_p (const rtx_insn *);
extern bool label_is_jump_target_p (const_rtx, const rtx_insn *);
extern int insn_rtx_cost (rtx, bool);
+extern unsigned seq_cost (const rtx_insn *, bool);

/* Given an insn and condition, return a canonical description of
the test being made. */
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 400798a..087ca26 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -2842,26 +2842,6 @@ get_use_iv_cost (struct ivopts_data *data, struct
iv_use *use,
return NULL;
}

-/* Returns estimate on cost of computing SEQ. */
-
-static unsigned
-seq_cost (rtx_insn *seq, bool speed)
-{
- unsigned cost = 0;
- rtx set;
-
- for (; seq; seq = NEXT_INSN (seq))
- {
- set = single_set (seq);
- if (set)
- cost += set_src_cost (SET_SRC (set), speed);
- else
- cost++;
- }
-
- return cost;
-}
-
/* Produce DECL_RTL for object obj so it looks like it is stored in memory.
*/
static rtx
produce_memory_decl_rtl (tree obj, int *regno)
Richard Biener
2014-10-09 09:20:34 UTC
Permalink
Post by Zhenqiang Chen
Hi,
The are two implementations of seq_cost. The function bodies are exactly the
same. The patch removes one of them and make the other global.
Bootstrap and no make check regression on X86-64.
OK for trunk?
The prototype should go to cfgloopanal.c.

Thanks,
RIchard.
Post by Zhenqiang Chen
Thanks!
-Zhenqiang
* cfgloopanal.c (seq_cost): Make it global.
* rtl.h (seq_cost): New prototype.
* tree-ssa-loop-ivopts.c (seq_cost): Delete.
diff --git a/gcc/cfgloopanal.c b/gcc/cfgloopanal.c
index 7ea1a5f..dd37aa0 100644
--- a/gcc/cfgloopanal.c
+++ b/gcc/cfgloopanal.c
@@ -304,7 +304,7 @@ get_loop_level (const struct loop *loop)
/* Returns estimate on cost of computing SEQ. */
-static unsigned
+unsigned
seq_cost (const rtx_insn *seq, bool speed)
{
unsigned cost = 0;
diff --git a/gcc/rtl.h b/gcc/rtl.h
index e73f731..b697417 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2921,6 +2921,7 @@ extern rtx_insn *find_first_parameter_load (rtx_insn
*, rtx_insn *);
extern bool keep_with_call_p (const rtx_insn *);
extern bool label_is_jump_target_p (const_rtx, const rtx_insn *);
extern int insn_rtx_cost (rtx, bool);
+extern unsigned seq_cost (const rtx_insn *, bool);
/* Given an insn and condition, return a canonical description of
the test being made. */
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 400798a..087ca26 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -2842,26 +2842,6 @@ get_use_iv_cost (struct ivopts_data *data, struct
iv_use *use,
return NULL;
}
-/* Returns estimate on cost of computing SEQ. */
-
-static unsigned
-seq_cost (rtx_insn *seq, bool speed)
-{
- unsigned cost = 0;
- rtx set;
-
- for (; seq; seq = NEXT_INSN (seq))
- {
- set = single_set (seq);
- if (set)
- cost += set_src_cost (SET_SRC (set), speed);
- else
- cost++;
- }
-
- return cost;
-}
-
/* Produce DECL_RTL for object obj so it looks like it is stored in memory.
*/
static rtx
produce_memory_decl_rtl (tree obj, int *regno)
Richard Biener
2014-10-09 09:21:20 UTC
Permalink
On Thu, Oct 9, 2014 at 11:20 AM, Richard Biener
Post by Richard Biener
Post by Zhenqiang Chen
Hi,
The are two implementations of seq_cost. The function bodies are exactly the
same. The patch removes one of them and make the other global.
Bootstrap and no make check regression on X86-64.
OK for trunk?
The prototype should go to cfgloopanal.c.
Err - cfgloopanal.h of course ;) Or rather the function sounds misplaced
in cfgloopanal.c.

Richard.
Post by Richard Biener
Thanks,
RIchard.
Post by Zhenqiang Chen
Thanks!
-Zhenqiang
* cfgloopanal.c (seq_cost): Make it global.
* rtl.h (seq_cost): New prototype.
* tree-ssa-loop-ivopts.c (seq_cost): Delete.
diff --git a/gcc/cfgloopanal.c b/gcc/cfgloopanal.c
index 7ea1a5f..dd37aa0 100644
--- a/gcc/cfgloopanal.c
+++ b/gcc/cfgloopanal.c
@@ -304,7 +304,7 @@ get_loop_level (const struct loop *loop)
/* Returns estimate on cost of computing SEQ. */
-static unsigned
+unsigned
seq_cost (const rtx_insn *seq, bool speed)
{
unsigned cost = 0;
diff --git a/gcc/rtl.h b/gcc/rtl.h
index e73f731..b697417 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2921,6 +2921,7 @@ extern rtx_insn *find_first_parameter_load (rtx_insn
*, rtx_insn *);
extern bool keep_with_call_p (const rtx_insn *);
extern bool label_is_jump_target_p (const_rtx, const rtx_insn *);
extern int insn_rtx_cost (rtx, bool);
+extern unsigned seq_cost (const rtx_insn *, bool);
/* Given an insn and condition, return a canonical description of
the test being made. */
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 400798a..087ca26 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -2842,26 +2842,6 @@ get_use_iv_cost (struct ivopts_data *data, struct
iv_use *use,
return NULL;
}
-/* Returns estimate on cost of computing SEQ. */
-
-static unsigned
-seq_cost (rtx_insn *seq, bool speed)
-{
- unsigned cost = 0;
- rtx set;
-
- for (; seq; seq = NEXT_INSN (seq))
- {
- set = single_set (seq);
- if (set)
- cost += set_src_cost (SET_SRC (set), speed);
- else
- cost++;
- }
-
- return cost;
-}
-
/* Produce DECL_RTL for object obj so it looks like it is stored in memory.
*/
static rtx
produce_memory_decl_rtl (tree obj, int *regno)
Loading...