We need to rebuild frequency after vrp, otherwise the following code in tree-ssa-threadupdate.c will make the frequency larger than upper-bound.
/* Excessive jump threading may make frequencies large enough so the computation overflows. */ if (rd->dup_blocks[0]->frequency < BB_FREQ_MAX * 2) rd->dup_blocks[0]->frequency += EDGE_FREQUENCY (e); This is referring to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61384 Thanks, Dehao On Mon, Jun 2, 2014 at 9:13 AM, Jan Hubicka <hubi...@ucw.cz> wrote: >> This patch rebuilds frequency after vrp. > > Why do you need to rebuild frequency after VRP? I always tought it may be > useful to do VRP as early optimization (modulo to compile time costs), > but I do not think we should unconditionally rebuild frequencies like this... > > Honza >> >> Bootstrapped and testing on-going. OK for trunk if test pass? >> >> Thanks, >> Dehao >> >> gcc/ChangeLog: >> 2014-06-02 Dehao Chen <de...@google.com> >> >> PR tree-optimization/61384 >> * tree-vrp.c (execute_vrp): rebuild frequency after vrp. >> >> gcc/testsuite/ChangeLog: >> 2014-06-02 Dehao Chen <de...@google.com> >> >> PR tree-optimization/61384 >> * gcc.dg/pr61384.c: New testcase. >> >> Index: gcc/testsuite/gcc.dg/pr61384.c >> =================================================================== >> --- gcc/testsuite/gcc.dg/pr61384.c (revision 0) >> +++ gcc/testsuite/gcc.dg/pr61384.c (revision 0) >> @@ -0,0 +1,32 @@ >> +/* PR tree-optimization/61384 */ >> +/* { dg-do compile } */ >> +/* { dg-options "-O3" } */ >> + >> +int a, b, d, e, g, h; >> +static int c = 1, f[5]; >> + >> +int >> +fn1 (int p1, int p2) >> +{ >> + return p1 && p2 && p2; >> +} >> + >> +void >> +fn2 () >> +{ >> + for (d = 0; d < 1; d++) >> + { >> + g = f[0]; >> + e = 0; >> + h = fn1 (1, (a && c) ^ b); >> + } >> + for (; e < 5; e++) >> + f[e] = 1; >> +} >> + >> +int >> +main () >> +{ >> + fn2 (); >> + return 0; >> +} >> >> Index: gcc/tree-vrp.c >> =================================================================== >> --- gcc/tree-vrp.c (revision 211137) >> +++ gcc/tree-vrp.c (working copy) >> @@ -9794,7 +9794,7 @@ execute_vrp (void) >> >> scev_finalize (); >> loop_optimizer_finalize (); >> - return 0; >> + return TODO_rebuild_frequencies; >> } >> >> namespace {