aboutsummaryrefslogtreecommitdiff
path: root/libgomp
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2022-08-17 15:45:56 +0200
committerTobias Burnus <tobias@codesourcery.com>2022-08-17 15:45:56 +0200
commitd9c9424d2c4f7b25acfc00db0076a65882c8a99f (patch)
tree30cfc4745cb01959490f0e7a79ca1792cadfb391 /libgomp
parent6b4e49fdfcc9bff5459d5a821dd7e9476c7c1c10 (diff)
downloadgcc-d9c9424d2c4f7b25acfc00db0076a65882c8a99f.zip
gcc-d9c9424d2c4f7b25acfc00db0076a65882c8a99f.tar.gz
gcc-d9c9424d2c4f7b25acfc00db0076a65882c8a99f.tar.bz2
OpenMP: Fix var replacement with 'simd' and linear-step vars [PR106548]
gcc/ChangeLog: PR middle-end/106548 * omp-low.cc (lower_rec_input_clauses): Use build_outer_var_ref for 'simd' linear-step values that are variable. libgomp/ChangeLog: PR middle-end/106548 * testsuite/libgomp.c/linear-2.c: New test.
Diffstat (limited to 'libgomp')
-rw-r--r--libgomp/testsuite/libgomp.c/linear-2.c254
1 files changed, 254 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.c/linear-2.c b/libgomp/testsuite/libgomp.c/linear-2.c
new file mode 100644
index 0000000..fd549a8
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/linear-2.c
@@ -0,0 +1,254 @@
+/* PR middle-end/106548. */
+/* { dg-additional-options "-msse2" { target sse2_runtime } } */
+/* { dg-additional-options "-mavx" { target avx_runtime } } */
+
+int a[256];
+
+__attribute__((noinline, noclone)) int
+f1 (int i)
+{
+ #pragma omp parallel for simd linear (i: 4)
+ for (int j = 16; j < 64; j++)
+ {
+ a[i] = j;
+ i += 4;
+ }
+ return i;
+}
+
+__attribute__((noinline, noclone)) short int
+f2 (short int i, char k)
+{
+ #pragma omp parallel for simd linear (i: k + 1)
+ for (long j = 16; j < 64; j++)
+ {
+ a[i] = j;
+ i += 4;
+ }
+ return i;
+}
+
+__attribute__((noinline, noclone)) long long int
+f3 (long long int i, long long int k)
+{
+ #pragma omp parallel for simd linear (i: k)
+ for (short j = 16; j < 64; j++)
+ {
+ a[i] = j;
+ i += 4;
+ }
+ return i;
+}
+
+__attribute__((noinline, noclone)) int
+f4 (int i)
+{
+ #pragma omp parallel for simd linear (i: 4) schedule(static, 3)
+ for (int j = 16; j < 64; j++)
+ {
+ a[i] = j;
+ i += 4;
+ }
+ return i;
+}
+
+__attribute__((noinline, noclone)) short int
+f5 (short int i, char k)
+{
+ #pragma omp parallel for simd linear (i: k + 1) schedule(static, 5)
+ for (long j = 16; j < 64; j++)
+ {
+ a[i] = j;
+ i += 4;
+ }
+ return i;
+}
+
+__attribute__((noinline, noclone)) long long int
+f6 (long long int i, long long int k)
+{
+ #pragma omp parallel for simd linear (i: k) schedule(static, 7)
+ for (short j = 16; j < 64; j++)
+ {
+ a[i] = j;
+ i += 4;
+ }
+ return i;
+}
+
+__attribute__((noinline, noclone)) int
+f7 (int i)
+{
+ #pragma omp parallel for simd linear (i: 4) schedule(dynamic, 3)
+ for (int j = 16; j < 64; j++)
+ {
+ a[i] = j;
+ i += 4;
+ }
+ return i;
+}
+
+__attribute__((noinline, noclone)) short int
+f8 (short int i, char k)
+{
+ #pragma omp parallel for simd linear (i: k + 1) schedule(dynamic, 5)
+ for (long j = 16; j < 64; j++)
+ {
+ a[i] = j;
+ i += 4;
+ }
+ return i;
+}
+
+__attribute__((noinline, noclone)) long long int
+f9 (long long int i, long long int k)
+{
+ #pragma omp parallel for simd linear (i: k) schedule(dynamic, 7)
+ for (short j = 16; j < 64; j++)
+ {
+ a[i] = j;
+ i += 4;
+ }
+ return i;
+}
+
+__attribute__((noinline, noclone)) int
+f10 (int i, long step)
+{
+ #pragma omp parallel for simd linear (i: 4)
+ for (int j = 16; j < 112; j += step)
+ {
+ a[i] = j / 2 + 8;
+ i += 4;
+ }
+ return i;
+}
+
+__attribute__((noinline, noclone)) short int
+f11 (short int i, char k, char step)
+{
+ #pragma omp parallel for simd linear (i: k + 1)
+ for (long j = 16; j < 112; j += step)
+ {
+ a[i] = j / 2 + 8;
+ i += 4;
+ }
+ return i;
+}
+
+__attribute__((noinline, noclone)) long long int
+f12 (long long int i, long long int k, int step)
+{
+ #pragma omp parallel for simd linear (i: k)
+ for (short j = 16; j < 112; j += step)
+ {
+ a[i] = j / 2 + 8;
+ i += 4;
+ }
+ return i;
+}
+
+__attribute__((noinline, noclone)) int
+f13 (int i, long long int step)
+{
+ #pragma omp parallel for simd linear (i: 4) schedule(static, 3)
+ for (int j = 16; j < 112; j += step)
+ {
+ a[i] = j / 2 + 8;
+ i += 4;
+ }
+ return i;
+}
+
+__attribute__((noinline, noclone)) short int
+f14 (short int i, char k, int step)
+{
+ #pragma omp parallel for simd linear (i: k + 1) schedule(static, 5)
+ for (long j = 16; j < 112; j += step)
+ {
+ a[i] = j / 2 + 8;
+ i += 4;
+ }
+ return i;
+}
+
+__attribute__((noinline, noclone)) long long int
+f15 (long long int i, long long int k, long int step)
+{
+ #pragma omp parallel for simd linear (i: k) schedule(static, 7)
+ for (short j = 16; j < 112; j += step)
+ {
+ a[i] = j / 2 + 8;
+ i += 4;
+ }
+ return i;
+}
+
+__attribute__((noinline, noclone)) int
+f16 (int i, long long int step)
+{
+ #pragma omp parallel for simd linear (i: 4) schedule(dynamic, 3)
+ for (int j = 16; j < 112; j += step)
+ {
+ a[i] = j / 2 + 8;
+ i += 4;
+ }
+ return i;
+}
+
+__attribute__((noinline, noclone)) short int
+f17 (short int i, char k, int step)
+{
+ #pragma omp parallel for simd linear (i: k + 1) schedule(dynamic, 5)
+ for (long j = 16; j < 112; j += step)
+ {
+ a[i] = j / 2 + 8;
+ i += 4;
+ }
+ return i;
+}
+
+__attribute__((noinline, noclone)) long long int
+f18 (long long int i, long long int k, long int step)
+{
+ #pragma omp parallel for simd linear (i: k) schedule(dynamic, 7)
+ for (short j = 16; j < 112; j += step)
+ {
+ a[i] = j / 2 + 8;
+ i += 4;
+ }
+ return i;
+}
+
+int
+main ()
+{
+#define TEST(x) \
+ if (x != 8 + 48 * 4) \
+ __builtin_abort (); \
+ for (int i = 0; i < 256; i++) \
+ if (a[i] != (((i & 3) == 0 && i >= 8 \
+ && i < 8 + 48 * 4) \
+ ? ((i - 8) / 4) + 16 : 0)) \
+ __builtin_abort (); \
+ __builtin_memset (a, 0, sizeof (a))
+ TEST (f1 (8));
+ TEST (f2 (8, 3));
+ TEST (f3 (8LL, 4LL));
+ TEST (f4 (8));
+ TEST (f5 (8, 3));
+ TEST (f6 (8LL, 4LL));
+ TEST (f7 (8));
+ TEST (f8 (8, 3));
+ TEST (f9 (8LL, 4LL));
+ TEST (f10 (8, 2));
+ TEST (f11 (8, 3, 2));
+ TEST (f12 (8LL, 4LL, 2));
+ TEST (f13 (8, 2));
+ TEST (f14 (8, 3, 2));
+ TEST (f15 (8LL, 4LL, 2));
+ TEST (f16 (8, 2));
+ TEST (f17 (8, 3, 2));
+ TEST (f18 (8LL, 4LL, 2));
+ return 0;
+}