diff mbox

[3/3] Fix PR46886: disable autopar when flag_tree_ch is not set.

Message ID 1297657022-27675-4-git-send-email-sebpop@gmail.com
State New
Headers show

Commit Message

Sebastian Pop Feb. 14, 2011, 4:17 a.m. UTC
2011-02-12  Sebastian Pop  <sebastian.pop@amd.com>

	PR tree-optimization/46886
	* tree-parloops.c (parallelize_loops): Disable autopar when
	flag_tree_ch is not set.

libgomp/
	* testsuite/libgomp.c/autopar-pr46886.c: New.
	* testsuite/libgomp.fortran/autopar-pr46886.f90: New.
---
 gcc/ChangeLog                                      |    6 ++++
 gcc/tree-parloops.c                                |    5 +++-
 libgomp/ChangeLog                                  |    6 ++++
 libgomp/testsuite/libgomp.c/autopar-pr46886.c      |   29 ++++++++++++++++++++
 .../testsuite/libgomp.fortran/autopar-pr46886.f90  |   21 ++++++++++++++
 5 files changed, 66 insertions(+), 1 deletions(-)
 create mode 100644 libgomp/testsuite/libgomp.c/autopar-pr46886.c
 create mode 100644 libgomp/testsuite/libgomp.fortran/autopar-pr46886.f90

Comments

Richard Biener Feb. 14, 2011, 11:33 a.m. UTC | #1
On Sun, 13 Feb 2011, Sebastian Pop wrote:

> 2011-02-12  Sebastian Pop  <sebastian.pop@amd.com>
> 
> 	PR tree-optimization/46886
> 	* tree-parloops.c (parallelize_loops): Disable autopar when
> 	flag_tree_ch is not set.
> 
> libgomp/
> 	* testsuite/libgomp.c/autopar-pr46886.c: New.
> 	* testsuite/libgomp.fortran/autopar-pr46886.f90: New.
> ---
>  gcc/ChangeLog                                      |    6 ++++
>  gcc/tree-parloops.c                                |    5 +++-
>  libgomp/ChangeLog                                  |    6 ++++
>  libgomp/testsuite/libgomp.c/autopar-pr46886.c      |   29 ++++++++++++++++++++
>  .../testsuite/libgomp.fortran/autopar-pr46886.f90  |   21 ++++++++++++++
>  5 files changed, 66 insertions(+), 1 deletions(-)
>  create mode 100644 libgomp/testsuite/libgomp.c/autopar-pr46886.c
>  create mode 100644 libgomp/testsuite/libgomp.fortran/autopar-pr46886.f90
> 
> diff --git a/gcc/ChangeLog b/gcc/ChangeLog
> index d3cc10f..9a31014 100644
> --- a/gcc/ChangeLog
> +++ b/gcc/ChangeLog
> @@ -1,5 +1,11 @@
>  2011-02-12  Sebastian Pop  <sebastian.pop@amd.com>
>  
> +	PR tree-optimization/46886
> +	* tree-parloops.c (parallelize_loops): Disable autopar when
> +	flag_tree_ch is not set.
> +
> +2011-02-12  Sebastian Pop  <sebastian.pop@amd.com>
> +
>  	* tree-parloops.c (parallelize_loops): Correct indentation.
>  
>  2011-02-12  Sebastian Pop  <sebastian.pop@amd.com>
> diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
> index f44442a..9530062 100644
> --- a/gcc/tree-parloops.c
> +++ b/gcc/tree-parloops.c
> @@ -2080,7 +2080,10 @@ parallelize_loops (void)
>  
>    /* Do not parallelize loops in the functions created by parallelization.  */
>    if (parallelized_function_p (cfun->decl)
> -      || cfun->has_nonlocal_label)
> +      || cfun->has_nonlocal_label
> +      /* If the loop copy headers pass is disabled, the code generated
> +	 in transform_to_exit_first_loop is not valid.  */
> +      || !flag_tree_ch)

Why is the code generated not valid - thus, what assumptions does
autopar have?  Why can't they be verified (even with -ftree-ch we
may fail to copy the header of some loop).

Richard.

