From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] tree-optimization/100398 - avoid DSE of control flow stmt
Date: Tue, 4 May 2021 12:31:43 +0200 (CEST) [thread overview]
Message-ID: <nycvar.YFH.7.76.2105041231310.2953@elmra.sevgm.obk> (raw)
The following makes sure to preserve control altering stmts
when removing trivially dead stmts in DSE.
Boostrapped and tested on x86_64-unknown-linux-gnu, pushed.
2021-05-04 Richard Biener <rguenther@suse.de>
PR tree-optimization/100398
* tree-ssa-dse.c (pass_dse::execute): Preserve control
altering stmts.
* gcc.dg/torture/pr100398.c: New testcase.
---
gcc/testsuite/gcc.dg/torture/pr100398.c | 13 +++++++++++++
gcc/tree-ssa-dse.c | 1 +
2 files changed, 14 insertions(+)
create mode 100644 gcc/testsuite/gcc.dg/torture/pr100398.c
diff --git a/gcc/testsuite/gcc.dg/torture/pr100398.c b/gcc/testsuite/gcc.dg/torture/pr100398.c
new file mode 100644
index 00000000000..41eaddee27e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr100398.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+int
+test5_limit (void)
+{
+ int addr;
+
+ asm goto ("" : "+r" (addr) : : : t_err);
+ return 0;
+
+ t_err:
+ return 1;
+}
diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c
index dfa6d314727..d7cf7477028 100644
--- a/gcc/tree-ssa-dse.c
+++ b/gcc/tree-ssa-dse.c
@@ -1219,6 +1219,7 @@ pass_dse::execute (function *fun)
dead SSA defs. */
if (has_zero_uses (DEF_FROM_PTR (def_p))
&& !gimple_has_side_effects (stmt)
+ && !is_ctrl_altering_stmt (stmt)
&& !stmt_unremovable_because_of_non_call_eh_p (cfun, stmt))
{
if (dump_file && (dump_flags & TDF_DETAILS))
--
2.26.2
reply other threads:[~2021-05-04 10:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=nycvar.YFH.7.76.2105041231310.2953@elmra.sevgm.obk \
--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).