]> gcc.gnu.org Git - gcc.git/commit
openmp: Fix up handling of reduction clauses on the loop construct [PR102431]
authorJakub Jelinek <jakub@redhat.com>
Tue, 23 Nov 2021 09:30:02 +0000 (10:30 +0100)
committerJakub Jelinek <jakub@redhat.com>
Tue, 10 May 2022 08:14:29 +0000 (10:14 +0200)
commit18e0162ecb5de800f1609bfda657183bf95c7901
tree3550967e4de008c9af8dffc750ed9c293899869a
parentd91c501fd705de0d4ca4b89021878d0133258fd4
openmp: Fix up handling of reduction clauses on the loop construct [PR102431]

We were using unshare_expr and walk_tree_without_duplicate replacement
of the placeholder vars.  The OMP_CLAUSE_REDUCTION_{INIT,MERGE} can contain
other trees that need to be duplicated though, e.g. BLOCKs referenced in
BIND_EXPR(s), or local VAR_DECLs.  This patch uses the inliner code to copy
all of that.  There is a slight complication that those local VAR_DECLs or
placeholders don't have DECL_CONTEXT set, they will get that only when
they are gimplified later on, so this patch sets DECL_CONTEXT for those
temporarily and resets it afterwards.

2021-11-23  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/102431
* gimplify.c (replace_reduction_placeholders): Remove.
(note_no_context_vars): New function.
(gimplify_omp_loop): For OMP_PARALLEL's BIND_EXPR create a new
BLOCK.  Use copy_tree_body_r with walk_tree instead of unshare_expr
and replace_reduction_placeholders for duplication of
OMP_CLAUSE_REDUCTION_{INIT,MERGE} expressions.  Ensure all mentioned
automatic vars have DECL_CONTEXT set to non-NULL before doing so
and reset it afterwards for those vars and their corresponding
vars.

* c-c++-common/gomp/pr102431.c: New test.
* g++.dg/gomp/pr102431.C: New test.

(cherry picked from commit 5e9b973bd60185f221222022f56db7df3d92250e)
gcc/gimplify.c
gcc/testsuite/c-c++-common/gomp/pr102431.c [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/pr102431.C [new file with mode: 0644]
This page took 0.066573 seconds and 6 git commands to generate.