public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, PR 54394] Compute loops when generating inline summaries
@ 2012-08-29 18:24 Martin Jambor
  2012-08-31  8:53 ` Jan Hubicka
  0 siblings, 1 reply; 7+ messages in thread
From: Martin Jambor @ 2012-08-29 18:24 UTC (permalink / raw)
  To: GCC Patches; +Cc: Jan Hubicka, Richard Guenther

Hi,

the patch below fixes PR 54394.  The problem is that since revision
190346 we depend on bb->loop_father being non-NULL to get loop_depth.
However, with loops not computed, the loop_father is NULL, loop_depth
is thus considered zero and call graph edges out of such BB can be
considered much cooler, leading to inlining regressions.

This patch fixes that by recomputing loops whenever optimizing, not
only for loop bounds hints.  We might put the computation elsewhere or
do it only under more restrictive circumstances, but I believe that
after rev. 190346 we have to do it.  In particular, I am not sure
whether we had (semi)correct loop_depths when doing early inlining or
not, this patch re-calculates it for early inliner too.

Bootstrapped and tested on x86_64-linux, fixes fatigue run-time on
an x86_64-linux and i686-linux for me.  What do you think?

Thanks,

Martin


2012-08-29  Martin Jambor  <mjambor@suse.cz>

	PR middle-end/54394
	* ipa-inline-analysis.c (estimate_function_body_sizes): Compute
	dominance info and loops whenever optimizing.


Index: src/gcc/ipa-inline-analysis.c
===================================================================
--- src.orig/gcc/ipa-inline-analysis.c
+++ src/gcc/ipa-inline-analysis.c
@@ -2102,6 +2102,11 @@ estimate_function_body_sizes (struct cgr
   info->conds = 0;
   info->entry = 0;
 
+  if (optimize)
+    {
+      calculate_dominance_info (CDI_DOMINATORS);
+      loop_optimizer_init (LOOPS_NORMAL | LOOPS_HAVE_RECORDED_EXITS);
+    }
 
   if (dump_file)
     fprintf (dump_file, "\nAnalyzing function body size: %s\n",
@@ -2270,9 +2275,6 @@ estimate_function_body_sizes (struct cgr
       loop_iterator li;
       predicate loop_iterations = true_predicate ();
 
-      calculate_dominance_info (CDI_DOMINATORS);
-      loop_optimizer_init (LOOPS_NORMAL
-			   | LOOPS_HAVE_RECORDED_EXITS);
       if (dump_file && (dump_flags & TDF_DETAILS))
 	flow_loops_dump (dump_file, NULL, 0);
       scev_initialize ();
@@ -2305,12 +2307,15 @@ estimate_function_body_sizes (struct cgr
           *inline_summary (node)->loop_iterations = loop_iterations;
 	}
       scev_finalize ();
-      loop_optimizer_finalize ();
-      free_dominance_info (CDI_DOMINATORS);
     }
   inline_summary (node)->self_time = time;
   inline_summary (node)->self_size = size;
   VEC_free (predicate_t, heap, nonconstant_names);
+  if (optimize)
+    {
+      loop_optimizer_finalize ();
+      free_dominance_info (CDI_DOMINATORS);
+    }
   if (dump_file)
     {
       fprintf (dump_file, "\n");

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

* Re: [PATCH, PR 54394] Compute loops when generating inline summaries
  2012-08-29 18:24 [PATCH, PR 54394] Compute loops when generating inline summaries Martin Jambor
@ 2012-08-31  8:53 ` Jan Hubicka
  2012-08-31  9:56   ` Martin Jambor
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Hubicka @ 2012-08-31  8:53 UTC (permalink / raw)
  To: GCC Patches, Jan Hubicka, Richard Guenther

> Hi,
> 
> the patch below fixes PR 54394.  The problem is that since revision
> 190346 we depend on bb->loop_father being non-NULL to get loop_depth.
> However, with loops not computed, the loop_father is NULL, loop_depth
> is thus considered zero and call graph edges out of such BB can be
> considered much cooler, leading to inlining regressions.
> 
> This patch fixes that by recomputing loops whenever optimizing, not
> only for loop bounds hints.  We might put the computation elsewhere or
> do it only under more restrictive circumstances, but I believe that
> after rev. 190346 we have to do it.  In particular, I am not sure
> whether we had (semi)correct loop_depths when doing early inlining or
> not, this patch re-calculates it for early inliner too.
> 
> Bootstrapped and tested on x86_64-linux, fixes fatigue run-time on
> an x86_64-linux and i686-linux for me.  What do you think?
> 
> Thanks,
> 
> Martin
> 
> 
> 2012-08-29  Martin Jambor  <mjambor@suse.cz>
> 
> 	PR middle-end/54394
> 	* ipa-inline-analysis.c (estimate_function_body_sizes): Compute
> 	dominance info and loops whenever optimizing.
> 
> 
> Index: src/gcc/ipa-inline-analysis.c
> ===================================================================
> --- src.orig/gcc/ipa-inline-analysis.c
> +++ src/gcc/ipa-inline-analysis.c
> @@ -2102,6 +2102,11 @@ estimate_function_body_sizes (struct cgr
>    info->conds = 0;
>    info->entry = 0;
>  
> +  if (optimize)

This is OK. I think you can also skip thi computation for early inlining
where we don't do any hints, so probably if (optimize && !early)

Honza

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

* Re: [PATCH, PR 54394] Compute loops when generating inline summaries
  2012-08-31  8:53 ` Jan Hubicka
