From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1534) id 99C593858288; Thu, 2 Feb 2023 09:20:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 99C593858288 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675329636; bh=QbbNGZjv3iyMQsdRHy5PZo0year1++/RUdSAQtr1ui4=; h=From:To:Subject:Date:From; b=u8vWErmBnMyzntbZlE+P5cCIFCF80Yt3NYoKhAQ2C46zwZOSmMb8+fvr0Y6PzAhO0 rkk/9iS2QLIW+yZIaHpJnYZS+2k6MqrBPgw1JAhKG6KBlnEqLMeVUldIf/HeEWuPV/ x77uE1u45AwHZ7/TwdAlXDE0UCV7lcnxCKRob550= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Tobias Burnus To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/omp/gcc-12] nested, openmp: Wrap OMP_CLAUSE_*_GIMPLE_SEQ into GIMPLE_BIND for declare_vars [PR108435] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/devel/omp/gcc-12 X-Git-Oldrev: 251c9fdb3bb59c2603b5db526eda1828badd768c X-Git-Newrev: 60524fd9069860a03182d9472863e1c5915db49c Message-Id: <20230202092036.99C593858288@sourceware.org> Date: Thu, 2 Feb 2023 09:20:36 +0000 (GMT) List-Id: https://gcc.gnu.org/g:60524fd9069860a03182d9472863e1c5915db49c commit 60524fd9069860a03182d9472863e1c5915db49c Author: Jakub Jelinek Date: Thu Feb 2 10:06:22 2023 +0100 nested, openmp: Wrap OMP_CLAUSE_*_GIMPLE_SEQ into GIMPLE_BIND for declare_vars [PR108435] When gimplifying OMP_CLAUSE_{LASTPRIVATE,LINEAR}_STMT, we wrap it always into a GIMPLE_BIND, but when putting statements directly into OMP_CLAUSE_{LASTPRIVATE,LINEAR}_GIMPLE_SEQ, we do it only if needed (there are any temporaries that need to be declared in the sequence). convert_nonlocal_omp_clauses was relying on the GIMPLE_BIND to be there always because it called declare_vars on it. The following patch wraps it into GIMPLE_BIND in tree-nested if we need to declare_vars on it on demand. 2023-02-02 Jakub Jelinek PR middle-end/108435 * tree-nested.cc (convert_nonlocal_omp_clauses) : If info->new_local_var_chain and *seq is not a GIMPLE_BIND, wrap the sequence into a new GIMPLE_BIND before calling declare_vars. (convert_nonlocal_omp_clauses) : Merge with the OMP_CLAUSE_LASTPRIVATE handling except for whether seq is initialized to &OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (clause) or &OMP_CLAUSE_LINEAR_GIMPLE_SEQ (clause). * gcc.dg/gomp/pr108435.c: New test. (cherry picked from commit 0f349928e16fdc7dba52561e8d40347909f9f0ff) Diff: --- gcc/ChangeLog.omp | 15 +++++++++++++++ gcc/testsuite/ChangeLog.omp | 8 ++++++++ gcc/testsuite/gcc.dg/gomp/pr108435.c | 18 ++++++++++++++++++ gcc/tree-nested.cc | 32 ++++++++++++++++---------------- 4 files changed, 57 insertions(+), 16 deletions(-) diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp index 74a2cec4d38..7993a077914 100644 --- a/gcc/ChangeLog.omp +++ b/gcc/ChangeLog.omp @@ -1,3 +1,18 @@ +2023-02-02 Tobias Burnus + + Backported from master: + 2023-02-02 Jakub Jelinek + + PR middle-end/108435 + * tree-nested.cc (convert_nonlocal_omp_clauses) + : If info->new_local_var_chain and *seq + is not a GIMPLE_BIND, wrap the sequence into a new GIMPLE_BIND + before calling declare_vars. + (convert_nonlocal_omp_clauses) : Merge + with the OMP_CLAUSE_LASTPRIVATE handling except for whether + seq is initialized to &OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (clause) + or &OMP_CLAUSE_LINEAR_GIMPLE_SEQ (clause). + 2023-01-26 Tobias Burnus Backported from master: diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp index 9279ac7c23a..5d77187f90c 100644 --- a/gcc/testsuite/ChangeLog.omp +++ b/gcc/testsuite/ChangeLog.omp @@ -1,3 +1,11 @@ +2023-02-02 Tobias Burnus + + Backported from master: + 2023-02-02 Jakub Jelinek + + PR middle-end/108435 + * gcc.dg/gomp/pr108435.c: New test. + 2023-02-01 Tobias Burnus Backport from mainline: diff --git a/gcc/testsuite/gcc.dg/gomp/pr108435.c b/gcc/testsuite/gcc.dg/gomp/pr108435.c new file mode 100644 index 00000000000..ca692ad0451 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/pr108435.c @@ -0,0 +1,18 @@ +/* PR middle-end/108435 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fopenmp" } */ + +int +main () +{ + int i, j; + void + bar (void) + { + #pragma omp for simd collapse(2) + for (i = 1; i <= 16; i++) + for (j = 1; j <= 16; j++) + ; + } + bar (); +} diff --git a/gcc/tree-nested.cc b/gcc/tree-nested.cc index ea7d57a0591..cf1c52ab4c8 100644 --- a/gcc/tree-nested.cc +++ b/gcc/tree-nested.cc @@ -1566,29 +1566,29 @@ convert_nonlocal_omp_clauses (tree *pclauses, struct walk_stmt_info *wi) break; case OMP_CLAUSE_LASTPRIVATE: - { - tree save_local_var_chain = info->new_local_var_chain; - info->new_local_var_chain = NULL; - gimple_seq *seq = &OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (clause); - walk_body (convert_nonlocal_reference_stmt, - convert_nonlocal_reference_op, info, seq); - if (info->new_local_var_chain) - declare_vars (info->new_local_var_chain, - gimple_seq_first_stmt (*seq), false); - info->new_local_var_chain = save_local_var_chain; - } - break; - case OMP_CLAUSE_LINEAR: { tree save_local_var_chain = info->new_local_var_chain; info->new_local_var_chain = NULL; - gimple_seq *seq = &OMP_CLAUSE_LINEAR_GIMPLE_SEQ (clause); + gimple_seq *seq; + if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_LASTPRIVATE) + seq = &OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (clause); + else + seq = &OMP_CLAUSE_LINEAR_GIMPLE_SEQ (clause); walk_body (convert_nonlocal_reference_stmt, convert_nonlocal_reference_op, info, seq); if (info->new_local_var_chain) - declare_vars (info->new_local_var_chain, - gimple_seq_first_stmt (*seq), false); + { + gimple *g = gimple_seq_first_stmt (*seq); + if (gimple_code (g) != GIMPLE_BIND) + { + g = gimple_build_bind (NULL_TREE, *seq, NULL_TREE); + *seq = NULL; + gimple_seq_add_stmt_without_update (seq, g); + } + declare_vars (info->new_local_var_chain, + gimple_seq_first_stmt (*seq), false); + } info->new_local_var_chain = save_local_var_chain; } break;