[Bug tree-optimization/87074] [8/9 Regression] Unroll and jam bug: O3 result differ from O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87074 Michael Matz changed: What|Removed |Added Keywords|needs-bisection | Status|NEW |RESOLVED Resolution|--- |FIXED Assignee|unassigned at gcc dot gnu.org |matz at gcc dot gnu.org --- Comment #7 from Michael Matz --- Fixed in trunk and gcc-8-branch
[Bug tree-optimization/87074] [8/9 Regression] Unroll and jam bug: O3 result differ from O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87074 --- Comment #6 from Michael Matz --- Author: matz Date: Sat Sep 1 17:33:45 2018 New Revision: 264030 URL: https://gcc.gnu.org/viewcvs?rev=264030=gcc=rev Log: Fix PR87074 Backport from mainline PR tree-optimization/87074 * gimple-loop-jam.c (unroll_jam_possible_p): Check loop exit PHIs for outer-loop uses. testsuite/ * gcc.dg/pr87074.c: New test. Added: branches/gcc-8-branch/gcc/testsuite/gcc.dg/pr87074.c Modified: branches/gcc-8-branch/gcc/ChangeLog branches/gcc-8-branch/gcc/gimple-loop-jam.c branches/gcc-8-branch/gcc/testsuite/ChangeLog
[Bug tree-optimization/87074] [8/9 Regression] Unroll and jam bug: O3 result differ from O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87074 --- Comment #5 from Michael Matz --- Author: matz Date: Sat Sep 1 17:22:05 2018 New Revision: 264029 URL: https://gcc.gnu.org/viewcvs?rev=264029=gcc=rev Log: Fix PR87074 PR tree-optimization/87074 * gimple-loop-jam.c (unroll_jam_possible_p): Check loop exit PHIs for outer-loop uses. testsuite/ * gcc.dg/pr87074.c: New test. Added: trunk/gcc/testsuite/gcc.dg/pr87074.c Modified: trunk/gcc/ChangeLog trunk/gcc/gimple-loop-jam.c trunk/gcc/testsuite/ChangeLog
[Bug tree-optimization/87074] [8/9 Regression] Unroll and jam bug: O3 result differ from O2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87074 --- Comment #4 from Jakub Jelinek --- outer->header is: bb_4 (preds = {bb_3 bb_11 }, succs = {bb_5 }) { [local count: 118111601]: # f.10_31 = PHI # .MEM_34 = PHI <.MEM_18(D)(3), .MEM_21(11)> # g_lsm.15_33 = PHI _75 = (unsigned int) g_lsm.15_33; } the bb into which the inner loop exits is: bb_6 (preds = {bb_5 }, succs = {bb_11 bb_7 }) { [local count: 118111601]: # _11 = PHI <_8(5)> _9 = (int) _11; _12 = f.10_31 + 1; if (_12 <= 10) goto ; [89.00%] else goto ; [11.00%] } and outer->latch is: bb_11 (preds = {bb_6 }, succs = {bb_4 }) { [local count: 105119325]: goto ; [100.00%] } >From what I can see, gimple-loop-jam.c verifies using bb_prevents_fusion_p these 3 bbs, but nothing checks the outer loop's IVs. The problem is that a value computed by the inner loop (_8) is then used inside of the outer loop and fed into the next inner loop too. So, shall we punt if there are any phis in single_exit (loop)->dest (other than virtual) (assuming here that we are in loop closed SSA form) and thus there are any SSA_NAME uses from the inner loop to next outer loop's iteration? Or are there perhaps any exceptions that can be handled, like if a value computed by the inner loop is not used only after the outer loop exits?