re PR tree-optimization/69728 (internal compiler error: in outer_projection_mupa...
authorRichard Biener <rguenther@suse.de>
Tue, 19 Sep 2017 08:25:17 +0000 (08:25 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 19 Sep 2017 08:25:17 +0000 (08:25 +0000)
2017-09-19  Richard Biener  <rguenther@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.

From-SVN: r252968

gcc/ChangeLog
gcc/graphite-sese-to-poly.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/graphite/pr69728.c [new file with mode: 0644]
gcc/testsuite/gfortran.dg/graphite/pr69728.f90 [new file with mode: 0644]

index 79a492f83a97c80649bbaf6f74d4801e945b072f..a7841b068f736c9f3c2b233bd63a2712467949d1 100644 (file)
@@ -1,3 +1,11 @@
+2017-09-19  Richard Biener  <rguenther@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.
+
 2017-09-19  Richard Biener  <rguenther@suse.de>
 
        * graphite-scop-detection.c (scop_detection::can_represent_loop):
index 8ff9a22e1291660d6d4c22d15441db18405d9142..6e64f13a77a5701bca4d72560240c9cad7c54a0a 100644 (file)
@@ -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");
index c971f2ff3a1414623fcaec980f844d20dff7b5e0..aa6c7251f0d01b55a1f6adbbdfd185b428a1d8bf 100644 (file)
@@ -1,3 +1,9 @@
+2017-09-19  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/69728
+       * gfortran.dg/graphite/pr69728.f90: New testcase.
+       * gcc.dg/graphite/pr69728.c: Likewise.
+
 2017-09-18  Paolo Carlini  <paolo.carlini@oracle.com>
 
        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 (file)
index 0000000..35ea5bd
--- /dev/null
@@ -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 (file)
index 0000000..6a3aec4
--- /dev/null
@@ -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