From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 59F373856DE8 for ; Tue, 2 Aug 2022 11:29:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 59F373856DE8 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 31E1C34A37 for ; Tue, 2 Aug 2022 11:29:00 +0000 (UTC) Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 2B7DD2C141 for ; Tue, 2 Aug 2022 11:29:00 +0000 (UTC) Date: Tue, 2 Aug 2022 11:29:00 +0000 (UTC) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/106497 - more forward threader can-copy-bb User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Aug 2022 11:29:02 -0000 Message-ID: <20220802112900.BKGVCg4CGzDXoMjDuhoFP2xZsJczpzSmcKCTm2FH9lE@z> This adds EDGE_COPY_SRC_JOINER_BLOCK sources to the set of blocks we need to check we can duplicate. Bootstrapped and tested on x86-64-unknown-linux-gnu, pushed. 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. --- gcc/testsuite/gcc.dg/torture/pr106497.c | 20 ++++++++++++++++++++ gcc/tree-ssa-threadupdate.cc | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr106497.c 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; } -- 2.35.3