The following fixes the (old) ICE in outer_projection_mupa we now run into with SPEC CPU 2006 as well. As I don't understand what the code does or how it should behave when the scheduling domain is empty the following simply adds a way to indicate failure when we'd previously ICE.
Bootstrap and regtest running on x86_64-unknown-linux-gnu, will apply once that finished. Richard. 2017-09-18 Richard Biener <rguent...@suse.de> PR tree-optimization/69728 * graphite-sese-to-poly.c (schedule_error): New global. (add_loop_schedule): Handle empty domain by failing the schedule. (build_original_schedule): Handle schedule_error. * gfortran.dg/graphite/pr69728.f90: New testcase. * gcc.dg/graphite/pr69728.c: Likewise. Index: gcc/graphite-sese-to-poly.c =================================================================== --- gcc/graphite-sese-to-poly.c (revision 252920) +++ gcc/graphite-sese-to-poly.c (working copy) @@ -1030,6 +1035,8 @@ outer_projection_mupa (__isl_take isl_un return isl_multi_union_pw_aff_from_union_pw_multi_aff (data.res); } +static bool schedule_error; + /* Embed SCHEDULE in the constraints of the LOOP domain. */ static isl_schedule * @@ -1043,6 +1050,14 @@ add_loop_schedule (__isl_take isl_schedu if (empty < 0 || empty) return empty < 0 ? isl_schedule_free (schedule) : schedule; + isl_union_set *domain = isl_schedule_get_domain (schedule); + if (isl_union_set_is_empty (domain)) + { + schedule_error = true; + isl_union_set_free (domain); + return schedule; + } + isl_space *space = isl_set_get_space (iterators); int loop_index = isl_space_dim (space, isl_dim_set) - 1; @@ -1063,7 +1078,6 @@ add_loop_schedule (__isl_take isl_schedu prefix = isl_multi_aff_set_tuple_id (prefix, isl_dim_out, label); int n = isl_multi_aff_dim (prefix, isl_dim_in); - isl_union_set *domain = isl_schedule_get_domain (schedule); isl_multi_union_pw_aff *mupa = outer_projection_mupa (domain, n); mupa = isl_multi_union_pw_aff_apply_multi_aff (mupa, prefix); return isl_schedule_insert_partial_schedule (schedule, mupa); @@ -1169,6 +1183,8 @@ build_schedule_loop_nest (scop_p scop, i static bool build_original_schedule (scop_p scop) { + schedule_error = false; + int i = 0; int n = scop->pbbs.length (); while (i < n) @@ -1183,6 +1199,14 @@ build_original_schedule (scop_p scop) scop->original_schedule = add_in_sequence (scop->original_schedule, s); } + if (schedule_error) + { + if (dump_file) + fprintf (dump_file, "[sese-to-poly] failed to build " + "original schedule\n"); + return false; + } + if (dump_file) { fprintf (dump_file, "[sese-to-poly] original schedule:\n"); Index: gcc/testsuite/gfortran.dg/graphite/pr69728.f90 =================================================================== --- gcc/testsuite/gfortran.dg/graphite/pr69728.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/graphite/pr69728.f90 (working copy) @@ -0,0 +1,26 @@ +! { dg-do compile } +! { dg-options "-O3 -floop-nest-optimize" } +SUBROUTINE rk_addtend_dry ( t_tend, t_tendf, t_save, rk_step, & + h_diabatic, mut, msft, ide, jde, & + ims,ime, jms,jme, kms,kme, & + its,ite, jts,jte, kts,kte) + IMPLICIT NONE + INTEGER , INTENT(IN ) :: ide, jde, ims, ime, jms, jme, kms, kme, & + its, ite, jts, jte, kts, kte + INTEGER , INTENT(IN ) :: rk_step + REAL , DIMENSION( ims:ime , kms:kme, jms:jme ), & + INTENT(INOUT) :: t_tend, t_tendf + REAL , DIMENSION( ims:ime , kms:kme, jms:jme ) , & + INTENT(IN ) :: t_save, h_diabatic + REAL , DIMENSION( ims:ime , jms:jme ) , INTENT(IN ) :: mut, msft + INTEGER :: i, j, k + DO j = jts,MIN(jte,jde-1) + DO k = kts,kte-1 + DO i = its,MIN(ite,ide-1) + IF(rk_step == 1)t_tendf(i,k,j) = t_tendf(i,k,j) + t_save(i,k,j) + t_tend(i,k,j) = t_tend(i,k,j) + t_tendf(i,k,j)/msft(i,j) & + + mut(i,j)*h_diabatic(i,k,j)/msft(i,j) + ENDDO + ENDDO + ENDDO +END SUBROUTINE rk_addtend_dry Index: gcc/testsuite/gcc.dg/graphite/pr69728.c =================================================================== --- gcc/testsuite/gcc.dg/graphite/pr69728.c (nonexistent) +++ gcc/testsuite/gcc.dg/graphite/pr69728.c (working copy) @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -floop-nest-optimize" } */ + +int a[1]; +int b, c, d, e; +void +fn1 () +{ + d = 9; + for (; c; c++) + { + ++d; + b = 8; + for (; b; b--) + { + if (d) + break; + a[b] = e; + } + } +}