diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 72fbdd70da5..50fa380fe06 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2015-02-10 Trevor Saunders + + PR tree-optimization/64326 + * cfghooks.c (make_forwarder_block): Cap frequency of created block. + 2015-02-10 Rainer Emrich PR gcov-profile/61889 diff --git a/gcc/cfghooks.c b/gcc/cfghooks.c index 4b572801693..abeab8cf1a5 100644 --- a/gcc/cfghooks.c +++ b/gcc/cfghooks.c @@ -863,6 +863,9 @@ make_forwarder_block (basic_block bb, bool (*redirect_edge_p) (edge), if (redirect_edge_p (e)) { dummy->frequency += EDGE_FREQUENCY (e); + if (dummy->frequency > BB_FREQ_MAX) + dummy->frequency = BB_FREQ_MAX; + dummy->count += e->count; fallthru->count += e->count; ei_next (&ei); diff --git a/gcc/testsuite/gcc.dg/torture/pr64326.c b/gcc/testsuite/gcc.dg/torture/pr64326.c new file mode 100644 index 00000000000..88ebf35d5c5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr64326.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ + +int a, b, c, d, e, f[5][2]; +char g; + +int +fn1 () +{ + return d && c ? 0 : 1; +} + +int +fn2 () +{ + int h; + for (;;) + for (; e;) + { + int i, j; + h = a ? 1 : b; + if (h || fn1 () ^ g - 682) + { + for (i = 0; i < 5; i++) + for (j = 0; j < 2; j++) + f[i][j] = 0; + return 0; + } + } +} +