Hi! On Wed, 10 Dec 2014 10:59:34 +0100, Jakub Jelinek <ja...@redhat.com> wrote: > On Wed, Dec 10, 2014 at 10:54:13AM +0100, Thomas Schwinge wrote: > > --- gcc/omp-low.c > > +++ gcc/omp-low.c > > @@ -9404,7 +9404,9 @@ build_omp_regions_1 (basic_block bb, struct > > omp_region *parent, > > else if (code == GIMPLE_OMP_TARGET > > && (gimple_omp_target_kind (stmt) == GF_OMP_TARGET_KIND_UPDATE > > || (gimple_omp_target_kind (stmt) > > - == GF_OMP_TARGET_KIND_OACC_UPDATE))) > > + == GF_OMP_TARGET_KIND_OACC_UPDATE) > > + || (gimple_omp_target_kind (stmt) > > + == GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA))) > > new_omp_region (bb, code, parent); > > else > > { > > @@ -12270,7 +12272,9 @@ make_gimple_omp_edges (basic_block bb, struct > > omp_region **region, > > cur_region = new_omp_region (bb, code, cur_region); > > fallthru = true; > > if (gimple_omp_target_kind (last) == GF_OMP_TARGET_KIND_UPDATE > > - || gimple_omp_target_kind (last) == GF_OMP_TARGET_KIND_OACC_UPDATE) > > + || gimple_omp_target_kind (last) == GF_OMP_TARGET_KIND_OACC_UPDATE > > + || (gimple_omp_target_kind (last) > > + == GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA)) > > I'd say that at this point a > switch (gimple_omp_target_kind (last)) > { > case GF_OMP_TARGET_KIND_UPDATE: > case GF_OMP_TARGET_KIND_OACC_UPDATE: > case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA: > ... > default: > ... > } > would be cleaner. The first hunk is more questionable, because there is > else and it would require duplicating of the else body in default:, goto > or similar, but perhaps it would be better that way too.
Thanks for the suggestion. I found a way to express the first one differently; committed to gomp-4_0-branch in r218837: commit c9c55fd5c318f0ed6b866930d445a3df4aa058e8 Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Wed Dec 17 22:14:58 2014 +0000 Simplify multi-line if conditions. gcc/ * omp-low.c (build_omp_regions_1, make_gimple_omp_edges): Simplify multi-line if conditions. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@218837 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog.gomp | 5 +++++ gcc/omp-low.c | 57 ++++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 45 insertions(+), 17 deletions(-) diff --git gcc/ChangeLog.gomp gcc/ChangeLog.gomp index 970e744..f925902 100644 --- gcc/ChangeLog.gomp +++ gcc/ChangeLog.gomp @@ -1,3 +1,8 @@ +2014-12-17 Thomas Schwinge <tho...@codesourcery.com> + + * omp-low.c (build_omp_regions_1, make_gimple_omp_edges): Simplify + multi-line if conditions. + 2014-12-10 Thomas Schwinge <tho...@codesourcery.com> * omp-low.c (scan_omp_target): Remove taskreg_nesting_level and diff --git gcc/omp-low.c gcc/omp-low.c index a1fbccf..fd117dc 100644 --- gcc/omp-low.c +++ gcc/omp-low.c @@ -9379,7 +9379,6 @@ build_omp_regions_1 (basic_block bb, struct omp_region *parent, region->exit = bb; parent = parent->outer; } - else if (code == GIMPLE_OMP_CONTINUE) { gcc_assert (parent); @@ -9389,21 +9388,34 @@ build_omp_regions_1 (basic_block bb, struct omp_region *parent, { /* GIMPLE_OMP_SECTIONS_SWITCH is part of GIMPLE_OMP_SECTIONS, and we do nothing for it. */ - ; } - else if (code == GIMPLE_OMP_TARGET - && (gimple_omp_target_kind (stmt) == GF_OMP_TARGET_KIND_UPDATE - || (gimple_omp_target_kind (stmt) - == GF_OMP_TARGET_KIND_OACC_UPDATE) - || (gimple_omp_target_kind (stmt) - == GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA))) - new_omp_region (bb, code, parent); else { - /* Otherwise, this directive becomes the parent for a new - region. */ region = new_omp_region (bb, code, parent); - parent = region; + /* Otherwise... */ + if (code == GIMPLE_OMP_TARGET) + { + switch (gimple_omp_target_kind (stmt)) + { + case GF_OMP_TARGET_KIND_REGION: + case GF_OMP_TARGET_KIND_DATA: + case GF_OMP_TARGET_KIND_OACC_PARALLEL: + case GF_OMP_TARGET_KIND_OACC_KERNELS: + case GF_OMP_TARGET_KIND_OACC_DATA: + break; + case GF_OMP_TARGET_KIND_UPDATE: + case GF_OMP_TARGET_KIND_OACC_UPDATE: + case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA: + /* ..., other than for those stand-alone directives... */ + region = NULL; + break; + default: + gcc_unreachable (); + } + } + /* ..., this directive becomes the parent for a new region. */ + if (region) + parent = region; } } @@ -12259,11 +12271,22 @@ make_gimple_omp_edges (basic_block bb, struct omp_region **region, case GIMPLE_OMP_TARGET: cur_region = new_omp_region (bb, code, cur_region); fallthru = true; - if (gimple_omp_target_kind (last) == GF_OMP_TARGET_KIND_UPDATE - || gimple_omp_target_kind (last) == GF_OMP_TARGET_KIND_OACC_UPDATE - || (gimple_omp_target_kind (last) - == GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA)) - cur_region = cur_region->outer; + switch (gimple_omp_target_kind (last)) + { + case GF_OMP_TARGET_KIND_REGION: + case GF_OMP_TARGET_KIND_DATA: + case GF_OMP_TARGET_KIND_OACC_PARALLEL: + case GF_OMP_TARGET_KIND_OACC_KERNELS: + case GF_OMP_TARGET_KIND_OACC_DATA: + break; + case GF_OMP_TARGET_KIND_UPDATE: + case GF_OMP_TARGET_KIND_OACC_UPDATE: + case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA: + cur_region = cur_region->outer; + break; + default: + gcc_unreachable (); + } break; case GIMPLE_OMP_SECTIONS: Grüße, Thomas
pgp1pL_7G7y2t.pgp
Description: PGP signature