The testcase: int a, c, d, e, f; int b[1]; short g; void fn1 () { for (; a; a++) if (f) for (; e; e--) { d = 0; for (; d <= 0; d++) if (c) break; (g = a) || (b[a] = 0); } } ICEs with -Ofast -floop-interchange: ../../gcc/isl/isl_aff.c:1001: position out of bounds mycrash.c: In function ‘fn1’: mycrash.c:6:1: internal compiler error: Aborted fn1 () ^~~ 0xbab71f crash_signal ../../gcc/gcc/toplev.c:333 0x13a4fe2 isl_handle_error ../../gcc/isl/isl_ctx.c:96 0x1365fa1 isl_aff_set_coefficient_si ../../gcc/isl/isl_aff.c:1000 0x12342da extract_affine_chrec ../../gcc/gcc/graphite-sese-to-poly.c:239 0x12342da extract_affine ../../gcc/gcc/graphite-sese-to-poly.c:381 0x123418e extract_affine ../../gcc/gcc/graphite-sese-to-poly.c:421 0x123523d add_condition_to_pbb ../../gcc/gcc/graphite-sese-to-poly.c:458 0x123523d add_conditions_to_domain ../../gcc/gcc/graphite-sese-to-poly.c:525 0x123523d build_iteration_domains ../../gcc/gcc/graphite-sese-to-poly.c:1017 0x1234fe5 build_iteration_domains ../../gcc/gcc/graphite-sese-to-poly.c:1040 0x123579f build_poly_scop(scop*) ../../gcc/gcc/graphite-sese-to-poly.c:1364 0x121fb9a graphite_transform_loops() ../../gcc/gcc/graphite.c:319 0x12201a0 graphite_transforms ../../gcc/gcc/graphite.c:356 0x12201a0 execute ../../gcc/gcc/graphite.c:433 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. This is using ISL 0.15 as downloaded from contrib/download_prerequisites. Don't know if this is an ISL bug or a bug in the way GCC communicates with it.
I get (pprobably) the same ICE on s390x with today's devel branch in pr68279.f90. Reduced test case (which intentionally has some out of bound array accesses): MODULE foo CONTAINS SUBROUTINE bar(o) INTEGER, DIMENSION(2, 1) :: a INTEGER, DIMENSION(1) :: b INTEGER, DIMENSION(1, 1) :: o INTEGER :: d DO i=1,2 b(1:2) = b(1:2) o(1:1, 1:d) = a(1:1, 1:d) a(1:2, 2) = b(1:2) d = d + 1 END DO END SUBROUTINE bar END MODULE ==> .../gcc/testsuite/gfortran2/../../gfortran -B.../gcc/testsuite/gfortran2/../../ -B.../s390x-ibm-linux-gnu/32/libgfortran/ x.f90 -floop-nest-optimize -O1 -S -m64 x.f90:9:10: b(1:2) = b(1:2) 1 Warning: Upper array reference at (1) is out of bounds (2 > 1) in dimension 1 x.f90:9:19: b(1:2) = b(1:2) 1 Warning: Upper array reference at (1) is out of bounds (2 > 1) in dimension 1 x.f90:11:15: a(1:2, 2) = b(1:2) 1 Warning: Array reference at (1) is out of bounds (2 > 1) in dimension 2 x.f90:11:22: a(1:2, 2) = b(1:2) 1 Warning: Upper array reference at (1) is out of bounds (2 > 1) in dimension 1 isl_aff.c:944: position out of bounds x.f90:3:0: SUBROUTINE bar(o) internal compiler error: Aborted 0x806bd397 crash_signal /home/vogt/src/t/gcc/toplev.c:335 0x80b3b683 extract_affine_chrec /home/vogt/src/t/gcc/graphite-sese-to-poly.c:239 0x80b3b683 extract_affine /home/vogt/src/t/gcc/graphite-sese-to-poly.c:381 0x80b3b8b7 extract_affine /home/vogt/src/t/gcc/graphite-sese-to-poly.c:421 0x80b3c52d add_condition_to_pbb /home/vogt/src/t/gcc/graphite-sese-to-poly.c:458 0x80b3c52d add_conditions_to_domain /home/vogt/src/t/gcc/graphite-sese-to-poly.c:525 0x80b3c52d build_iteration_domains /home/vogt/src/t/gcc/graphite-sese-to-poly.c:1017 0x80b3c2dd build_iteration_domains /home/vogt/src/t/gcc/graphite-sese-to-poly.c:1040 0x80b3c95f build_poly_scop(scop*) /home/vogt/src/t/gcc/graphite-sese-to-poly.c:1364 0x80b296c9 graphite_transform_loops() /home/vogt/src/t/gcc/graphite.c:319 0x80b29c4f graphite_transforms /home/vogt/src/t/gcc/graphite.c:356 0x80b29c4f execute /home/vogt/src/t/gcc/graphite.c:433
I cannot reproduce this ICE w/ testcase from #c0, compiling it w/ current gcc 7 snapshot for both x86_64 and 32-bit powerpc. Note that I have ISL 0.17.1 installed. However, I see a similar ICE on both archs w/ the following testcase: int j6, u6, ip; int vi[2], sx[3]; void i0 (void) { for (ip = 0; ip < 2; ++ip) { static int xj[2] = { 0 }; for (j6 = 0; j6 < 2; ++j6) u6 = xj[j6]; if (xj[ip] != 0) u6 = sx[ip + 1]; for (j6 = 0; j6 < 2; ++j6) vi[j6] = 0; } } % x86_64-pc-linux-gnu-gcc-7.0.0-alpha20160703 -c -O2 -floop-nest-optimize uagtztry.c isl-0.17.1/work/isl-0.17.1/isl_aff.c:1019: position out of bounds uagtztry.c: In function 'i0': uagtztry.c:5:1: internal compiler error: Aborted i0 (void) ^~
GCC 6.2 is being released, adjusting target milestone.
GCC 6.3 is being released, adjusting target milestone.
This no longer happens with current trunk. The warnings are still present, but the ICE is gone: (In reply to Dominik Vogt from comment #1) > I get (pprobably) the same ICE on s390x with today's devel branch in > pr68279.f90. Reduced test case (which intentionally has some out of bound > array accesses): > > MODULE foo > CONTAINS > SUBROUTINE bar(o) > INTEGER, DIMENSION(2, 1) :: a > INTEGER, DIMENSION(1) :: b > INTEGER, DIMENSION(1, 1) :: o > INTEGER :: d > DO i=1,2 > b(1:2) = b(1:2) > o(1:1, 1:d) = a(1:1, 1:d) > a(1:2, 2) = b(1:2) > d = d + 1 > END DO > END SUBROUTINE bar > END MODULE > internal compiler error: Aborted > 0x806bd397 crash_signal > /home/vogt/src/t/gcc/toplev.c:335 > 0x80b3b683 extract_affine_chrec > /home/vogt/src/t/gcc/graphite-sese-to-poly.c:239 > 0x80b3b683 extract_affine > /home/vogt/src/t/gcc/graphite-sese-to-poly.c:381 > 0x80b3b8b7 extract_affine > /home/vogt/src/t/gcc/graphite-sese-to-poly.c:421 > 0x80b3c52d add_condition_to_pbb > /home/vogt/src/t/gcc/graphite-sese-to-poly.c:458 > 0x80b3c52d add_conditions_to_domain > /home/vogt/src/t/gcc/graphite-sese-to-poly.c:525 > 0x80b3c52d build_iteration_domains > /home/vogt/src/t/gcc/graphite-sese-to-poly.c:1017 > 0x80b3c2dd build_iteration_domains > /home/vogt/src/t/gcc/graphite-sese-to-poly.c:1040 > 0x80b3c95f build_poly_scop(scop*) > /home/vogt/src/t/gcc/graphite-sese-to-poly.c:1364 > 0x80b296c9 graphite_transform_loops() > /home/vogt/src/t/gcc/graphite.c:319 > 0x80b29c4f graphite_transforms > /home/vogt/src/t/gcc/graphite.c:356 > 0x80b29c4f execute > /home/vogt/src/t/gcc/graphite.c:433
The ICE (s390x) has gone away with this commit: 2017-01-31 Richard Biener <rguenther@suse.de> PR tree-optimization/77318 * graphite-sese-to-poly.c (extract_affine): Fix assert. (create_pw_aff_from_tree): Take loop parameter. (add_condition_to_pbb): Pass loop of the condition to create_pw_aff_from_tree. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@245064 138bc75d-0d04-0410-96
GCC 6.4 is being released, adjusting target milestone.
I can reproduce ICEs w/ C testcases from comments 0 and 2 only w/ gcc 6.3. I believe the issue is fixed on 7 and all newer branches.
GCC 6 branch is being closed
The GCC 7 branch is being closed, re-targeting to GCC 8.4.
I believe this PR can be closed, per comment 9 (and likely comment 7).
GCC 8.4.0 has been released, adjusting target milestone.
GCC 8 branch is being closed.
GCC 9.4 is being released, retargeting bugs to GCC 9.5.
GCC 9 branch is being closed
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
GCC 10 branch is being closed.