diff mbox

[1/3] Fix PR47653: do not handle loops using wrapping semantics in graphite

Message ID 1311492333-30309-2-git-send-email-sebpop@gmail.com
State New
Headers show

Commit Message

Sebastian Pop July 24, 2011, 7:25 a.m. UTC
2011-07-23  Sebastian Pop  <sebastian.pop@amd.com>

	PR middle-end/47653
	* graphite-scop-detection.c (graphite_can_represent_loop): Discard
	loops using wrapping semantics.

	* gcc.dg/graphite/run-id-pr47653.c: New.
	* gcc.dg/graphite/interchange-3.c: Do not use unsigned types for
	induction variables.
	* gcc.dg/graphite/scop-16.c: Same.
	* gcc.dg/graphite/scop-17.c: Same.
	* gcc.dg/graphite/scop-21.c: Same.
---
 gcc/ChangeLog                                      |    6 ++++++
 gcc/graphite-scop-detection.c                      |   18 +++++++++---------
 gcc/testsuite/ChangeLog                            |   10 ++++++++++
 gcc/testsuite/gcc.dg/graphite/interchange-3.c      |    2 +-
 gcc/testsuite/gcc.dg/graphite/run-id-pr47653.c     |   17 +++++++++++++++++
 gcc/testsuite/gcc.dg/graphite/scop-16.c            |    2 +-
 gcc/testsuite/gcc.dg/graphite/scop-17.c            |    2 +-
 gcc/testsuite/gcc.dg/graphite/scop-21.c            |    2 +-
 .../testsuite/libgomp.graphite/force-parallel-1.c  |    2 +-
 9 files changed, 47 insertions(+), 14 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/graphite/run-id-pr47653.c

Comments

Richard Biener July 24, 2011, 11 a.m. UTC | #1
On Sun, Jul 24, 2011 at 9:25 AM, Sebastian Pop <sebpop@gmail.com> wrote:
> 2011-07-23  Sebastian Pop  <sebastian.pop@amd.com>
>
>        PR middle-end/47653
>        * graphite-scop-detection.c (graphite_can_represent_loop): Discard
>        loops using wrapping semantics.
>
>        * gcc.dg/graphite/run-id-pr47653.c: New.
>        * gcc.dg/graphite/interchange-3.c: Do not use unsigned types for
>        induction variables.
>        * gcc.dg/graphite/scop-16.c: Same.
>        * gcc.dg/graphite/scop-17.c: Same.
>        * gcc.dg/graphite/scop-21.c: Same.

Ok.

Thanks,
Richard.

