[ was: Re: [PATCH, 3/5] Handle original loop tree in
expand_omp_for_generic ]
On 13/10/15 23:48, Thomas Schwinge wrote:
Hi Tom!
On Mon, 12 Oct 2015 18:56:29 +0200, Tom de Vries<tom_devr...@mentor.com> wrote:
>Handle original loop tree in expand_omp_for_generic
>
>2015-09-12 Tom de Vries<t...@codesourcery.com>
>
> PR tree-optimization/67476
> * omp-low.c (expand_omp_for_generic): Handle original loop tree.
Working on a merge from trunk into gomp-4_0-branch, I'm seeing your
change (trunk r228754) conflict with code Chung-Lin changed
(gomp-4_0-branch r224505). So, would you two please cherry-pick/merge
trunk r228754 into gomp-4_0-branch? Thanks! (I'm assuming you can
easily tell what needs to be done here; it's been a long time that
Chung-Lin touched this code, so CCing him just in case.) Thanks!
Hi Thomas,
I've backport the whole patch series:
1 Handle simple latch in expand_omp_for_generic
2 Add missing phis in expand_omp_for_generic
3 Handle original loop tree in expand_omp_for_generic
4 Support DEFPARAMENUM in params.def
5 Add param parloops-schedule
and committed to gomp-4_0-branch.
I'm only posting patch nr. 3, the only one with a non-trivial conflict.
Thanks,
- Tom
Handle original loop tree in expand_omp_for_generic
2015-10-14 Tom de Vries <t...@codesourcery.com>
backport from trunk:
2015-10-13 Tom de Vries <t...@codesourcery.com>
PR tree-optimization/67476
* omp-low.c (expand_omp_for_generic): Handle original loop tree.
---
gcc/omp-low.c | 38 +++++++++++++++++++++++++-------------
1 file changed, 25 insertions(+), 13 deletions(-)
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 473e2e7..dde3e1b 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -6924,7 +6924,6 @@ expand_omp_for_generic (struct omp_region *region,
remove_edge (e);
make_edge (cont_bb, l2_bb, EDGE_FALSE_VALUE);
- add_bb_to_loop (l2_bb, cont_bb->loop_father);
e = find_edge (cont_bb, l1_bb);
if (e == NULL)
{
@@ -7002,23 +7001,36 @@ expand_omp_for_generic (struct omp_region *region,
set_immediate_dominator (CDI_DOMINATORS, l1_bb,
recompute_dominator (CDI_DOMINATORS, l1_bb));
- struct loop *outer_loop;
- if (seq_loop)
- outer_loop = l0_bb->loop_father;
- else
+ /* We enter expand_omp_for_generic with a loop. This original loop may
+ have its own loop struct, or it may be part of an outer loop struct
+ (which may be the fake loop). */
+ struct loop *outer_loop = entry_bb->loop_father;
+ bool orig_loop_has_loop_struct = l1_bb->loop_father != outer_loop;
+
+ add_bb_to_loop (l2_bb, outer_loop);
+
+ struct loop *new_loop = NULL;
+ if (!seq_loop)
{
- outer_loop = alloc_loop ();
- outer_loop->header = l0_bb;
- outer_loop->latch = l2_bb;
- add_loop (outer_loop, l0_bb->loop_father);
+ /* We've added a new loop around the original loop. Allocate the
+ corresponding loop struct. */
+ new_loop = alloc_loop ();
+ new_loop->header = l0_bb;
+ new_loop->latch = l2_bb;
+ add_loop (new_loop, outer_loop);
}
- if (!gimple_omp_for_combined_p (fd->for_stmt))
+ /* Allocate a loop structure for the original loop unless we already
+ had one. */
+ if (!orig_loop_has_loop_struct
+ && !gimple_omp_for_combined_p (fd->for_stmt))
{
- struct loop *loop = alloc_loop ();
- loop->header = l1_bb;
+ struct loop *orig_loop = alloc_loop ();
+ orig_loop->header = l1_bb;
/* The loop may have multiple latches. */
- add_loop (loop, outer_loop);
+ add_loop (orig_loop, (new_loop != NULL
+ ? new_loop
+ : outer_loop));
}
}
}
--
1.9.1