>      return false;
>  
>    gcc_obstack_init (&parloop_obstack);
> diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
> index 2aea502..5bb3082 100644
> --- a/libgomp/ChangeLog
> +++ b/libgomp/ChangeLog
> @@ -1,3 +1,9 @@
> +2011-02-12  Sebastian Pop  <sebastian.pop@amd.com>
> +
> +	PR tree-optimization/46886
> +	* testsuite/libgomp.c/autopar-pr46886.c: New.
> +	* testsuite/libgomp.fortran/autopar-pr46886.f90: New.
> +
>  2011-01-20  Benjamin Kosnik  <bkoz@redhat.com>
>  
>  	PR libstdc++/36104
> diff --git a/libgomp/testsuite/libgomp.c/autopar-pr46886.c b/libgomp/testsuite/libgomp.c/autopar-pr46886.c
> new file mode 100644
> index 0000000..8dde5a5
> --- /dev/null
> +++ b/libgomp/testsuite/libgomp.c/autopar-pr46886.c
> @@ -0,0 +1,29 @@
> +/* { dg-do run } */
> +/* { dg-options "-O -ftree-parallelize-loops=2 -fstrict-overflow -fno-tree-ch" } */
> +
> +extern void abort (void);
> +
> +__attribute__((noinline, noclone)) void
> +foo (int *__restrict__ p, int *__restrict__ q, int n)
> +{
> +  int i;
> +  for (i = 0; i < n; i++)
> +    p[i] = q[i];
> +}
> +
> +int
> +main (void)
> +{
> +  int *p = __builtin_calloc (1025, sizeof (int));
> +  int *q = __builtin_calloc (1025, sizeof (int));
> +
> +  p[1024] = 42;
> +  q[1024] = 24;
> +
> +  foo (p, q, 1024);
> +
> +  if (q[1024] == 42)
> +    abort ();
> +
> +  return 0;
> +}
> diff --git a/libgomp/testsuite/libgomp.fortran/autopar-pr46886.f90 b/libgomp/testsuite/libgomp.fortran/autopar-pr46886.f90
> new file mode 100644
> index 0000000..6b1ccdd
> --- /dev/null
> +++ b/libgomp/testsuite/libgomp.fortran/autopar-pr46886.f90
> @@ -0,0 +1,21 @@
> +! { dg-do run }
> +! { dg-options "-O -ftree-parallelize-loops=2 -fstrict-overflow -fno-tree-ch" } */
> +
> +program main
> +  implicit none
> +  call build ()
> +contains
> +  function gen (order)
> +    real, dimension (:, :), pointer :: gen
> +    integer :: order
> +    allocate (gen (order, order + 1))
> +  end function gen
> +  subroutine build ()
> +    integer :: i
> +    call test ((/ (gen (i), i = 1, 9) /))
> +    call test ((/ (gen (i), i = 1, 9) /))
> +  end subroutine build
> +  subroutine test (values)
> +    real, dimension (:) :: values
> +  end subroutine test
> +end program main
>
diff mbox

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d3cc10f..9a31014 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@ 
 2011-02-12  Sebastian Pop  <sebastian.pop@amd.com>
 
+	PR tree-optimization/46886
+	* tree-parloops.c (parallelize_loops): Disable autopar when
+	flag_tree_ch is not set.
+
+2011-02-12  Sebastian Pop  <sebastian.pop@amd.com>
+
 	* tree-parloops.c (parallelize_loops): Correct indentation.
 
 2011-02-12  Sebastian Pop  <sebastian.pop@amd.com>
diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index f44442a..9530062 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -2080,7 +2080,10 @@  parallelize_loops (void)
 
   /* Do not parallelize loops in the functions created by parallelization.  */
   if (parallelized_function_p (cfun->decl)
-      || cfun->has_nonlocal_label)
+      || cfun->has_nonlocal_label
+      /* If the loop copy headers pass is disabled, the code generated
+	 in transform_to_exit_first_loop is not valid.  */
+      || !flag_tree_ch)
     return false;
 
   gcc_obstack_init (&parloop_obstack);
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 2aea502..5bb3082 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,3 +1,9 @@ 
+2011-02-12  Sebastian Pop  <sebastian.pop@amd.com>
+
+	PR tree-optimization/46886
+	* testsuite/libgomp.c/autopar-pr46886.c: New.
+	* testsuite/libgomp.fortran/autopar-pr46886.f90: New.
+
 2011-01-20  Benjamin Kosnik  <bkoz@redhat.com>
 
 	PR libstdc++/36104
diff --git a/libgomp/testsuite/libgomp.c/autopar-pr46886.c b/libgomp/testsuite/libgomp.c/autopar-pr46886.c
new file mode 100644
index 0000000..8dde5a5
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/autopar-pr46886.c
@@ -0,0 +1,29 @@ 
+/* { dg-do run } */
+/* { dg-options "-O -ftree-parallelize-loops=2 -fstrict-overflow -fno-tree-ch" } */
+
+extern void abort (void);
+
+__attribute__((noinline, noclone)) void
+foo (int *__restrict__ p, int *__restrict__ q, int n)
+{
+  int i;
+  for (i = 0; i < n; i++)
+    p[i] = q[i];
+}
+
+int
+main (void)
+{
+  int *p = __builtin_calloc (1025, sizeof (int));
+  int *q = __builtin_calloc (1025, sizeof (int));
+
+  p[1024] = 42;
+  q[1024] = 24;
+
+  foo (p, q, 1024);
+
+  if (q[1024] == 42)
+    abort ();
+
+  return 0;
+}
diff --git a/libgomp/testsuite/libgomp.fortran/autopar-pr46886.f90 b/libgomp/testsuite/libgomp.fortran/autopar-pr46886.f90
new file mode 100644
index 0000000..6b1ccdd
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/autopar-pr46886.f90
@@ -0,0 +1,21 @@ 
+! { dg-do run }
+! { dg-options "-O -ftree-parallelize-loops=2 -fstrict-overflow -fno-tree-ch" } */
+
+program main
+  implicit none
+  call build ()
+contains
+  function gen (order)
+    real, dimension (:, :), pointer :: gen
+    integer :: order
+    allocate (gen (order, order + 1))
+  end function gen
+  subroutine build ()
+    integer :: i
+    call test ((/ (gen (i), i = 1, 9) /))
+    call test ((/ (gen (i), i = 1, 9) /))
+  end subroutine build
+  subroutine test (values)
+    real, dimension (:) :: values
+  end subroutine test
+end program main