aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.dg/autopar
diff options
context:
space:
mode:
authorBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
committerBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
commit1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch)
treec607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/gcc/testsuite/gcc.dg/autopar
parent283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff)
downloadtoolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gcc.dg/autopar')
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/autopar.exp40
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/outer-1.c33
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/outer-2.c33
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/outer-3.c33
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/outer-4.c37
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/outer-5.c50
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/outer-6.c51
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/parallelization-1.c33
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr39500-1.c28
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr39500-2.c20
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr46066.c18
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr46099.c47
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr46194.c24
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr46561.c17
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr46799.c12
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr46885.c23
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr46969.c31
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr47060.c21
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr49580.c38
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr49960-1.c36
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr49960.c56
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr57103.c19
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr57185.c29
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-1.c73
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-1char.c67
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-1short.c66
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-2.c70
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-2char.c68
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-2short.c66
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-3.c57
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-6.c63
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-7.c91
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-8.c90
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-9.c90
34 files changed, 1530 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/autopar.exp b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/autopar.exp
new file mode 100644
index 000000000..c20cc3d47
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/autopar.exp
@@ -0,0 +1,40 @@
+# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# GCC testsuite that uses the `dg.exp' driver.
+
+# Load support procs.
+load_lib gcc-dg.exp
+
+if ![check_effective_target_pthread] {
+ return
+}
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_CFLAGS
+if ![info exists DEFAULT_CFLAGS] then {
+ set DEFAULT_CFLAGS " -ansi -pedantic-errors"
+}
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \
+ "" $DEFAULT_CFLAGS
+
+# All done.
+dg-finish
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/outer-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/outer-1.c
new file mode 100644
index 000000000..a9d2185f0
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/outer-1.c
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details -fdump-tree-optimized" } */
+
+void abort (void);
+
+void parloop (int N)
+{
+ int i, j;
+ int x[10000][10000];
+
+ for (i = 0; i < N; i++)
+ for (j = 0; j < N; j++)
+ x[i][j] = i + j + 3;
+
+ for (i = 0; i < N; i++)
+ for (j = 0; j < N; j++)
+ if (x[i][j] != i + j + 3)
+ abort ();
+}
+
+int main(void)
+{
+ parloop(10000);
+
+ return 0;
+}
+
+
+/* Check that outer loop is parallelized. */
+/* { dg-final { scan-tree-dump-times "parallelizing outer loop" 1 "parloops" } } */
+/* { dg-final { scan-tree-dump-times "loopfn" 4 "optimized" } } */
+/* { dg-final { cleanup-tree-dump "parloops" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/outer-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/outer-2.c
new file mode 100644
index 000000000..e0a142f0d
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/outer-2.c
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details -fdump-tree-optimized" } */
+
+void abort (void);
+
+void parloop (int N)
+{
+ int i, j,ii;
+ int x[401][10][401];
+
+for (ii = 0; ii < N; ii++)
+ for (i = 0; i < N; i++)
+ for (j = 0; j < N; j++)
+ x[i][j][ii] = ii+i + j + 3;
+
+for (ii = 0; ii < N; ii++)
+ for (i = 0; i < N;i++)
+ for (j = 0; j < N; j++)
+ if (x[i][j][ii] != ii+i + j + 3)
+ abort ();
+}
+
+int main(void)
+{
+ parloop(400);
+
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "parallelizing outer loop" 1 "parloops" } } */
+/* { dg-final { scan-tree-dump-times "loopfn" 4 "optimized" } } */
+/* { dg-final { cleanup-tree-dump "parloops" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/outer-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/outer-3.c
new file mode 100644
index 000000000..c6e0adbff
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/outer-3.c
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details -fdump-tree-optimized" } */
+
+void abort (void);
+
+void parloop (int N)
+{
+ int i, j;
+ int x[500][500];
+
+ for (i = 0; i < N; i++)
+ for (j = 0; j < i; j++)
+ x[i][j] = i + j + 3;
+
+ for (i = 0; i < N; i++)
+ for (j = 0; j < i; j++)
+ if (x[i][j] != i + j + 3)
+ abort ();
+}
+
+int main(void)
+{
+ parloop(500);
+
+ return 0;
+}
+
+
+/* Check that outer loop is parallelized. */
+/* { dg-final { scan-tree-dump-times "parallelizing outer loop" 1 "parloops" } } */
+/* { dg-final { scan-tree-dump-times "loopfn" 4 "optimized" } } */
+/* { dg-final { cleanup-tree-dump "parloops" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/outer-4.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/outer-4.c
new file mode 100644
index 000000000..d60023f5d
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/outer-4.c
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details -fdump-tree-optimized" } */
+
+void abort (void);
+
+int g_sum=0;
+int x[500][500];
+
+__attribute__((noinline))
+void parloop (int N)
+{
+ int i, j;
+ int sum;
+
+ /* Double reduction is currently not supported, outer loop is not
+ parallelized. Inner reduction is detected, inner loop is
+ parallelized. */
+ sum = 0;
+ for (i = 0; i < N; i++)
+ for (j = 0; j < N; j++)
+ sum += x[i][j];
+
+ g_sum = sum;
+}
+
+int main(void)
+{
+ parloop(500);
+
+ return 0;
+}
+
+
+/* { dg-final { scan-tree-dump-times "parallelizing outer loop" 1 "parloops" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "loopfn" 4 "optimized" } } */
+/* { dg-final { cleanup-tree-dump "parloops" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/outer-5.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/outer-5.c
new file mode 100644
index 000000000..fa8029326
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/outer-5.c
@@ -0,0 +1,50 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details -fdump-tree-optimized" } */
+
+void abort (void);
+
+int x[500][500];
+int y[500];
+int g_sum=0;
+
+__attribute__((noinline))
+void init (int i, int j)
+{
+ x[i][j]=1;
+}
+
+__attribute__((noinline))
+void parloop (int N)
+{
+ int i, j;
+ int sum;
+
+ /* Inner cycle is currently not supported, outer loop is not
+ parallelized. Inner reduction is detected, inner loop is
+ parallelized. */
+ for (i = 0; i < N; i++)
+ {
+ sum = 0;
+ for (j = 0; j < N; j++)
+ sum += x[i][j];
+ y[i]=sum;
+ }
+ g_sum = sum;
+}
+
+int main(void)
+{
+ int i,j;
+ for (i = 0; i < 500; i++)
+ for (j = 0; j < 500; j++)
+ init(i, j);
+
+ parloop(500);
+
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "parallelizing outer loop" 1 "parloops" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "loopfn" 4 "optimized" } } */
+/* { dg-final { cleanup-tree-dump "parloops" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/outer-6.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/outer-6.c
new file mode 100644
index 000000000..b16366932
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/outer-6.c
@@ -0,0 +1,51 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details -fdump-tree-optimized" } */
+
+void abort (void);
+
+int x[500][500];
+int y[500];
+int g_sum=0;
+
+__attribute__((noinline))
+void init (int i, int j)
+{
+ x[i][j]=1;
+}
+
+__attribute__((noinline))
+void parloop (int N)
+{
+ int i, j;
+ int sum;
+
+ /* Outer loop reduction, outerloop is parallelized. */
+ sum=0;
+ for (i = 0; i < N; i++)
+ {
+ for (j = 0; j < N; j++)
+ y[i]=x[i][j];
+ sum += y[i];
+ }
+ g_sum = sum;
+}
+
+int main(void)
+{
+ int i,j;
+ for (i = 0; i < 500; i++)
+ for (j = 0; j < 500; j++)
+ init(i, j);
+
+ parloop(500);
+
+ return 0;
+}
+
+
+/* Check that outer loop is parallelized. */
+/* { dg-final { scan-tree-dump-times "parallelizing outer loop" 1 "parloops" } } */
+/* { dg-final { scan-tree-dump-times "parallelizing inner loop" 0 "parloops" } } */
+/* { dg-final { scan-tree-dump-times "loopfn" 4 "optimized" } } */
+/* { dg-final { cleanup-tree-dump "parloops" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/parallelization-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/parallelization-1.c
new file mode 100644
index 000000000..de2a0f3cc
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/parallelization-1.c
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details -fdump-tree-optimized" } */
+
+void abort (void);
+
+void parloop (int N)
+{
+ int i;
+ int x[10000990];
+
+ for (i = 0; i < N; i++)
+ x[i] = i + 3;
+
+ for (i = 0; i < N; i++)
+ {
+ if (x[i] != i + 3)
+ abort ();
+ }
+}
+
+int main(void)
+{
+ parloop(10000);
+
+ return 0;
+}
+
+/* Check that the first loop in parloop got parallelized. */
+
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops" } } */
+/* { dg-final { scan-tree-dump-times "loopfn" 4 "optimized" } } */
+/* { dg-final { cleanup-tree-dump "parloops" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr39500-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr39500-1.c
new file mode 100644
index 000000000..6428bd062
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr39500-1.c
@@ -0,0 +1,28 @@
+/* pr39500: autopar fails to parallel */
+/* origin: nemokingdom@gmail.com(LiFeng) */
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details" } */
+
+void abort (void);
+
+int main (void)
+{
+ int i;
+ int x[100000];
+
+ for (i = 0; i < 10000; i++)
+ x[i] = x[i+10000];
+
+ for (i = 0; i < 10000; i++)
+ {
+ if (x[i] != x[i+10000])
+ abort ();
+ }
+
+ return 0;
+}
+
+/* Check that the first loop in parloop got parallelized. */
+
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops" } } */
+/* { dg-final { cleanup-tree-dump "parloops" } } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr39500-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr39500-2.c
new file mode 100644
index 000000000..eabac3f88
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr39500-2.c
@@ -0,0 +1,20 @@
+/* pr39500: autopar fails to parallel */
+/* origin: nemokingdom@gmail.com(LiFeng) */
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details" } */
+
+int main (void)
+{
+ int i;
+ int x[1000];
+
+ for (i = 0; i < 101; i++)
+ x[i] = x[i+100];
+
+ return x[12];
+}
+
+/* This loop cannot be parallelized due to a dependence. */
+
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 0 "parloops" } } */
+/* { dg-final { cleanup-tree-dump "parloops" } } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr46066.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr46066.c
new file mode 100644
index 000000000..e9bf6c59e
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr46066.c
@@ -0,0 +1,18 @@
+/* PR tree-optimization/46066 */
+/* { dg-do compile } */
+/* { dg-options "-fcompare-debug -O -ftree-parallelize-loops=4" } */
+
+void
+parloop (int N)
+{
+ int i, j, ii;
+ int x[400][10][400];
+ for (ii = 0; ii < N; ii++)
+ for (i = 0; i < N; i++)
+ for (j = 0; j < N; j++)
+ x[i][j][ii] = 3;
+ for (i = 0; i < N; i++)
+ for (j = 0; j < N; j++)
+ if (x[i][j][0] != 3)
+ __builtin_abort ();
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr46099.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr46099.c
new file mode 100644
index 000000000..074278e64
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr46099.c
@@ -0,0 +1,47 @@
+/* PR tree-optimization/46099 */
+/* { dg-do compile } */
+/* { dg-options "-ftree-parallelize-loops=2 -fcompare-debug -O" } */
+
+static inline void
+bar (int *i)
+{
+ int j = *i;
+}
+
+void baz (int *, int *, int *);
+
+void
+f1 (int n)
+{
+ int i;
+ for (i = 0; i < n; i++)
+ bar (&i);
+}
+
+void
+f2 (int n)
+{
+ int i;
+ int a[10000], b[10000], c[10000];
+ baz (a, b, c);
+ for (i = 0; i < n; i++)
+ {
+ void *p = c;
+ a[i] = b[i] + c[i];
+ }
+ baz (a, b, c);
+}
+
+void
+f3 (int n)
+{
+ int i;
+ int a[10000], b[10000], c[10000];
+ baz (a, b, c);
+ for (i = 0; i < n; i++)
+ {
+ a[i] = b[i] + c[i];
+ void *p = c;
+ }
+ baz (a, b, c);
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr46194.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr46194.c
new file mode 100644
index 000000000..574d6e672
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr46194.c
@@ -0,0 +1,24 @@
+/* PR tree-optimization/46194 */
+/* { dg-do compile } */
+/* { dg-options "-O -ftree-parallelize-loops=2 -fdump-tree-parloops-details" } */
+
+#define N 1000
+int a[N];
+
+int foo (void)
+{
+ int j;
+ int i;
+
+ /* This is not blocked as it is not profitable. */
+ for (i = 0; i < N; i++)
+ for (j = 0; j < N; j++)
+ a[j] = a[i] + 1;
+
+ return a[0];
+}
+
+/* This loop cannot be parallelized due to a dependence. */
+
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 0 "parloops" } } */
+/* { dg-final { cleanup-tree-dump "parloops" } } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr46561.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr46561.c
new file mode 100644
index 000000000..a9499f340
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr46561.c
@@ -0,0 +1,17 @@
+/* PR debug/46561 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-vectorize -ftree-parallelize-loops=2 -fcompare-debug" } */
+
+extern void abort (void);
+
+void foo (char *c)
+{
+ int i;
+ unsigned x = 0;
+ {
+ for (i = 0; i < 64; i += 4)
+ x = x | *((unsigned *) (&c[i]));
+ if (x)
+ abort ();
+ }
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr46799.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr46799.c
new file mode 100644
index 000000000..575e12c55
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr46799.c
@@ -0,0 +1,12 @@
+/* PR debug/46799 */
+/* { dg-do compile } */
+/* { dg-options "-O -ftree-parallelize-loops=2 -fno-tree-dce -ftree-pre -fcompare-debug" } */
+
+int
+foo (int i, int *a)
+{
+ int e;
+ for (; i; i++)
+ e = *a;
+ return e;
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr46885.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr46885.c
new file mode 100644
index 000000000..9560c92bf
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr46885.c
@@ -0,0 +1,23 @@
+/* PR debug/46885 */
+/* { dg-do compile } */
+/* { dg-options "-O -ftree-parallelize-loops=4 -fcompare-debug -fno-tree-dominator-opts -funswitch-loops" } */
+
+static inline void
+bar (int i)
+{
+ (void) i;
+}
+
+int
+foo (int *begin, int *end)
+{
+ int s = 0;
+ int *i;
+ for (i = begin; i != end; ++i)
+ {
+ bar (0);
+ if (begin)
+ return s;
+ }
+ return 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr46969.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr46969.c
new file mode 100644
index 000000000..807ce4f92
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr46969.c
@@ -0,0 +1,31 @@
+/* PR tree-optimization/46969 */
+/* { dg-do compile } */
+/* { dg-options "-O3 -ftree-parallelize-loops=2 -fcompare-debug" } */
+
+extern void abort (void);
+#define F(name) \
+int \
+name (unsigned char *x) \
+{ \
+ int i; \
+ unsigned int c, d, e; \
+ if (x != 0) \
+ { \
+ for (i = 0, d = 0, e = 0xFFFFFFFF; \
+ i < 64; \
+ i += (int) sizeof(unsigned int)) \
+ { \
+ c = *((unsigned int *)(&x[i])); \
+ d = d | c; \
+ e = e & c; \
+ } \
+ if (!((d == e) && ((d >> 8) == (e & 0x00FFFFFF)))) \
+ abort (); \
+ } \
+ return 0; \
+}
+F (foo0) F (foo1)
+F (foo2) F (foo3)
+F (foo4) F (foo5)
+F (foo6) F (foo7)
+F (foo8) F (foo9)
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr47060.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr47060.c
new file mode 100644
index 000000000..e8cdfd667
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr47060.c
@@ -0,0 +1,21 @@
+/* PR tree-optimization/47060 */
+/* { dg-do compile } */
+/* { dg-options "-O -ffast-math -ftree-parallelize-loops=2 -fno-tree-dce" } */
+
+struct S
+{
+ int n;
+ float *a;
+};
+
+float
+foo (struct S *b)
+{
+ float c, d;
+ int j;
+ for (j = 0; j < b->n; j++)
+ d += b->a[j];
+ for (j = 0; j < b->n; j++)
+ c += b->a[j];
+ return d;
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr49580.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr49580.c
new file mode 100644
index 000000000..e08fd0e0c
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr49580.c
@@ -0,0 +1,38 @@
+/* PR debug/49580 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details" } */
+
+#include <stdarg.h>
+#include <stdlib.h>
+
+#define N 1600
+
+unsigned int ub[N];
+unsigned char reg_has_output_reload[N];
+unsigned int uc[N];
+
+ __attribute__ ((noinline))
+ void main2 (unsigned int regno, unsigned int n_reloads)
+ {
+ unsigned int nr=0;
+
+ if (regno> ub[regno])
+ nr=regno;
+ else
+ nr=ub[nr];
+
+ while (nr-- > 0)
+ if (n_reloads == 0 || reg_has_output_reload[regno + nr] == 0)
+ ub[regno + nr] = 0;
+}
+
+int main (void)
+{
+ main2 (799, 0);
+ return 0;
+}
+
+
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops" } } */
+/* { dg-final { cleanup-tree-dump "parloops" } } */
+
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr49960-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr49960-1.c
new file mode 100644
index 000000000..ac9d56784
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr49960-1.c
@@ -0,0 +1,36 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details -fdump-tree-optimized" } */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+int main()
+{
+ unsigned int x, y, idx, H = 1024, W = 1024;
+
+ int * tmps = (int *)malloc(H*W*sizeof(int));
+
+ /* This loop gets parallelized even though output dependences exist
+ between writes to 'tmps' that prevent parallelization.
+ For example: tmps[1] = 1, ..., tmps[1] = 17. */
+
+ for(x = 1; x < H; x++)
+ {
+ for(y = 1; y < W; y++)
+ {
+ idx = x*W+y;
+ tmps[idx % 4096] = idx;
+ }
+ }
+
+ for(x = 1; x < 8; x++)
+ printf("tmps[%d]=%d\n", x, tmps[x]);
+
+ return 0;
+}
+/* Check that no loop gets parallelized. */
+
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 0 "parloops" } } */
+/* { dg-final { scan-tree-dump-times "loopfn" 0 "optimized" } } */
+/* { dg-final { cleanup-tree-dump "parloops" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr49960.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr49960.c
new file mode 100644
index 000000000..5dacb8de8
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr49960.c
@@ -0,0 +1,56 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details -fdump-tree-optimized -fno-partial-inlining" } */
+
+#include <stdio.h>
+#define MB 100
+#define NA 450
+#define MA 400
+
+int T[MA][MB],A[MA][NA],B[MB][NA];
+void MRTRBR(int MA_1, int NA_1, int MB_1)
+{
+ int i,j, t,k;
+
+ /* At the moment we are not able to hoist the loop headers out of the loop
+ nest.
+ Partial inlining needs to be disabled so we do not optimize this out
+ of the function body. */
+ if (MA_1 < 4 || NA_1 < 4 || MB_1 < 4)
+ return;
+
+ /* The outer most loop is not parallel because for different k's there
+ is write-write dependency for T[i][j]. */
+
+ /* The two inner loops don't get parallelized due to low number of
+ iterations. */
+
+ for (k = 3; k < NA_1; k++)
+ for (i = 3; i < MA_1; i++)
+ for (j = 3; j < MB_1; j++)
+ {
+ t = T[i][j];
+ T[i][j] = t+2+A[i][k]*B[j][k];
+ }
+}
+void main ()
+{
+ int j,i;
+
+ for (i = 3; i < MA; i++)
+ for (j = 3; j < MB; j++)
+ T[i][j] = (i>j?i:j);
+
+ MRTRBR (MA,NA,MB);
+
+ for (i = MA-1; i < MA; i++)
+ for (j = MB-10; j < MB; j++)
+ printf ("i %d j %d T[i][j] = %d\n",i,j,T[i][j]);
+}
+
+
+/* Check that the outer most loop doesn't get parallelized (thus no loop gets parallelized) */
+
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 0 "parloops" } } */
+/* { dg-final { scan-tree-dump-times "loopfn" 0 "optimized" } } */
+/* { dg-final { cleanup-tree-dump "parloops" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr57103.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr57103.c
new file mode 100644
index 000000000..fa7067607
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr57103.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O -ftree-parallelize-loops=4" } */
+
+int d[1024];
+
+static inline int foo (void)
+{
+ int s = 0;
+ int i = 0;
+ for (; i < 1024; i++)
+ s += d[i];
+ return s;
+}
+
+void bar (void)
+{
+ if (foo ())
+ __builtin_abort ();
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr57185.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr57185.c
new file mode 100644
index 000000000..b4657576d
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/pr57185.c
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -ftree-parallelize-loops=2 -fipa-pta" } */
+
+int a, b;
+int *d;
+void f(void)
+{
+ int c;
+ b %= 1;
+
+ if(1 - (b < 1))
+ {
+ int *q = 0;
+
+ if(a)
+ {
+ c = 0;
+lbl:
+ for(*d; *d; ++*d)
+ if(c ? : a ? : (c = 1) ? : 0)
+ *q &= 1;
+ return;
+ }
+
+ q = (int *)1;
+ }
+ goto lbl;
+}
+
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-1.c
new file mode 100644
index 000000000..8018a558c
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-1.c
@@ -0,0 +1,73 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details -fdump-tree-optimized" } */
+
+#include <stdarg.h>
+#include <stdlib.h>
+
+ #define N 1600
+ #define DIFF 2558402
+
+unsigned int ub[N];
+unsigned int uc[N];
+
+ /* Reduction of unsigned-int. */
+
+ void main1 (unsigned int x, unsigned int max_result, unsigned int min_result)
+ {
+ int i;
+ unsigned int udiff = 2;
+ unsigned int umax = x;
+ unsigned int umin = x;
+
+ /* Summation. */
+ for (i = 0; i < N; i++) {
+ udiff += (ub[i] - uc[i]);
+ }
+
+ /* Maximum. */
+ for (i = 0; i < N; i++) {
+ umax = umax < uc[i] ? uc[i] : umax;
+ }
+
+ /* Minimum. */
+ for (i = 0; i < N; i++) {
+ umin = umin > uc[i] ? uc[i] : umin;
+ }
+
+ /* check results: */
+ if (udiff != DIFF)
+ abort ();
+ if (umax != max_result)
+ abort ();
+ if (umin != min_result)
+ abort ();
+ }
+
+ __attribute__((noinline))
+ void init_arrays ()
+ {
+ int i;
+
+ ub[0] = 1;
+ uc[0] = 1;
+ for (i=1; i<N; i++)
+ {
+ ub[i] = i * 3;
+ uc[i] = i;
+ }
+}
+
+int main (void)
+{
+ init_arrays ();
+ main1 (2000, 2000, 1);
+ main1 (0, 1599, 0);
+ return 0;
+}
+
+
+/* { dg-final { scan-tree-dump-times "Detected reduction" 3 "parloops" } } */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 4 "parloops" } } */
+/* { dg-final { cleanup-tree-dump "parloops" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
+
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-1char.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-1char.c
new file mode 100644
index 000000000..76645c850
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-1char.c
@@ -0,0 +1,67 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details -fdump-tree-optimized" } */
+
+#include <stdarg.h>
+#include <stdlib.h>
+
+#define N 1600
+#define DIFF 242
+
+unsigned char ub[N] = {1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
+unsigned char uc[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
+
+__attribute__ ((noinline)) void
+main1 (unsigned char x, unsigned char max_result, unsigned char min_result)
+{
+ int i;
+ unsigned char udiff = 2;
+ unsigned char umax = x;
+ unsigned char umin = x;
+
+ for (i = 0; i < N; i++) {
+ udiff += (unsigned char)(ub[i] - uc[i]);
+ }
+
+ for (i = 0; i < N; i++) {
+ umax = umax < uc[i] ? uc[i] : umax;
+ }
+
+ for (i = 0; i < N; i++) {
+ umin = umin > uc[i] ? uc[i] : umin;
+ }
+
+ /* check results: */
+ if (udiff != DIFF)
+ abort ();
+ if (umax != max_result)
+ abort ();
+ if (umin != min_result)
+ abort ();
+}
+
+ __attribute__((noinline))
+ void init_arrays ()
+ {
+ int i;
+
+ for (i=16; i<N; i++)
+ {
+ ub[i] = 1;
+ uc[i] = 1;
+ }
+}
+
+int main (void)
+{
+ init_arrays();
+ main1 (100, 100, 1);
+ main1 (0, 15, 0);
+ return 0;
+}
+
+
+/* { dg-final { scan-tree-dump-times "Detected reduction" 3 "parloops" } } */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 4 "parloops" } } */
+/* { dg-final { cleanup-tree-dump "parloops" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
+
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-1short.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-1short.c
new file mode 100644
index 000000000..526f17009
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-1short.c
@@ -0,0 +1,66 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details -fdump-tree-optimized" } */
+
+#include <stdarg.h>
+#include <stdlib.h>
+
+#define N 1600
+#define DIFF 242
+
+unsigned short ub[N] = {1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
+unsigned short uc[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
+
+__attribute__ ((noinline)) void
+main1 (unsigned short x, unsigned short max_result, unsigned short min_result)
+{
+ int i;
+ unsigned short udiff = 2;
+ unsigned short umax = x;
+ unsigned short umin = x;
+
+ for (i = 0; i < N; i++) {
+ udiff += (unsigned short)(ub[i] - uc[i]);
+ }
+
+ for (i = 0; i < N; i++) {
+ umax = umax < uc[i] ? uc[i] : umax;
+ }
+
+ for (i = 0; i < N; i++) {
+ umin = umin > uc[i] ? uc[i] : umin;
+ }
+
+ /* check results: */
+ if (udiff != DIFF)
+ abort ();
+ if (umax != max_result)
+ abort ();
+ if (umin != min_result)
+ abort ();
+}
+
+ __attribute__((noinline))
+ void init_arrays ()
+ {
+ int i;
+
+ for (i=16; i<N; i++)
+ {
+ ub[i] = 1;
+ uc[i] = 1;
+ }
+}
+
+int main (void)
+{
+ init_arrays();
+ main1 (100, 100, 1);
+ main1 (0, 15, 0);
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "Detected reduction" 3 "parloops" } } */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 4 "parloops" } } */
+/* { dg-final { cleanup-tree-dump "parloops" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
+
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-2.c
new file mode 100644
index 000000000..e0abb265b
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-2.c
@@ -0,0 +1,70 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details -fdump-tree-optimized" } */
+
+#include <stdarg.h>
+#include <stdlib.h>
+
+#define N 1600
+#define DIFF 2558400
+
+int b[N];
+int c[N];
+
+/* Reduction of signed-int. */
+
+__attribute__ ((noinline))
+void main1 (int x, int max_result, int min_result)
+{
+ int i;
+ int diff = 0;
+ int max = x;
+ int min = x;
+
+ for (i = 0; i < N; i++) {
+ diff += (b[i] - c[i]);
+ }
+
+ for (i = 0; i < N; i++) {
+ max = max < c[i] ? c[i] : max;
+ }
+
+ for (i = 0; i < N; i++) {
+ min = min > c[i] ? c[i] : min;
+ }
+
+ /* check results: */
+ if (diff != DIFF)
+ abort ();
+ if (max != max_result)
+ abort ();
+ if (min != min_result)
+ abort ();
+}
+
+ __attribute__((noinline))
+ void init_arrays ()
+ {
+ int i;
+
+ b[0] = 1;
+ c[0] = 1;
+ for (i=1; i<N; i++)
+ {
+ b[i] = i * 3;
+ c[i] = i;
+ }
+}
+
+int main (void)
+{
+ init_arrays ();
+ main1 (2000, 2000, 1);
+ main1 (0, 1599, 0);
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "Detected reduction" 3 "parloops" } } */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 4 "parloops" } } */
+/* { dg-final { cleanup-tree-dump "parloops" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
+
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-2char.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-2char.c
new file mode 100644
index 000000000..ada1275f9
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-2char.c
@@ -0,0 +1,68 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details -fdump-tree-optimized" } */
+
+#include <stdarg.h>
+#include <stdlib.h>
+
+#define N 1600
+#define DIFF 121
+
+signed char b[N] = {1,2,3,6,8,10,12,14,16,18,20,22,24,26,28,30};
+signed char c[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
+
+__attribute__ ((noinline))
+void main1 (signed char x, signed char max_result, signed char min_result)
+{
+ int i;
+ signed char diff = 2;
+ signed char max = x;
+ signed char min = x;
+
+ for (i = 0; i < N; i++) {
+ diff += (signed char)(b[i] - c[i]);
+ }
+
+ for (i = 0; i < N; i++) {
+ max = max < c[i] ? c[i] : max;
+ }
+
+ for (i = 0; i < N; i++) {
+ min = min > c[i] ? c[i] : min;
+ }
+
+ /* check results: */
+ if (diff != DIFF)
+ abort ();
+ if (max != max_result)
+ abort ();
+ if (min != min_result)
+ abort ();
+}
+
+ __attribute__((noinline))
+ void init_arrays ()
+ {
+ int i;
+
+ for (i=16; i<N; i++)
+ {
+ b[i] = 1;
+ c[i] = 1;
+ }
+}
+
+int main (void)
+{
+ init_arrays();
+ main1 (100, 100, 1);
+ main1 (0, 15, 0);
+ return 0;
+}
+
+
+/* { dg-final { scan-tree-dump-times "Detected reduction" 2 "parloops" } } */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 3 "parloops" } } */
+/* { dg-final { cleanup-tree-dump "parloops" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
+
+
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-2short.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-2short.c
new file mode 100644
index 000000000..3363c68f4
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-2short.c
@@ -0,0 +1,66 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details -fdump-tree-optimized" } */
+
+#include <stdarg.h>
+#include <stdlib.h>
+
+#define N 1600
+#define DIFF 242
+
+short b[N] = {1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
+short c[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
+
+__attribute__ ((noinline))
+void main1 (short x, short max_result, short min_result)
+{
+ int i;
+ short diff = 2;
+ short max = x;
+ short min = x;
+
+ for (i = 0; i < N; i++) {
+ diff += (short)(b[i] - c[i]);
+ }
+ for (i = 0; i < N; i++) {
+ max = max < c[i] ? c[i] : max;
+ }
+
+ for (i = 0; i < N; i++) {
+ min = min > c[i] ? c[i] : min;
+ }
+
+ /* check results: */
+ if (diff != DIFF)
+ abort ();
+ if (max != max_result)
+ abort ();
+ if (min != min_result)
+ abort ();
+}
+
+ __attribute__((noinline))
+ void init_arrays ()
+ {
+ int i;
+
+ for (i=16; i<N; i++)
+ {
+ b[i] = 1;
+ c[i] = 1;
+ }
+}
+
+int main (void)
+{
+ init_arrays();
+ main1 (100, 100, 1);
+ main1 (0, 15, 0);
+ return 0;
+}
+
+
+/* { dg-final { scan-tree-dump-times "Detected reduction" 2 "parloops" } } */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 3 "parloops" } } */
+/* { dg-final { cleanup-tree-dump "parloops" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
+
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-3.c
new file mode 100644
index 000000000..6bc204711
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-3.c
@@ -0,0 +1,57 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details -fdump-tree-optimized" } */
+
+#include <stdarg.h>
+#include <stdlib.h>
+
+#define N 1600
+
+unsigned int ub[N];
+unsigned int uc[N];
+
+/* Reduction of unsigned-int. */
+
+__attribute__ ((noinline))
+int main1 (int n, int res)
+{
+ int i;
+ unsigned int udiff;
+
+ udiff = 0;
+ for (i = 0; i < n; i++) {
+ udiff += (ub[i] - uc[i]);
+ }
+
+ /* check results: */
+ if (udiff != res)
+ abort ();
+
+ return 0;
+}
+
+__attribute__((noinline))
+void init_arrays ()
+{
+ int i;
+
+ for (i=0; i<N; i++)
+ {
+ ub[i] = i * 3;
+ uc[i] = i;
+ }
+}
+
+int main (void)
+{
+ init_arrays ();
+ main1 (N, 2558400);
+ main1 (N-1, 2555202);
+ return 0;
+}
+
+
+/* { dg-final { scan-tree-dump-times "Detected reduction" 1 "parloops" } } */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 2 "parloops" } } */
+/* { dg-final { cleanup-tree-dump "parloops" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
+
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-6.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-6.c
new file mode 100644
index 000000000..fface8fed
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-6.c
@@ -0,0 +1,63 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details -fdump-tree-optimized" } */
+
+#include <stdarg.h>
+#include <stdlib.h>
+
+#define N 1600
+#define DIFF 2558402
+
+
+__attribute__ ((noinline))
+int main1 (float x, float max_result)
+{
+ int i;
+ float b[N];
+ float c[N];
+ float diff = 2;
+ float max = x;
+ float min = 10;
+
+ for (i=0; i<N; i++)
+ {
+ b[i] = i * 3;
+ c[i] = i;
+ }
+
+ for (i = 0; i < N; i++) {
+ diff += (b[i] - c[i]);
+ }
+
+ for (i = 0; i < N; i++) {
+ max = max < c[i] ? c[i] : max;
+ }
+
+ for (i = 0; i < N; i++) {
+ min = min > c[i] ? c[i] : min;
+ }
+
+ /* check results: */
+ if (diff != DIFF)
+ abort ();
+ if (max != max_result)
+ abort ();
+ if (min != 0)
+ abort ();
+
+ return 0;
+}
+
+int main (void)
+{
+ main1 (2000, 2000);
+ main1 (0, 1599);
+ return 0;
+}
+
+
+/* need -ffast-math to parallelize these loops. */
+/* { dg-final { scan-tree-dump-times "Detected reduction" 0 "parloops" } } */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops" } } */
+/* { dg-final { scan-tree-dump-times "FAILED: it is not a part of reduction" 3 "parloops" } } */
+/* { dg-final { cleanup-tree-dump "parloops" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-7.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-7.c
new file mode 100644
index 000000000..f66069e56
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-7.c
@@ -0,0 +1,91 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details -fdump-tree-optimized" } */
+
+#include <stdlib.h>
+
+#define N 3200
+
+extern void abort (void);
+typedef unsigned char T;
+
+__attribute__ ((noinline)) void
+testmax (const T *c, T init, T result)
+{
+ T lc[N], accum = init;
+ int i;
+
+ __builtin_memcpy (lc, c, sizeof(lc));
+
+ for (i = 0; i < N; i++) {
+ accum = accum < lc[i] ? lc[i] : accum;
+ }
+
+ if (accum != result)
+ abort ();
+}
+
+__attribute__ ((noinline)) void
+testmin (const T *c, T init, T result)
+{
+ T lc[N], accum = init;
+ int i;
+
+ __builtin_memcpy (lc, c, sizeof(lc));
+
+ for (i = 0; i < N; i++) {
+ accum = accum > lc[i] ? lc[i] : accum;
+ }
+
+ if (accum != result)
+ abort ();
+}
+
+int main (void)
+{
+ static unsigned char A[N] = {
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
+ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+ 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f
+ };
+
+ static unsigned char B[N] = {
+ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+ 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
+ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f
+ };
+
+ static unsigned char C[N] = {
+ 0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8,
+ 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
+ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+ };
+
+ int i;
+
+ for (i=32; i<N; i++)
+ {
+ A[i]= 0x01;
+ B[i]= 0x70;
+ C[i]= 0xff;
+ }
+
+ testmin (A, 10, 1);
+ testmin (B, 0x7f, 0x70);
+ testmin (C, 0x7f, 0x09);
+
+ testmax (A, 0, 0x7f);
+ testmax (B, 0, 0x8f);
+ testmax (C, 0, 0xff);
+
+ return 0;
+}
+
+
+/* { dg-final { scan-tree-dump-times "Detected reduction" 2 "parloops" } } */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 3 "parloops" } } */
+/* { dg-final { cleanup-tree-dump "parloops" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
+
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-8.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-8.c
new file mode 100644
index 000000000..4a416df23
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-8.c
@@ -0,0 +1,90 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details -fdump-tree-optimized" } */
+
+#include <stdlib.h>
+
+#define N 3200
+
+extern void abort (void);
+typedef signed char T;
+
+__attribute__ ((noinline)) void
+testmax (const T *c, T init, T result)
+{
+ T lc[N], accum = init;
+ int i;
+
+ __builtin_memcpy (lc, c, sizeof(lc));
+
+ for (i = 0; i < N; i++) {
+ accum = accum < lc[i] ? lc[i] : accum;
+ }
+
+ if (accum != result)
+ abort ();
+}
+
+__attribute__ ((noinline)) void
+testmin (const T *c, T init, T result)
+{
+ T lc[N], accum = init;
+ int i;
+
+ __builtin_memcpy (lc, c, sizeof(lc));
+
+ for (i = 0; i < N; i++) {
+ accum = accum > lc[i] ? lc[i] : accum;
+ }
+
+ if (accum != result)
+ abort ();
+}
+
+int main (void)
+{
+ static signed char A[N] = {
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
+ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+ 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f
+ };
+
+ static signed char B[N] = {
+ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+ 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
+ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f
+ };
+
+ static signed char C[N] = {
+ 0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8,
+ 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
+ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+ };
+
+ int i;
+
+ for (i=32; i<N; i++)
+ {
+ A[i]= 0x01;
+ B[i]= 0x70;
+ C[i]= 0xff;
+ }
+
+ testmin (A, 0, 0);
+ testmin (B, 0, 0x80);
+ testmin (C, 0, 0x80);
+
+ testmax (A, 0, 0x7f);
+ testmax (B, 0, 0x7f);
+ testmax (C, 0, 0x77);
+
+ return 0;
+}
+
+
+/* { dg-final { scan-tree-dump-times "Detected reduction" 2 "parloops" } } */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 3 "parloops" } } */
+/* { dg-final { cleanup-tree-dump "parloops" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-9.c b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-9.c
new file mode 100644
index 000000000..2c1677ce5
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/autopar/reduc-9.c
@@ -0,0 +1,90 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=4 -fdump-tree-parloops-details -fdump-tree-optimized" } */
+
+#include <stdlib.h>
+
+#define N 3200
+
+extern void abort (void);
+typedef unsigned short T;
+
+__attribute__ ((noinline)) void
+testmax (const T *c, T init, T result)
+{
+ T lc[N], accum = init;
+ int i;
+
+ __builtin_memcpy (lc, c, sizeof(lc));
+
+ for (i = 0; i < N; i++) {
+ accum = accum < lc[i] ? lc[i] : accum;
+ }
+
+ if (accum != result)
+ abort ();
+}
+
+__attribute__ ((noinline)) void
+testmin (const T *c, T init, T result)
+{
+ T lc[N], accum = init;
+ int i;
+
+ __builtin_memcpy (lc, c, sizeof(lc));
+
+ for (i = 0; i < N; i++) {
+ accum = accum > lc[i] ? lc[i] : accum;
+ }
+
+ if (accum != result)
+ abort ();
+}
+
+int main (void)
+{
+ static unsigned short A[N] = {
+ 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008,
+ 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, 0x0010,
+ 0x7000, 0x7100, 0x7200, 0x7300, 0x7400, 0x7500, 0x7600, 0x7700,
+ 0x7ff8, 0x7ff9, 0x7ffa, 0x7ffb, 0x7ffc, 0x7ffd, 0x7ffe, 0x7fff
+ };
+
+ static unsigned short B[N] = {
+ 0x7000, 0x7100, 0x7200, 0x7300, 0x7400, 0x7500, 0x7600, 0x7700,
+ 0x7ff8, 0x7ff9, 0x7ffa, 0x7ffb, 0x7ffc, 0x7ffd, 0x7ffe, 0x7fff,
+ 0x8000, 0x8001, 0x8002, 0x8003, 0x8004, 0x8005, 0x8006, 0x8007,
+ 0x8008, 0x8009, 0x800a, 0x800b, 0x800c, 0x800d, 0x800e, 0x800f
+ };
+
+ static unsigned short C[N] = {
+ 0xffff, 0xfffe, 0xfffd, 0xfffc, 0xfffb, 0xfffa, 0xfff9, 0xfff8,
+ 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, 0x0010,
+ 0x8000, 0x8001, 0x8002, 0x8003, 0x8004, 0x8005, 0x8006, 0x8007,
+ 0x7000, 0x7100, 0x7200, 0x7300, 0x7400, 0x7500, 0x7600, 0x7700,
+ };
+
+ int i;
+
+ for (i=32; i<N; i++)
+ {
+ A[i]= 0x0001;
+ B[i]= 0x7000;
+ C[i]= 0xffff;
+ }
+
+ testmin (A, 10, 1);
+ testmin (B, 0x7fff, 0x7000);
+ testmin (C, 0x7fff, 0x0009);
+
+ testmax (A, 0, 0x7fff);
+ testmax (B, 0, 0x800f);
+ testmax (C, 0, 0xffff);
+
+ return 0;
+}
+
+
+/* { dg-final { scan-tree-dump-times "Detected reduction" 2 "parloops" } } */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 3 "parloops" } } */
+/* { dg-final { cleanup-tree-dump "parloops" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */