Patchwork Fix PR48186

login
register
mail settings
Submitter Marek Polacek
Date April 4, 2013, 2:29 p.m.
Message ID <20130404142934.GF24873@redhat.com>
Download mbox | patch
Permalink /patch/233847/
State New
Headers show

Comments

Marek Polacek - April 4, 2013, 2:29 p.m.
On Thu, Apr 04, 2013 at 04:20:36PM +0200, Marek Polacek wrote:
> On Thu, Apr 04, 2013 at 04:06:35PM +0200, Jakub Jelinek wrote:
> > In this second hunk the division is done only for flag_guess_branch_prob,
> > so shouldn't it be
> >   if (flag_guess_branch_prob)
> >     {
> >       if (PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION) == 0
> > 	  || edge->frequency <= (CGRAPH_FREQ_BASE
> > 				 / PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION)))
> > 	return false;
> >     }
> >   return true;
> > instead?
> 
> Yeah, I guess so.  Thanks; fixed:

Now really.

2013-04-04  Marek Polacek  <polacek@redhat.com>

	PR tree-optimization/48186
	* predict.c (maybe_hot_frequency_p): Return false if
	HOT_BB_FREQUENCY_FRACTION is 0.
	(cgraph_maybe_hot_edge_p): Likewise.

	* gcc.dg/pr48186.c: New test.


	Marek
Jakub Jelinek - April 4, 2013, 2:30 p.m.
On Thu, Apr 04, 2013 at 04:29:34PM +0200, Marek Polacek wrote:
> On Thu, Apr 04, 2013 at 04:20:36PM +0200, Marek Polacek wrote:
> > On Thu, Apr 04, 2013 at 04:06:35PM +0200, Jakub Jelinek wrote:
> > > In this second hunk the division is done only for flag_guess_branch_prob,
> > > so shouldn't it be
> > >   if (flag_guess_branch_prob)
> > >     {
> > >       if (PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION) == 0
> > > 	  || edge->frequency <= (CGRAPH_FREQ_BASE
> > > 				 / PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION)))
> > > 	return false;
> > >     }
> > >   return true;
> > > instead?
> > 
> > Yeah, I guess so.  Thanks; fixed:
> 
> Now really.
> 
> 2013-04-04  Marek Polacek  <polacek@redhat.com>
> 
> 	PR tree-optimization/48186
> 	* predict.c (maybe_hot_frequency_p): Return false if
> 	HOT_BB_FREQUENCY_FRACTION is 0.
> 	(cgraph_maybe_hot_edge_p): Likewise.
> 
> 	* gcc.dg/pr48186.c: New test.

Ok, if it passes bootstrap/regtest.

	Jakub

Patch

--- gcc/predict.c.mp	2013-04-04 16:16:16.396977123 +0200
+++ gcc/predict.c	2013-04-04 16:25:51.621794236 +0200
@@ -122,6 +122,8 @@  maybe_hot_frequency_p (struct function *
   if (node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
       && freq < (ENTRY_BLOCK_PTR_FOR_FUNCTION (fun)->frequency * 2 / 3))
     return false;
+  if (PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION) == 0)
+    return false;
   if (freq < (ENTRY_BLOCK_PTR_FOR_FUNCTION (fun)->frequency
 	      / PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION)))
     return false;
@@ -202,10 +204,13 @@  cgraph_maybe_hot_edge_p (struct cgraph_e
   if (edge->caller->frequency == NODE_FREQUENCY_EXECUTED_ONCE
       && edge->frequency < CGRAPH_FREQ_BASE * 3 / 2)
     return false;
-  if (flag_guess_branch_prob
-      && edge->frequency <= (CGRAPH_FREQ_BASE
-      			     / PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION)))
-    return false;
+  if (flag_guess_branch_prob)
+    {
+      if (PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION) == 0
+	  || edge->frequency <= (CGRAPH_FREQ_BASE
+				 / PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION)))
+        return false;
+    }
   return true;
 }
 
--- gcc/testsuite/gcc.dg/pr48186.c.mp	2013-04-04 16:26:16.720871459 +0200
+++ gcc/testsuite/gcc.dg/pr48186.c	2013-04-04 16:26:55.809991847 +0200
@@ -0,0 +1,5 @@ 
+/* PR tree-optimization/48186 */
+/* { dg-do compile } */
+/* { dg-options "-O --param hot-bb-frequency-fraction=0" } */
+
+void foo (void) { }