diff options
author | vries <vries@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-09-03 11:01:14 +0000 |
---|---|---|
committer | vries <vries@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-09-03 11:01:14 +0000 |
commit | 281001a9a2e363dcabc6799c0e095c7a9cac5775 (patch) | |
tree | 135974571dbf7f23c3c4e4d50e4fb8a510ae8965 | |
parent | 4d556e29f0acd5a2baeb348dc0b3185d4457e987 (diff) | |
download | gcc-281001a9a2e363dcabc6799c0e095c7a9cac5775.tar.gz |
Fix inner loop phi in expand_omp_for_static_chunk
2015-09-03 Tom de Vries <tom@codesourcery.com>
PR tree-optimization/65637
* omp-low.c (find_phi_with_arg_on_edge): New function.
(expand_omp_for_static_chunk): Fix inner loop phi.
* testsuite/libgomp.c/autopar-2.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@227437 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/omp-low.c | 32 | ||||
-rw-r--r-- | libgomp/ChangeLog | 5 | ||||
-rw-r--r-- | libgomp/testsuite/libgomp.c/autopar-2.c | 4 |
4 files changed, 46 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ae76185f51c..f09f24f6e95 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,6 +1,12 @@ 2015-09-03 Tom de Vries <tom@codesourcery.com> PR tree-optimization/65637 + * omp-low.c (find_phi_with_arg_on_edge): New function. + (expand_omp_for_static_chunk): Fix inner loop phi. + +2015-09-03 Tom de Vries <tom@codesourcery.com> + + PR tree-optimization/65637 * omp-low.c (expand_omp_for_static_chunk): Fix gcc_assert for the case that head is NULL. diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 0995652c6d3..22e55f6c3cf 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -6885,6 +6885,24 @@ expand_omp_for_static_nochunk (struct omp_region *region, } } +/* Return phi in E->DEST with ARG on edge E. */ + +static gphi * +find_phi_with_arg_on_edge (tree arg, edge e) +{ + basic_block bb = e->dest; + + for (gphi_iterator gpi = gsi_start_phis (bb); + !gsi_end_p (gpi); + gsi_next (&gpi)) + { + gphi *phi = gpi.phi (); + if (PHI_ARG_DEF_FROM_EDGE (phi, e) == arg) + return phi; + } + + return NULL; +} /* A subroutine of expand_omp_for. Generate code for a parallel loop with static schedule and a specified chunk size. Given @@ -7324,7 +7342,19 @@ expand_omp_for_static_chunk (struct omp_region *region, t = vextra; add_phi_arg (nphi, t, ene, locus); locus = redirect_edge_var_map_location (vm); - add_phi_arg (nphi, redirect_edge_var_map_def (vm), re, locus); + tree back_arg = redirect_edge_var_map_def (vm); + add_phi_arg (nphi, back_arg, re, locus); + edge ce = find_edge (cont_bb, body_bb); + if (ce == NULL) + { + ce = BRANCH_EDGE (cont_bb); + gcc_assert (single_succ (ce->dest) == body_bb); + ce = single_succ_edge (ce->dest); + } + gphi *inner_loop_phi = find_phi_with_arg_on_edge (back_arg, ce); + gcc_assert (inner_loop_phi != NULL); + add_phi_arg (inner_loop_phi, gimple_phi_result (nphi), + find_edge (seq_start_bb, body_bb), locus); } gcc_assert (gsi_end_p (psi) && (head == NULL || i == head->length ())); redirect_edge_var_map_clear (re); diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 71e1fbaae42..d5aaa486204 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,8 @@ +2015-09-03 Tom de Vries <tom@codesourcery.com> + + PR tree-optimization/65637 + * testsuite/libgomp.c/autopar-2.c: New test. + 2015-08-29 Tom de Vries <tom@codesourcery.com> PR tree-optimization/46193 diff --git a/libgomp/testsuite/libgomp.c/autopar-2.c b/libgomp/testsuite/libgomp.c/autopar-2.c new file mode 100644 index 00000000000..821a4dabc47 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/autopar-2.c @@ -0,0 +1,4 @@ +/* { dg-do run } */ +/* { dg-additional-options "-ftree-parallelize-loops=4 -ffast-math --param parloops-chunk-size=100" } */ + +#include "autopar-1.c" |