]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Handle DR_NUM_DIMENSIONS == 0 in initialize_data_dependence_relation
authorTom de Vries <tom@codesourcery.com>
Tue, 26 Jan 2016 22:11:51 +0000 (22:11 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Tue, 26 Jan 2016 22:11:51 +0000 (22:11 +0000)
2016-01-26  Tom de Vries  <tom@codesourcery.com>

PR tree-optimization/69110
* tree-data-ref.c (initialize_data_dependence_relation): Handle
DR_NUM_DIMENSIONS == 0.

* gcc.dg/autopar/pr69110.c: New test.

* testsuite/libgomp.c/pr69110.c: New test.

From-SVN: r232852

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/autopar/pr69110.c [new file with mode: 0644]
gcc/tree-data-ref.c
libgomp/ChangeLog
libgomp/testsuite/libgomp.c/pr69110.c [new file with mode: 0644]

index 0358f1c04aa7849f0a2da64f8928202819d59a1c..f38b374e58ffb59cb6892c3ba8c40ecfc7f3e008 100644 (file)
@@ -1,3 +1,9 @@
+2016-01-26  Tom de Vries  <tom@codesourcery.com>
+
+       PR tree-optimization/69110
+       * tree-data-ref.c (initialize_data_dependence_relation): Handle
+       DR_NUM_DIMENSIONS == 0.
+
 2016-01-26  Abderrazek Zaafrani  <a.zaafrani@samsung.com>
             Sebastian Pop  <s.pop@samsung.com>
 
index ee59ff14610c45690c8d386f225e3d06ca7c1359..08e2485086577c18f1e1d1fd75417e1eb5eeff08 100644 (file)
@@ -1,3 +1,8 @@
+2016-01-26  Tom de Vries  <tom@codesourcery.com>
+
+       PR tree-optimization/69110
+       * gcc.dg/autopar/pr69110.c: New test.
+
 2016-01-26  Abderrazek Zaafrani  <a.zaafrani@samsung.com>
             Sebastian Pop  <s.pop@samsung.com>
 
diff --git a/gcc/testsuite/gcc.dg/autopar/pr69110.c b/gcc/testsuite/gcc.dg/autopar/pr69110.c
new file mode 100644 (file)
index 0000000..27cdae5
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -ftree-parallelize-loops=2 -fno-tree-loop-im -fdump-tree-parloops2-details" } */
+
+#define N 1000
+
+unsigned int i = 0;
+
+void
+foo (void)
+{
+  unsigned int z;
+  for (z = 0; z < N; ++z)
+    ++i;
+}
+
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 0 "parloops2" } } */
+/* { dg-final { scan-tree-dump-times "FAILED: data dependencies exist across iterations" 1 "parloops2" } } */
index a40f40dc33965142746f176a3f0713b777daaa5d..d6d9ffcaa3424992c7203712a9c16969bc50ad02 100644 (file)
@@ -1509,13 +1509,14 @@ initialize_data_dependence_relation (struct data_reference *a,
   /* The case where the references are exactly the same.  */
   if (operand_equal_p (DR_REF (a), DR_REF (b), 0))
     {
-     if (loop_nest.exists ()
-        && !object_address_invariant_in_loop_p (loop_nest[0],
-                                                       DR_BASE_OBJECT (a)))
-      {
-        DDR_ARE_DEPENDENT (res) = chrec_dont_know;
-        return res;
-      }
+      if ((loop_nest.exists ()
+          && !object_address_invariant_in_loop_p (loop_nest[0],
+                                                  DR_BASE_OBJECT (a)))
+         || DR_NUM_DIMENSIONS (a) == 0)
+       {
+         DDR_ARE_DEPENDENT (res) = chrec_dont_know;
+         return res;
+       }
       DDR_AFFINE_P (res) = true;
       DDR_ARE_DEPENDENT (res) = NULL_TREE;
       DDR_SUBSCRIPTS (res).create (DR_NUM_DIMENSIONS (a));
@@ -1547,9 +1548,9 @@ initialize_data_dependence_relation (struct data_reference *a,
   /* If the base of the object is not invariant in the loop nest, we cannot
      analyze it.  TODO -- in fact, it would suffice to record that there may
      be arbitrary dependences in the loops where the base object varies.  */
-  if (loop_nest.exists ()
-      && !object_address_invariant_in_loop_p (loop_nest[0],
-                                             DR_BASE_OBJECT (a)))
+  if ((loop_nest.exists ()
+       && !object_address_invariant_in_loop_p (loop_nest[0], DR_BASE_OBJECT (a)))
+      || DR_NUM_DIMENSIONS (a) == 0)
     {
       DDR_ARE_DEPENDENT (res) = chrec_dont_know;
       return res;
index 818d9942e4bdee803e6b0a5065e0375f7bac9c55..9c09ac50cba825fa86c4f14485c099f3ecdccc5a 100644 (file)
@@ -1,3 +1,8 @@
+2016-01-26  Tom de Vries  <tom@codesourcery.com>
+
+       PR tree-optimization/69110
+       * testsuite/libgomp.c/pr69110.c: New test.
+
 2016-01-25  Richard Biener  <rguenther@suse.de>
 
        PR lto/69393
diff --git a/libgomp/testsuite/libgomp.c/pr69110.c b/libgomp/testsuite/libgomp.c/pr69110.c
new file mode 100644 (file)
index 0000000..0d9e5ca
--- /dev/null
@@ -0,0 +1,26 @@
+/* { dg-do run } */
+/* { dg-options "-ftree-parallelize-loops=2 -O1 -fno-tree-loop-im" } */
+
+#define N 1000
+
+unsigned int i = 0;
+
+static void __attribute__((noinline, noclone))
+foo (void)
+{
+  unsigned int z;
+  for (z = 0; z < N; ++z)
+    ++i;
+}
+
+extern void abort (void);
+
+int
+main (void)
+{
+  foo ();
+  if (i != N)
+    abort ();
+
+  return 0;
+}