public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Clean up duplicated function seq_cost
@ 2014-10-09  9:14 Zhenqiang Chen
  2014-10-09  9:21 ` Richard Biener
  0 siblings, 1 reply; 5+ messages in thread
From: Zhenqiang Chen @ 2014-10-09  9:14 UTC (permalink / raw)
  To: gcc-patches

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  <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)



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Clean up duplicated function seq_cost
  2014-10-09  9:14 [PATCH] Clean up duplicated function seq_cost Zhenqiang Chen
@ 2014-10-09  9:21 ` Richard Biener
  2014-10-09  9:24   ` Richard Biener
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Biener @ 2014-10-09  9:21 UTC (permalink / raw)
  To: Zhenqiang Chen; +Cc: GCC Patches

On Thu, Oct 9, 2014 at 11:14 AM, Zhenqiang Chen <zhenqiang.chen@arm.com> wrote:
> 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.

> Thanks!
> -Zhenqiang
>
> ChangeLog:
> 2014-10-09  Zhenqiang Chen  <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)
>
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Clean up duplicated function seq_cost
  2014-10-09  9:21 ` Richard Biener
@ 2014-10-09  9:24   ` Richard Biener
  2014-10-10  8:40     ` Zhenqiang Chen
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Biener @ 2014-10-09  9:24 UTC (permalink / raw)
  To: Zhenqiang Chen; +Cc: GCC Patches

On Thu, Oct 9, 2014 at 11:20 AM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Thu, Oct 9, 2014 at 11:14 AM, Zhenqiang Chen <zhenqiang.chen@arm.com> wrote:
>> 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.

>
> Thanks,
> RIchard.
>
>> Thanks!
>> -Zhenqiang
>>
>> ChangeLog:
>> 2014-10-09  Zhenqiang Chen  <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)
>>
>>
>>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] Clean up duplicated function seq_cost
  2014-10-09  9:24   ` Richard Biener
@ 2014-10-10  8:40     ` Zhenqiang Chen
  2014-10-10 16:30       ` Jeff Law
  0 siblings, 1 reply; 5+ messages in thread
From: Zhenqiang Chen @ 2014-10-10  8:40 UTC (permalink / raw)
  To: 'Richard Biener'; +Cc: GCC Patches


> -----Original Message-----
> From: Richard Biener [mailto:richard.guenther@gmail.com]
> Sent: Thursday, October 09, 2014 5:21 PM
> To: Zhenqiang Chen
> Cc: GCC Patches
> Subject: Re: [PATCH] Clean up duplicated function seq_cost
> 
> On Thu, Oct 9, 2014 at 11:20 AM, Richard Biener
> <richard.guenther@gmail.com> wrote:
> > On Thu, Oct 9, 2014 at 11:14 AM, Zhenqiang Chen
> <zhenqiang.chen@arm.com> wrote:
> >> 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.

Thanks for the comments. I think seq_cost should be in rtlanal.c, just like rtx_cost, insn_rtx_cost and so on.

ChangeLog:
2014-10-10  Zhenqiang Chen  <zhenqiang.chen@arm.com>

	* cfgloopanal.c (seq_cost): Delete.
	* rtl.h (seq_cost): New prototype.
	* rtlanal.c (seq_cost): New function.
	* tree-ssa-loop-ivopts.c (seq_cost): Delete.

diff --git a/gcc/cfgloopanal.c b/gcc/cfgloopanal.c
index 7ea1a5f..006b419 100644
--- a/gcc/cfgloopanal.c
+++ b/gcc/cfgloopanal.c
@@ -302,26 +302,6 @@ get_loop_level (const struct loop *loop)
   return mx;
 }
 
-/* Returns estimate on cost of computing SEQ.  */
-
-static unsigned
-seq_cost (const rtx_insn *seq, bool speed)
-{
-  unsigned cost = 0;
-  rtx set;
-
-  for (; seq; seq = NEXT_INSN (seq))
-    {
-      set = single_set (seq);
-      if (set)
-	cost += set_rtx_cost (set, speed);
-      else
-	cost++;
-    }
-
-  return cost;
-}
-
 /* Initialize the constants for computing set costs.  */
 
 void
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/rtlanal.c b/gcc/rtlanal.c
index 3063458..93eda12 100644
--- a/gcc/rtlanal.c
+++ b/gcc/rtlanal.c
@@ -5017,6 +5017,26 @@ insn_rtx_cost (rtx pat, bool speed)
   return cost > 0 ? cost : COSTS_N_INSNS (1);
 }
 
+/* Returns estimate on cost of computing SEQ.  */
+
+unsigned
+seq_cost (const rtx_insn *seq, bool speed)
+{
+  unsigned cost = 0;
+  rtx set;
+
+  for (; seq; seq = NEXT_INSN (seq))
+    {
+      set = single_set (seq);
+      if (set)
+        cost += set_rtx_cost (set, speed);
+      else
+        cost++;
+    }
+
+  return cost;
+}
+
 /* Given an insn INSN and condition COND, return the condition in a
    canonical form to simplify testing by callers.  Specifically:
 
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)




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Clean up duplicated function seq_cost
  2014-10-10  8:40     ` Zhenqiang Chen
@ 2014-10-10 16:30       ` Jeff Law
  0 siblings, 0 replies; 5+ messages in thread
From: Jeff Law @ 2014-10-10 16:30 UTC (permalink / raw)
  To: Zhenqiang Chen, 'Richard Biener'; +Cc: GCC Patches

On 10/10/14 02:17, Zhenqiang Chen wrote:
>
>> -----Original Message-----
>> From: Richard Biener [mailto:richard.guenther@gmail.com]
>> Sent: Thursday, October 09, 2014 5:21 PM
>> To: Zhenqiang Chen
>> Cc: GCC Patches
>> Subject: Re: [PATCH] Clean up duplicated function seq_cost
>>
>> On Thu, Oct 9, 2014 at 11:20 AM, Richard Biener
>> <richard.guenther@gmail.com> wrote:
>>> On Thu, Oct 9, 2014 at 11:14 AM, Zhenqiang Chen
>> <zhenqiang.chen@arm.com> wrote:
>>>> 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.
>
> Thanks for the comments. I think seq_cost should be in rtlanal.c, just like rtx_cost, insn_rtx_cost and so on.
>
> ChangeLog:
> 2014-10-10  Zhenqiang Chen  <zhenqiang.chen@arm.com>
>
> 	* cfgloopanal.c (seq_cost): Delete.
> 	* rtl.h (seq_cost): New prototype.
> 	* rtlanal.c (seq_cost): New function.
> 	* tree-ssa-loop-ivopts.c (seq_cost): Delete.
Ok.
Jeff

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-10-10 16:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-09  9:14 [PATCH] Clean up duplicated function seq_cost Zhenqiang Chen
2014-10-09  9:21 ` Richard Biener
2014-10-09  9:24   ` Richard Biener
2014-10-10  8:40     ` Zhenqiang Chen
2014-10-10 16:30       ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).