From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id AA54D3853828; Tue, 2 Aug 2022 11:29:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AA54D3853828 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-1929] tree-optimization/106497 - more forward threader can-copy-bb X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: 84beef30a51988e77e9df3104ed6203756172d65 X-Git-Newrev: 0f3514756e0b4d8993ee43dcd958974eb1424061 Message-Id: <20220802112949.AA54D3853828@sourceware.org> Date: Tue, 2 Aug 2022 11:29:49 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Aug 2022 11:29:49 -0000 https://gcc.gnu.org/g:0f3514756e0b4d8993ee43dcd958974eb1424061 commit r13-1929-g0f3514756e0b4d8993ee43dcd958974eb1424061 Author: Richard Biener Date: Tue Aug 2 12:19:25 2022 +0200 tree-optimization/106497 - more forward threader can-copy-bb This adds EDGE_COPY_SRC_JOINER_BLOCK sources to the set of blocks we need to check we can duplicate. PR tree-optimization/106497 * tree-ssa-threadupdate.cc (fwd_jt_path_registry::update_cfg): Also verify we can copy EDGE_COPY_SRC_JOINER_BLOCK. * gcc.dg/torture/pr106497.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/torture/pr106497.c | 20 ++++++++++++++++++++ gcc/tree-ssa-threadupdate.cc | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/torture/pr106497.c b/gcc/testsuite/gcc.dg/torture/pr106497.c new file mode 100644 index 00000000000..601200de9e3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr106497.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fno-tree-dce" } */ + +int n; + +__attribute__ ((pure,returns_twice)) int +bar (void); + +int +foo (int x) +{ + n = 0; + + bar (); + + if (x && n) + return 0; + + foo (x); +} diff --git a/gcc/tree-ssa-threadupdate.cc b/gcc/tree-ssa-threadupdate.cc index 0f2b319d44a..59c268a3567 100644 --- a/gcc/tree-ssa-threadupdate.cc +++ b/gcc/tree-ssa-threadupdate.cc @@ -2679,7 +2679,8 @@ fwd_jt_path_registry::update_cfg (bool may_peel_loop_headers) { edge e = (*path)[j]->e; if (m_removed_edges->find_slot (e, NO_INSERT) - || ((*path)[j]->type == EDGE_COPY_SRC_BLOCK + || (((*path)[j]->type == EDGE_COPY_SRC_BLOCK + || (*path)[j]->type == EDGE_COPY_SRC_JOINER_BLOCK) && !can_duplicate_block_p (e->src))) break; }