From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] tree-optimization/106497 - more forward threader can-copy-bb
Date: Tue, 2 Aug 2022 11:29:00 +0000 (UTC) [thread overview]
Message-ID: <20220802112900.BKGVCg4CGzDXoMjDuhoFP2xZsJczpzSmcKCTm2FH9lE@z> (raw)
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
next reply other threads:[~2022-08-02 11:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-02 11:29 Richard Biener [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-08-02 11:29 Richard Biener
2022-08-02 11:29 Richard Biener
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220802112900.BKGVCg4CGzDXoMjDuhoFP2xZsJczpzSmcKCTm2FH9lE@z \
--to=rguenther@suse.de \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).