Compiler output: $ gcc -O1 -ftree-loop-linear vect-cond-5.c && ./a.out Aborted Tested revisions: r157985 - fail 4.4.3, 4.3.4 - fail 4.2.4, 4.1.2 - OK
Created attachment 20319 [details] slightly reduced testcase, showing computed data $ gcc-4.5.0-alpha20100401 -O1 -ftree-loop-linear pr43657.c && ./a.out 0 6 2 1 5 2 2 4 2 3 3 2 4 2 2 5 0 0 6 0 0 7 0 0 8 0 0 9 0 0 10 0 0 11 0 0 12 0 0 13 0 0 14 0 0 15 0 0 16 0 0 17 0 0 18 0 0 19 0 0 20 0 0 21 0 0 22 0 0 23 0 0 24 0 0 25 0 0 26 0 0 27 0 0 28 0 0 29 0 0 30 0 0 31 0 0 Aborted $ gcc-4.2.4 -O1 -ftree-loop-linear pr43657.c && ./a.out 0 2 2 1 2 2 2 2 2 3 2 2 4 2 2 5 0 0 6 0 0 7 0 0 8 0 0 9 0 0 10 0 0 11 0 0 12 0 0 13 0 0 14 0 0 15 0 0 16 0 0 17 0 0 18 0 0 19 0 0 20 0 0 21 0 0 22 0 0 23 0 0 24 0 0 25 0 0 26 0 0 27 0 0 28 0 0 29 0 0 30 0 0 31 0 0
GCC 4.3.5 is being released, adjusting target milestone.
Created attachment 20748 [details] pr43657.c Slightly adjusted testcase.
for (k = 0; k < 32; k++) { res = 0; for (j = 0; j < 32; j++) for (i = 0; i < 32; i++) { next = a[i][j]; res = c > cond_array[i+k][j] ? next : res; } out[k] = res; } gcc interchanges i and j loops, which is not legal in this case. Apparently, res takes the last value of a[i][j] that satisfies the condition c > cond_array[i+k][j]. As a result, change in the reference order will get a different value for res. Anyone knows where to do this legality check? What about the interchange in Graphite for this case?
Been looking into this. There doesn't seem to be anything to prevent the loop from being transformed when an SSA DEF escapes the loop. Trying to fix.
Created attachment 22982 [details] Proposed patch This avoids the transformation, but... Is the test too strict? My reasoning is that, since we're in closed form (right?), the exit block will only have PHIs for stuff that is changed wthin the loop and is used outside the loop. Does that sound sound? :-)
Author: spop Date: Tue Jan 18 20:54:34 2011 New Revision: 168964 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=168964 Log: Add testcase for PR43657. 2011-01-18 Sebastian Pop <sebastian.pop@amd.com> PR tree-optimization/43657 * gcc.dg/graphite/pr43657.c: New. Added: branches/graphite/gcc/testsuite/gcc.dg/graphite/pr43657.c Modified: branches/graphite/gcc/ChangeLog.graphite
Fixed on the graphite branch.
Author: spop Date: Tue Jan 25 21:24:53 2011 New Revision: 169254 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=169254 Log: Add testcase for PR43657. 2011-01-18 Sebastian Pop <sebastian.pop@amd.com> PR tree-optimization/43657 * gcc.dg/graphite/pr43657.c: New. Added: trunk/gcc/testsuite/gcc.dg/graphite/pr43657.c Modified: trunk/gcc/testsuite/ChangeLog
Fixed.
Author: dnovillo Date: Wed Feb 2 17:48:17 2011 New Revision: 169593 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=169593 Log: Add testcase for PR43657. 2011-01-18 Sebastian Pop <sebastian.pop@amd.com> PR tree-optimization/43657 * gcc.dg/graphite/pr43657.c: New. Added: branches/google/integration/gcc/testsuite/gcc.dg/graphite/pr43657.c Modified: branches/google/integration/gcc/testsuite/ChangeLog