[Bug tree-optimization/57488] [4.9 regression] loop terminates early at -O3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57488 Richard Biener changed: What|Removed |Added CC||su at cs dot ucdavis.edu --- Comment #7 from Richard Biener --- *** Bug 58830 has been marked as a duplicate of this bug. ***
[Bug tree-optimization/57488] [4.9 regression] loop terminates early at -O3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57488 --- Comment #6 from Richard Biener --- Author: rguenth Date: Wed Oct 23 11:59:05 2013 New Revision: 203958 URL: http://gcc.gnu.org/viewcvs?rev=203958&root=gcc&view=rev Log: 2013-10-23 Richard Biener Backport from mainline 2013-06-24 Richard Biener PR tree-optimization/57488 * tree-ssa-pre.c (insert): Clear NEW sets before each iteration. * gcc.dg/torture/pr57488.c: New testcase. Added: branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/torture/pr57488.c branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/torture/pr58830.c Modified: branches/gcc-4_8-branch/gcc/ChangeLog branches/gcc-4_8-branch/gcc/testsuite/ChangeLog branches/gcc-4_8-branch/gcc/tree-ssa-pre.c
[Bug tree-optimization/57488] [4.9 regression] loop terminates early at -O3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57488 Richard Biener changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED --- Comment #5 from Richard Biener --- Author: rguenth Date: Mon Jun 24 10:22:22 2013 New Revision: 200363 URL: http://gcc.gnu.org/viewcvs?rev=200363&root=gcc&view=rev Log: 2013-06-24 Richard Biener PR tree-optimization/57488 * tree-ssa-pre.c (insert): Clear NEW sets before each iteration. * gcc.dg/torture/pr57488.c: New testcase. Added: trunk/gcc/testsuite/gcc.dg/torture/pr57488.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-pre.c
[Bug tree-optimization/57488] [4.9 regression] loop terminates early at -O3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57488 --- Comment #4 from Richard Biener --- The fun thing is that this is a regular partial redundancy but requires an earlier partial partial redundancy elimination to be performed. So what happens is that int v; void foo (int n) { int i, j; for (i = 0; i < n; ++i) for (j = 0; j < n; ++j) v++; } gets transformed to int v; void foo (int n) { int i, j; for (i = 0; i < n; ++i) tem = v; for (j = 0; j < n; ++j) # PHI v = tem + 1; } and in the 3rd insert iteration this becomes int v; void foo (int n) { int i, j; tem2 = v; for (i = 0; i < n; ++i) # tem2 = PHI tem = tem2; for (j = 0; j < n; ++j) # tem = PHI v = tem + 1; } with ... replaced by the value and representative 'tem' because via the NEW sets we propagate that down to the latch. Of course PRE works fine with the above simplified testcase ... The following speedup patch fixes the bug: Index: gcc/tree-ssa-pre.c === --- gcc/tree-ssa-pre.c (revision 200237) +++ gcc/tree-ssa-pre.c (working copy) @@ -3665,6 +3666,12 @@ insert (void) if (dump_file && dump_flags & TDF_DETAILS) fprintf (dump_file, "Starting insert iteration %d\n", num_iterations); new_stuff = insert_aux (ENTRY_BLOCK_PTR); + + /* Clear the NEW sets before the next iteration. We have already + fully propagated its contents. */ + if (new_stuff) + FOR_ALL_BB (bb) + bitmap_set_free (NEW_SETS (bb)); } statistics_histogram_event (cfun, "insert iterations", num_iterations); } remains to be seen why ... (I can only think of NEW sets propagated over backedges requiring a 2nd iteration to make their effect visible) That said, this bug seems to be latent for a long time.
[Bug tree-optimization/57488] [4.9 regression] loop terminates early at -O3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57488 --- Comment #3 from Richard Biener --- -fno-tree-partial-pre fixes this, partial PRE figures that v on entry to the l loop is invariant in the outer loop. Thus it does tem = v; for (k = 1; k >= 0; k--) { int l; bar (0); v = tem; for (l = 1; l < 5; l++) { int m; for (m = 6; m; m--) { v--; *ps = *pc; } } } effectively cutting the number of decrements in half.
[Bug tree-optimization/57488] [4.9 regression] loop terminates early at -O3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57488 Richard Biener changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org Target Milestone|--- |4.9.0 --- Comment #2 from Richard Biener --- I will have a look later this week unless somebody beats me here.
[Bug tree-optimization/57488] [4.9 regression] loop terminates early at -O3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57488 Jakub Jelinek changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2013-05-31 CC||jakub at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Jakub Jelinek --- Started with r198333.