backport: re PR tree-optimization/48189 (ICE: SIGFPE (division by zero) in in predict_loops () at predict.c:991 with --param max-predicted-iterations=0)

Backport from mainline
	2013-01-08  Steven Bosscher  <steven@gcc.gnu.org>
		    Jakub Jelinek  <jakub@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.

From-SVN: r198085
This commit is contained in:
Marek Polacek 2013-04-19 08:18:29 +00:00 committed by Marek Polacek
parent 81a8c3172c
commit ff166d81d9
4 changed files with 39 additions and 1 deletions

View File

@ -1,3 +1,13 @@
2013-04-19 Marek Polacek <polacek@redhat.com>
Backport from mainline
2013-01-08 Steven Bosscher <steven@gcc.gnu.org>
Jakub Jelinek <jakub@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.
2013-04-16 Jack Howarth <howarth@bromo.med.uc.edu>
Backport from mainline

View File

@ -983,7 +983,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;
@ -1005,6 +1006,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);
}

View File

@ -1,3 +1,12 @@
2013-04-19 Marek Polacek <polacek@redhat.com>
Backport from mainline
2013-01-08 Steven Bosscher <steven@gcc.gnu.org>
Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/48189
* gcc.dg/pr48189.c: New test.
2013-04-15 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* gcc.dg/torture/pr53922.c: Skip on alpha*-*-osf*.

View File

@ -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];
}