diff options
author | Tom de Vries <tom@codesourcery.com> | 2015-06-05 15:57:34 +0000 |
---|---|---|
committer | Tom de Vries <vries@gcc.gnu.org> | 2015-06-05 15:57:34 +0000 |
commit | 7c82d82716dd3e5c3377b2392e02e9c2454382fa (patch) | |
tree | 299636b9713d77014b892241dd301e1b62c714b3 /libgomp | |
parent | ddb63209a8dc059a7b2a137d7a1859222bb43dd6 (diff) | |
download | gcc-7c82d82716dd3e5c3377b2392e02e9c2454382fa.zip gcc-7c82d82716dd3e5c3377b2392e02e9c2454382fa.tar.gz gcc-7c82d82716dd3e5c3377b2392e02e9c2454382fa.tar.bz2 |
Add transform_to_exit_first_loop_alt
2015-06-05 Tom de Vries <tom@codesourcery.com>
merge from gomp4 branch:
2015-05-28 Tom de Vries <tom@codesourcery.com>
PR tree-optimization/65443
* tree-parloops.c (replace_imm_uses, replace_uses_in_bb_by)
(replace_uses_in_bbs_by, transform_to_exit_first_loop_alt)
(try_transform_to_exit_first_loop_alt): New function.
(transform_to_exit_first_loop): Use
try_transform_to_exit_first_loop_alt.
* gcc.dg/parloops-exit-first-loop-alt-2.c: New test.
* gcc.dg/parloops-exit-first-loop-alt-3.c: New test.
* gcc.dg/parloops-exit-first-loop-alt.c: New test.
* testsuite/libgomp.c/parloops-exit-first-loop-alt-2.c: New test.
* testsuite/libgomp.c/parloops-exit-first-loop-alt-3.c: New test.
* testsuite/libgomp.c/parloops-exit-first-loop-alt.c: New test.
From-SVN: r224154
Diffstat (limited to 'libgomp')
-rw-r--r-- | libgomp/ChangeLog | 10 | ||||
-rw-r--r-- | libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-2.c | 48 | ||||
-rw-r--r-- | libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-3.c | 29 | ||||
-rw-r--r-- | libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt.c | 48 |
4 files changed, 135 insertions, 0 deletions
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 134d1e3..c0a03c8 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,13 @@ +2015-06-05 Tom de Vries <tom@codesourcery.com> + + merge from gomp4 branch: + 2015-05-28 Tom de Vries <tom@codesourcery.com> + + PR tree-optimization/65443 + * testsuite/libgomp.c/parloops-exit-first-loop-alt-2.c: New test. + * testsuite/libgomp.c/parloops-exit-first-loop-alt-3.c: New test. + * testsuite/libgomp.c/parloops-exit-first-loop-alt.c: New test. + 2015-05-29 Bernhard Reutner-Fischer <aldot@gcc.gnu.org> * testsuite/libgomp.graphite/bounds.c: Adjust for diff --git a/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-2.c b/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-2.c new file mode 100644 index 0000000..eb5e11f --- /dev/null +++ b/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-2.c @@ -0,0 +1,48 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -ftree-parallelize-loops=2" } */ + +#include <stdio.h> +#include <stdlib.h> + +#define N 1000 + +unsigned int a[N]; +unsigned int b[N]; +unsigned int c[N]; + +void __attribute__((noclone,noinline)) +f (void) +{ + int i; + + for (i = 0; i < N; ++i) + c[i] = a[i] + b[i]; +} + +int +main (void) +{ + int i, j; + + /* Complexify loop to inhibit parloops. */ + for (j = 0; j < 100; ++j) + for (i = 0; i < 10; i++) + { + int k = i + (10 * j); + a[k] = k; + b[k] = (k * 3) % 7; + c[k] = k * 2; + } + + f (); + + for (i = 0; i < N; i++) + { + unsigned int actual = c[i]; + unsigned int expected = i + ((i * 3) % 7); + if (actual != expected) + abort (); + } + + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-3.c b/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-3.c new file mode 100644 index 0000000..b426b3f --- /dev/null +++ b/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt-3.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -ftree-parallelize-loops=2" } */ + +unsigned int *a; + +unsigned int __attribute__((noclone,noinline)) +f (unsigned int n) +{ + 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[4000]; + int i; + for (i = 0; i < 4000; ++i) + array[i] = i % 7; + a = &array[0]; + res = f (4000); + return !(res == 11995); +} diff --git a/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt.c b/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt.c new file mode 100644 index 0000000..d7d4003 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/parloops-exit-first-loop-alt.c @@ -0,0 +1,48 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -ftree-parallelize-loops=2" } */ + +#include <stdio.h> +#include <stdlib.h> + +#define N 1000 + +unsigned int a[N]; +unsigned int b[N]; +unsigned int c[N]; + +void __attribute__((noclone,noinline)) +f (unsigned int n) +{ + int i; + + for (i = 0; i < n; ++i) + c[i] = a[i] + b[i]; +} + +int +main (void) +{ + int i, j; + + /* Complexify loop to inhibit parloops. */ + for (j = 0; j < 100; ++j) + for (i = 0; i < 10; i++) + { + int k = i + (10 * j); + a[k] = k; + b[k] = (k * 3) % 7; + c[k] = k * 2; + } + + f (N); + + for (i = 0; i < N; i++) + { + unsigned int actual = c[i]; + unsigned int expected = i + ((i * 3) % 7); + if (actual != expected) + abort (); + } + + return 0; +} |