Patchwork Fix PR48184

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

Comments

Marek Polacek - April 4, 2013, 2:01 p.m.
This fixes an ICE in case we use weirdo --param value for 
PARAM_ALIGN_THRESHOLD.  The patch is by Andrew; I added CL, testcase
and tested.

Bootstrapped/regtested on x86_64-linux, ok for trunk?  And what about other
branches?

2013-04-04  Marek Polacek  <polacek@redhat.com>
	    Andrew Pinski  <apinski@cavium.com>

	PR tree-optimization/48184
	* final.c (compute_alignments): Set threshold to 0
	if PARAM_ALIGN_THRESHOLD is 0.

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


	Marek
Marek Polacek - April 10, 2013, 9:44 a.m.
Ping.

On Thu, Apr 04, 2013 at 04:01:09PM +0200, Marek Polacek wrote:
> This fixes an ICE in case we use weirdo --param value for 
> PARAM_ALIGN_THRESHOLD.  The patch is by Andrew; I added CL, testcase
> and tested.
> 
> Bootstrapped/regtested on x86_64-linux, ok for trunk?  And what about other
> branches?
> 
> 2013-04-04  Marek Polacek  <polacek@redhat.com>
> 	    Andrew Pinski  <apinski@cavium.com>
> 
> 	PR tree-optimization/48184
> 	* final.c (compute_alignments): Set threshold to 0
> 	if PARAM_ALIGN_THRESHOLD is 0.
> 
> 	* gcc.dg/pr48184.c: New test.
> 
> --- gcc/final.c.mp	2013-04-04 14:09:04.626020852 +0200
> +++ gcc/final.c	2013-04-04 14:09:05.672024174 +0200
> @@ -701,7 +701,10 @@ compute_alignments (void)
>    FOR_EACH_BB (bb)
>      if (bb->frequency > freq_max)
>        freq_max = bb->frequency;
> -  freq_threshold = freq_max / PARAM_VALUE (PARAM_ALIGN_THRESHOLD);
> +  if (PARAM_VALUE (PARAM_ALIGN_THRESHOLD) == 0)
> +    freq_threshold = 0;
> +  else
> +    freq_threshold = freq_max / PARAM_VALUE (PARAM_ALIGN_THRESHOLD);
>  
>    if (dump_file)
>      fprintf(dump_file, "freq_max: %i\n",freq_max);
> --- gcc/testsuite/gcc.dg/pr48184.c.mp	2013-04-04 13:23:15.356769534 +0200
> +++ gcc/testsuite/gcc.dg/pr48184.c	2013-04-04 14:05:05.506241464 +0200
> @@ -0,0 +1,5 @@
> +/* PR tree-optimization/48184 */
> +/* { dg-do compile } */
> +/* { dg-options "-O --param align-threshold=0" } */
> +
> +void foo (void) { }
> 
> 	Marek
Jakub Jelinek - April 10, 2013, 9:49 a.m.
On Wed, Apr 10, 2013 at 11:44:18AM +0200, Marek Polacek wrote:
> Ping.
> 
> On Thu, Apr 04, 2013 at 04:01:09PM +0200, Marek Polacek wrote:
> > This fixes an ICE in case we use weirdo --param value for 
> > PARAM_ALIGN_THRESHOLD.  The patch is by Andrew; I added CL, testcase
> > and tested.
> > 
> > Bootstrapped/regtested on x86_64-linux, ok for trunk?  And what about other
> > branches?
> > 
> > 2013-04-04  Marek Polacek  <polacek@redhat.com>
> > 	    Andrew Pinski  <apinski@cavium.com>
> > 
> > 	PR tree-optimization/48184
> > 	* final.c (compute_alignments): Set threshold to 0
> > 	if PARAM_ALIGN_THRESHOLD is 0.
> > 
> > 	* gcc.dg/pr48184.c: New test.

Shouldn't this be again solved instead by bumping minimum for the param to 1
from 0?  Because, the smaller the param is, the bigger freq_threshold is,
so if for the smallest param we suddenly set freq_threshold to 0, it isn't
consistent.

> > --- gcc/final.c.mp	2013-04-04 14:09:04.626020852 +0200
> > +++ gcc/final.c	2013-04-04 14:09:05.672024174 +0200
> > @@ -701,7 +701,10 @@ compute_alignments (void)
> >    FOR_EACH_BB (bb)
> >      if (bb->frequency > freq_max)
> >        freq_max = bb->frequency;
> > -  freq_threshold = freq_max / PARAM_VALUE (PARAM_ALIGN_THRESHOLD);
> > +  if (PARAM_VALUE (PARAM_ALIGN_THRESHOLD) == 0)
> > +    freq_threshold = 0;
> > +  else
> > +    freq_threshold = freq_max / PARAM_VALUE (PARAM_ALIGN_THRESHOLD);
> >  
> >    if (dump_file)
> >      fprintf(dump_file, "freq_max: %i\n",freq_max);

	Jakub

Patch

--- gcc/final.c.mp	2013-04-04 14:09:04.626020852 +0200
+++ gcc/final.c	2013-04-04 14:09:05.672024174 +0200
@@ -701,7 +701,10 @@  compute_alignments (void)
   FOR_EACH_BB (bb)
     if (bb->frequency > freq_max)
       freq_max = bb->frequency;
-  freq_threshold = freq_max / PARAM_VALUE (PARAM_ALIGN_THRESHOLD);
+  if (PARAM_VALUE (PARAM_ALIGN_THRESHOLD) == 0)
+    freq_threshold = 0;
+  else
+    freq_threshold = freq_max / PARAM_VALUE (PARAM_ALIGN_THRESHOLD);
 
   if (dump_file)
     fprintf(dump_file, "freq_max: %i\n",freq_max);
--- gcc/testsuite/gcc.dg/pr48184.c.mp	2013-04-04 13:23:15.356769534 +0200
+++ gcc/testsuite/gcc.dg/pr48184.c	2013-04-04 14:05:05.506241464 +0200
@@ -0,0 +1,5 @@ 
+/* PR tree-optimization/48184 */
+/* { dg-do compile } */
+/* { dg-options "-O --param align-threshold=0" } */
+
+void foo (void) { }