This fixes the wrong direction of dependence edges in loop distribution (this happens when you think that if you choose the wrong direction a testcase will trip and thus you don't think hard enough ...).
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2013-11-05 Richard Biener <rguent...@suse.de> PR tree-optimization/58955 * tree-loop-distribution.c (pg_add_dependence_edges): Fix edge direction. * gcc.dg/torture/pr58955-1.c: New testcase. * gcc.dg/torture/pr58955-2.c: Likewise. Index: gcc/tree-loop-distribution.c =================================================================== *** gcc/tree-loop-distribution.c (revision 204388) --- gcc/tree-loop-distribution.c (working copy) *************** pg_add_dependence_edges (struct graph *r *** 1324,1330 **** for (int ii = 0; drs1.iterate (ii, &dr1); ++ii) for (int jj = 0; drs2.iterate (jj, &dr2); ++jj) { ! int this_dir = 1; ddr_p ddr; /* Re-shuffle data-refs to be in dominator order. */ if (rdg_vertex_for_stmt (rdg, DR_STMT (dr1)) --- 1324,1330 ---- for (int ii = 0; drs1.iterate (ii, &dr1); ++ii) for (int jj = 0; drs2.iterate (jj, &dr2); ++jj) { ! int this_dir = -1; ddr_p ddr; /* Re-shuffle data-refs to be in dominator order. */ if (rdg_vertex_for_stmt (rdg, DR_STMT (dr1)) Index: gcc/testsuite/gcc.dg/torture/pr58955-1.c =================================================================== *** gcc/testsuite/gcc.dg/torture/pr58955-1.c (revision 0) --- gcc/testsuite/gcc.dg/torture/pr58955-1.c (working copy) *************** *** 0 **** --- 1,20 ---- + /* { dg-do run } */ + + extern void abort (void); + + int a, b, c, d[4] = { 0, 0, 0, 1 }; + + int + main () + { + for (; a < 4; a++) + { + int e = d[a]; + for (c = 1; c < 1; c++); + b = e; + d[a] = 0; + } + if (b != 1) + abort (); + return 0; + } Index: gcc/testsuite/gcc.dg/torture/pr58955-2.c =================================================================== *** gcc/testsuite/gcc.dg/torture/pr58955-2.c (revision 0) --- gcc/testsuite/gcc.dg/torture/pr58955-2.c (working copy) *************** *** 0 **** --- 1,18 ---- + /* { dg-do run } */ + + extern void abort (void); + + int a, b[10]; + + int + main () + { + for (; a < 2; a++) + { + b[a] = 1; + b[a + 1] = 0; + } + if (b[1] != 1) + abort (); + return 0; + }