From 197d2f5b2c2bece593f29ffe1e98c23f62ffbbbb Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Tue, 19 Sep 2017 08:25:17 +0000 Subject: [PATCH] re PR tree-optimization/69728 (internal compiler error: in outer_projection_mupa, at graphite-sese-to-poly.c:1175) 2017-09-19 Richard Biener 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. From-SVN: r252968 --- gcc/ChangeLog | 8 ++++++ gcc/graphite-sese-to-poly.c | 23 +++++++++++++++- gcc/testsuite/ChangeLog | 6 +++++ gcc/testsuite/gcc.dg/graphite/pr69728.c | 21 +++++++++++++++ .../gfortran.dg/graphite/pr69728.f90 | 26 +++++++++++++++++++ 5 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/graphite/pr69728.c create mode 100644 gcc/testsuite/gfortran.dg/graphite/pr69728.f90 diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 79a492f83a9..a7841b068f7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2017-09-19 Richard Biener + + 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. + 2017-09-19 Richard Biener * graphite-scop-detection.c (scop_detection::can_represent_loop): diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c index 8ff9a22e129..6e64f13a77a 100644 --- a/gcc/graphite-sese-to-poly.c +++ b/gcc/graphite-sese-to-poly.c @@ -1030,6 +1030,8 @@ outer_projection_mupa (__isl_take isl_union_set *set, int n) 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 +1045,16 @@ add_loop_schedule (__isl_take isl_schedule *schedule, loop_p loop, if (empty < 0 || empty) return empty < 0 ? isl_schedule_free (schedule) : schedule; + isl_union_set *domain = isl_schedule_get_domain (schedule); + /* We cannot apply an empty domain to pbbs in this loop so fail. + ??? Somehow drop pbbs in the loop instead. */ + 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 +1075,6 @@ add_loop_schedule (__isl_take isl_schedule *schedule, loop_p loop, 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 +1180,8 @@ build_schedule_loop_nest (scop_p scop, int *index, loop_p context_loop) static bool build_original_schedule (scop_p scop) { + schedule_error = false; + int i = 0; int n = scop->pbbs.length (); while (i < n) @@ -1183,6 +1196,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"); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c971f2ff3a1..aa6c7251f0d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2017-09-19 Richard Biener + + PR tree-optimization/69728 + * gfortran.dg/graphite/pr69728.f90: New testcase. + * gcc.dg/graphite/pr69728.c: Likewise. + 2017-09-18 Paolo Carlini PR c++/80947 diff --git a/gcc/testsuite/gcc.dg/graphite/pr69728.c b/gcc/testsuite/gcc.dg/graphite/pr69728.c new file mode 100644 index 00000000000..35ea5bd15bb --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr69728.c @@ -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; + } + } +} diff --git a/gcc/testsuite/gfortran.dg/graphite/pr69728.f90 b/gcc/testsuite/gfortran.dg/graphite/pr69728.f90 new file mode 100644 index 00000000000..6a3aec469ca --- /dev/null +++ b/gcc/testsuite/gfortran.dg/graphite/pr69728.f90 @@ -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 -- 2.30.2