Add gcc.dg/parloops-exit-first-loop-alt-4.c
authorTom de Vries <tom@codesourcery.com>
Sat, 13 Jun 2015 08:05:54 +0000 (08:05 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Sat, 13 Jun 2015 08:05:54 +0000 (08:05 +0000)
2015-06-13  Tom de Vries  <tom@codesourcery.com>

* gcc.dg/parloops-exit-first-loop-alt-4.c: New test.

* testsuite/libgomp.c/parloops-exit-first-loop-alt-4.c: New test.

From-SVN: r224453

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-4.c [new file with mode: 0644]
libgomp/ChangeLog
libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-4.c [new file with mode: 0644]

index 03c3c7c924e3c42135a40fab180b8a3ff298c88b..35822f36c769d31630740f499275306ccd1a610e 100644 (file)
@@ -1,3 +1,7 @@
+2015-06-13  Tom de Vries  <tom@codesourcery.com>
+
+       * gcc.dg/parloops-exit-first-loop-alt-4.c: New test.
+
 2015-06-13  Tom de Vries  <tom@codesourcery.com>
 
        * gcc.dg/parloops-exit-first-loop-alt-2.c: Add comment.
diff --git a/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-4.c b/gcc/testsuite/gcc.dg/parloops-exit-first-loop-alt-4.c
new file mode 100644 (file)
index 0000000..2b8d289
--- /dev/null
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target pthread } */
+/* { dg-options "-O2 -ftree-parallelize-loops=2 -fdump-tree-parloops" } */
+
+/* Constant bound, reduction.  */
+
+#define N 4000
+
+unsigned int *a;
+
+unsigned int
+f (void)
+{
+  int i;
+  unsigned int sum = 1;
+
+  for (i = 0; i < N; ++i)
+    sum += a[i];
+
+  return sum;
+}
+
+/* Three array accesses:
+   - one in f._loopfn.0
+   - one in the parallel
+   - one in the low iteration count loop
+   Crucially, none for a peeled off last iteration following the parallel.  */
+/* { dg-final { scan-tree-dump-times "(?n)\\\* 4" 3 "parloops" } } */
index 258d2f5fc80c03a0ec231cda9d9dea2548561cc8..a6d667dd04e14a13b2eaae49efade4fa3b90feb8 100644 (file)
@@ -1,3 +1,7 @@
+2015-06-13  Tom de Vries  <tom@codesourcery.com>
+
+       * testsuite/libgomp.c/parloops-exit-first-loop-alt-4.c: New test.
+
 2015-06-13  Tom de Vries  <tom@codesourcery.com>
 
        * testsuite/libgomp.c/parloops-exit-first-loop-alt-2.c: Add comment.
diff --git a/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-4.c b/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-4.c
new file mode 100644 (file)
index 0000000..1beae3e
--- /dev/null
@@ -0,0 +1,33 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -ftree-parallelize-loops=2" } */
+
+/* Constant bound, reduction.  */
+
+#define N 4000
+
+unsigned int *a;
+
+unsigned int
+f (void)
+{
+  int i;
+  unsigned int sum = 1;
+
+  for (i = 0; i < N; ++i)
+    sum += a[i];
+
+  return sum;
+}
+
+int
+main (void)
+{
+  unsigned int res;
+  unsigned int array[N];
+  int i;
+  for (i = 0; i < N; ++i)
+    array[i] = i % 7;
+  a = &array[0];
+  res = f ();
+  return !(res == 11995);
+}