summaryrefslogtreecommitdiff
path: root/libgomp
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2014-06-24 07:53:52 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2014-06-24 07:53:52 +0000
commite471cc6fa22dd96c645987ad86fa6b469340242f (patch)
tree8eeccb0956a7e6b8abafc24234634fa3736769cf /libgomp
parentc3f3b68d345b6ce507570035196453a0aec6887c (diff)
downloadgcc-e471cc6fa22dd96c645987ad86fa6b469340242f.tar.gz
* gimplify.c (gimplify_omp_for): For #pragma omp for simd iterator
not mentioned in clauses use private clause if the iterator is declared in #pragma omp for simd, and when adding lastprivate instead, add it to the outer #pragma omp for too. Diagnose if the variable is private in outer context. For simd collapse > 1 loops, replace all iterators with temporaries. * omp-low.c (lower_rec_input_clauses): Handle LINEAR clause the same even in collapse > 1 loops. gcc/c/ * c-parser.c (c_parser_omp_for_loop): For #pragma omp parallel for simd move lastprivate clause from parallel to for rather than simd. gcc/cp/ * parser.c (cp_parser_omp_for_loop): For #pragma omp parallel for simd move lastprivate clause from parallel to for rather than simd. libgomp/ * testsuite/libgomp.c/for-2.c: Define SC to static for #pragma omp for simd testing. * testsuite/libgomp.c/for-2.h (SC): Define if not defined. (N(f5), N(f6), N(f7), N(f8), N(f10), N(f12), N(f14)): Use SC macro. * testsuite/libgomp.c/simd-14.c: New test. * testsuite/libgomp.c/simd-15.c: New test. * testsuite/libgomp.c/simd-16.c: New test. * testsuite/libgomp.c/simd-17.c: New test. * testsuite/libgomp.c++/for-10.C: Define SC to static for #pragma omp for simd testing. * testsuite/libgomp.c++/simd10.C: New test. * testsuite/libgomp.c++/simd11.C: New test. * testsuite/libgomp.c++/simd12.C: New test. * testsuite/libgomp.c++/simd13.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@211930 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgomp')
-rw-r--r--libgomp/ChangeLog16
-rw-r--r--libgomp/testsuite/libgomp.c++/for-10.C3
-rw-r--r--libgomp/testsuite/libgomp.c++/simd10.C6
-rw-r--r--libgomp/testsuite/libgomp.c++/simd11.C6
-rw-r--r--libgomp/testsuite/libgomp.c++/simd12.C6
-rw-r--r--libgomp/testsuite/libgomp.c++/simd13.C6
-rw-r--r--libgomp/testsuite/libgomp.c/for-2.c3
-rw-r--r--libgomp/testsuite/libgomp.c/for-2.h21
-rw-r--r--libgomp/testsuite/libgomp.c/simd-14.c123
-rw-r--r--libgomp/testsuite/libgomp.c/simd-15.c129
-rw-r--r--libgomp/testsuite/libgomp.c/simd-16.c67
-rw-r--r--libgomp/testsuite/libgomp.c/simd-17.c73
12 files changed, 450 insertions, 9 deletions
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 4b63b9a3ce0..1bed6eae8ec 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,5 +1,21 @@
2014-06-24 Jakub Jelinek <jakub@redhat.com>
+ * testsuite/libgomp.c/for-2.c: Define SC to static for
+ #pragma omp for simd testing.
+ * testsuite/libgomp.c/for-2.h (SC): Define if not defined.
+ (N(f5), N(f6), N(f7), N(f8), N(f10), N(f12), N(f14)): Use
+ SC macro.
+ * testsuite/libgomp.c/simd-14.c: New test.
+ * testsuite/libgomp.c/simd-15.c: New test.
+ * testsuite/libgomp.c/simd-16.c: New test.
+ * testsuite/libgomp.c/simd-17.c: New test.
+ * testsuite/libgomp.c++/for-10.C: Define SC to static for
+ #pragma omp for simd testing.
+ * testsuite/libgomp.c++/simd10.C: New test.
+ * testsuite/libgomp.c++/simd11.C: New test.
+ * testsuite/libgomp.c++/simd12.C: New test.
+ * testsuite/libgomp.c++/simd13.C: New test.
+
* testsuite/libgomp.fortran/aligned1.f03: New test.
* testsuite/libgomp.fortran/nestedfn5.f90: New test.
* testsuite/libgomp.fortran/target7.f90: Surround loop spawning
diff --git a/libgomp/testsuite/libgomp.c++/for-10.C b/libgomp/testsuite/libgomp.c++/for-10.C
index fb1a3e952b1..c67096ac92a 100644
--- a/libgomp/testsuite/libgomp.c++/for-10.C
+++ b/libgomp/testsuite/libgomp.c++/for-10.C
@@ -19,11 +19,14 @@ extern "C" void abort ();
#undef F
#undef G
+#undef SC
+#define SC static
#define F for simd
#define G f_simd
#include "../libgomp.c/for-1.h"
#undef F
#undef G
+#undef SC
int
main ()
diff --git a/libgomp/testsuite/libgomp.c++/simd10.C b/libgomp/testsuite/libgomp.c++/simd10.C
new file mode 100644
index 00000000000..390e65ffea3
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/simd10.C
@@ -0,0 +1,6 @@
+// { dg-do run }
+// { dg-options "-O2" }
+// { dg-additional-options "-msse2" { target sse2_runtime } }
+// { dg-additional-options "-mavx" { target avx_runtime } }
+
+#include "../libgomp.c/simd-14.c"
diff --git a/libgomp/testsuite/libgomp.c++/simd11.C b/libgomp/testsuite/libgomp.c++/simd11.C
new file mode 100644
index 00000000000..b9668685601
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/simd11.C
@@ -0,0 +1,6 @@
+// { dg-do run }
+// { dg-options "-O2" }
+// { dg-additional-options "-msse2" { target sse2_runtime } }
+// { dg-additional-options "-mavx" { target avx_runtime } }
+
+#include "../libgomp.c/simd-15.c"
diff --git a/libgomp/testsuite/libgomp.c++/simd12.C b/libgomp/testsuite/libgomp.c++/simd12.C
new file mode 100644
index 00000000000..ecfc912aeea
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/simd12.C
@@ -0,0 +1,6 @@
+// { dg-do run }
+// { dg-options "-O2" }
+// { dg-additional-options "-msse2" { target sse2_runtime } }
+// { dg-additional-options "-mavx" { target avx_runtime } }
+
+#include "../libgomp.c/simd-16.c"
diff --git a/libgomp/testsuite/libgomp.c++/simd13.C b/libgomp/testsuite/libgomp.c++/simd13.C
new file mode 100644
index 00000000000..f7496209680
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/simd13.C
@@ -0,0 +1,6 @@
+// { dg-do run }
+// { dg-options "-O2" }
+// { dg-additional-options "-msse2" { target sse2_runtime } }
+// { dg-additional-options "-mavx" { target avx_runtime } }
+
+#include "../libgomp.c/simd-17.c"
diff --git a/libgomp/testsuite/libgomp.c/for-2.c b/libgomp/testsuite/libgomp.c/for-2.c
index f5a01ab05ec..ae810087454 100644
--- a/libgomp/testsuite/libgomp.c/for-2.c
+++ b/libgomp/testsuite/libgomp.c/for-2.c
@@ -21,11 +21,14 @@ extern void abort (void);
#undef F
#undef G
+#undef SC
+#define SC static
#define F for simd
#define G f_simd
#include "for-1.h"
#undef F
#undef G
+#undef SC
int
main ()
diff --git a/libgomp/testsuite/libgomp.c/for-2.h b/libgomp/testsuite/libgomp.c/for-2.h
index 57c385ec876..920d23b5202 100644
--- a/libgomp/testsuite/libgomp.c/for-2.h
+++ b/libgomp/testsuite/libgomp.c/for-2.h
@@ -8,6 +8,9 @@ noreturn (void)
for (;;);
}
#endif
+#ifndef SC
+#define SC
+#endif
__attribute__((noinline, noclone)) void
N(f0) (void)
@@ -57,7 +60,7 @@ __attribute__((noinline, noclone)) void
N(f5) (int n11, int n12, int n21, int n22, int n31, int n32,
int s1, int s2, int s3)
{
- int v1, v2, v3;
+ SC int v1, v2, v3;
#pragma omp F S collapse(3)
for (v1 = n11; v1 < n12; v1 += s1)
for (v2 = n21; v2 < n22; v2 += s2)
@@ -69,8 +72,8 @@ __attribute__((noinline, noclone)) void
N(f6) (int n11, int n12, int n21, int n22, long long n31, long long n32,
int s1, int s2, long long int s3)
{
- int v1, v2;
- long long v3;
+ SC int v1, v2;
+ SC long long v3;
#pragma omp F S collapse(3)
for (v1 = n11; v1 > n12; v1 += s1)
for (v2 = n21; v2 > n22; v2 += s2)
@@ -81,8 +84,8 @@ N(f6) (int n11, int n12, int n21, int n22, long long n31, long long n32,
__attribute__((noinline, noclone)) void
N(f7) (void)
{
- unsigned int v1, v3;
- unsigned long long v2;
+ SC unsigned int v1, v3;
+ SC unsigned long long v2;
#pragma omp F S collapse(3)
for (v1 = 0; v1 < 20; v1 += 2)
for (v2 = __LONG_LONG_MAX__ + 16ULL;
@@ -94,7 +97,7 @@ N(f7) (void)
__attribute__((noinline, noclone)) void
N(f8) (void)
{
- long long v1, v2, v3;
+ SC long long v1, v2, v3;
#pragma omp F S collapse(3)
for (v1 = 0; v1 < 20; v1 += 2)
for (v2 = 30; v2 < 20; v2++)
@@ -118,7 +121,7 @@ N(f9) (void)
__attribute__((noinline, noclone)) void
N(f10) (void)
{
- int i;
+ SC int i;
#pragma omp F S collapse(3)
for (i = 0; i < 10; i++)
for (int j = 10; j < 8; j++)
@@ -146,7 +149,7 @@ N(f11) (int n)
__attribute__((noinline, noclone)) void
N(f12) (int n)
{
- int i;
+ SC int i;
#pragma omp F S collapse(3)
for (i = 0; i < 10; i++)
for (int j = n; j < 8; j++)
@@ -170,7 +173,7 @@ N(f13) (void)
__attribute__((noinline, noclone)) void
N(f14) (void)
{
- float *i;
+ SC float *i;
#pragma omp F S collapse(3)
for (i = &b[0][0][0]; i < &b[0][0][10]; i++)
for (float *j = &b[0][15][0]; j > &b[0][0][0]; j -= 10)
diff --git a/libgomp/testsuite/libgomp.c/simd-14.c b/libgomp/testsuite/libgomp.c/simd-14.c
new file mode 100644
index 00000000000..50e8d5e9011
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/simd-14.c
@@ -0,0 +1,123 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+/* { dg-additional-options "-msse2" { target sse2_runtime } } */
+/* { dg-additional-options "-mavx" { target avx_runtime } } */
+
+int
+main ()
+{
+ int i, j, b, c = 0;
+ i = 4; j = 4; b = 7;
+ #pragma omp simd linear(b:2) reduction(+:c)
+ for (i = 0; i < 64; i++)
+ {
+ c = c + (b != 7 + 2 * i);
+ b = b + 2;
+ }
+ if (c || i != 64 || b != 7 + 64 * 2)
+ __builtin_abort ();
+ i = 4; j = 4; b = 7;
+ #pragma omp simd linear(b:3) reduction(+:c)
+ for (i = 0; i < 64; i += 4)
+ {
+ c = c + (b != 7 + i / 4 * 3);
+ b = b + 3;
+ }
+ if (c || i != 64 || b != 7 + 16 * 3)
+ __builtin_abort ();
+ i = 4; j = 4; b = 7;
+ #pragma omp simd linear(i) linear(b:2) reduction(+:c)
+ for (i = 0; i < 64; i++)
+ {
+ c = c + (b != 7 + 2 * i);
+ b = b + 2;
+ }
+ if (c || i != 64 || b != 7 + 64 * 2)
+ __builtin_abort ();
+ i = 4; j = 4; b = 7;
+ #pragma omp simd linear(i:4) linear(b:3) reduction(+:c)
+ for (i = 0; i < 64; i += 4)
+ {
+ c = c + (b != 7 + i / 4 * 3);
+ b = b + 3;
+ }
+ if (c || i != 64 || b != 7 + 16 * 3)
+ __builtin_abort ();
+ i = 4; j = 4; b = 7;
+ #pragma omp simd collapse (2) linear(b:2) reduction(+:c)
+ for (i = 0; i < 8; i++)
+ for (j = 0; j < 8; j++)
+ {
+ c = c + (b != 7 + 2 * j + 2 * 8 * i);
+ b = b + 2;
+ }
+ if (c || i != 8 || j != 8 || b != 7 + 64 * 2)
+ __builtin_abort ();
+ i = 4; j = 4; b = 7;
+ #pragma omp simd collapse (2) lastprivate (i, j) linear(b:2) reduction(+:c)
+ for (i = 0; i < 8; i++)
+ for (j = 0; j < 8; j++)
+ {
+ c = c + (b != 7 + 2 * j + 2 * 8 * i);
+ b = b + 2;
+ }
+ if (c || i != 8 || j != 8 || b != 7 + 64 * 2)
+ __builtin_abort ();
+ i = 4; j = 4; b = 7;
+ #pragma omp parallel for simd schedule (static, 4) linear(b:2) reduction(+:c)
+ for (i = 0; i < 64; i++)
+ {
+ c = c + (b != 7 + 2 * i);
+ b = b + 2;
+ }
+ if (c || i != 64 || b != 7 + 64 * 2)
+ __builtin_abort ();
+ i = 4; j = 4; b = 7;
+ #pragma omp parallel for simd schedule (static, 4) linear(b:3) reduction(+:c)
+ for (i = 0; i < 64; i += 4)
+ {
+ c = c + (b != 7 + i / 4 * 3);
+ b = b + 3;
+ }
+ if (c || i != 64 || b != 7 + 16 * 3)
+ __builtin_abort ();
+ i = 4; j = 4; b = 7;
+ #pragma omp parallel for simd schedule (static, 4) linear(i) linear(b:2) reduction(+:c)
+ for (i = 0; i < 64; i++)
+ {
+ c = c + (b != 7 + 2 * i);
+ b = b + 2;
+ }
+ if (c || i != 64 || b != 7 + 64 * 2)
+ __builtin_abort ();
+ i = 4; j = 4; b = 7;
+ #pragma omp parallel for simd schedule (static, 4) linear(i:4) linear(b:3) reduction(+:c)
+ for (i = 0; i < 64; i += 4)
+ {
+ c = c + (b != 7 + i / 4 * 3);
+ b = b + 3;
+ }
+ if (c || i != 64 || b != 7 + 16 * 3)
+ __builtin_abort ();
+ i = 4; j = 4; b = 7;
+ #pragma omp parallel for simd lastprivate (i, j) collapse (2) schedule (static, 4) linear(b:2) reduction(+:c)
+ for (i = 0; i < 8; i++)
+ for (j = 0; j < 8; j++)
+ {
+ c = c + (b != 7 + 2 * j + 2 * 8 * i);
+ b = b + 2;
+ }
+ if (c || i != 8 || j != 8 || b != 7 + 64 * 2)
+ __builtin_abort ();
+ i = 4; j = 4; b = 7;
+ #pragma omp parallel for simd collapse (2) schedule (static, 4) linear(b:2) reduction(+:c)
+ for (i = 0; i < 8; i++)
+ for (j = 0; j < 8; j++)
+ {
+ c = c + (b != 7 + 2 * j + 2 * 8 * i);
+ b = b + 2;
+ }
+ if (c || i != 8 || j != 8 || b != 7 + 64 * 2)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/libgomp/testsuite/libgomp.c/simd-15.c b/libgomp/testsuite/libgomp.c/simd-15.c
new file mode 100644
index 00000000000..e474b81fa44
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/simd-15.c
@@ -0,0 +1,129 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+/* { dg-additional-options "-msse2" { target sse2_runtime } } */
+/* { dg-additional-options "-mavx" { target avx_runtime } } */
+
+static inline void
+foo (int *b, int *i, int *j, int x)
+{
+ *b = *b + x + (*i - *i) + (*j - *j);
+}
+
+int
+main ()
+{
+ int i, j, b, c = 0;
+ i = 4; j = 4; b = 7;
+ #pragma omp simd linear(b:2) reduction(+:c)
+ for (i = 0; i < 64; i++)
+ {
+ c = c + (b != 7 + 2 * i);
+ foo (&b, &i, &j, 2);
+ }
+ if (c || i != 64 || b != 7 + 64 * 2)
+ __builtin_abort ();
+ i = 4; j = 4; b = 7;
+ #pragma omp simd linear(b:3) reduction(+:c)
+ for (i = 0; i < 64; i += 4)
+ {
+ c = c + (b != 7 + i / 4 * 3);
+ foo (&b, &i, &j, 3);
+ }
+ if (c || i != 64 || b != 7 + 16 * 3)
+ __builtin_abort ();
+ i = 4; j = 4; b = 7;
+ #pragma omp simd linear(i) linear(b:2) reduction(+:c)
+ for (i = 0; i < 64; i++)
+ {
+ c = c + (b != 7 + 2 * i);
+ foo (&b, &i, &j, 2);
+ }
+ if (c || i != 64 || b != 7 + 64 * 2)
+ __builtin_abort ();
+ i = 4; j = 4; b = 7;
+ #pragma omp simd linear(i:4) linear(b:3) reduction(+:c)
+ for (i = 0; i < 64; i += 4)
+ {
+ c = c + (b != 7 + i / 4 * 3);
+ foo (&b, &i, &j, 3);
+ }
+ if (c || i != 64 || b != 7 + 16 * 3)
+ __builtin_abort ();
+ i = 4; j = 4; b = 7;
+ #pragma omp simd collapse (2) linear(b:2) reduction(+:c)
+ for (i = 0; i < 8; i++)
+ for (j = 0; j < 8; j++)
+ {
+ c = c + (b != 7 + 2 * j + 2 * 8 * i);
+ foo (&b, &i, &j, 2);
+ }
+ if (c || i != 8 || j != 8 || b != 7 + 64 * 2)
+ __builtin_abort ();
+ i = 4; j = 4; b = 7;
+ #pragma omp simd collapse (2) lastprivate (i, j) linear(b:2) reduction(+:c)
+ for (i = 0; i < 8; i++)
+ for (j = 0; j < 8; j++)
+ {
+ c = c + (b != 7 + 2 * j + 2 * 8 * i);
+ foo (&b, &i, &j, 2);
+ }
+ if (c || i != 8 || j != 8 || b != 7 + 64 * 2)
+ __builtin_abort ();
+ i = 4; j = 4; b = 7;
+ #pragma omp parallel for simd schedule (static, 4) linear(b:2) reduction(+:c)
+ for (i = 0; i < 64; i++)
+ {
+ c = c + (b != 7 + 2 * i);
+ foo (&b, &i, &j, 2);
+ }
+ if (c || i != 64 || b != 7 + 64 * 2)
+ __builtin_abort ();
+ i = 4; j = 4; b = 7;
+ #pragma omp parallel for simd schedule (static, 4) linear(b:3) reduction(+:c)
+ for (i = 0; i < 64; i += 4)
+ {
+ c = c + (b != 7 + i / 4 * 3);
+ foo (&b, &i, &j, 3);
+ }
+ if (c || i != 64 || b != 7 + 16 * 3)
+ __builtin_abort ();
+ i = 4; j = 4; b = 7;
+ #pragma omp parallel for simd schedule (static, 4) linear(i) linear(b:2) reduction(+:c)
+ for (i = 0; i < 64; i++)
+ {
+ c = c + (b != 7 + 2 * i);
+ foo (&b, &i, &j, 2);
+ }
+ if (c || i != 64 || b != 7 + 64 * 2)
+ __builtin_abort ();
+ i = 4; j = 4; b = 7;
+ #pragma omp parallel for simd schedule (static, 4) linear(i:4) linear(b:3) reduction(+:c)
+ for (i = 0; i < 64; i += 4)
+ {
+ c = c + (b != 7 + i / 4 * 3);
+ foo (&b, &i, &j, 3);
+ }
+ if (c || i != 64 || b != 7 + 16 * 3)
+ __builtin_abort ();
+ i = 4; j = 4; b = 7;
+ #pragma omp parallel for simd lastprivate (i, j) collapse (2) schedule (static, 4) linear(b:2) reduction(+:c)
+ for (i = 0; i < 8; i++)
+ for (j = 0; j < 8; j++)
+ {
+ c = c + (b != 7 + 2 * j + 2 * 8 * i);
+ foo (&b, &i, &j, 2);
+ }
+ if (c || i != 8 || j != 8 || b != 7 + 64 * 2)
+ __builtin_abort ();
+ i = 4; j = 4; b = 7;
+ #pragma omp parallel for simd collapse (2) schedule (static, 4) linear(b:2) reduction(+:c)
+ for (i = 0; i < 8; i++)
+ for (j = 0; j < 8; j++)
+ {
+ c = c + (b != 7 + 2 * j + 2 * 8 * i);
+ foo (&b, &i, &j, 2);
+ }
+ if (c || i != 8 || j != 8 || b != 7 + 64 * 2)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/libgomp/testsuite/libgomp.c/simd-16.c b/libgomp/testsuite/libgomp.c/simd-16.c
new file mode 100644
index 00000000000..c8c29c744d7
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/simd-16.c
@@ -0,0 +1,67 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -std=c99" } */
+/* { dg-additional-options "-msse2" { target sse2_runtime } } */
+/* { dg-additional-options "-mavx" { target avx_runtime } } */
+
+int
+main ()
+{
+ int b, c = 0;
+ b = 7;
+ #pragma omp simd linear(b:2) reduction(+:c)
+ for (int i = 0; i < 64; i++)
+ {
+ c = c + (b != 7 + 2 * i);
+ b = b + 2;
+ }
+ if (c || b != 7 + 64 * 2)
+ __builtin_abort ();
+ b = 7;
+ #pragma omp simd linear(b:3) reduction(+:c)
+ for (int i = 0; i < 64; i += 4)
+ {
+ c = c + (b != 7 + i / 4 * 3);
+ b = b + 3;
+ }
+ if (c || b != 7 + 16 * 3)
+ __builtin_abort ();
+ b = 7;
+ #pragma omp simd collapse (2) linear(b:2) reduction(+:c)
+ for (int i = 0; i < 8; i++)
+ for (int j = 0; j < 8; j++)
+ {
+ c = c + (b != 7 + 2 * j + 2 * 8 * i);
+ b = b + 2;
+ }
+ if (c || b != 7 + 64 * 2)
+ __builtin_abort ();
+ b = 7;
+ #pragma omp parallel for simd schedule (static, 4) linear(b:2) reduction(+:c)
+ for (int i = 0; i < 64; i++)
+ {
+ c = c + (b != 7 + 2 * i);
+ b = b + 2;
+ }
+ if (c || b != 7 + 64 * 2)
+ __builtin_abort ();
+ b = 7;
+ #pragma omp parallel for simd schedule (static, 4) linear(b:3) reduction(+:c)
+ for (int i = 0; i < 64; i += 4)
+ {
+ c = c + (b != 7 + i / 4 * 3);
+ b = b + 3;
+ }
+ if (c || b != 7 + 16 * 3)
+ __builtin_abort ();
+ b = 7;
+ #pragma omp parallel for simd collapse (2) schedule (static, 4) linear(b:2) reduction(+:c)
+ for (int i = 0; i < 8; i++)
+ for (int j = 0; j < 8; j++)
+ {
+ c = c + (b != 7 + 2 * j + 2 * 8 * i);
+ b = b + 2;
+ }
+ if (c || b != 7 + 64 * 2)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/libgomp/testsuite/libgomp.c/simd-17.c b/libgomp/testsuite/libgomp.c/simd-17.c
new file mode 100644
index 00000000000..136e6e64ade
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/simd-17.c
@@ -0,0 +1,73 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -std=c99" } */
+/* { dg-additional-options "-msse2" { target sse2_runtime } } */
+/* { dg-additional-options "-mavx" { target avx_runtime } } */
+
+static inline void
+foo (int *b, int *i, int *j, int x)
+{
+ *b = *b + x + (*i - *i) + (*j - *j);
+}
+
+int
+main ()
+{
+ int b, c = 0;
+ b = 7;
+ #pragma omp simd linear(b:2) reduction(+:c)
+ for (int i = 0; i < 64; i++)
+ {
+ c = c + (b != 7 + 2 * i);
+ foo (&b, &i, &i, 2);
+ }
+ if (c || b != 7 + 64 * 2)
+ __builtin_abort ();
+ b = 7;
+ #pragma omp simd linear(b:3) reduction(+:c)
+ for (int i = 0; i < 64; i += 4)
+ {
+ c = c + (b != 7 + i / 4 * 3);
+ foo (&b, &i, &i, 3);
+ }
+ if (c || b != 7 + 16 * 3)
+ __builtin_abort ();
+ b = 7;
+ #pragma omp simd collapse (2) linear(b:2) reduction(+:c)
+ for (int i = 0; i < 8; i++)
+ for (int j = 0; j < 8; j++)
+ {
+ c = c + (b != 7 + 2 * j + 2 * 8 * i);
+ foo (&b, &i, &j, 2);
+ }
+ if (c || b != 7 + 64 * 2)
+ __builtin_abort ();
+ b = 7;
+ #pragma omp parallel for simd schedule (static, 4) linear(b:2) reduction(+:c)
+ for (int i = 0; i < 64; i++)
+ {
+ c = c + (b != 7 + 2 * i);
+ foo (&b, &i, &i, 2);
+ }
+ if (c || b != 7 + 64 * 2)
+ __builtin_abort ();
+ b = 7;
+ #pragma omp parallel for simd schedule (static, 4) linear(b:3) reduction(+:c)
+ for (int i = 0; i < 64; i += 4)
+ {
+ c = c + (b != 7 + i / 4 * 3);
+ foo (&b, &i, &i, 3);
+ }
+ if (c || b != 7 + 16 * 3)
+ __builtin_abort ();
+ b = 7;
+ #pragma omp parallel for simd collapse (2) schedule (static, 4) linear(b:2) reduction(+:c)
+ for (int i = 0; i < 8; i++)
+ for (int j = 0; j < 8; j++)
+ {
+ c = c + (b != 7 + 2 * j + 2 * 8 * i);
+ foo (&b, &i, &j, 2);
+ }
+ if (c || b != 7 + 64 * 2)
+ __builtin_abort ();
+ return 0;
+}