From: Richard Biener Date: Tue, 4 May 2021 07:18:11 +0000 (+0200) Subject: tree-optimization/100398 - avoid DSE of control flow stmt X-Git-Tag: basepoints/gcc-13~7883 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2326627eb19d8c21251fd60479f1a190621c475b;p=thirdparty%2Fgcc.git tree-optimization/100398 - avoid DSE of control flow stmt The following makes sure to preserve control altering stmts when removing trivially dead stmts in DSE. 2021-05-04 Richard Biener PR tree-optimization/100398 * tree-ssa-dse.c (pass_dse::execute): Preserve control altering stmts. * gcc.dg/torture/pr100398.c: New testcase. --- diff --git a/gcc/testsuite/gcc.dg/torture/pr100398.c b/gcc/testsuite/gcc.dg/torture/pr100398.c new file mode 100644 index 000000000000..41eaddee27e4 --- /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 dfa6d3147270..d7cf74770285 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))