for the testcase to be attached (what about enhancing bugzilla with an option to attach files at initial submit time?) gfortran -v -c -O2 -funroll-loops -fprefetch-loop-arrays test.f90 Using built-in specs. Target: x86_64-unknown-linux-gnu Configured with: /data03/vondele/gcc_trunk/gcc/configure --prefix=/data03/vondele/gcc_trunk/build --enable-languages=c,c++,fortran --disable-multilib --with-ppl=/data03/vondele/gcc_trunk/build/ --with-cloog=/data03/vondele/gcc_trunk/build/ Thread model: posix gcc version 4.5.0 20090527 (experimental) [trunk revision 147915] (GCC) COLLECT_GCC_OPTIONS='-v' '-c' '-O2' '-funroll-loops' '-fprefetch-loop-arrays' '-mtune=generic' /data03/vondele/gcc_trunk/build/libexec/gcc/x86_64-unknown-linux-gnu/4.5.0/f951 test.f90 -quiet -dumpbase test.f90 -mtune=generic -auxbase test -O2 -version -funroll-loops -fprefetch-loop-arrays -fintrinsic-modules-path /data03/vondele/gcc_trunk/build/lib/gcc/x86_64-unknown-linux-gnu/4.5.0/finclude -o /tmp/ccDzkBkL.s GNU Fortran (GCC) version 4.5.0 20090527 (experimental) [trunk revision 147915] (x86_64-unknown-linux-gnu) compiled by GNU C version 4.5.0 20090527 (experimental) [trunk revision 147915], GMP version 4.2.2, MPFR version 2.3.1 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 GNU Fortran (GCC) version 4.5.0 20090527 (experimental) [trunk revision 147915] (x86_64-unknown-linux-gnu) compiled by GNU C version 4.5.0 20090527 (experimental) [trunk revision 147915], GMP version 4.2.2, MPFR version 2.3.1 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 test.f90: In function ‘makedcoul’: test.f90:7: internal compiler error: in initialize_matrix_A, at tree-data-ref.c:1887 Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions.
Created attachment 17923 [details] testcase compile as gfortran -v -c -O2 -funroll-loops -fprefetch-loop-arrays PR40281.f90
Created attachment 18024 [details] testcase The attatched testcase is from cpu2006 component 464.h264ref and appears to fail in the same manner on PowerPC. work/spec_err> /home/pthaugen/install/gcc/trunk/bin/gcc -c -m32 -O2 -fprefetch-loop-arrays q_matrix.c q_matrix.c: In function #ParseMatrix#: q_matrix.c:5:6: internal compiler error: in initialize_matrix_A, at tree-data-ref.c:1896 Please submit a full bug report, with preprocessed source if appropriate.
Confirmed, reduced testcase: void f(int, int); int g(int); extern char errortext[300]; void ParseMatrix (void) { char items[1000]; extern int item; int range; int i, j, type, cnt; for (i=0; i<item; i+=cnt) { cnt=1; if (!type) range = 16; else range = 64; for(j=0; j<range; j++) if (1 != g (items[i+cnt+j])) f (items[i], items[i+cnt+j]); cnt+=j; } }
Test case in comment 2 fails for me on x86-64-linux with 4.4.1 [gcc-4_4-branch revision 150839] and with 4.4.3 20091105 [gcc-4_4-branch revision 153928]. Marking thus as 4.4 regression. Maybe related: PR 41957
Hm. (gdb) call debug_generic_expr (chrec) {{1, +, {2, +, 1}_2}_1, +, 1}_2 how can this happen? Why does evolution_function_is_affine_multivariate_p not reject this chrec?
*** Bug 41957 has been marked as a duplicate of this bug. ***
Even shorter testcase (crashes with "-O -fprefetch-loop-arrays"): ======================================= void foo(int); void bar(int n) { int a[2], i, j = 0; for (i = 0; i < 2; i += j+1) for (j = 0; j < (n ? 1 : 2); ++j) foo(a[i] + a[j]); } =======================================
Subject: Re: [4.4/4.5 Regression] -fprefetch-loop-arrays: ICE: in initialize_matrix_A, at tree-data-ref.c:1887 Hi, Here is a fix for this one, on top of the graphite branch. I will commit this fix to the graphite branch to run the automatic testers, and then it will be included in the merge from graphite to trunk. Sebastian diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index fcd3382..7321b6e 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -2215,9 +2215,21 @@ instantiate_scev_poly (basic_block instantiate_below, if (CHREC_LEFT (chrec) != op0 || CHREC_RIGHT (chrec) != op1) { + unsigned var = CHREC_VARIABLE (chrec); + + /* When the instantiated stride or base has an evolution in an + innermost loop, return chrec_dont_know, as this is not a + valid SCEV representation. In the reduced testcase for + PR40281 we would have {0, +, {1, +, 1}_2}_1 that has no + meaning. */ + if ((tree_is_chrec (op0) && CHREC_VARIABLE (op0) > var) + || (tree_is_chrec (op1) && CHREC_VARIABLE (op1) > var)) + return chrec_dont_know; + op1 = chrec_convert_rhs (chrec_type (op0), op1, NULL); - chrec = build_polynomial_chrec (CHREC_VARIABLE (chrec), op0, op1); + chrec = build_polynomial_chrec (var, op0, op1); } + return chrec; }
Subject: Bug 40281 Author: spop Date: Thu Nov 19 22:32:50 2009 New Revision: 154348 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154348 Log: Fix PR40281. 2009-11-18 Sebastian Pop <sebastian.pop@amd.com> PR middle-end/40281 * testsuite/gcc.dg/graphite/pr40281.c: New. * tree-scalar-evolution.c (instantiate_scev_poly): Base and stride evolutions should not variate in inner loops. Added: branches/graphite/gcc/testsuite/gcc.dg/graphite/pr40281.c Modified: branches/graphite/gcc/ChangeLog.graphite branches/graphite/gcc/tree-scalar-evolution.c
Subject: Bug 40281 Author: spop Date: Wed Nov 25 05:35:58 2009 New Revision: 154641 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154641 Log: 2009-11-18 Sebastian Pop <sebastian.pop@amd.com> PR middle-end/40281 * testsuite/gcc.dg/graphite/pr40281.c: New. * tree-scalar-evolution.c (instantiate_scev_poly): Base and stride evolutions should not variate in inner loops. Modified: trunk/gcc/ChangeLog.graphite trunk/gcc/tree-scalar-evolution.c
Fixed.
testcase from comment #7 still fails on the 4.4 branch. 4.4.1 doesn't work.
Subject: Bug 40281 Author: spop Date: Wed Jan 13 07:58:50 2010 New Revision: 155851 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155851 Log: 2010-01-13 Sebastian Pop <sebastian.pop@amd.com> PR middle-end/40281 * tree-scalar-evolution.c (instantiate_scev_1): Base and stride evolutions should not variate in inner loops. * gcc.dg/graphite/pr40281.c: New. Added: branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/graphite/pr40281.c Modified: branches/gcc-4_4-branch/gcc/ChangeLog branches/gcc-4_4-branch/gcc/testsuite/ChangeLog branches/gcc-4_4-branch/gcc/tree-scalar-evolution.c
Fixed also in the 4.4 branch.