Don't return NULL access_fns in dr_analyze_indices
2016-01-12 Tom de Vries <tom@codesourcery.com>
* tree-data-ref.c (dr_analyze_indices): Don't return NULL access_fns.
* gcc.dg/autopar/pr69110.c: New test.
* testsuite/libgomp.c/pr69110.c: New test.
---
gcc/testsuite/gcc.dg/autopar/pr69110.c | 19 +++++++++++++++++++
gcc/tree-data-ref.c | 3 +++
libgomp/testsuite/libgomp.c/pr69110.c | 26 ++++++++++++++++++++++++++
3 files changed, 48 insertions(+)
new file mode 100644
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -ftree-parallelize-loops=2 -fno-tree-loop-im -fdump-tree-parloops-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 "parloops" } } */
+/* { dg-final { scan-tree-dump-times "FAILED: data dependencies exist across iterations" 1 "parloops" } } */
+
+
@@ -1023,6 +1023,9 @@ dr_analyze_indices (struct data_reference *dr, loop_p nest, loop_p loop)
build_int_cst (reference_alias_ptr_type (ref), 0));
}
+ if (access_fns == vNULL)
+ access_fns.safe_push (integer_zero_node);
+
DR_BASE_OBJECT (dr) = ref;
DR_ACCESS_FNS (dr) = access_fns;
}
new file mode 100644
@@ -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;
+}