]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/100398 - avoid DSE of control flow stmt
authorRichard Biener <rguenther@suse.de>
Tue, 4 May 2021 07:18:11 +0000 (09:18 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 4 May 2021 10:31:50 +0000 (12:31 +0200)
The following makes sure to preserve control altering stmts
when removing trivially dead stmts in DSE.

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 [new file with mode: 0644]
gcc/tree-ssa-dse.c

diff --git a/gcc/testsuite/gcc.dg/torture/pr100398.c b/gcc/testsuite/gcc.dg/torture/pr100398.c
new file mode 100644 (file)
index 0000000..41eadde
--- /dev/null
@@ -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;
+}
index dfa6d3147270f31552b07f2366a35bbdffa065eb..d7cf747702850165c6bd0ceb74a29e503afeb04e 100644 (file)
@@ -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))