> ---
>  gcc/ChangeLog                                      |    6 ++++++
>  gcc/graphite-scop-detection.c                      |   18 +++++++++---------
>  gcc/testsuite/ChangeLog                            |   10 ++++++++++
>  gcc/testsuite/gcc.dg/graphite/interchange-3.c      |    2 +-
>  gcc/testsuite/gcc.dg/graphite/run-id-pr47653.c     |   17 +++++++++++++++++
>  gcc/testsuite/gcc.dg/graphite/scop-16.c            |    2 +-
>  gcc/testsuite/gcc.dg/graphite/scop-17.c            |    2 +-
>  gcc/testsuite/gcc.dg/graphite/scop-21.c            |    2 +-
>  .../testsuite/libgomp.graphite/force-parallel-1.c  |    2 +-
>  9 files changed, 47 insertions(+), 14 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.dg/graphite/run-id-pr47653.c
>
> diff --git a/gcc/ChangeLog b/gcc/ChangeLog
> index 36347d6..2d147b8 100644
> --- a/gcc/ChangeLog
> +++ b/gcc/ChangeLog
> @@ -1,5 +1,11 @@
>  2011-07-23  Sebastian Pop  <sebastian.pop@amd.com>
>
> +       PR middle-end/47653
> +       * graphite-scop-detection.c (graphite_can_represent_loop): Discard
> +       loops using wrapping semantics.
> +
> +2011-07-23  Sebastian Pop  <sebastian.pop@amd.com>
> +
>        PR middle-end/47691
>        * graphite.c (graphite_initialize): Call scev_const_prop when
>        flag_tree_scev_cprop is not set.
> diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c
> index 45c6c75..3460568 100644
> --- a/gcc/graphite-scop-detection.c
> +++ b/gcc/graphite-scop-detection.c
> @@ -378,17 +378,17 @@ harmful_stmt_in_bb (basic_block scop_entry, loop_p outer_loop, basic_block bb)
>  static bool
>  graphite_can_represent_loop (basic_block scop_entry, loop_p loop)
>  {
> -  tree niter = number_of_latch_executions (loop);
> +  tree niter;
> +  struct tree_niter_desc niter_desc;
>
> -  /* Number of iterations unknown.  */
> -  if (chrec_contains_undetermined (niter))
> -    return false;
> -
> -  /* Number of iterations not affine.  */
> -  if (!graphite_can_represent_expr (scop_entry, loop, niter))
> -    return false;
> +  /* FIXME: For the moment, graphite cannot be used on loops that
> +     iterate using induction variables that wrap.  */
>
> -  return true;
> +  return number_of_iterations_exit (loop, single_exit (loop), &niter_desc, false)
> +    && niter_desc.control.no_overflow
> +    && (niter = number_of_latch_executions (loop))
> +    && !chrec_contains_undetermined (niter)
> +    && graphite_can_represent_expr (scop_entry, loop, niter);
>  }
>
>  /* Store information needed by scopdet_* functions.  */
> diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
> index 5f9b79d..c3ded27 100644
> --- a/gcc/testsuite/ChangeLog
> +++ b/gcc/testsuite/ChangeLog
> @@ -1,5 +1,15 @@
>  2011-07-23  Sebastian Pop  <sebastian.pop@amd.com>
>
> +       PR middle-end/47653
> +       * gcc.dg/graphite/run-id-pr47653.c: New.
> +       * gcc.dg/graphite/interchange-3.c: Do not use unsigned types for
> +       induction variables.
> +       * gcc.dg/graphite/scop-16.c: Same.
> +       * gcc.dg/graphite/scop-17.c: Same.
> +       * gcc.dg/graphite/scop-21.c: Same.
> +
> +2011-07-23  Sebastian Pop  <sebastian.pop@amd.com>
> +
>        PR middle-end/47691
>        * gfortran.dg/graphite/id-pr47691.f: New.
>
> diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-3.c b/gcc/testsuite/gcc.dg/graphite/interchange-3.c
> index 26ec4d9..1419749 100644
> --- a/gcc/testsuite/gcc.dg/graphite/interchange-3.c
> +++ b/gcc/testsuite/gcc.dg/graphite/interchange-3.c
> @@ -12,7 +12,7 @@ double u[1782225];
>  static void __attribute__((noinline))
>  foo (int N, int *res)
>  {
> -  unsigned int i, j;
> +  int i, j;
>   double sum = 0;
>   for (i = 0; i < N; i++)
>     {
> diff --git a/gcc/testsuite/gcc.dg/graphite/run-id-pr47653.c b/gcc/testsuite/gcc.dg/graphite/run-id-pr47653.c
> new file mode 100644
> index 0000000..b62b891
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/graphite/run-id-pr47653.c
> @@ -0,0 +1,17 @@
> +/* { dg-options "-O -fstack-check=generic -ftree-pre -fgraphite-identity" } */
> +
> +int main ()
> +{
> +  int i, j;
> +  int x[8][8];
> +  for (i = 0; i < 8; i++)
> +    for (j = i; j < 8; j++)
> +      x[i][j] = 4;
> +
> +  for (i = 0; i < 8; i++)
> +    for (j = i; j < 8; j++)
> +      if (x[i][j] != 4)
> +       __builtin_abort ();
> +
> +  return 0;
> +}
> diff --git a/gcc/testsuite/gcc.dg/graphite/scop-16.c b/gcc/testsuite/gcc.dg/graphite/scop-16.c
> index 0849e86..83cbb96 100644
> --- a/gcc/testsuite/gcc.dg/graphite/scop-16.c
> +++ b/gcc/testsuite/gcc.dg/graphite/scop-16.c
> @@ -6,7 +6,7 @@ int test ()
>  {
>   int a[N][N];
>   int b[N][N];
> -  unsigned i, j;
> +  int i, j;
>
>   for (i = 0; i < N; i++)
>     for (j = 0; j < N; j++)
> diff --git a/gcc/testsuite/gcc.dg/graphite/scop-17.c b/gcc/testsuite/gcc.dg/graphite/scop-17.c
> index ee37aea..a7dff5f 100644
> --- a/gcc/testsuite/gcc.dg/graphite/scop-17.c
> +++ b/gcc/testsuite/gcc.dg/graphite/scop-17.c
> @@ -5,7 +5,7 @@ void foo (int);
>  int test ()
>  {
>   int a[N][N];
> -  unsigned i, j;
> +  int i, j;
>
>   for (i = 0; i < N; i++)
>     for (j = 0; j < N; j++)
> diff --git a/gcc/testsuite/gcc.dg/graphite/scop-21.c b/gcc/testsuite/gcc.dg/graphite/scop-21.c
> index 5e58834..1cbad5d 100644
> --- a/gcc/testsuite/gcc.dg/graphite/scop-21.c
> +++ b/gcc/testsuite/gcc.dg/graphite/scop-21.c
> @@ -3,7 +3,7 @@ void foo (int);
>  int test ()
>  {
>   int a[N+6];
> -  unsigned i;
> +  int i;
>
>   for (i = 0; i < N; i++)
>     {
> diff --git a/libgomp/testsuite/libgomp.graphite/force-parallel-1.c b/libgomp/testsuite/libgomp.graphite/force-parallel-1.c
> index 7f043d8..71ed332 100644
> --- a/libgomp/testsuite/libgomp.graphite/force-parallel-1.c
> +++ b/libgomp/testsuite/libgomp.graphite/force-parallel-1.c
> @@ -23,7 +23,7 @@ int main(void)
>  }
>
>  /* Check that parallel code generation part make the right answer.  */
> -/* { dg-final { scan-tree-dump-times "1 loops carried no dependency" 2 "graphite" } } */
> +/* { dg-final { scan-tree-dump-times "1 loops carried no dependency" 2 "graphite" { xfail *-*-* } } } */
>  /* { dg-final { cleanup-tree-dump "graphite" } } */
>  /* { dg-final { scan-tree-dump-times "loopfn" 5 "optimized" } } */
>  /* { dg-final { cleanup-tree-dump "parloops" } } */
> --
> 1.7.4.1
>
>
Tobias Grosser July 28, 2011, 4:47 p.m. UTC | #2
On 07/24/2011 08:25 AM, Sebastian Pop wrote:
> 2011-07-23  Sebastian Pop<sebastian.pop@amd.com>
>
> 	PR middle-end/47653
> 	* graphite-scop-detection.c (graphite_can_represent_loop): Discard
> 	loops using wrapping semantics.
>
> 	* gcc.dg/graphite/run-id-pr47653.c: New.
> 	* gcc.dg/graphite/interchange-3.c: Do not use unsigned types for
> 	induction variables.
> 	* gcc.dg/graphite/scop-16.c: Same.
> 	* gcc.dg/graphite/scop-17.c: Same.
> 	* gcc.dg/graphite/scop-21.c: Same.
> ---
>   gcc/ChangeLog                                      |    6 ++++++
>   gcc/graphite-scop-detection.c                      |   18 +++++++++---------
>   gcc/testsuite/ChangeLog                            |   10 ++++++++++
>   gcc/testsuite/gcc.dg/graphite/interchange-3.c      |    2 +-
>   gcc/testsuite/gcc.dg/graphite/run-id-pr47653.c     |   17 +++++++++++++++++
>   gcc/testsuite/gcc.dg/graphite/scop-16.c            |    2 +-
>   gcc/testsuite/gcc.dg/graphite/scop-17.c            |    2 +-
>   gcc/testsuite/gcc.dg/graphite/scop-21.c            |    2 +-
>   .../testsuite/libgomp.graphite/force-parallel-1.c  |    2 +-
>   9 files changed, 47 insertions(+), 14 deletions(-)
>   create mode 100644 gcc/testsuite/gcc.dg/graphite/run-id-pr47653.c
diff mbox

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 36347d6..2d147b8 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@ 
 2011-07-23  Sebastian Pop  <sebastian.pop@amd.com>
 
+	PR middle-end/47653
+	* graphite-scop-detection.c (graphite_can_represent_loop): Discard
+	loops using wrapping semantics.
+
+2011-07-23  Sebastian Pop  <sebastian.pop@amd.com>
+
 	PR middle-end/47691
 	* graphite.c (graphite_initialize): Call scev_const_prop when
 	flag_tree_scev_cprop is not set.
diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c
index 45c6c75..3460568 100644
--- a/gcc/graphite-scop-detection.c
+++ b/gcc/graphite-scop-detection.c
@@ -378,17 +378,17 @@  harmful_stmt_in_bb (basic_block scop_entry, loop_p outer_loop, basic_block bb)
 static bool
 graphite_can_represent_loop (basic_block scop_entry, loop_p loop)
 {
-  tree niter = number_of_latch_executions (loop);
+  tree niter;
+  struct tree_niter_desc niter_desc;
 
-  /* Number of iterations unknown.  */
-  if (chrec_contains_undetermined (niter))
-    return false;
-
-  /* Number of iterations not affine.  */
-  if (!graphite_can_represent_expr (scop_entry, loop, niter))
-    return false;
+  /* FIXME: For the moment, graphite cannot be used on loops that
+     iterate using induction variables that wrap.  */
 
-  return true;
+  return number_of_iterations_exit (loop, single_exit (loop), &niter_desc, false)
+    && niter_desc.control.no_overflow
+    && (niter = number_of_latch_executions (loop))
+    && !chrec_contains_undetermined (niter)
+    && graphite_can_represent_expr (scop_entry, loop, niter);
 }
 
 /* Store information needed by scopdet_* functions.  */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5f9b79d..c3ded27 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,15 @@ 
 2011-07-23  Sebastian Pop  <sebastian.pop@amd.com>
 
+	PR middle-end/47653
+	* gcc.dg/graphite/run-id-pr47653.c: New.
+	* gcc.dg/graphite/interchange-3.c: Do not use unsigned types for
+	induction variables.
+	* gcc.dg/graphite/scop-16.c: Same.
+	* gcc.dg/graphite/scop-17.c: Same.
+	* gcc.dg/graphite/scop-21.c: Same.
+
+2011-07-23  Sebastian Pop  <sebastian.pop@amd.com>
+
 	PR middle-end/47691
 	* gfortran.dg/graphite/id-pr47691.f: New.
 
diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-3.c b/gcc/testsuite/gcc.dg/graphite/interchange-3.c
index 26ec4d9..1419749 100644
--- a/gcc/testsuite/gcc.dg/graphite/interchange-3.c
+++ b/gcc/testsuite/gcc.dg/graphite/interchange-3.c
@@ -12,7 +12,7 @@  double u[1782225];
 static void __attribute__((noinline))
 foo (int N, int *res)
 {
-  unsigned int i, j;
+  int i, j;
   double sum = 0;
   for (i = 0; i < N; i++)
     {
diff --git a/gcc/testsuite/gcc.dg/graphite/run-id-pr47653.c b/gcc/testsuite/gcc.dg/graphite/run-id-pr47653.c
new file mode 100644
index 0000000..b62b891
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/graphite/run-id-pr47653.c
@@ -0,0 +1,17 @@ 
+/* { dg-options "-O -fstack-check=generic -ftree-pre -fgraphite-identity" } */
+
+int main ()
+{
+  int i, j;
+  int x[8][8];
+  for (i = 0; i < 8; i++)
+    for (j = i; j < 8; j++)
+      x[i][j] = 4;
+
+  for (i = 0; i < 8; i++)
+    for (j = i; j < 8; j++)
+      if (x[i][j] != 4)
+	__builtin_abort ();
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/graphite/scop-16.c b/gcc/testsuite/gcc.dg/graphite/scop-16.c
index 0849e86..83cbb96 100644
--- a/gcc/testsuite/gcc.dg/graphite/scop-16.c
+++ b/gcc/testsuite/gcc.dg/graphite/scop-16.c
@@ -6,7 +6,7 @@  int test ()
 {
   int a[N][N];
   int b[N][N];
-  unsigned i, j;
+  int i, j;
 
   for (i = 0; i < N; i++) 
     for (j = 0; j < N; j++)
diff --git a/gcc/testsuite/gcc.dg/graphite/scop-17.c b/gcc/testsuite/gcc.dg/graphite/scop-17.c
index ee37aea..a7dff5f 100644
--- a/gcc/testsuite/gcc.dg/graphite/scop-17.c
+++ b/gcc/testsuite/gcc.dg/graphite/scop-17.c
@@ -5,7 +5,7 @@  void foo (int);
 int test ()
 {
   int a[N][N];
-  unsigned i, j;
+  int i, j;
 
   for (i = 0; i < N; i++) 
     for (j = 0; j < N; j++)
diff --git a/gcc/testsuite/gcc.dg/graphite/scop-21.c b/gcc/testsuite/gcc.dg/graphite/scop-21.c
index 5e58834..1cbad5d 100644
--- a/gcc/testsuite/gcc.dg/graphite/scop-21.c
+++ b/gcc/testsuite/gcc.dg/graphite/scop-21.c
@@ -3,7 +3,7 @@  void foo (int);
 int test ()
 {
   int a[N+6];
-  unsigned i;
+  int i;
 
   for (i = 0; i < N; i++)
     {
diff --git a/libgomp/testsuite/libgomp.graphite/force-parallel-1.c b/libgomp/testsuite/libgomp.graphite/force-parallel-1.c
index 7f043d8..71ed332 100644
--- a/libgomp/testsuite/libgomp.graphite/force-parallel-1.c
+++ b/libgomp/testsuite/libgomp.graphite/force-parallel-1.c
@@ -23,7 +23,7 @@  int main(void)
 }
 
 /* Check that parallel code generation part make the right answer.  */
-/* { dg-final { scan-tree-dump-times "1 loops carried no dependency" 2 "graphite" } } */
+/* { dg-final { scan-tree-dump-times "1 loops carried no dependency" 2 "graphite" { xfail *-*-* } } } */
 /* { dg-final { cleanup-tree-dump "graphite" } } */
 /* { dg-final { scan-tree-dump-times "loopfn" 5 "optimized" } } */
 /* { dg-final { cleanup-tree-dump "parloops" } } */