@ 2012-08-31  9:56   ` Martin Jambor
  2012-08-31 10:06     ` Jan Hubicka
  0 siblings, 1 reply; 7+ messages in thread
From: Martin Jambor @ 2012-08-31  9:56 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: GCC Patches, Richard Guenther

On Fri, Aug 31, 2012 at 10:53:32AM +0200, Jan Hubicka wrote:
> > Hi,
> > 
> > the patch below fixes PR 54394.  The problem is that since revision
> > 190346 we depend on bb->loop_father being non-NULL to get loop_depth.
> > However, with loops not computed, the loop_father is NULL, loop_depth
> > is thus considered zero and call graph edges out of such BB can be
> > considered much cooler, leading to inlining regressions.
> > 
> > This patch fixes that by recomputing loops whenever optimizing, not
> > only for loop bounds hints.  We might put the computation elsewhere or
> > do it only under more restrictive circumstances, but I believe that
> > after rev. 190346 we have to do it.  In particular, I am not sure
> > whether we had (semi)correct loop_depths when doing early inlining or
> > not, this patch re-calculates it for early inliner too.
> > 
> > Bootstrapped and tested on x86_64-linux, fixes fatigue run-time on
> > an x86_64-linux and i686-linux for me.  What do you think?
> > 
> > Thanks,
> > 
> > Martin
> > 
> > 
> > 2012-08-29  Martin Jambor  <mjambor@suse.cz>
> > 
> > 	PR middle-end/54394
> > 	* ipa-inline-analysis.c (estimate_function_body_sizes): Compute
> > 	dominance info and loops whenever optimizing.
> > 
> > 
> > Index: src/gcc/ipa-inline-analysis.c
> > ===================================================================
> > --- src.orig/gcc/ipa-inline-analysis.c
> > +++ src/gcc/ipa-inline-analysis.c
> > @@ -2102,6 +2102,11 @@ estimate_function_body_sizes (struct cgr
> >    info->conds = 0;
> >    info->entry = 0;
> >  
> > +  if (optimize)
> 
> This is OK. I think you can also skip thi computation for early inlining
> where we don't do any hints, so probably if (optimize && !early)
> 
> Honza

This is not required to make hints working, it is necessary because of
the following line a in estimate_function_body_sizes:

	      es->loop_depth = bb_loop_depth (bb);

which always yields zero if we don't have loops computed.  So I can
skip the computation only if we don't care about loop depths in early
inlining either.  Should I skip it?

Thanks,

Martin

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

* Re: [PATCH, PR 54394] Compute loops when generating inline summaries
  2012-08-31  9:56   ` Martin Jambor
@ 2012-08-31 10:06     ` Jan Hubicka
  2012-08-31 14:41       ` Martin Jambor
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Hubicka @ 2012-08-31 10:06 UTC (permalink / raw)
  To: Jan Hubicka, GCC Patches, Richard Guenther

> 
> This is not required to make hints working, it is necessary because of
> the following line a in estimate_function_body_sizes:
> 
> 	      es->loop_depth = bb_loop_depth (bb);
> 
> which always yields zero if we don't have loops computed.  So I can
> skip the computation only if we don't care about loop depths in early
> inlining either.  Should I skip it?

Only place we care is the badness computation and only if profile guessing is off,
so just initialize it to 0 for early inliner.

Honza
> 
> Thanks,
> 
> Martin

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

* Re: [PATCH, PR 54394] Compute loops when generating inline summaries
  2012-08-31 10:06     ` Jan Hubicka
@ 2012-08-31 14:41       ` Martin Jambor
  2012-12-03 17:51         ` H.J. Lu
  0 siblings, 1 reply; 7+ messages in thread
From: Martin Jambor @ 2012-08-31 14:41 UTC (permalink / raw)
  To: gcc-patches

Hi,

On Fri, Aug 31, 2012 at 12:06:33PM +0200, Jan Hubicka wrote:
> > 
> > This is not required to make hints working, it is necessary because of
> > the following line a in estimate_function_body_sizes:
> > 
> > 	      es->loop_depth = bb_loop_depth (bb);
> > 
> > which always yields zero if we don't have loops computed.  So I can
> > skip the computation only if we don't care about loop depths in early
> > inlining either.  Should I skip it?
> 
> Only place we care is the badness computation and only if profile guessing is off,
> so just initialize it to 0 for early inliner.
> 

Thanks.  For the record, this is what I have committed.

Martin


2012-08-31  Martin Jambor  <mjambor@suse.cz>

	PR middle-end/54394
	* ipa-inline-analysis.c (estimate_function_body_sizes): Compute
	dominance info and loops whenever optimizing.


Index: src/gcc/ipa-inline-analysis.c
===================================================================
--- src.orig/gcc/ipa-inline-analysis.c
+++ src/gcc/ipa-inline-analysis.c
@@ -2102,6 +2102,11 @@ estimate_function_body_sizes (struct cgr
   info->conds = 0;
   info->entry = 0;
 
+  if (optimize && !early)
+    {
+      calculate_dominance_info (CDI_DOMINATORS);
+      loop_optimizer_init (LOOPS_NORMAL | LOOPS_HAVE_RECORDED_EXITS);
+    }
 
   if (dump_file)
     fprintf (dump_file, "\nAnalyzing function body size: %s\n",
@@ -2270,9 +2275,6 @@ estimate_function_body_sizes (struct cgr
       loop_iterator li;
       predicate loop_iterations = true_predicate ();
 
-      calculate_dominance_info (CDI_DOMINATORS);
-      loop_optimizer_init (LOOPS_NORMAL
-			   | LOOPS_HAVE_RECORDED_EXITS);
       if (dump_file && (dump_flags & TDF_DETAILS))
 	flow_loops_dump (dump_file, NULL, 0);
       scev_initialize ();
@@ -2305,12 +2307,15 @@ estimate_function_body_sizes (struct cgr
           *inline_summary (node)->loop_iterations = loop_iterations;
 	}
       scev_finalize ();
-      loop_optimizer_finalize ();
-      free_dominance_info (CDI_DOMINATORS);
     }
   inline_summary (node)->self_time = time;
   inline_summary (node)->self_size = size;
   VEC_free (predicate_t, heap, nonconstant_names);
+  if (optimize && !early)
+    {
+      loop_optimizer_finalize ();
+      free_dominance_info (CDI_DOMINATORS);
+    }
   if (dump_file)
     {
       fprintf (dump_file, "\n");

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

* Re: [PATCH, PR 54394] Compute loops when generating inline summaries
  2012-08-31 14:41       ` Martin Jambor
@ 2012-12-03 17:51         ` H.J. Lu
  2012-12-03 18:08           ` H.J. Lu
  0 siblings, 1 reply; 7+ messages in thread
From: H.J. Lu @ 2012-12-03 17:51 UTC (permalink / raw)
  To: GCC Patches, Martin Jambor

On Fri, Aug 31, 2012 at 7:41 AM, Martin Jambor <mjambor@suse.cz> wrote:
> Hi,
>
> On Fri, Aug 31, 2012 at 12:06:33PM +0200, Jan Hubicka wrote:
>> >
>> > This is not required to make hints working, it is necessary because of
>> > the following line a in estimate_function_body_sizes:
>> >
>> >           es->loop_depth = bb_loop_depth (bb);
>> >
>> > which always yields zero if we don't have loops computed.  So I can
>> > skip the computation only if we don't care about loop depths in early
>> > inlining either.  Should I skip it?
>>
>> Only place we care is the badness computation and only if profile guessing is off,
>> so just initialize it to 0 for early inliner.
>>
>
> Thanks.  For the record, this is what I have committed.
>
> Martin
>
>
> 2012-08-31  Martin Jambor  <mjambor@suse.cz>
>
>         PR middle-end/54394
>         * ipa-inline-analysis.c (estimate_function_body_sizes): Compute
>         dominance info and loops whenever optimizing.
>
>

This caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55564

-- 
H.J.

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

* Re: [PATCH, PR 54394] Compute loops when generating inline summaries
  2012-12-03 17:51         ` H.J. Lu
@ 2012-12-03 18:08           ` H.J. Lu
  0 siblings, 0 replies; 7+ messages in thread
From: H.J. Lu @ 2012-12-03 18:08 UTC (permalink / raw)
  To: GCC Patches, Martin Jambor

On Mon, Dec 3, 2012 at 9:50 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Fri, Aug 31, 2012 at 7:41 AM, Martin Jambor <mjambor@suse.cz> wrote:
>> Hi,
>>
>> On Fri, Aug 31, 2012 at 12:06:33PM +0200, Jan Hubicka wrote:
>>> >
>>> > This is not required to make hints working, it is necessary because of
>>> > the following line a in estimate_function_body_sizes:
>>> >
>>> >           es->loop_depth = bb_loop_depth (bb);
>>> >
>>> > which always yields zero if we don't have loops computed.  So I can
>>> > skip the computation only if we don't care about loop depths in early
>>> > inlining either.  Should I skip it?
>>>
>>> Only place we care is the badness computation and only if profile guessing is off,
>>> so just initialize it to 0 for early inliner.
>>>
>>
>> Thanks.  For the record, this is what I have committed.
>>
>> Martin
>>
>>
>> 2012-08-31  Martin Jambor  <mjambor@suse.cz>
>>
>>         PR middle-end/54394
>>         * ipa-inline-analysis.c (estimate_function_body_sizes): Compute
>>         dominance info and loops whenever optimizing.
>>
>>
>
> This caused:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55564
>

Oops. Wrong link.  Please ignore this.


-- 
H.J.

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

end of thread, other threads:[~2012-12-03 18:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-29 18:24 [PATCH, PR 54394] Compute loops when generating inline summaries Martin Jambor
2012-08-31  8:53 ` Jan Hubicka
2012-08-31  9:56   ` Martin Jambor
2012-08-31 10:06     ` Jan Hubicka
2012-08-31 14:41       ` Martin Jambor
2012-12-03 17:51         ` H.J. Lu
2012-12-03 18:08           ` H.J. Lu

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