diff mbox

[gomp4,committed] Don't unnecessarily set address taken in expand_omp_for_generic

Message ID 560A5FAB.2050900@mentor.com
State New
Headers show

Commit Message

Tom de Vries Sept. 29, 2015, 9:53 a.m. UTC
Hi,

this patch sets the address taken bit for start0 and end0 in 
expand_omp_for_generic only if necessary. This fixes an ICE while 
compiling the test-case.

Committed to gomp-4_0-branch.

Thanks,
- Tom
diff mbox

Patch

Don't unnecessarily set address taken in expand_omp_for_generic

2015-09-29  Tom de Vries  <tom@codesourcery.com>

	* omp-low.c (expand_omp_for_generic): Only set address taken for istart0
	and end0 unless necessary.

	* c-c++-common/goacc/kernels-acc-loop-smaller-equal.c: New test.
---
 gcc/omp-low.c                                      | 10 ++++++---
 .../goacc/kernels-acc-loop-smaller-equal.c         | 25 ++++++++++++++++++++++
 2 files changed, 32 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/c-c++-common/goacc/kernels-acc-loop-smaller-equal.c

diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 597035f..a53a872 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -6564,7 +6564,7 @@  expand_omp_for_generic (struct omp_region *region,
   gassign *assign_stmt;
   bool in_combined_parallel = is_combined_parallel (region);
   bool broken_loop = region->cont == NULL;
-  bool seq_loop = (!start_fn || !next_fn);
+  bool seq_loop = (start_fn == BUILT_IN_NONE || next_fn == BUILT_IN_NONE);
   edge e, ne;
   tree *counts = NULL;
   int i;
@@ -6576,8 +6576,12 @@  expand_omp_for_generic (struct omp_region *region,
   type = TREE_TYPE (fd->loop.v);
   istart0 = create_tmp_var (fd->iter_type, ".istart0");
   iend0 = create_tmp_var (fd->iter_type, ".iend0");
-  TREE_ADDRESSABLE (istart0) = 1;
-  TREE_ADDRESSABLE (iend0) = 1;
+
+  if (!seq_loop)
+    {
+      TREE_ADDRESSABLE (istart0) = 1;
+      TREE_ADDRESSABLE (iend0) = 1;
+    }
 
   /* See if we need to bias by LLONG_MIN.  */
   if (fd->iter_type == long_long_unsigned_type_node
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-acc-loop-smaller-equal.c b/gcc/testsuite/c-c++-common/goacc/kernels-acc-loop-smaller-equal.c
new file mode 100644
index 0000000..ba7414a
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-acc-loop-smaller-equal.c
@@ -0,0 +1,25 @@ 
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-ftree-parallelize-loops=32" } */
+/* { dg-additional-options "-fdump-tree-parloops_oacc_kernels-all" } */
+/* { dg-additional-options "-fdump-tree-optimized" } */
+
+unsigned int
+foo (int n)
+{
+  unsigned int sum = 1;
+
+  #pragma acc kernels loop
+  for (int i = 1; i <= n; i++)
+    sum += i;
+
+  return sum;
+}
+
+/* Check that only one loop is analyzed, and that it can be parallelized.  */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops_oacc_kernels" } } */
+/* { dg-final { scan-tree-dump-not "FAILED:" "parloops_oacc_kernels" } } */
+
+/* Check that the loop has been split off into a function.  */
+/* { dg-final { scan-tree-dump-times "(?n);; Function .*foo.*\\._omp_fn\\.0" 1 "optimized" } } */
+
+/* { dg-final { scan-tree-dump-times "(?n)pragma omp target oacc_parallel.*num_gangs\\(32\\)" 1 "parloops_oacc_kernels" } } */
-- 
1.9.1