From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 330CF386FC03 for ; Tue, 4 May 2021 10:31:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 330CF386FC03 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rguenther@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 50981B2E4 for ; Tue, 4 May 2021 10:31:43 +0000 (UTC) Date: Tue, 4 May 2021 12:31:43 +0200 (CEST) From: Richard Biener Sender: rguenther@ryzen.fritz.box To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/100398 - avoid DSE of control flow stmt Message-ID: User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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, 04 May 2021 10:31:47 -0000 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 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