diff options
author | Jakub Jelinek <jakub@redhat.com> | 2006-12-04 11:26:00 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2006-12-04 11:26:00 +0100 |
commit | 22568cc62cabbea1eec20ef65e1da9b0caaa6f02 (patch) | |
tree | f94786a4fcf50b6049962a9a01cc79e07e724e65 /libgomp/testsuite | |
parent | d3c673c74acfcc0202b0013677ef280e76fffb72 (diff) | |
download | gcc-22568cc62cabbea1eec20ef65e1da9b0caaa6f02.zip gcc-22568cc62cabbea1eec20ef65e1da9b0caaa6f02.tar.gz gcc-22568cc62cabbea1eec20ef65e1da9b0caaa6f02.tar.bz2 |
re PR middle-end/29947 (OpenMP parallel for fails for reversed loop range)
PR libgomp/29947
* omp-low.c (expand_omp_for_static_nochunk,
expand_omp_for_static_chunk): Do all arithmetics in signed rather than
unsigned type.
* loop.c (gomp_loop_init): Make parameters signed. Set ws->end to
start if there shouldn't be any loop iterations.
(gomp_loop_ordered_static_start): Remove start == end test.
* testsuite/libgomp.c/pr29947-1.c: New test.
* testsuite/libgomp.c/pr29947-2.c: New test.
From-SVN: r119485
Diffstat (limited to 'libgomp/testsuite')
-rw-r--r-- | libgomp/testsuite/libgomp.c/pr29947-1.c | 328 | ||||
-rw-r--r-- | libgomp/testsuite/libgomp.c/pr29947-2.c | 328 |
2 files changed, 656 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.c/pr29947-1.c b/libgomp/testsuite/libgomp.c/pr29947-1.c new file mode 100644 index 0000000..78b40ac --- /dev/null +++ b/libgomp/testsuite/libgomp.c/pr29947-1.c @@ -0,0 +1,328 @@ +/* PR libgomp/29947 */ +/* { dg-options "-O2 -fopenmp" } */ +/* { dg-do run } */ + +extern void abort (void); + +int cnt; + +void +test1 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel reduction (+:e,c) + { +#pragma omp for schedule (dynamic) + for (i = j1; i <= k1; ++i) + { + if (i < j2 || i > k2) + ++e; + ++c; + } +#pragma omp atomic + ++cnt; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test2 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel reduction (+:e,c) + { +#pragma omp for schedule (dynamic) + for (i = k1; i >= j1; --i) + { + if (i < j2 || i > k2) + ++e; + ++c; + } +#pragma omp atomic + ++cnt; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test3 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel reduction (+:e,c) + { +#pragma omp for schedule (guided) + for (i = j1; i <= k1; ++i) + { + if (i < j2 || i > k2) + ++e; + ++c; + } +#pragma omp atomic + ++cnt; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test4 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel reduction (+:e,c) + { +#pragma omp for schedule (guided) + for (i = k1; i >= j1; --i) + { + if (i < j2 || i > k2) + ++e; + ++c; + } +#pragma omp atomic + ++cnt; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test5 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel reduction (+:e,c) + { +#pragma omp for schedule (dynamic) ordered + for (i = j1; i <= k1; ++i) + { + if (i < j2 || i > k2) + ++e; +#pragma omp ordered + ++c; + } +#pragma omp atomic + ++cnt; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test6 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel reduction (+:e,c) + { +#pragma omp for schedule (dynamic) ordered + for (i = k1; i >= j1; --i) + { + if (i < j2 || i > k2) + ++e; +#pragma omp ordered + ++c; + } +#pragma omp atomic + ++cnt; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test7 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel reduction (+:e,c) + { +#pragma omp for schedule (guided) ordered + for (i = j1; i <= k1; ++i) + { + if (i < j2 || i > k2) + ++e; +#pragma omp ordered + ++c; + } +#pragma omp atomic + ++cnt; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test8 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel reduction (+:e,c) + { +#pragma omp for schedule (guided) ordered + for (i = k1; i >= j1; --i) + { + if (i < j2 || i > k2) + ++e; +#pragma omp ordered + ++c; + } +#pragma omp atomic + ++cnt; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test9 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel for reduction (+:e,c) schedule (dynamic) + for (i = j1; i <= k1; ++i) + { + if (i < j2 || i > k2) + ++e; + ++c; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test10 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel for reduction (+:e,c) schedule (dynamic) + for (i = k1; i >= j1; --i) + { + if (i < j2 || i > k2) + ++e; + ++c; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test11 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel for reduction (+:e,c) schedule (guided) + for (i = j1; i <= k1; ++i) + { + if (i < j2 || i > k2) + ++e; + ++c; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test12 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel for reduction (+:e,c) schedule (guided) + for (i = k1; i >= j1; --i) + { + if (i < j2 || i > k2) + ++e; + ++c; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test13 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel for reduction (+:e,c) schedule (dynamic) ordered + for (i = j1; i <= k1; ++i) + { + if (i < j2 || i > k2) + ++e; +#pragma omp ordered + ++c; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test14 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel for reduction (+:e,c) schedule (dynamic) ordered + for (i = k1; i >= j1; --i) + { + if (i < j2 || i > k2) + ++e; +#pragma omp ordered + ++c; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test15 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel for reduction (+:e,c) schedule (guided) ordered + for (i = j1; i <= k1; ++i) + { + if (i < j2 || i > k2) + ++e; +#pragma omp ordered + ++c; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test16 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel for reduction (+:e,c) schedule (guided) ordered + for (i = k1; i >= j1; --i) + { + if (i < j2 || i > k2) + ++e; +#pragma omp ordered + ++c; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +int +__attribute__((noinline)) +test (long j1, long k1, long j2, long k2) +{ + test1 (j1, k1, j2, k2); + test2 (j1, k1, j2, k2); + test3 (j1, k1, j2, k2); + test4 (j1, k1, j2, k2); + test5 (j1, k1, j2, k2); + test6 (j1, k1, j2, k2); + test7 (j1, k1, j2, k2); + test8 (j1, k1, j2, k2); + test9 (j1, k1, j2, k2); + test10 (j1, k1, j2, k2); + test11 (j1, k1, j2, k2); + test12 (j1, k1, j2, k2); + test13 (j1, k1, j2, k2); + test14 (j1, k1, j2, k2); + test15 (j1, k1, j2, k2); + test16 (j1, k1, j2, k2); + return cnt; +} + +int +main (void) +{ + test (1, 5, 1, 5); + test (5, 5, 5, 5); + test (5, 4, 5, 4); + test (5, 1, 5, 1); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/pr29947-2.c b/libgomp/testsuite/libgomp.c/pr29947-2.c new file mode 100644 index 0000000..231cd5d --- /dev/null +++ b/libgomp/testsuite/libgomp.c/pr29947-2.c @@ -0,0 +1,328 @@ +/* PR libgomp/29947 */ +/* { dg-options "-O2 -fopenmp" } */ +/* { dg-do run } */ + +extern void abort (void); + +int cnt; + +void +test1 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel reduction (+:e,c) + { +#pragma omp for schedule (static) + for (i = j1; i <= k1; ++i) + { + if (i < j2 || i > k2) + ++e; + ++c; + } +#pragma omp atomic + ++cnt; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test2 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel reduction (+:e,c) + { +#pragma omp for schedule (static) + for (i = k1; i >= j1; --i) + { + if (i < j2 || i > k2) + ++e; + ++c; + } +#pragma omp atomic + ++cnt; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test3 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel reduction (+:e,c) + { +#pragma omp for schedule (static, 1) + for (i = j1; i <= k1; ++i) + { + if (i < j2 || i > k2) + ++e; + ++c; + } +#pragma omp atomic + ++cnt; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test4 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel reduction (+:e,c) + { +#pragma omp for schedule (static, 1) + for (i = k1; i >= j1; --i) + { + if (i < j2 || i > k2) + ++e; + ++c; + } +#pragma omp atomic + ++cnt; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test5 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel reduction (+:e,c) + { +#pragma omp for schedule (static) ordered + for (i = j1; i <= k1; ++i) + { + if (i < j2 || i > k2) + ++e; +#pragma omp ordered + ++c; + } +#pragma omp atomic + ++cnt; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test6 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel reduction (+:e,c) + { +#pragma omp for schedule (static) ordered + for (i = k1; i >= j1; --i) + { + if (i < j2 || i > k2) + ++e; +#pragma omp ordered + ++c; + } +#pragma omp atomic + ++cnt; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test7 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel reduction (+:e,c) + { +#pragma omp for schedule (static, 1) ordered + for (i = j1; i <= k1; ++i) + { + if (i < j2 || i > k2) + ++e; +#pragma omp ordered + ++c; + } +#pragma omp atomic + ++cnt; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test8 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel reduction (+:e,c) + { +#pragma omp for schedule (static, 1) ordered + for (i = k1; i >= j1; --i) + { + if (i < j2 || i > k2) + ++e; +#pragma omp ordered + ++c; + } +#pragma omp atomic + ++cnt; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test9 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel for reduction (+:e,c) schedule (static) + for (i = j1; i <= k1; ++i) + { + if (i < j2 || i > k2) + ++e; + ++c; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test10 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel for reduction (+:e,c) schedule (static) + for (i = k1; i >= j1; --i) + { + if (i < j2 || i > k2) + ++e; + ++c; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test11 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel for reduction (+:e,c) schedule (static, 1) + for (i = j1; i <= k1; ++i) + { + if (i < j2 || i > k2) + ++e; + ++c; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test12 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel for reduction (+:e,c) schedule (static, 1) + for (i = k1; i >= j1; --i) + { + if (i < j2 || i > k2) + ++e; + ++c; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test13 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel for reduction (+:e,c) schedule (static) ordered + for (i = j1; i <= k1; ++i) + { + if (i < j2 || i > k2) + ++e; +#pragma omp ordered + ++c; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test14 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel for reduction (+:e,c) schedule (static) ordered + for (i = k1; i >= j1; --i) + { + if (i < j2 || i > k2) + ++e; +#pragma omp ordered + ++c; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test15 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel for reduction (+:e,c) schedule (static, 1) ordered + for (i = j1; i <= k1; ++i) + { + if (i < j2 || i > k2) + ++e; +#pragma omp ordered + ++c; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +void +test16 (long j1, long k1, long j2, long k2) +{ + long i, e = 0, c = 0; +#pragma omp parallel for reduction (+:e,c) schedule (static, 1) ordered + for (i = k1; i >= j1; --i) + { + if (i < j2 || i > k2) + ++e; +#pragma omp ordered + ++c; + } + if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1)) + abort (); +} + +int +__attribute__((noinline)) +test (long j1, long k1, long j2, long k2) +{ + test1 (j1, k1, j2, k2); + test2 (j1, k1, j2, k2); + test3 (j1, k1, j2, k2); + test4 (j1, k1, j2, k2); + test5 (j1, k1, j2, k2); + test6 (j1, k1, j2, k2); + test7 (j1, k1, j2, k2); + test8 (j1, k1, j2, k2); + test9 (j1, k1, j2, k2); + test10 (j1, k1, j2, k2); + test11 (j1, k1, j2, k2); + test12 (j1, k1, j2, k2); + test13 (j1, k1, j2, k2); + test14 (j1, k1, j2, k2); + test15 (j1, k1, j2, k2); + test16 (j1, k1, j2, k2); + return cnt; +} + +int +main (void) +{ + test (1, 5, 1, 5); + test (5, 5, 5, 5); + test (5, 4, 5, 4); + test (5, 1, 5, 1); + return 0; +} |