On Tue, 8 Jan 2013, Jakub Jelinek wrote:

> Hi!
> 
> This is Steven's patch from the PR plus mine hunk, bootstrapped/regtested on
> x86_64-linux and i686-linux, ok for trunk?

Ok.

Thanks,
Richard.

> 2013-01-08  Steven Bosscher  <ste...@gcc.gnu.org>
>           Jakub Jelinek  <ja...@redhat.com>
> 
>       PR tree-optimization/48189
>       * predict.c (predict_loops): If max is 0, don't call compare_tree_int.
>       If nitercst is 0, don't predict the exit edge.
> 
>       * gcc.dg/pr48189.c: New test.
> 
> --- gcc/predict.c.jj  2013-01-04 13:44:35.000000000 +0100
> +++ gcc/predict.c     2013-01-08 15:58:15.552884491 +0100
> @@ -1434,7 +1434,8 @@ predict_loops (void)
>         if (TREE_CODE (niter) == INTEGER_CST)
>           {
>             if (host_integerp (niter, 1)
> -               && compare_tree_int (niter, max-1) == -1)
> +               && max
> +               && compare_tree_int (niter, max - 1) == -1)
>               nitercst = tree_low_cst (niter, 1) + 1;
>             else
>               nitercst = max;
> @@ -1456,6 +1457,11 @@ predict_loops (void)
>         else
>           continue;
>  
> +       /* If the prediction for number of iterations is zero, do not
> +          predict the exit edges.  */
> +       if (nitercst == 0)
> +         continue;
> +
>         probability = ((REG_BR_PROB_BASE + nitercst / 2) / nitercst);
>         predict_edge (ex, predictor, probability);
>       }
> --- gcc/testsuite/gcc.dg/pr48189.c.jj 2013-01-08 15:59:38.319433008 +0100
> +++ gcc/testsuite/gcc.dg/pr48189.c    2013-01-08 15:52:31.000000000 +0100
> @@ -0,0 +1,13 @@
> +/* PR tree-optimization/48189 */
> +/* { dg-do compile } */
> +/* { dg-options "-O --param max-predicted-iterations=0" } */
> +
> +struct S { int s[8]; };
> +  
> +void
> +foo (int *x, struct S *y)
> +{
> +  int i;
> +  for (i = 0; y[i].s[i]; i++)
> +    *x++ = y[i].s[i];
> +}
> 
>       Jakub
> 
> 

-- 
Richard Biener <rguent...@suse.de>
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imend

Reply via email to